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