FreeCalypso > hg > fc-magnetite
comparison src/cs/layer1/tpu_drivers/source0/tpudrv10.c @ 404:35638332aff5
tpudrv10.c: initial placeholder version
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 18 Jan 2018 02:51:16 +0000 |
parents | src/cs/layer1/tpu_drivers/source0/tpudrv12.c@17d79c62e638 |
children | d926a8986755 |
comparison
equal
deleted
inserted
replaced
403:74af3c360866 | 404:35638332aff5 |
---|---|
1 /* | |
2 * The situation with the tpudrv10 RF TPU driver is even worse than with | |
3 * tpudrv12: not only are we missing the original tpudrv10.c source, | |
4 * but we don't even have a tpudrv10.obj to reconstruct from. | |
5 * | |
6 * We are going to try reconstructing the necessary tpudrv10 bits | |
7 * from the 20020917 fw image sans symbols that came with our D-Sample | |
8 * board, but for now this C file is mostly a placeholder for compilation. | |
9 */ | |
10 | |
11 #define TPUDRV10_C | |
12 | |
13 #include "board.cfg" | |
14 #include "chipset.cfg" | |
15 #include "l1sw.cfg" | |
16 #include "rf.cfg" | |
17 #include "swconfig.cfg" | |
18 #include "sys.cfg" | |
19 | |
20 #include "sys_types.h" | |
21 #include "l1_confg.h" | |
22 | |
23 #include "l1_macro.h" | |
24 #include "l1_const.h" | |
25 #include "l1_types.h" | |
26 #if TESTMODE | |
27 #include "l1tm_defty.h" | |
28 #endif | |
29 #if (AUDIO_TASK == 1) | |
30 #include "l1audio_const.h" | |
31 #include "l1audio_cust.h" | |
32 #include "l1audio_defty.h" | |
33 #endif | |
34 #if (L1_GTT == 1) | |
35 #include "l1gtt_const.h" | |
36 #include "l1gtt_defty.h" | |
37 #endif | |
38 #if (L1_MP3 == 1) | |
39 #include "l1mp3_defty.h" | |
40 #endif | |
41 #if (L1_MIDI == 1) | |
42 #include "l1midi_defty.h" | |
43 #endif | |
44 | |
45 #if (L1_AAC == 1) | |
46 #include "l1aac_defty.h" | |
47 #endif | |
48 | |
49 #include "l1_defty.h" | |
50 #include "l1_time.h" | |
51 #include "l1_ctl.h" | |
52 #include "tpudrv.h" | |
53 #include "tpudrv10.h" | |
54 #include "l1_rf10.h" | |
55 | |
56 #include "mem.h" | |
57 #include "armio.h" | |
58 #include "clkm.h" | |
59 | |
60 // Global variables | |
61 extern T_L1_CONFIG l1_config; | |
62 extern UWORD16 AGC_TABLE[]; | |
63 extern UWORD16 *TP_Ptr; | |
64 | |
65 static UWORD8 rf_index; /* index into rf_path[] */ | |
66 static UWORD16 rf_chip_band; /* from tpudrv12.obj, not in tpudrv61.c */ | |
67 static UWORD8 rfband; /* ditto */ | |
68 | |
69 // Internal function prototypes | |
70 void l1dmacro_rx_down (WORD32 t); | |
71 | |
72 SYS_UWORD16 Convert_l1_radio_freq(SYS_UWORD16 radio_freq); | |
73 WORD32 rf_init(WORD32 t); | |
74 | |
75 // External function prototypes | |
76 UWORD8 Cust_is_band_high(UWORD16 radio_freq); | |
77 | |
78 | |
79 extern T_RF_BAND rf_band[]; | |
80 extern T_RF rf; | |
81 | |
82 /**************************************************************************/ | |
83 /**************************************************************************/ | |
84 /* DEFINITION OF MACROS FOR CHIPS SERIAL PROGRAMMATION */ | |
85 /**************************************************************************/ | |
86 /**************************************************************************/ | |
87 | |
88 /*------------------------------------------*/ | |
89 /* Is arfcn in the DCS band (512-885) ? */ | |
90 /*------------------------------------------*/ | |
91 #define IS_HIGH_BAND(arfcn) (((arfcn >= 512) && (arfcn <= 885)) ? 1 : 0) | |
92 | |
93 /*------------------------------------------*/ | |
94 /* Send a value to Rita RF */ | |
95 /*------------------------------------------*/ | |
96 #define TSP_TO_RF(rf_data)\ | |
97 {\ | |
98 *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_1, ((rf_data) >> 8) & 0xFF); \ | |
99 *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_2, (rf_data) & 0xFF); \ | |
100 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_RF | 0x0F); \ | |
101 *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR); \ | |
102 } | |
103 | |
104 /*------------------------------------------*/ | |
105 /* Send a TSP command to ABB */ | |
106 /*------------------------------------------*/ | |
107 #define TSP_TO_ABB(data)\ | |
108 {\ | |
109 *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_1, (data) & 0xFF); \ | |
110 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_ABB | 0x06); \ | |
111 *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR); \ | |
112 } | |
113 | |
114 /*------------------------------------------*/ | |
115 /* Trace arfcn for conversion debug */ | |
116 /*------------------------------------------*/ | |
117 #ifdef ARFCN_DEBUG | |
118 // ----Debug information : record all arfcn programmed into synthesizer! | |
119 #define MAX_ARFCN_TRACE 4096 // enough for 5 sessions of 124+374 | |
120 SYS_UWORD16 arfcn_trace[MAX_ARFCN_TRACE]; | |
121 static UWORD32 arfcn_trace_index = 0; | |
122 | |
123 void trace_arfcn(SYS_UWORD16 arfcn) | |
124 { | |
125 arfcn_trace[arfcn_trace_index++] = arfcn; | |
126 | |
127 // Wrap to beginning | |
128 if (arfcn_trace_index == MAX_ARFCN_TRACE) | |
129 arfcn_trace_index = 0; | |
130 } | |
131 #endif | |
132 | |
133 | |
134 /**************************************************************************/ | |
135 /**************************************************************************/ | |
136 /* DEFINITION OF HARWARE DEPENDANT CONSTANTS */ | |
137 /**************************************************************************/ | |
138 /**************************************************************************/ | |
139 | |
140 /**************************************************************************/ | |
141 /**************************************************************************/ | |
142 /* INTERNAL FUNCTIONS OF TPUDRV14.C */ | |
143 /* EFFECTIVE DOWNLOADING THROUGH TSP */ | |
144 /**************************************************************************/ | |
145 /**************************************************************************/ | |
146 // rx & tx | |
147 typedef struct tx_rx_s | |
148 { | |
149 UWORD16 farfcn0; | |
150 WORD8 ou; | |
151 } | |
152 T_TX_RX; | |
153 | |
154 struct synth_s { | |
155 // common | |
156 UWORD16 arfcn0; | |
157 UWORD16 limit; | |
158 UWORD16 rf_chip_band; /* from tpudrv12.obj, not in tpudrv61.c */ | |
159 T_TX_RX tx_rx[2]; | |
160 }; | |
161 | |
162 struct rf_path_s { | |
163 UWORD8 rx_up; | |
164 UWORD8 rx_down; | |
165 UWORD8 tx_up; | |
166 UWORD8 tx_down; | |
167 struct synth_s *synth; | |
168 }; | |
169 | |
170 const struct synth_s synth_900[] = | |
171 { | |
172 { 0, 124, BAND_SELECT_GSM, {{ 890, 1}, { 935, 2}}},// gsm 0 - 124 | |
173 {974, 1023, BAND_SELECT_GSM, {{ 880, 1}, { 925, 2}}},// egsm 975 - 1023 | |
174 }; | |
175 | |
176 const struct synth_s synth_1800[] = | |
177 { | |
178 {511, 885, BAND_SELECT_DCS, {{1710, 1}, {1805, 1}}}, // dcs 512 - 885 | |
179 }; | |
180 | |
181 const struct synth_s synth_1900[] = | |
182 { | |
183 {511, 810, BAND_SELECT_PCS, {{1850, 1}, {1930, 1}}}, // pcs 512 - 810; | |
184 }; | |
185 | |
186 const struct synth_s synth_850[] = | |
187 { | |
188 {127, 192, BAND_SELECT_850_LO, {{ 824, 2}, { 869, 2}}}, // gsm850 low | |
189 {127, 251, BAND_SELECT_850_HI, {{ 824, 1}, { 869, 2}}}, // gsm850 high | |
190 }; | |
191 | |
192 struct rf_path_s rf_path[] = { //same index used as for band_config[] - 1 | |
193 { RU_900, RD_900, TU_900, TD_900, (struct synth_s *)synth_900 }, //EGSM | |
194 { RU_1800, RD_1800, TU_1800, TD_1800, (struct synth_s *)synth_1800}, //DCS | |
195 { RU_1900, RD_1900, TU_1900, TD_1900, (struct synth_s *)synth_1900}, //PCS | |
196 { RU_850, RD_850, TU_850, TD_850, (struct synth_s *)synth_850 }, //GSM850 | |
197 { RU_900, RD_900, TU_900, TD_900, (struct synth_s *)synth_900 }, //GSM | |
198 }; | |
199 | |
200 /* | |
201 * Leonardo tpudrv12.obj contains a function named calc_a_b(); there is | |
202 * no such function in the LoCosto version, but there is a similar-looking | |
203 * calc_rf_freq() function instead. Let's try making our calc_a_b() | |
204 * from LoCosto's calc_rf_freq(). | |
205 */ | |
206 | |
207 UWORD32 calc_a_b(UWORD16 arfcn, UWORD8 downlink) | |
208 { | |
209 UWORD32 farfcn; /* in 200 kHz units */ | |
210 UWORD32 n; /* B * P + A */ | |
211 struct synth_s *s; | |
212 | |
213 s = rf_path[rf_index].synth; | |
214 while(s->limit < arfcn) | |
215 s++; | |
216 | |
217 rf_chip_band = s->rf_chip_band; | |
218 | |
219 // Convert the ARFCN to the channel frequency (times 5 to avoid the decimal value) | |
220 farfcn = 5*s->tx_rx[downlink].farfcn0 + (arfcn - s->arfcn0); | |
221 n = farfcn * s->tx_rx[downlink].ou; | |
222 | |
223 /* magic A & B encoding for Rita */ | |
224 return((n - 4096) << 3); | |
225 } | |
226 | |
227 /*------------------------------------------*/ | |
228 /* Convert_l1_radio_freq */ | |
229 /*------------------------------------------*/ | |
230 /* conversion of l1 radio_freq to */ | |
231 /* real channel number */ | |
232 /*------------------------------------------*/ | |
233 SYS_UWORD16 Convert_l1_radio_freq(SYS_UWORD16 radio_freq) | |
234 { | |
235 switch(l1_config.std.id) | |
236 { | |
237 case GSM: | |
238 case DCS1800: | |
239 case PCS1900: | |
240 case GSM850: | |
241 return (radio_freq); | |
242 //omaps00090550 break; | |
243 | |
244 case DUAL: | |
245 { | |
246 if (radio_freq < l1_config.std.first_radio_freq_band2) | |
247 // GSM band... | |
248 return(radio_freq); | |
249 else | |
250 // DCS band... | |
251 return (radio_freq - l1_config.std.first_radio_freq_band2 + 512); | |
252 } | |
253 //omaps00090550 break; | |
254 | |
255 case DUALEXT: | |
256 { | |
257 if (radio_freq < l1_config.std.first_radio_freq_band2) | |
258 // E-GSM band... | |
259 { | |
260 if(radio_freq <= 124) | |
261 // GSM part... | |
262 return(radio_freq); | |
263 if(radio_freq < 174) | |
264 // Extended part... | |
265 return (radio_freq - 125 + 975); | |
266 else | |
267 // Extended part, special case of ARFCN=0 | |
268 return(0); | |
269 } | |
270 else | |
271 { | |
272 // DCS band... | |
273 return (radio_freq - l1_config.std.first_radio_freq_band2 + 512); | |
274 } | |
275 } | |
276 // break; | |
277 | |
278 case GSM_E: | |
279 { | |
280 if(radio_freq <= 124) | |
281 // GSM part... | |
282 return(radio_freq); | |
283 else | |
284 if(radio_freq < 174) | |
285 // Extended part... | |
286 return (radio_freq - 125 + 975); | |
287 else | |
288 // Extended part, special case of ARFCN=0 | |
289 return(0); | |
290 } | |
291 //omaps00090550 break; | |
292 | |
293 case DUAL_US: | |
294 { | |
295 if (radio_freq < l1_config.std.first_radio_freq_band2) | |
296 { | |
297 return(radio_freq - l1_config.std.first_radio_freq + 128); | |
298 } | |
299 else | |
300 { | |
301 // PCS band... | |
302 return (radio_freq - l1_config.std.first_radio_freq_band2 + 512); | |
303 } | |
304 } | |
305 // break; | |
306 | |
307 default: // should never occur. | |
308 return(radio_freq); | |
309 } // end of switch | |
310 } | |
311 | |
312 /*------------------------------------------*/ | |
313 /* rf_init */ | |
314 /*------------------------------------------*/ | |
315 /* Initialization routine for PLL */ | |
316 /* Effective downloading through TSP */ | |
317 /*------------------------------------------*/ | |
318 /* Rita and LoCosto versions look totally */ | |
319 /* different, reconstructing from disasm. */ | |
320 /*------------------------------------------*/ | |
321 WORD32 rf_init(WORD32 t) | |
322 { | |
323 *TP_Ptr++ = TPU_AT(t); | |
324 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, 0x47); | |
325 t += 5; | |
326 *TP_Ptr++ = TPU_AT(t); | |
327 *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_OFF); | |
328 t += 8; | |
329 *TP_Ptr++ = TPU_AT(t); | |
330 *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON); | |
331 t += 5; | |
332 *TP_Ptr++ = TPU_AT(t); | |
333 TSP_TO_RF(0x0012); | |
334 t += 7; | |
335 *TP_Ptr++ = TPU_AT(t); | |
336 *TP_Ptr++ = TPU_AT(t); | |
337 *TP_Ptr++ = TPU_AT(t); | |
338 *TP_Ptr++ = TPU_AT(t); | |
339 *TP_Ptr++ = TPU_AT(t); | |
340 *TP_Ptr++ = TPU_AT(t); | |
341 TSP_TO_RF(0x003A); | |
342 t += 117; | |
343 *TP_Ptr++ = TPU_AT(t); | |
344 TSP_TO_RF(0xC003); | |
345 t += 7; | |
346 *TP_Ptr++ = TPU_AT(t); | |
347 TSP_TO_RF(0x02FE); | |
348 t += 7; | |
349 *TP_Ptr++ = TPU_AT(t); | |
350 TSP_TO_RF(0x401F); | |
351 t += 7; | |
352 *TP_Ptr++ = TPU_AT(t); | |
353 TSP_TO_RF(0x043D); | |
354 t += 7; | |
355 return(t); | |
356 } | |
357 | |
358 /*------------------------------------------*/ | |
359 /* rf_init_light */ | |
360 /*------------------------------------------*/ | |
361 /* Initialization routine for PLL */ | |
362 /* Effective downloading through TSP */ | |
363 /*------------------------------------------*/ | |
364 WORD32 rf_init_light(WORD32 t) | |
365 { | |
366 // initialization for change of multi-band configuration dependent on STD | |
367 return(t); | |
368 } | |
369 | |
370 UWORD8 arfcn_to_rf_index(SYS_UWORD16 arfcn) | |
371 { | |
372 UWORD8 index; | |
373 extern const T_STD_CONFIG std_config[]; | |
374 index = std_config[l1_config.std.id].band[0]; | |
375 | |
376 if ((std_config[l1_config.std.id].band[1] != BAND_NONE) && IS_HIGH_BAND(arfcn)) | |
377 index = std_config[l1_config.std.id].band[1]; | |
378 | |
379 return (index - 1); | |
380 } | |
381 | |
382 /*------------------------------------------*/ | |
383 /* rf_program */ | |
384 /*------------------------------------------*/ | |
385 /* Programs the RF synthesizer */ | |
386 /* called each frame */ | |
387 /* downloads NA counter value */ | |
388 /* t = start time in the current frame */ | |
389 /*------------------------------------------*/ //change 2 UWORD8 | |
390 UWORD32 rf_program(UWORD32 t, SYS_UWORD16 radio_freq, UWORD32 rx) | |
391 { | |
392 UWORD32 rfdiv; | |
393 SYS_UWORD16 arfcn; | |
394 | |
395 rfband = Cust_is_band_high(radio_freq); | |
396 | |
397 arfcn = Convert_l1_radio_freq(radio_freq); | |
398 #ifdef ARFCN_DEBUG | |
399 trace_arfcn(arfcn); | |
400 #endif | |
401 rf_index = arfcn_to_rf_index(arfcn); | |
402 | |
403 rfdiv = calc_a_b(arfcn, rx); | |
404 | |
405 if (rx != 1) { | |
406 TSP_TO_RF(rfdiv | REG_PLL); | |
407 *TP_Ptr++ = TPU_FAT(0x1274); | |
408 TSP_TO_RF(0x043A | rf_chip_band); | |
409 } else { | |
410 TSP_TO_RF(rfdiv | REG_PLL); | |
411 *TP_Ptr++ = TPU_FAT(0x12FD); | |
412 TSP_TO_RF(0x023A | rf_chip_band); | |
413 } | |
414 | |
415 return(t); | |
416 } | |
417 | |
418 /**************************************************************************/ | |
419 /**************************************************************************/ | |
420 /* EXTERNAL FUNCTIONS CALLED BY LAYER1 */ | |
421 /* COMMON TO L1 and TOOLKIT */ | |
422 /**************************************************************************/ | |
423 /**************************************************************************/ | |
424 | |
425 /*------------------------------------------*/ | |
426 /* agc */ | |
427 /*------------------------------------------*/ | |
428 /* Program a gain into IF amp */ | |
429 /* agc_value : gain in dB */ | |
430 /* */ | |
431 /* additional parameter for LNA setting */ | |
432 /*------------------------------------------*/ | |
433 /* Rita and LoCosto versions look totally */ | |
434 /* different, reconstructing from disasm. */ | |
435 /*------------------------------------------*/ | |
436 | |
437 void l1dmacro_agc(SYS_UWORD16 radio_freq, WORD8 gain, UWORD8 lna_off) | |
438 { | |
439 int agc_table_index; | |
440 UWORD16 rf_data; | |
441 | |
442 agc_table_index = gain - 2; | |
443 if (agc_table_index < 0) | |
444 agc_table_index++; | |
445 agc_table_index >>= 1; | |
446 if (gain >= 42) | |
447 agc_table_index = 19; | |
448 if (gain < 16) | |
449 agc_table_index = 6; | |
450 *TP_Ptr++ = TPU_FAT(0x1334); | |
451 rf_data = REG_RX; | |
452 if (!lna_off) | |
453 rf_data |= RF_GAIN; | |
454 rf_data |= AGC_TABLE[agc_table_index] << 11; | |
455 rf_data |= RX_CAL_MODE; | |
456 TSP_TO_RF(rf_data); | |
457 } | |
458 | |
459 /*------------------------------------------*/ | |
460 /* l1dmacro_rx_synth */ | |
461 /*------------------------------------------*/ | |
462 /* programs RF synth for recceive */ | |
463 /*------------------------------------------*/ | |
464 void l1dmacro_rx_synth(SYS_UWORD16 radio_freq) | |
465 { | |
466 UWORD32 t; | |
467 | |
468 // Important: always use rx_synth_start_time for first TPU_AT | |
469 // Never remove below 2 lines!!! | |
470 t = l1_config.params.rx_synth_start_time; | |
471 *TP_Ptr++ = TPU_FAT (t); | |
472 | |
473 t = rf_program(t, radio_freq, 1); // direction is set to 1 for Rx | |
474 } | |
475 | |
476 /*------------------------------------------*/ | |
477 /* l1dmacro_tx_synth */ | |
478 /*------------------------------------------*/ | |
479 /* programs RF synth for transmit */ | |
480 /* programs OPLL for transmit */ | |
481 /*------------------------------------------*/ | |
482 void l1dmacro_tx_synth(SYS_UWORD16 radio_freq) | |
483 { | |
484 UWORD32 t; | |
485 | |
486 // Important: always use tx_synth_start_time for first TPU_AT | |
487 // Never remove below 2 lines!!! | |
488 t = l1_config.params.tx_synth_start_time; | |
489 *TP_Ptr++ = TPU_FAT (t); | |
490 | |
491 t = rf_program(t, radio_freq, 0); // direction set to 0 for Tx | |
492 } | |
493 | |
494 /*------------------------------------------*/ | |
495 /* l1dmacro_rx_up */ | |
496 /*------------------------------------------*/ | |
497 /* Open window for normal burst reception */ | |
498 /*------------------------------------------*/ | |
499 /* Rita version differs from LoCosto, */ | |
500 /* reconstructing from disassembly. */ | |
501 /*------------------------------------------*/ | |
502 void l1dmacro_rx_up (void) | |
503 { | |
504 *TP_Ptr++ = TPU_FAT(0x1377); | |
505 TSP_TO_RF(0x0A3A | rf_chip_band); | |
506 *TP_Ptr++ = TPU_FAT(0x137E); | |
507 TSP_TO_ABB(0x10); | |
508 *TP_Ptr++ = TPU_FAT(0x1383); | |
509 TSP_TO_ABB(0x18); | |
510 *TP_Ptr++ = TPU_FAT(58); | |
511 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_up | RF_SER_ON); | |
512 *TP_Ptr++ = TPU_FAT(62); | |
513 TSP_TO_ABB(0x14); | |
514 } | |
515 | |
516 /*------------------------------------------*/ | |
517 /* l1pdmacro_rx_down */ | |
518 /*------------------------------------------*/ | |
519 /* Close window for normal burst reception */ | |
520 /*------------------------------------------*/ | |
521 /* Rita version differs from LoCosto, */ | |
522 /* reconstructing from disassembly. */ | |
523 /*------------------------------------------*/ | |
524 void l1dmacro_rx_down (WORD32 t) | |
525 { | |
526 *TP_Ptr++ = TPU_FAT(t - 37); | |
527 TSP_TO_RF(0x003A); | |
528 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_ON); | |
529 *TP_Ptr++ = TPU_FAT(t - 4); | |
530 TSP_TO_ABB(0x00); | |
531 } | |
532 | |
533 /*------------------------------------------*/ | |
534 /* l1dmacro_tx_up */ | |
535 /*------------------------------------------*/ | |
536 /* Open transmission window for normal burst*/ | |
537 /*------------------------------------------*/ | |
538 /* Rita version differs from LoCosto, */ | |
539 /* reconstructing from disassembly. */ | |
540 /*------------------------------------------*/ | |
541 void l1dmacro_tx_up (void) | |
542 { | |
543 if (l1_config.std.id == DCS1800 || | |
544 rfband == MULTI_BAND2 && | |
545 (l1_config.std.id == DUAL || l1_config.std.id == DUALEXT)) { | |
546 *TP_Ptr++ = TPU_FAT(0x127E); | |
547 TSP_TO_RF(0x0007); | |
548 *TP_Ptr++ = TPU_FAT(0x1288); | |
549 TSP_TO_RF(0xC00B); | |
550 *TP_Ptr++ = TPU_FAT(0x1292); | |
551 TSP_TO_RF(0x3077); | |
552 } else { | |
553 *TP_Ptr++ = TPU_FAT(0x127E); | |
554 TSP_TO_RF(0xC003); | |
555 } | |
556 *TP_Ptr++ = TPU_FAT(0x12C6); | |
557 TSP_TO_ABB(0x80); | |
558 *TP_Ptr++ = TPU_FAT(0x12E3); | |
559 TSP_TO_RF(0x243A | rf_chip_band); | |
560 *TP_Ptr++ = TPU_FAT(0x1302); | |
561 TSP_TO_ABB(0xC0); | |
562 *TP_Ptr++ = TPU_FAT(0x1352); | |
563 TSP_TO_ABB(0x80); | |
564 *TP_Ptr++ = TPU_FAT(0x1384); | |
565 TSP_TO_ABB(0xA0); | |
566 *TP_Ptr++ = TPU_FAT(16); | |
567 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_up | RF_SER_ON); | |
568 *TP_Ptr++ = TPU_FAT(21); | |
569 *TP_Ptr++ = TPU_MOVE(TSP_ACTX, 0x0F); | |
570 } | |
571 | |
572 /*-------------------------------------------*/ | |
573 /* l1dmacro_tx_down */ | |
574 /*-------------------------------------------*/ | |
575 /* Close transmission window for normal burst*/ | |
576 /*-------------------------------------------*/ | |
577 /* Rita version differs from LoCosto, */ | |
578 /* reconstructing from disassembly. */ | |
579 /*-------------------------------------------*/ | |
580 void l1dmacro_tx_down (WORD32 t, BOOL tx_flag, UWORD8 adc_active) | |
581 { | |
582 if (adc_active == ACTIVE) | |
583 l1dmacro_adc_read_tx(t - 44); | |
584 *TP_Ptr++ = TPU_FAT(t - 4); | |
585 TSP_TO_ABB(0x80); | |
586 *TP_Ptr++ = TPU_FAT(t + 22); | |
587 *TP_Ptr++ = TPU_MOVE(TSP_ACTX, 0x00); | |
588 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_down | RF_SER_ON); | |
589 *TP_Ptr++ = TPU_FAT(t + 25); | |
590 TSP_TO_RF(0x003A); | |
591 *TP_Ptr++ = TPU_FAT(t + 31); | |
592 TSP_TO_ABB(0x00); | |
593 } | |
594 | |
595 /* | |
596 * l1dmacro_rx_nb | |
597 * | |
598 * Receive Normal burst | |
599 */ | |
600 void l1dmacro_rx_nb (SYS_UWORD16 radio_freq) | |
601 { | |
602 l1dmacro_rx_up(); | |
603 l1dmacro_rx_down(STOP_RX_SNB); | |
604 } | |
605 | |
606 /* | |
607 * l1dmacro_rx_sb | |
608 * Receive Synchro burst | |
609 */ | |
610 void l1dmacro_rx_sb (SYS_UWORD16 radio_freq) | |
611 { | |
612 l1dmacro_rx_up(); | |
613 l1dmacro_rx_down (STOP_RX_SB); | |
614 } | |
615 | |
616 /* | |
617 * l1dmacro_rx_ms | |
618 * | |
619 * Receive Power Measurement window | |
620 */ | |
621 void l1dmacro_rx_ms (SYS_UWORD16 radio_freq) | |
622 { | |
623 l1dmacro_rx_up(); | |
624 l1dmacro_rx_down (STOP_RX_PW_1); | |
625 } | |
626 | |
627 /* | |
628 * l1dmacro_rx_fb | |
629 * | |
630 * Receive Frequency burst | |
631 */ | |
632 void l1dmacro_rx_fb (SYS_UWORD16 radio_freq) | |
633 { | |
634 l1dmacro_rx_up(); | |
635 | |
636 *TP_Ptr++ = TPU_AT(0); | |
637 *TP_Ptr++ = TPU_AT(0); | |
638 *TP_Ptr++ = TPU_AT(0); | |
639 *TP_Ptr++ = TPU_AT(0); | |
640 *TP_Ptr++ = TPU_AT(0); | |
641 *TP_Ptr++ = TPU_AT(0); | |
642 *TP_Ptr++ = TPU_AT(0); | |
643 *TP_Ptr++ = TPU_AT(0); | |
644 *TP_Ptr++ = TPU_AT(0); | |
645 *TP_Ptr++ = TPU_AT(0); | |
646 *TP_Ptr++ = TPU_AT(0); | |
647 | |
648 l1dmacro_rx_down (STOP_RX_FB); | |
649 } | |
650 | |
651 /* | |
652 * l1dmacro_rx_fb26 | |
653 * | |
654 * Receive Frequency burst for TCH. | |
655 */ | |
656 void l1dmacro_rx_fb26 (SYS_UWORD16 radio_freq) | |
657 { | |
658 l1dmacro_rx_up(); | |
659 | |
660 *TP_Ptr++ = TPU_AT(0); | |
661 | |
662 l1dmacro_rx_down (STOP_RX_FB26); | |
663 } | |
664 | |
665 /* | |
666 * l1dmacro_tx_nb | |
667 * | |
668 * Transmit Normal burst | |
669 */ | |
670 void l1dmacro_tx_nb (SYS_UWORD16 radio_freq, UWORD8 txpwr, UWORD8 adc_active) | |
671 { | |
672 l1dmacro_tx_up (); | |
673 l1dmacro_tx_down (l1_config.params.tx_nb_duration, FALSE, adc_active); | |
674 } | |
675 | |
676 /* | |
677 * l1dmacro_tx_ra | |
678 * | |
679 * Transmit Random Access burst | |
680 */ | |
681 void l1dmacro_tx_ra (SYS_UWORD16 radio_freq, UWORD8 txpwr, UWORD8 adc_active) | |
682 { | |
683 l1dmacro_tx_up (); | |
684 l1dmacro_tx_down (l1_config.params.tx_ra_duration, FALSE, adc_active); | |
685 } | |
686 | |
687 #if TESTMODE | |
688 /* | |
689 * l1dmacro_rx_cont | |
690 * | |
691 * Receive continuously | |
692 */ | |
693 void l1dmacro_rx_cont (SYS_UWORD16 radio_freq, UWORD8 txpwr) | |
694 { | |
695 l1dmacro_rx_up (); | |
696 } | |
697 | |
698 /* | |
699 * l1dmacro_tx_cont | |
700 * | |
701 * Transmit continuously | |
702 */ | |
703 void l1dmacro_tx_cont (SYS_UWORD16 radio_freq, UWORD8 txpwr) | |
704 { | |
705 l1dmacro_tx_up (); | |
706 } | |
707 | |
708 /* | |
709 * l1d_macro_stop_cont | |
710 * | |
711 * Stop continuous Tx or Rx | |
712 */ | |
713 void l1dmacro_stop_cont (void) | |
714 { | |
715 if (l1_config.tmode.rf_params.down_up == TMODE_DOWNLINK) | |
716 l1dmacro_rx_down(STOP_RX_SNB); | |
717 else | |
718 l1dmacro_tx_down(l1_config.params.tx_nb_duration, FALSE, 0); | |
719 } | |
720 #endif /* TESTMODE */ | |
721 | |
722 | |
723 /*------------------------------------------*/ | |
724 /* l1dmacro_reset_hw */ | |
725 /*------------------------------------------*/ | |
726 /* Reset and set OFFSET register */ | |
727 /*------------------------------------------*/ | |
728 | |
729 void l1dmacro_reset_hw(UWORD32 servingCellOffset) | |
730 { | |
731 TPU_Reset(1); // reset TPU only, no TSP reset | |
732 TPU_Reset(0); | |
733 TP_Ptr = (UWORD16 *) TPU_RAM; | |
734 | |
735 *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON); | |
736 *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON | FEM_OFF); | |
737 | |
738 *TP_Ptr++ = TPU_OFFSET(servingCellOffset); | |
739 } | |
740 | |
741 // l1dmacro_RF_sleep | |
742 // Program RF for BIG or DEEP sleep | |
743 | |
744 | |
745 /* Rita version differs from LoCosto, reconstructing from disassembly */ | |
746 void l1dmacro_RF_sleep (void) | |
747 { | |
748 TSP_TO_RF(0x0002); | |
749 *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON); | |
750 *TP_Ptr++ = TPU_WAIT(1); | |
751 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET1, 0x21); | |
752 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET2, 0x02); | |
753 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_RF | 0x01); | |
754 *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR); | |
755 *TP_Ptr++ = TPU_WAIT(100); | |
756 /* code from tpudrv61.c follows, same for Rita and LoCosto */ | |
757 *TP_Ptr++ = TPU_SLEEP; | |
758 TP_Ptr = (SYS_UWORD16 *) TPU_RAM; | |
759 TP_Enable(1); | |
760 #if 0 /* present in LoCosto but not in TCS211 */ | |
761 TPU_wait_idle(); | |
762 #endif | |
763 } | |
764 | |
765 // l1dmacro_RF_wakeup | |
766 //* wakeup RF from BIG or DEEP sleep | |
767 | |
768 /* Rita version differs from LoCosto, reconstructing from disassembly */ | |
769 void l1dmacro_RF_wakeup (void) | |
770 { | |
771 TP_Ptr = (SYS_UWORD16 *) TPU_RAM; | |
772 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET1, 0x01); | |
773 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET2, 0x06); | |
774 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_RF | 0x01); | |
775 *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR); | |
776 *TP_Ptr++ = TPU_WAIT(100); | |
777 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_ON); | |
778 *TP_Ptr++ = TPU_WAIT(1); | |
779 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_OFF); | |
780 *TP_Ptr++ = TPU_WAIT(8); | |
781 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_ON); | |
782 *TP_Ptr++ = TPU_WAIT(5); | |
783 TSP_TO_RF(0x0012); | |
784 *TP_Ptr++ = TPU_FAT(0); | |
785 *TP_Ptr++ = TPU_FAT(0); | |
786 *TP_Ptr++ = TPU_FAT(0); | |
787 *TP_Ptr++ = TPU_FAT(0); | |
788 *TP_Ptr++ = TPU_FAT(0); | |
789 *TP_Ptr++ = TPU_FAT(0); | |
790 TSP_TO_RF(0x003A); | |
791 *TP_Ptr++ = TPU_WAIT(7); | |
792 TSP_TO_RF(0xC003); | |
793 *TP_Ptr++ = TPU_WAIT(7); | |
794 TSP_TO_RF(0x02FE); | |
795 *TP_Ptr++ = TPU_WAIT(7); | |
796 TSP_TO_RF(0x401F); | |
797 *TP_Ptr++ = TPU_WAIT(7); | |
798 TSP_TO_RF(0x043D); | |
799 *TP_Ptr++ = TPU_WAIT(7); | |
800 *TP_Ptr++ = TPU_WAIT(117); | |
801 /* code from tpudrv61.c follows, same for Rita and LoCosto */ | |
802 *TP_Ptr++ = TPU_SLEEP; | |
803 TP_Ptr = (SYS_UWORD16 *) TPU_RAM; | |
804 TP_Enable(1); | |
805 #if 0 /* present in LoCosto but not in TCS211 */ | |
806 TPU_wait_idle(); | |
807 #endif | |
808 } | |
809 | |
810 | |
811 // l1dmacro_init_hw | |
812 // Reset VEGA, then remove reset | |
813 // Init RF/IF synthesizers | |
814 | |
815 void l1dmacro_init_hw(void) | |
816 { | |
817 WORD32 t = 100; // start time for actions | |
818 | |
819 TP_Reset(1); // reset TPU and TSP | |
820 | |
821 // GSM 1.5 : TPU clock enable is in TPU | |
822 //--------------------------------------- | |
823 TPU_ClkEnable(1); // TPU CLOCK ON | |
824 | |
825 TP_Reset(0); | |
826 | |
827 | |
828 TP_Ptr = (UWORD16 *) TPU_RAM; | |
829 | |
830 // Set FEM to inactive state before turning ON the RF Board | |
831 // At this point the RF regulators are still OFF. Thus the | |
832 // FEM command is not inverted yet => Must use the FEM "SLEEP programming" | |
833 *TP_Ptr++ = TPU_MOVE(TSP_ACT, FEM_SLEEP | RF_SER_ON); | |
834 | |
835 // TPU_SLEEP | |
836 l1dmacro_idle(); | |
837 | |
838 *TP_Ptr++ = TPU_AT(t); | |
839 *TP_Ptr++ = TPU_SYNC(0); | |
840 | |
841 /* from disassembly, differs from LoCosto version */ | |
842 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET1, 0x20); | |
843 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET2, 0x06); | |
844 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET3, 0x00); | |
845 | |
846 t = 1000; // arbitrary start time | |
847 | |
848 t = rf_init(t); // Initialize RF Board | |
849 | |
850 *TP_Ptr++ = TPU_AT(t); | |
851 | |
852 // TPU_SLEEP | |
853 l1dmacro_idle(); | |
854 | |
855 return; | |
856 } | |
857 | |
858 /*------------------------------------------*/ | |
859 /* l1dmacro_init_hw_light */ | |
860 /*------------------------------------------*/ | |
861 /* Reset VEGA, then remove reset */ | |
862 /* Init RF/IF synthesizers */ | |
863 /*------------------------------------------*/ | |
864 void l1dmacro_init_hw_light(void) | |
865 { | |
866 UWORD32 t = 100; // start time for actions // | |
867 TP_Ptr = (SYS_UWORD16 *) TPU_RAM; // | |
868 *TP_Ptr++ = TPU_AT(t); // | |
869 t = 1000; // arbitrary start time // | |
870 | |
871 t = rf_init_light(t); // Initialize RF Board // | |
872 | |
873 *TP_Ptr++ = TPU_AT(t); // | |
874 l1dmacro_idle(); // | |
875 | |
876 return; | |
877 } |