2 * This code was written by Mychaela Falconia <falcon@freecalypso.org>
3 * who refuses to claim copyright on it and has released it as public domain
4 * instead. NO rights reserved, all rights relinquished.
6 * Tweaked (coding style changes) by Vadim Yanitskiy <axilirator@gmail.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
24 * The APC offset value used by SE J100 official fw is different from the
25 * Mot C1xx value, and this different APC offset value must be used by any
26 * aftermarket fw on this target in order for the Tx levels from Compal's
27 * factory records to apply correctly. This correct value has been determined
28 * by breaking into a running SE J100 fw with tfc139, running fc-loadtool
29 * with all ABB register state still intact from the interrupted official fw,
30 * and reading the APCOFF register with the abbr command.
32 uint8_t apc_offset
= 52;
35 * The following tables of Tx ramp templates have been extracted from
36 * SE J100 fw version R1C004 (R1C004-se.bin in the j100-flashimg-r1.zip
37 * FTP release); Compal's modified versions of TI's rf_XXX structures
38 * begin at address 0x5E898 in this J100 fw version.
40 * Please note that these SE J100 Tx ramp templates are different from
41 * both C11x/12x/155/156 (SKY77324) and C139/140 (SKY77325) versions.
43 struct txcal_ramp_def rf_tx_ramps_850
[RF_TX_RAMP_SIZE
] = {
46 { 1, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0, 0},
48 { 15, 31, 31, 20, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
52 { 1, 0, 0, 0, 0, 0, 0, 0, 14, 31, 31, 31, 20, 0, 0, 0},
54 { 20, 31, 31, 15, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
58 { 1, 0, 0, 0, 0, 0, 0, 0, 14, 31, 31, 31, 20, 0, 0, 0},
60 { 25, 31, 31, 10, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
64 { 1, 0, 0, 0, 0, 0, 0, 0, 9, 31, 31, 31, 25, 0, 0, 0},
66 { 29, 31, 31, 31, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
70 { 1, 0, 0, 0, 0, 0, 0, 0, 9, 31, 31, 31, 25, 0, 0, 0},
72 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
76 { 1, 0, 0, 0, 0, 0, 0, 0, 3, 31, 31, 31, 31, 0, 0, 0},
78 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
82 { 1, 0, 0, 0, 0, 0, 0, 0, 3, 31, 31, 31, 31, 0, 0, 0},
84 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
88 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 29, 31, 31, 31, 5, 0, 0},
90 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
94 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 29, 31, 31, 31, 5, 0, 0},
96 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
100 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0},
102 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
106 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0},
108 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
112 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0},
114 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
118 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0},
120 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
124 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0},
126 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
130 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0},
132 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
136 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
138 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
142 struct txcal_ramp_def rf_tx_ramps_900
[RF_TX_RAMP_SIZE
] = {
145 { 1, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0, 0},
147 { 25, 25, 31, 16, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
151 { 1, 0, 0, 0, 0, 0, 0, 0, 14, 31, 31, 31, 20, 0, 0, 0},
153 { 27, 31, 31, 8, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
157 { 1, 0, 0, 0, 0, 0, 0, 0, 14, 31, 31, 31, 20, 0, 0, 0},
159 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
163 { 1, 0, 0, 0, 0, 0, 0, 0, 9, 31, 31, 31, 25, 0, 0, 0},
165 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
169 { 1, 0, 0, 0, 0, 0, 0, 0, 3, 31, 31, 31, 31, 0, 0, 0},
171 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
175 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 29, 31, 31, 31, 5, 0, 0},
177 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
181 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 29, 31, 31, 31, 5, 0, 0},
183 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
187 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 29, 31, 31, 31, 5, 0, 0},
189 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
193 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 29, 31, 31, 31, 5, 0, 0},
195 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
199 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 29, 31, 31, 31, 5, 0, 0},
201 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
205 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0},
207 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
211 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0},
213 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
217 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0},
219 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
223 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0},
225 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
229 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0},
231 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
235 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
237 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
241 struct txcal_ramp_def rf_tx_ramps_1800
[RF_TX_RAMP_SIZE
] = {
244 { 1, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0, 0},
246 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
250 { 1, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0, 0},
252 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
256 { 1, 0, 0, 0, 0, 0, 0, 0, 14, 31, 31, 31, 20, 0, 0, 0},
258 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
262 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 31, 31, 4, 0, 0},
264 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
268 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 30, 31, 31, 31, 4, 0, 0},
270 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
274 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 29, 31, 31, 31, 5, 0, 0},
276 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
280 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0},
282 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
286 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0},
288 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
292 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0},
294 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
298 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0},
300 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
304 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0},
306 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
310 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0},
312 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
316 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 9, 31, 31, 31, 25, 0, 0},
318 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
322 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 9, 31, 31, 31, 25, 0, 0},
324 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
328 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, 31, 31, 31, 31, 0, 0},
330 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
334 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, 31, 31, 31, 31, 0, 0},
336 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
340 struct txcal_ramp_def rf_tx_ramps_1900
[RF_TX_RAMP_SIZE
] = {
343 { 1, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0, 0},
345 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
349 { 1, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0, 0},
351 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
355 { 1, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0, 0},
357 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
361 { 1, 0, 0, 0, 0, 0, 0, 0, 14, 31, 31, 31, 20, 0, 0, 0},
363 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
367 { 1, 0, 0, 0, 0, 0, 0, 0, 14, 31, 31, 31, 20, 0, 0, 0},
369 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
373 { 1, 0, 0, 0, 0, 0, 0, 0, 3, 31, 31, 31, 31, 0, 0, 0},
375 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
379 { 1, 0, 0, 0, 0, 0, 0, 0, 3, 31, 31, 31, 31, 0, 0, 0},
381 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
385 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 29, 31, 31, 31, 5, 0, 0},
387 { 31, 31, 31, 4, 31, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
391 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 29, 31, 31, 31, 5, 0, 0},
393 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
397 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0},
399 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
403 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 24, 31, 31, 31, 10, 0, 0},
405 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
409 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 19, 31, 31, 31, 15, 0, 0},
411 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
415 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 9, 31, 31, 31, 25, 0, 0},
417 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
421 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 9, 31, 31, 31, 25, 0, 0},
423 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
427 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 31, 31, 31, 0, 0},
429 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
433 { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 31, 31, 31, 0, 0},
435 { 31, 31, 31, 31, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},