comparison chipsetsw/layer1/tpu_drivers/source0/tpudrv12.c.fc @ 18:ffee43b74949

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