FreeCalypso > hg > fc-magnetite
comparison src/cs/layer1/tpu_drivers/source0/tpudrv10.c @ 415:b3d65ae5f02c
tpudrv10.c: magic2 tables added
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 20 Jan 2018 00:03:02 +0000 |
parents | cbc25978be5a |
children | 5ca341a26dda |
comparison
equal
deleted
inserted
replaced
414:cbc25978be5a | 415:b3d65ae5f02c |
---|---|
63 extern UWORD16 *TP_Ptr; | 63 extern UWORD16 *TP_Ptr; |
64 | 64 |
65 static UWORD8 rf_index; /* index into rf_path[] */ | 65 static UWORD8 rf_index; /* index into rf_path[] */ |
66 static UWORD16 rf_chip_band; /* from tpudrv12.obj, not in tpudrv61.c */ | 66 static UWORD16 rf_chip_band; /* from tpudrv12.obj, not in tpudrv61.c */ |
67 static UWORD8 rfband; /* ditto */ | 67 static UWORD8 rfband; /* ditto */ |
68 static UWORD8 magic2_byte; | |
68 | 69 |
69 // Internal function prototypes | 70 // Internal function prototypes |
70 void l1dmacro_rx_down (WORD32 t); | 71 void l1dmacro_rx_down (WORD32 t); |
71 | 72 |
72 SYS_UWORD16 Convert_l1_radio_freq(SYS_UWORD16 radio_freq); | 73 SYS_UWORD16 Convert_l1_radio_freq(SYS_UWORD16 radio_freq); |
159 struct magic1_s { | 160 struct magic1_s { |
160 UWORD16 limit; | 161 UWORD16 limit; |
161 UWORD16 magic; | 162 UWORD16 magic; |
162 }; | 163 }; |
163 | 164 |
165 struct magic2_s { | |
166 UWORD16 limit; | |
167 UWORD8 magic; | |
168 }; | |
169 | |
164 struct rf_path_s { | 170 struct rf_path_s { |
165 UWORD16 rf_chip_band; | 171 UWORD16 rf_chip_band; |
166 UWORD8 rx_up; | 172 UWORD8 rx_up; |
167 UWORD8 rx_down; | 173 UWORD8 rx_down; |
168 UWORD8 tx_up; | 174 UWORD8 tx_up; |
169 UWORD8 tx_down; | 175 UWORD8 tx_down; |
170 UWORD8 tx_up_rev; | 176 UWORD8 tx_up_rev; |
171 struct synth_s *synth; | 177 const struct synth_s *synth; |
172 struct magic1_s *magic1; | 178 const struct magic1_s *tx_magic1; |
179 const struct magic2_s *rx_magic2; | |
173 }; | 180 }; |
174 | 181 |
175 static const struct synth_s synth_900[] = | 182 static const struct synth_s synth_900[] = |
176 { | 183 { |
177 { 0, 124, 890, 1, 935, 4},// gsm 0 - 124 | 184 { 0, 124, 890, 1, 935, 4},// gsm 0 - 124 |
195 { 988, 0x0820}, | 202 { 988, 0x0820}, |
196 {1014, 0x083A}, | 203 {1014, 0x083A}, |
197 {1023, 0x0820}, | 204 {1023, 0x0820}, |
198 }; | 205 }; |
199 | 206 |
207 static const struct magic2_s magic2_rx900[] = | |
208 { | |
209 {0x4B00, 7}, | |
210 {0x4E20, 7}, | |
211 {0xFFFF, 7}, | |
212 }; | |
213 | |
200 static const struct synth_s synth_1800[] = | 214 static const struct synth_s synth_1800[] = |
201 { | 215 { |
202 {511, 885, 1710, -1, 1805, 1}, // dcs 512 - 885 | 216 {511, 885, 1710, -1, 1805, 1}, // dcs 512 - 885 |
203 }; | 217 }; |
204 | 218 |
214 {794, 0x0847}, | 228 {794, 0x0847}, |
215 {845, 0x0820}, | 229 {845, 0x0820}, |
216 {885, 0x082D}, | 230 {885, 0x082D}, |
217 }; | 231 }; |
218 | 232 |
233 static const struct magic2_s magic2_rx1800[] = | |
234 { | |
235 {0x24B8, 0}, | |
236 {0x2710, 0}, | |
237 {0xFFFF, 0}, | |
238 }; | |
239 | |
219 static const struct synth_s synth_1900[] = | 240 static const struct synth_s synth_1900[] = |
220 { | 241 { |
221 {511, 810, 1850, -1, 1930, 1}, // pcs 512 - 810; | 242 {511, 810, 1850, -1, 1930, 1}, // pcs 512 - 810; |
222 }; | 243 }; |
223 | 244 |
229 {702, 0x0820}, | 250 {702, 0x0820}, |
230 {777, 0x0854}, | 251 {777, 0x0854}, |
231 {810, 0x0861}, | 252 {810, 0x0861}, |
232 }; | 253 }; |
233 | 254 |
255 static const struct magic2_s magic2_rx1900[] = | |
256 { | |
257 {0x26DE, 0}, | |
258 {0x2710, 0}, | |
259 {0xFFFF, 0}, | |
260 }; | |
261 | |
234 static const struct synth_s synth_850[] = | 262 static const struct synth_s synth_850[] = |
235 { | 263 { |
236 {127, 251, 824, 1, 869, 4}, // gsm850 | 264 {127, 251, 824, 1, 869, 4}, // gsm850 |
237 }; | 265 }; |
238 | 266 |
239 static const struct magic1_s magic1_850[] = | 267 static const struct magic1_s magic1_850[] = |
240 { | 268 { |
241 {251, 0x0924}, | 269 {251, 0x0924}, |
242 }; | 270 }; |
243 | 271 |
244 struct rf_path_s rf_path[] = { //same index used as for band_config[] - 1 | 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 | |
245 /* EGSM */ | 289 /* EGSM */ |
246 { BAND_SELECT_GSM, RU_900, RD_900, TU_900, TD_900, TU_REV_900, | 290 { BAND_SELECT_GSM, RU_900, RD_900, TU_900, TD_900, TU_REV_900, |
247 (struct synth_s *)synth_900, (struct magic1_s *)magic1_900}, | 291 synth_900, magic1_900, magic2_rx900}, |
248 /* DCS */ | 292 /* DCS */ |
249 { BAND_SELECT_DCS, RU_1800, RD_1800, TU_1800, TD_1800, TU_REV_1800, | 293 { BAND_SELECT_DCS, RU_1800, RD_1800, TU_1800, TD_1800, TU_REV_1800, |
250 (struct synth_s *)synth_1800, (struct magic1_s *)magic1_1800}, | 294 synth_1800, magic1_1800, magic2_rx1800}, |
251 /* PCS */ | 295 /* PCS */ |
252 { BAND_SELECT_PCS, RU_1900, RD_1900, TU_1900, TD_1900, TU_REV_1900, | 296 { BAND_SELECT_PCS, RU_1900, RD_1900, TU_1900, TD_1900, TU_REV_1900, |
253 (struct synth_s *)synth_1900, (struct magic1_s *)magic1_1900}, | 297 synth_1900, magic1_1900, magic2_rx1900}, |
254 /* GSM850 */ | 298 /* GSM850 */ |
255 { BAND_SELECT_850, RU_850, RD_850, TU_850, TD_850, TU_REV_850, | 299 { BAND_SELECT_850, RU_850, RD_850, TU_850, TD_850, TU_REV_850, |
256 (struct synth_s *)synth_850, (struct magic1_s *)magic1_850}, | 300 synth_850, magic1_850, magic2_rx850}, |
257 /* PCS in dual-us */ | 301 /* PCS in dual-us */ |
258 { BAND_SELECT_PCS, RU_1900, RD_1900, TU_1900, TD_1900, TU_REV_1900, | 302 { BAND_SELECT_PCS, RU_1900, RD_1900, TU_1900, TD_1900, TU_REV_1900, |
259 (struct synth_s *)synth_1900, (struct magic1_s *)magic1_1900}, | 303 synth_1900, magic1_1900, magic2_rx1900}, |
260 /* non-E GSM */ | 304 /* non-E GSM */ |
261 { BAND_SELECT_GSM, RU_900, RD_900, TU_900, TD_900, TU_REV_900, | 305 { BAND_SELECT_GSM, RU_900, RD_900, TU_900, TD_900, TU_REV_900, |
262 (struct synth_s *)synth_900, (struct magic1_s *)magic1_900}, | 306 synth_900, magic1_900, magic2_rx900}, |
263 }; | 307 }; |
264 | 308 |
265 /* | 309 /* |
266 * Leonardo tpudrv12.obj contains a function named calc_a_b(); there is | 310 * Leonardo tpudrv12.obj contains a function named calc_a_b(); there is |
267 * no such function in the LoCosto version, but there is a similar-looking | 311 * no such function in the LoCosto version, but there is a similar-looking |
273 UWORD32 calc_a_b(UWORD16 arfcn, UWORD8 downlink) | 317 UWORD32 calc_a_b(UWORD16 arfcn, UWORD8 downlink) |
274 { | 318 { |
275 UWORD32 farfcn; /* sp+0x1C, in 200 kHz units */ | 319 UWORD32 farfcn; /* sp+0x1C, in 200 kHz units */ |
276 struct synth_s *s; | 320 struct synth_s *s; |
277 struct magic1_s *m1; | 321 struct magic1_s *m1; |
322 struct magic2_s *m2; | |
278 UWORD32 magic1; /* sp+0x24 */ | 323 UWORD32 magic1; /* sp+0x24 */ |
279 UWORD16 sp4; | 324 UWORD16 sp4; |
280 UWORD32 sp0x14, sp0x18, sp0x20; | 325 UWORD32 sp0x14, sp0x18, sp0x20; |
281 | 326 |
282 s = rf_path[rf_index].synth; | 327 s = rf_path[rf_index].synth; |
283 while(s->limit < arfcn) | 328 while(s->limit < arfcn) |
284 s++; | 329 s++; |
285 | 330 |
286 m1 = rf_path[rf_index].magic1; | 331 m1 = rf_path[rf_index].tx_magic1; |
287 while(m1->limit < arfcn) | 332 while(m1->limit < arfcn) |
288 m1++; | 333 m1++; |
289 magic1 = m1->magic; | 334 magic1 = m1->magic; |
290 | 335 |
291 if (downlink) { | 336 if (downlink) { |
292 sp0x20 = 0x27627 * s->dl_mult + 8; | 337 sp0x20 = 0x27627 * s->dl_mult + 8; |
293 farfcn = 5*s->dl_farfcn0 + (arfcn - s->arfcn0); | 338 farfcn = 5*s->dl_farfcn0 + (arfcn - s->arfcn0); |
294 sp4 = farfcn * s->dl_mult; | 339 sp4 = farfcn * s->dl_mult; |
295 sp0x18 = sp4 << 21; | 340 sp0x18 = sp4 << 21; |
296 sp0x14 = sp0x20 * farfcn; | 341 sp0x14 = sp0x20 * farfcn; |
342 m2 = rf_path[rf_index].rx_magic2; | |
297 } else { | 343 } else { |
298 sp0x20 = 0x2762F; | 344 sp0x20 = 0x2762F; |
299 farfcn = 5*s->ul_farfcn0 + (arfcn - s->arfcn0); | 345 farfcn = 5*s->ul_farfcn0 + (arfcn - s->arfcn0); |
300 sp4 = magic1 * s->ul_sign + farfcn; | 346 sp4 = magic1 * s->ul_sign + farfcn; |
301 sp0x18 = sp4 << 21; | 347 sp0x18 = sp4 << 21; |
302 sp0x14 = sp0x20 * (magic1 * s->ul_sign + farfcn); | 348 sp0x14 = sp0x20 * (magic1 * s->ul_sign + farfcn); |
349 m2 = magic2_tx; | |
303 } | 350 } |
351 | |
352 while(m2->limit < sp4) | |
353 m2++; | |
354 magic2_byte = (m2->magic & 7) << 5; | |
304 | 355 |
305 rf_chip_band = s->rf_chip_band; | 356 rf_chip_band = s->rf_chip_band; |
306 | 357 |
307 // Convert the ARFCN to the channel frequency (times 5 to avoid the decimal value) | 358 // Convert the ARFCN to the channel frequency (times 5 to avoid the decimal value) |
308 farfcn = 5*s->tx_rx[downlink].farfcn0 + (arfcn - s->arfcn0); | 359 farfcn = 5*s->tx_rx[downlink].farfcn0 + (arfcn - s->arfcn0); |