comparison src/cs/layer1/tpu_drivers/source0/tpudrv10.c @ 0:b6a5e36de839

src/cs: initial import from Magnetite
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 15 Jul 2018 04:39:26 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:b6a5e36de839
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 static UWORD8 magic2_byte;
69
70 // Internal function prototypes
71 void l1dmacro_rx_down (WORD32 t);
72
73 SYS_UWORD16 Convert_l1_radio_freq(SYS_UWORD16 radio_freq);
74 WORD32 rf_init(WORD32 t);
75
76 // External function prototypes
77 UWORD8 Cust_is_band_high(UWORD16 radio_freq);
78
79
80 extern T_RF_BAND rf_band[];
81 extern T_RF rf;
82
83 /**************************************************************************/
84 /**************************************************************************/
85 /* DEFINITION OF MACROS FOR CHIPS SERIAL PROGRAMMATION */
86 /**************************************************************************/
87 /**************************************************************************/
88
89 /*------------------------------------------*/
90 /* Is arfcn in the DCS band (512-885) ? */
91 /*------------------------------------------*/
92 #define IS_HIGH_BAND(arfcn) (((arfcn >= 512) && (arfcn <= 885)) ? 1 : 0)
93
94 /*------------------------------------------*/
95 /* Send a value to Rita RF */
96 /*------------------------------------------*/
97 #define TSP_TO_RF(rf_data)\
98 {\
99 *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_1, ((rf_data) >> 8) & 0xFF); \
100 *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_2, (rf_data) & 0xFF); \
101 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_RF | 0x0F); \
102 *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR); \
103 }
104
105 /*------------------------------------------*/
106 /* Send a TSP command to ABB */
107 /*------------------------------------------*/
108 #define TSP_TO_ABB(data)\
109 {\
110 *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_1, (data) & 0xFF); \
111 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_ABB | 0x06); \
112 *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR); \
113 }
114
115 /*------------------------------------------*/
116 /* Trace arfcn for conversion debug */
117 /*------------------------------------------*/
118 #ifdef ARFCN_DEBUG
119 // ----Debug information : record all arfcn programmed into synthesizer!
120 #define MAX_ARFCN_TRACE 4096 // enough for 5 sessions of 124+374
121 SYS_UWORD16 arfcn_trace[MAX_ARFCN_TRACE];
122 static UWORD32 arfcn_trace_index = 0;
123
124 void trace_arfcn(SYS_UWORD16 arfcn)
125 {
126 arfcn_trace[arfcn_trace_index++] = arfcn;
127
128 // Wrap to beginning
129 if (arfcn_trace_index == MAX_ARFCN_TRACE)
130 arfcn_trace_index = 0;
131 }
132 #endif
133
134
135 /**************************************************************************/
136 /**************************************************************************/
137 /* DEFINITION OF HARWARE DEPENDANT CONSTANTS */
138 /**************************************************************************/
139 /**************************************************************************/
140
141 /**************************************************************************/
142 /**************************************************************************/
143 /* INTERNAL FUNCTIONS OF TPUDRV14.C */
144 /* EFFECTIVE DOWNLOADING THROUGH TSP */
145 /**************************************************************************/
146 /**************************************************************************/
147
148 struct synth_s {
149 // common
150 UWORD16 arfcn0;
151 UWORD16 limit;
152 // Tx
153 UWORD16 ul_farfcn0;
154 WORD8 ul_sign;
155 // Rx
156 UWORD16 dl_farfcn0;
157 UWORD8 dl_mult;
158 };
159
160 struct magic1_s {
161 UWORD16 limit;
162 UWORD16 magic;
163 };
164
165 struct magic2_s {
166 UWORD16 limit;
167 UWORD8 magic;
168 };
169
170 struct rf_path_s {
171 UWORD16 rf_chip_band;
172 UWORD8 rx_up;
173 UWORD8 rx_down;
174 UWORD8 tx_up;
175 UWORD8 tx_down;
176 UWORD8 tx_up_rev;
177 const struct synth_s *synth;
178 const struct magic1_s *tx_magic1;
179 const struct magic2_s *rx_magic2;
180 };
181
182 static const struct synth_s synth_900[] =
183 {
184 { 0, 124, 890, 1, 935, 4},// gsm 0 - 124
185 {974, 1023, 880, 1, 925, 4},// egsm 975 - 1023
186 };
187
188 static const struct magic1_s magic1_900[] =
189 {
190 { 26, 0x0820},
191 { 35, 0x0854},
192 { 42, 0x0847},
193 { 54, 0x0861},
194 { 60, 0x0847},
195 { 69, 0x0861},
196 { 79, 0x0847},
197 { 94, 0x083A},
198 { 105, 0x0847},
199 { 112, 0x0854},
200 { 117, 0x082D},
201 { 124, 0x0847},
202 { 988, 0x0820},
203 {1014, 0x083A},
204 {1023, 0x0820},
205 };
206
207 static const struct magic2_s magic2_rx900[] =
208 {
209 {0x4B00, 7},
210 {0x4E20, 7},
211 {0xFFFF, 7},
212 };
213
214 static const struct synth_s synth_1800[] =
215 {
216 {511, 885, 1710, -1, 1805, 1}, // dcs 512 - 885
217 };
218
219 static const struct magic1_s magic1_1800[] =
220 {
221 {571, 0x0820},
222 {610, 0x0847},
223 {671, 0x083A},
224 {688, 0x082D},
225 {719, 0x083A},
226 {730, 0x0861},
227 {755, 0x083A},
228 {794, 0x0847},
229 {845, 0x0820},
230 {885, 0x082D},
231 };
232
233 static const struct magic2_s magic2_rx1800[] =
234 {
235 {0x24B8, 0},
236 {0x2710, 0},
237 {0xFFFF, 0},
238 };
239
240 static const struct synth_s synth_1900[] =
241 {
242 {511, 810, 1850, -1, 1930, 1}, // pcs 512 - 810;
243 };
244
245 static const struct magic1_s magic1_1900[] =
246 {
247 {550, 0x0847},
248 {615, 0x082D},
249 {642, 0x083A},
250 {702, 0x0820},
251 {777, 0x0854},
252 {810, 0x0861},
253 };
254
255 static const struct magic2_s magic2_rx1900[] =
256 {
257 {0x26DE, 0},
258 {0x2710, 0},
259 {0xFFFF, 0},
260 };
261
262 static const struct synth_s synth_850[] =
263 {
264 {127, 251, 824, 1, 869, 4}, // gsm850
265 };
266
267 static const struct magic1_s magic1_850[] =
268 {
269 {251, 0x0924},
270 };
271
272 static const struct magic2_s magic2_rx850[] =
273 {
274 {0x4B00, 7},
275 {0x4E20, 7},
276 {0xFFFF, 7},
277 };
278
279 static const struct magic2_s magic2_tx[] =
280 {
281 {0x1A90, 6},
282 {0x1CED, 7},
283 {0x1D4C, 7},
284 {0xFFFF, 7},
285 };
286
287 static const struct rf_path_s rf_path[] = {
288 //same index used as for band_config[] - 1
289 /* EGSM */
290 { BAND_SELECT_GSM, RU_900, RD_900, TU_900, TD_900, TU_REV_900,
291 synth_900, magic1_900, magic2_rx900},
292 /* DCS */
293 { BAND_SELECT_DCS, RU_1800, RD_1800, TU_1800, TD_1800, TU_REV_1800,
294 synth_1800, magic1_1800, magic2_rx1800},
295 /* PCS */
296 { BAND_SELECT_PCS, RU_1900, RD_1900, TU_1900, TD_1900, TU_REV_1900,
297 synth_1900, magic1_1900, magic2_rx1900},
298 /* GSM850 */
299 { BAND_SELECT_850, RU_850, RD_850, TU_850, TD_850, TU_REV_850,
300 synth_850, magic1_850, magic2_rx850},
301 /* PCS in dual-us */
302 { BAND_SELECT_PCS, RU_1900, RD_1900, TU_1900, TD_1900, TU_REV_1900,
303 synth_1900, magic1_1900, magic2_rx1900},
304 /* non-E GSM */
305 { BAND_SELECT_GSM, RU_900, RD_900, TU_900, TD_900, TU_REV_900,
306 synth_900, magic1_900, magic2_rx900},
307 };
308
309 static UWORD32 calc_freq_prog(UWORD16 arfcn, UWORD8 downlink)
310 {
311 UWORD32 farfcn; /* sp+0x1C, in 200 kHz units */
312 const struct synth_s *s;
313 const struct magic1_s *m1;
314 const struct magic2_s *m2;
315 UWORD32 magic1; /* sp+0x24 */
316 UWORD16 sp4;
317 UWORD32 sp8, sp0xC, sp0x10, sp0x14, sp0x18, sp0x20;
318
319 s = rf_path[rf_index].synth;
320 while(s->limit < arfcn)
321 s++;
322
323 m1 = rf_path[rf_index].tx_magic1;
324 while(m1->limit < arfcn)
325 m1++;
326 magic1 = m1->magic;
327
328 if (downlink) {
329 sp0x20 = 0x27627 * s->dl_mult + 8;
330 farfcn = 5*s->dl_farfcn0 + (arfcn - s->arfcn0);
331 sp4 = farfcn * s->dl_mult;
332 sp0x18 = sp4 << 21;
333 sp0x14 = sp0x20 * farfcn;
334 m2 = rf_path[rf_index].rx_magic2;
335 } else {
336 sp0x20 = 0x2762F;
337 farfcn = 5*s->ul_farfcn0 + (arfcn - s->arfcn0);
338 sp4 = magic1 * s->ul_sign + farfcn;
339 sp0x18 = sp4 << 21;
340 sp0x14 = sp0x20 * (magic1 * s->ul_sign + farfcn);
341 m2 = magic2_tx;
342 }
343
344 while(m2->limit < sp4)
345 m2++;
346 magic2_byte = (m2->magic & 7) << 5;
347
348 sp8 = (sp0x14 / 16) >> 21;
349 sp0xC = sp0x14 - (sp8 << 25);
350 sp0x10 = (((sp8 << 4) + sp0xC) * 0x1A00000 - 0x18) >> 21;
351
352 return ((sp0xC & 0xF) << 12) | ((sp8 & 0x7F) << 16) | ((sp0x10 & 0xF) << 8);
353 }
354
355 /*------------------------------------------*/
356 /* Convert_l1_radio_freq */
357 /*------------------------------------------*/
358 /* conversion of l1 radio_freq to */
359 /* real channel number */
360 /*------------------------------------------*/
361 SYS_UWORD16 Convert_l1_radio_freq(SYS_UWORD16 radio_freq)
362 {
363 switch(l1_config.std.id)
364 {
365 case GSM:
366 case DCS1800:
367 case PCS1900:
368 case GSM850:
369 return (radio_freq);
370 //omaps00090550 break;
371
372 case DUAL:
373 {
374 if (radio_freq < l1_config.std.first_radio_freq_band2)
375 // GSM band...
376 return(radio_freq);
377 else
378 // DCS band...
379 return (radio_freq - l1_config.std.first_radio_freq_band2 + 512);
380 }
381 //omaps00090550 break;
382
383 case DUALEXT:
384 {
385 if (radio_freq < l1_config.std.first_radio_freq_band2)
386 // E-GSM band...
387 {
388 if(radio_freq <= 124)
389 // GSM part...
390 return(radio_freq);
391 if(radio_freq < 174)
392 // Extended part...
393 return (radio_freq - 125 + 975);
394 else
395 // Extended part, special case of ARFCN=0
396 return(0);
397 }
398 else
399 {
400 // DCS band...
401 return (radio_freq - l1_config.std.first_radio_freq_band2 + 512);
402 }
403 }
404 // break;
405
406 case GSM_E:
407 {
408 if(radio_freq <= 124)
409 // GSM part...
410 return(radio_freq);
411 else
412 if(radio_freq < 174)
413 // Extended part...
414 return (radio_freq - 125 + 975);
415 else
416 // Extended part, special case of ARFCN=0
417 return(0);
418 }
419 //omaps00090550 break;
420
421 case DUAL_US:
422 {
423 if (radio_freq < l1_config.std.first_radio_freq_band2)
424 {
425 return(radio_freq - l1_config.std.first_radio_freq + 128);
426 }
427 else
428 {
429 // PCS band...
430 return (radio_freq - l1_config.std.first_radio_freq_band2 + 512);
431 }
432 }
433 // break;
434
435 default: // should never occur.
436 return(radio_freq);
437 } // end of switch
438 }
439
440 /*------------------------------------------*/
441 /* rf_init */
442 /*------------------------------------------*/
443 /* Initialization routine for PLL */
444 /* Effective downloading through TSP */
445 /*------------------------------------------*/
446 /* Rita and LoCosto versions look totally */
447 /* different, reconstructing from disasm. */
448 /*------------------------------------------*/
449 WORD32 rf_init(WORD32 t)
450 {
451 #if 0
452 *TP_Ptr++ = TPU_AT(t);
453 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, 0x47);
454 t += 5;
455 *TP_Ptr++ = TPU_AT(t);
456 *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_OFF);
457 t += 8;
458 *TP_Ptr++ = TPU_AT(t);
459 *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON);
460 t += 5;
461 *TP_Ptr++ = TPU_AT(t);
462 TSP_TO_RF(0x0012);
463 t += 7;
464 *TP_Ptr++ = TPU_AT(t);
465 *TP_Ptr++ = TPU_AT(t);
466 *TP_Ptr++ = TPU_AT(t);
467 *TP_Ptr++ = TPU_AT(t);
468 *TP_Ptr++ = TPU_AT(t);
469 *TP_Ptr++ = TPU_AT(t);
470 TSP_TO_RF(0x003A);
471 t += 117;
472 *TP_Ptr++ = TPU_AT(t);
473 TSP_TO_RF(0xC003);
474 t += 7;
475 *TP_Ptr++ = TPU_AT(t);
476 TSP_TO_RF(0x02FE);
477 t += 7;
478 *TP_Ptr++ = TPU_AT(t);
479 TSP_TO_RF(0x401F);
480 t += 7;
481 *TP_Ptr++ = TPU_AT(t);
482 TSP_TO_RF(0x043D);
483 t += 7;
484 #endif
485 return(t);
486 }
487
488 /*------------------------------------------*/
489 /* rf_init_light */
490 /*------------------------------------------*/
491 /* Initialization routine for PLL */
492 /* Effective downloading through TSP */
493 /*------------------------------------------*/
494 WORD32 rf_init_light(WORD32 t)
495 {
496 // initialization for change of multi-band configuration dependent on STD
497 return(t);
498 }
499
500 UWORD8 arfcn_to_rf_index(SYS_UWORD16 arfcn)
501 {
502 UWORD8 index;
503 extern const T_STD_CONFIG std_config[];
504 index = std_config[l1_config.std.id].band[0];
505
506 if ((std_config[l1_config.std.id].band[1] != BAND_NONE) && IS_HIGH_BAND(arfcn))
507 index = std_config[l1_config.std.id].band[1];
508
509 return (index - 1);
510 }
511
512 /*------------------------------------------*/
513 /* rf_program */
514 /*------------------------------------------*/
515 /* Programs the RF synthesizer */
516 /* called each frame */
517 /* downloads NA counter value */
518 /* t = start time in the current frame */
519 /*------------------------------------------*/ //change 2 UWORD8
520 UWORD32 rf_program(UWORD32 t, SYS_UWORD16 radio_freq, UWORD32 rx)
521 {
522 UWORD32 rfdiv;
523 SYS_UWORD16 arfcn;
524
525 rfband = Cust_is_band_high(radio_freq);
526
527 arfcn = Convert_l1_radio_freq(radio_freq);
528 #ifdef ARFCN_DEBUG
529 trace_arfcn(arfcn);
530 #endif
531 rf_index = arfcn_to_rf_index(arfcn);
532
533 #if 0
534 rfdiv = calc_a_b(arfcn, rx);
535
536 if (rx != 1) {
537 TSP_TO_RF(rfdiv | REG_PLL);
538 *TP_Ptr++ = TPU_FAT(0x1274);
539 TSP_TO_RF(0x043A | rf_chip_band);
540 } else {
541 TSP_TO_RF(rfdiv | REG_PLL);
542 *TP_Ptr++ = TPU_FAT(0x12FD);
543 TSP_TO_RF(0x023A | rf_chip_band);
544 }
545 #endif
546
547 return(t);
548 }
549
550 /**************************************************************************/
551 /**************************************************************************/
552 /* EXTERNAL FUNCTIONS CALLED BY LAYER1 */
553 /* COMMON TO L1 and TOOLKIT */
554 /**************************************************************************/
555 /**************************************************************************/
556
557 /*------------------------------------------*/
558 /* agc */
559 /*------------------------------------------*/
560 /* Program a gain into IF amp */
561 /* agc_value : gain in dB */
562 /* */
563 /* additional parameter for LNA setting */
564 /*------------------------------------------*/
565 /* Rita and LoCosto versions look totally */
566 /* different, reconstructing from disasm. */
567 /*------------------------------------------*/
568
569 void l1dmacro_agc(SYS_UWORD16 radio_freq, WORD8 gain, UWORD8 lna_off)
570 {
571 int agc_table_index;
572 UWORD16 rf_data;
573
574 #if 0
575 agc_table_index = gain - 2;
576 if (agc_table_index < 0)
577 agc_table_index++;
578 agc_table_index >>= 1;
579 if (gain >= 42)
580 agc_table_index = 19;
581 if (gain < 16)
582 agc_table_index = 6;
583 *TP_Ptr++ = TPU_FAT(0x1334);
584 rf_data = REG_RX;
585 if (!lna_off)
586 rf_data |= RF_GAIN;
587 rf_data |= AGC_TABLE[agc_table_index] << 11;
588 rf_data |= RX_CAL_MODE;
589 TSP_TO_RF(rf_data);
590 #endif
591 }
592
593 /*------------------------------------------*/
594 /* l1dmacro_rx_synth */
595 /*------------------------------------------*/
596 /* programs RF synth for recceive */
597 /*------------------------------------------*/
598 void l1dmacro_rx_synth(SYS_UWORD16 radio_freq)
599 {
600 UWORD32 t;
601
602 // Important: always use rx_synth_start_time for first TPU_AT
603 // Never remove below 2 lines!!!
604 t = l1_config.params.rx_synth_start_time;
605 *TP_Ptr++ = TPU_FAT (t);
606
607 t = rf_program(t, radio_freq, 1); // direction is set to 1 for Rx
608 }
609
610 /*------------------------------------------*/
611 /* l1dmacro_tx_synth */
612 /*------------------------------------------*/
613 /* programs RF synth for transmit */
614 /* programs OPLL for transmit */
615 /*------------------------------------------*/
616 void l1dmacro_tx_synth(SYS_UWORD16 radio_freq)
617 {
618 UWORD32 t;
619
620 // Important: always use tx_synth_start_time for first TPU_AT
621 // Never remove below 2 lines!!!
622 t = l1_config.params.tx_synth_start_time;
623 *TP_Ptr++ = TPU_FAT (t);
624
625 t = rf_program(t, radio_freq, 0); // direction set to 0 for Tx
626 }
627
628 /*------------------------------------------*/
629 /* l1dmacro_rx_up */
630 /*------------------------------------------*/
631 /* Open window for normal burst reception */
632 /*------------------------------------------*/
633 /* Rita version differs from LoCosto, */
634 /* reconstructing from disassembly. */
635 /*------------------------------------------*/
636 void l1dmacro_rx_up (void)
637 {
638 #if 0
639 *TP_Ptr++ = TPU_FAT(0x1377);
640 TSP_TO_RF(0x0A3A | rf_chip_band);
641 *TP_Ptr++ = TPU_FAT(0x137E);
642 TSP_TO_ABB(0x10);
643 *TP_Ptr++ = TPU_FAT(0x1383);
644 TSP_TO_ABB(0x18);
645 *TP_Ptr++ = TPU_FAT(58);
646 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_up | RF_SER_ON);
647 *TP_Ptr++ = TPU_FAT(62);
648 TSP_TO_ABB(0x14);
649 #endif
650 }
651
652 /*------------------------------------------*/
653 /* l1pdmacro_rx_down */
654 /*------------------------------------------*/
655 /* Close window for normal burst reception */
656 /*------------------------------------------*/
657 /* Rita version differs from LoCosto, */
658 /* reconstructing from disassembly. */
659 /*------------------------------------------*/
660 void l1dmacro_rx_down (WORD32 t)
661 {
662 #if 0
663 *TP_Ptr++ = TPU_FAT(t - 37);
664 TSP_TO_RF(0x003A);
665 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_ON);
666 *TP_Ptr++ = TPU_FAT(t - 4);
667 TSP_TO_ABB(0x00);
668 #endif
669 }
670
671 /*------------------------------------------*/
672 /* l1dmacro_tx_up */
673 /*------------------------------------------*/
674 /* Open transmission window for normal burst*/
675 /*------------------------------------------*/
676 /* Rita version differs from LoCosto, */
677 /* reconstructing from disassembly. */
678 /*------------------------------------------*/
679 void l1dmacro_tx_up (void)
680 {
681 #if 0
682 if (l1_config.std.id == DCS1800 ||
683 rfband == MULTI_BAND2 &&
684 (l1_config.std.id == DUAL || l1_config.std.id == DUALEXT)) {
685 *TP_Ptr++ = TPU_FAT(0x127E);
686 TSP_TO_RF(0x0007);
687 *TP_Ptr++ = TPU_FAT(0x1288);
688 TSP_TO_RF(0xC00B);
689 *TP_Ptr++ = TPU_FAT(0x1292);
690 TSP_TO_RF(0x3077);
691 } else {
692 *TP_Ptr++ = TPU_FAT(0x127E);
693 TSP_TO_RF(0xC003);
694 }
695 *TP_Ptr++ = TPU_FAT(0x12C6);
696 TSP_TO_ABB(0x80);
697 *TP_Ptr++ = TPU_FAT(0x12E3);
698 TSP_TO_RF(0x243A | rf_chip_band);
699 *TP_Ptr++ = TPU_FAT(0x1302);
700 TSP_TO_ABB(0xC0);
701 *TP_Ptr++ = TPU_FAT(0x1352);
702 TSP_TO_ABB(0x80);
703 *TP_Ptr++ = TPU_FAT(0x1384);
704 TSP_TO_ABB(0xA0);
705 *TP_Ptr++ = TPU_FAT(16);
706 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_up | RF_SER_ON);
707 *TP_Ptr++ = TPU_FAT(21);
708 *TP_Ptr++ = TPU_MOVE(TSP_ACTX, 0x0F);
709 #endif
710 }
711
712 /*-------------------------------------------*/
713 /* l1dmacro_tx_down */
714 /*-------------------------------------------*/
715 /* Close transmission window for normal burst*/
716 /*-------------------------------------------*/
717 /* Rita version differs from LoCosto, */
718 /* reconstructing from disassembly. */
719 /*-------------------------------------------*/
720 void l1dmacro_tx_down (WORD32 t, BOOL tx_flag, UWORD8 adc_active)
721 {
722 #if 0
723 if (adc_active == ACTIVE)
724 l1dmacro_adc_read_tx(t - 44);
725 *TP_Ptr++ = TPU_FAT(t - 4);
726 TSP_TO_ABB(0x80);
727 *TP_Ptr++ = TPU_FAT(t + 22);
728 *TP_Ptr++ = TPU_MOVE(TSP_ACTX, 0x00);
729 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_down | RF_SER_ON);
730 *TP_Ptr++ = TPU_FAT(t + 25);
731 TSP_TO_RF(0x003A);
732 *TP_Ptr++ = TPU_FAT(t + 31);
733 TSP_TO_ABB(0x00);
734 #endif
735 }
736
737 /*
738 * l1dmacro_rx_nb
739 *
740 * Receive Normal burst
741 */
742 void l1dmacro_rx_nb (SYS_UWORD16 radio_freq)
743 {
744 l1dmacro_rx_up();
745 l1dmacro_rx_down(STOP_RX_SNB);
746 }
747
748 /*
749 * l1dmacro_rx_sb
750 * Receive Synchro burst
751 */
752 void l1dmacro_rx_sb (SYS_UWORD16 radio_freq)
753 {
754 l1dmacro_rx_up();
755 l1dmacro_rx_down (STOP_RX_SB);
756 }
757
758 /*
759 * l1dmacro_rx_ms
760 *
761 * Receive Power Measurement window
762 */
763 void l1dmacro_rx_ms (SYS_UWORD16 radio_freq)
764 {
765 l1dmacro_rx_up();
766 l1dmacro_rx_down (STOP_RX_PW_1);
767 }
768
769 /*
770 * l1dmacro_rx_fb
771 *
772 * Receive Frequency burst
773 */
774 void l1dmacro_rx_fb (SYS_UWORD16 radio_freq)
775 {
776 l1dmacro_rx_up();
777
778 *TP_Ptr++ = TPU_AT(0);
779 *TP_Ptr++ = TPU_AT(0);
780 *TP_Ptr++ = TPU_AT(0);
781 *TP_Ptr++ = TPU_AT(0);
782 *TP_Ptr++ = TPU_AT(0);
783 *TP_Ptr++ = TPU_AT(0);
784 *TP_Ptr++ = TPU_AT(0);
785 *TP_Ptr++ = TPU_AT(0);
786 *TP_Ptr++ = TPU_AT(0);
787 *TP_Ptr++ = TPU_AT(0);
788 *TP_Ptr++ = TPU_AT(0);
789
790 l1dmacro_rx_down (STOP_RX_FB);
791 }
792
793 /*
794 * l1dmacro_rx_fb26
795 *
796 * Receive Frequency burst for TCH.
797 */
798 void l1dmacro_rx_fb26 (SYS_UWORD16 radio_freq)
799 {
800 l1dmacro_rx_up();
801
802 *TP_Ptr++ = TPU_AT(0);
803
804 l1dmacro_rx_down (STOP_RX_FB26);
805 }
806
807 /*
808 * l1dmacro_tx_nb
809 *
810 * Transmit Normal burst
811 */
812 void l1dmacro_tx_nb (SYS_UWORD16 radio_freq, UWORD8 txpwr, UWORD8 adc_active)
813 {
814 l1dmacro_tx_up ();
815 l1dmacro_tx_down (l1_config.params.tx_nb_duration, FALSE, adc_active);
816 }
817
818 /*
819 * l1dmacro_tx_ra
820 *
821 * Transmit Random Access burst
822 */
823 void l1dmacro_tx_ra (SYS_UWORD16 radio_freq, UWORD8 txpwr, UWORD8 adc_active)
824 {
825 l1dmacro_tx_up ();
826 l1dmacro_tx_down (l1_config.params.tx_ra_duration, FALSE, adc_active);
827 }
828
829 #if TESTMODE
830 /*
831 * l1dmacro_rx_cont
832 *
833 * Receive continuously
834 */
835 void l1dmacro_rx_cont (SYS_UWORD16 radio_freq, UWORD8 txpwr)
836 {
837 l1dmacro_rx_up ();
838 }
839
840 /*
841 * l1dmacro_tx_cont
842 *
843 * Transmit continuously
844 */
845 void l1dmacro_tx_cont (SYS_UWORD16 radio_freq, UWORD8 txpwr)
846 {
847 l1dmacro_tx_up ();
848 }
849
850 /*
851 * l1d_macro_stop_cont
852 *
853 * Stop continuous Tx or Rx
854 */
855 void l1dmacro_stop_cont (void)
856 {
857 if (l1_config.tmode.rf_params.down_up == TMODE_DOWNLINK)
858 l1dmacro_rx_down(STOP_RX_SNB);
859 else
860 l1dmacro_tx_down(l1_config.params.tx_nb_duration, FALSE, 0);
861 }
862 #endif /* TESTMODE */
863
864
865 /*------------------------------------------*/
866 /* l1dmacro_reset_hw */
867 /*------------------------------------------*/
868 /* Reset and set OFFSET register */
869 /*------------------------------------------*/
870
871 void l1dmacro_reset_hw(UWORD32 servingCellOffset)
872 {
873 TPU_Reset(1); // reset TPU only, no TSP reset
874 TPU_Reset(0);
875 TP_Ptr = (UWORD16 *) TPU_RAM;
876
877 #if 0
878 *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON);
879 *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON | FEM_OFF);
880 #endif
881
882 *TP_Ptr++ = TPU_OFFSET(servingCellOffset);
883 }
884
885 // l1dmacro_RF_sleep
886 // Program RF for BIG or DEEP sleep
887
888
889 /* Rita version differs from LoCosto, reconstructing from disassembly */
890 void l1dmacro_RF_sleep (void)
891 {
892 #if 0
893 TSP_TO_RF(0x0002);
894 *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON);
895 *TP_Ptr++ = TPU_WAIT(1);
896 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET1, 0x21);
897 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET2, 0x02);
898 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_RF | 0x01);
899 *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR);
900 *TP_Ptr++ = TPU_WAIT(100);
901 #endif
902 /* code from tpudrv61.c follows, same for Rita and LoCosto */
903 *TP_Ptr++ = TPU_SLEEP;
904 TP_Ptr = (SYS_UWORD16 *) TPU_RAM;
905 TP_Enable(1);
906 #if 0 /* present in LoCosto but not in TCS211 */
907 TPU_wait_idle();
908 #endif
909 }
910
911 // l1dmacro_RF_wakeup
912 //* wakeup RF from BIG or DEEP sleep
913
914 /* Rita version differs from LoCosto, reconstructing from disassembly */
915 void l1dmacro_RF_wakeup (void)
916 {
917 TP_Ptr = (SYS_UWORD16 *) TPU_RAM;
918 #if 0
919 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET1, 0x01);
920 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET2, 0x06);
921 *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_RF | 0x01);
922 *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR);
923 *TP_Ptr++ = TPU_WAIT(100);
924 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_ON);
925 *TP_Ptr++ = TPU_WAIT(1);
926 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_OFF);
927 *TP_Ptr++ = TPU_WAIT(8);
928 *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_ON);
929 *TP_Ptr++ = TPU_WAIT(5);
930 TSP_TO_RF(0x0012);
931 *TP_Ptr++ = TPU_FAT(0);
932 *TP_Ptr++ = TPU_FAT(0);
933 *TP_Ptr++ = TPU_FAT(0);
934 *TP_Ptr++ = TPU_FAT(0);
935 *TP_Ptr++ = TPU_FAT(0);
936 *TP_Ptr++ = TPU_FAT(0);
937 TSP_TO_RF(0x003A);
938 *TP_Ptr++ = TPU_WAIT(7);
939 TSP_TO_RF(0xC003);
940 *TP_Ptr++ = TPU_WAIT(7);
941 TSP_TO_RF(0x02FE);
942 *TP_Ptr++ = TPU_WAIT(7);
943 TSP_TO_RF(0x401F);
944 *TP_Ptr++ = TPU_WAIT(7);
945 TSP_TO_RF(0x043D);
946 *TP_Ptr++ = TPU_WAIT(7);
947 *TP_Ptr++ = TPU_WAIT(117);
948 #endif
949 /* code from tpudrv61.c follows, same for Rita and LoCosto */
950 *TP_Ptr++ = TPU_SLEEP;
951 TP_Ptr = (SYS_UWORD16 *) TPU_RAM;
952 TP_Enable(1);
953 #if 0 /* present in LoCosto but not in TCS211 */
954 TPU_wait_idle();
955 #endif
956 }
957
958
959 // l1dmacro_init_hw
960 // Reset VEGA, then remove reset
961 // Init RF/IF synthesizers
962
963 void l1dmacro_init_hw(void)
964 {
965 WORD32 t = 100; // start time for actions
966
967 TP_Reset(1); // reset TPU and TSP
968
969 // GSM 1.5 : TPU clock enable is in TPU
970 //---------------------------------------
971 TPU_ClkEnable(1); // TPU CLOCK ON
972
973 TP_Reset(0);
974
975
976 TP_Ptr = (UWORD16 *) TPU_RAM;
977
978 #if 0
979 // Set FEM to inactive state before turning ON the RF Board
980 // At this point the RF regulators are still OFF. Thus the
981 // FEM command is not inverted yet => Must use the FEM "SLEEP programming"
982 *TP_Ptr++ = TPU_MOVE(TSP_ACT, FEM_SLEEP | RF_SER_ON);
983 #endif
984
985 // TPU_SLEEP
986 l1dmacro_idle();
987
988 *TP_Ptr++ = TPU_AT(t);
989 *TP_Ptr++ = TPU_SYNC(0);
990
991 #if 0
992 /* from disassembly, differs from LoCosto version */
993 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET1, 0x20);
994 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET2, 0x06);
995 *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET3, 0x00);
996 #endif
997
998 t = 1000; // arbitrary start time
999
1000 t = rf_init(t); // Initialize RF Board
1001
1002 *TP_Ptr++ = TPU_AT(t);
1003
1004 // TPU_SLEEP
1005 l1dmacro_idle();
1006
1007 return;
1008 }
1009
1010 /*------------------------------------------*/
1011 /* l1dmacro_init_hw_light */
1012 /*------------------------------------------*/
1013 /* Reset VEGA, then remove reset */
1014 /* Init RF/IF synthesizers */
1015 /*------------------------------------------*/
1016 void l1dmacro_init_hw_light(void)
1017 {
1018 UWORD32 t = 100; // start time for actions //
1019 TP_Ptr = (SYS_UWORD16 *) TPU_RAM; //
1020 *TP_Ptr++ = TPU_AT(t); //
1021 t = 1000; // arbitrary start time //
1022
1023 t = rf_init_light(t); // Initialize RF Board //
1024
1025 *TP_Ptr++ = TPU_AT(t); //
1026 l1dmacro_idle(); //
1027
1028 return;
1029 }