FreeCalypso > hg > fc-magnetite
changeset 616:f8e74b692c80
tpudrv10.c: first actual reconstruction attempt
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 06 Oct 2019 02:33:10 +0000 |
parents | 2bd7c1dcac4b |
children | c32c887ced3a |
files | src/cs/layer1/tpu_drivers/source0/tpudrv10.c |
diffstat | 1 files changed, 112 insertions(+), 113 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cs/layer1/tpu_drivers/source0/tpudrv10.c Sat Jun 29 02:06:50 2019 +0000 +++ b/src/cs/layer1/tpu_drivers/source0/tpudrv10.c Sun Oct 06 02:33:10 2019 +0000 @@ -2,10 +2,11 @@ * The situation with the tpudrv10 RF TPU driver is even worse than with * tpudrv12: not only are we missing the original tpudrv10.c source, * but we don't even have a tpudrv10.obj to reconstruct from. + * The present reconstruction has been made from the 20020917 fw + * image that came with our D-Sample board. * - * We are going to try reconstructing the necessary tpudrv10 bits - * from the 20020917 fw image sans symbols that came with our D-Sample - * board, but for now this C file is mostly a placeholder for compilation. + * The deep sleep functions haven't been reconstructed yet, + * thus the firmware needs to be built with DISABLE_SLEEP=1. */ #define TPUDRV10_C @@ -63,9 +64,13 @@ extern UWORD16 *TP_Ptr; static UWORD8 rf_index; /* index into rf_path[] */ -static UWORD16 rf_chip_band; /* from tpudrv12.obj, not in tpudrv61.c */ static UWORD8 rfband; /* ditto */ static UWORD8 magic2_byte; +static UWORD16 lna_off_flag; + +static UWORD8 magic_83be24 = 0x0E; +static UWORD8 magic_83be25 = 0x01; +static UWORD8 magic_83be26 = 0x00; // Internal function prototypes void l1dmacro_rx_down (WORD32 t); @@ -92,9 +97,18 @@ #define IS_HIGH_BAND(arfcn) (((arfcn >= 512) && (arfcn <= 885)) ? 1 : 0) /*------------------------------------------*/ -/* Send a value to Rita RF */ +/* Send a value to Clara RF */ /*------------------------------------------*/ -#define TSP_TO_RF(rf_data)\ +#define TSP_TO_RF_24(rf_data)\ + {\ + *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_1, ((rf_data) >> 16) & 0xFF); \ + *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_2, ((rf_data) >> 8) & 0xFF); \ + *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_3, (rf_data) & 0xFF); \ + *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_RF | 0x17); \ + *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR); \ + } + +#define TSP_TO_RF_16(rf_data)\ {\ *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_1, ((rf_data) >> 8) & 0xFF); \ *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_2, (rf_data) & 0xFF); \ @@ -102,6 +116,13 @@ *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR); \ } +#define TSP_TO_RF_8(rf_data)\ + {\ + *TP_Ptr++ = TPU_MOVE(TSP_TX_REG_1, (rf_data) & 0xFF); \ + *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_RF | 0x07); \ + *TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR); \ + } + /*------------------------------------------*/ /* Send a TSP command to ABB */ /*------------------------------------------*/ @@ -306,6 +327,19 @@ synth_900, magic1_900, magic2_rx900}, }; +static UWORD16 calc_tx_magic(UWORD16 arfcn) +{ + const struct magic1_s *m1; + UWORD16 sp6, sp8; + + m1 = rf_path[rf_index].tx_magic1; + while(m1->limit < arfcn) + m1++; + sp6 = m1->magic << 1; + sp8 = sp6 / 13; + return ((sp8 & 0x1FF) << 5); +} + static UWORD32 calc_freq_prog(UWORD16 arfcn, UWORD8 downlink) { UWORD32 farfcn; /* sp+0x1C, in 200 kHz units */ @@ -448,18 +482,15 @@ /*------------------------------------------*/ WORD32 rf_init(WORD32 t) { -#if 0 *TP_Ptr++ = TPU_AT(t); *TP_Ptr++ = TPU_MOVE(TSP_CTRL1, 0x47); - t += 5; - *TP_Ptr++ = TPU_AT(t); - *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_OFF); + *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x01); + *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x00); + *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x01); t += 8; *TP_Ptr++ = TPU_AT(t); - *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON); - t += 5; - *TP_Ptr++ = TPU_AT(t); - TSP_TO_RF(0x0012); + TSP_TO_RF_16(0x8008); + *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x1F); t += 7; *TP_Ptr++ = TPU_AT(t); *TP_Ptr++ = TPU_AT(t); @@ -467,21 +498,23 @@ *TP_Ptr++ = TPU_AT(t); *TP_Ptr++ = TPU_AT(t); *TP_Ptr++ = TPU_AT(t); - TSP_TO_RF(0x003A); - t += 117; + *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x1F); + *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x1E); + *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x1F); + TSP_TO_RF_16(0x8018); + t += 9; *TP_Ptr++ = TPU_AT(t); - TSP_TO_RF(0xC003); - t += 7; + TSP_TO_RF_24(0x140753); + t += 8; *TP_Ptr++ = TPU_AT(t); - TSP_TO_RF(0x02FE); - t += 7; + TSP_TO_RF_24(0x2db084); + t += 8; *TP_Ptr++ = TPU_AT(t); - TSP_TO_RF(0x401F); - t += 7; + TSP_TO_RF_8((magic_83be26 << 4) | (magic_83be25 << 5) | 0x06); + t += 384; *TP_Ptr++ = TPU_AT(t); - TSP_TO_RF(0x043D); - t += 7; -#endif + TSP_TO_RF_24(((UWORD32) magic_83be24 << 19) | 7); + t += 8; return(t); } @@ -519,8 +552,8 @@ /*------------------------------------------*/ //change 2 UWORD8 UWORD32 rf_program(UWORD32 t, SYS_UWORD16 radio_freq, UWORD32 rx) { - UWORD32 rfdiv; SYS_UWORD16 arfcn; + UWORD32 sp0x10, sp0x14; rfband = Cust_is_band_high(radio_freq); @@ -530,19 +563,27 @@ #endif rf_index = arfcn_to_rf_index(arfcn); -#if 0 - rfdiv = calc_a_b(arfcn, rx); - - if (rx != 1) { - TSP_TO_RF(rfdiv | REG_PLL); - *TP_Ptr++ = TPU_FAT(0x1274); - TSP_TO_RF(0x043A | rf_chip_band); + sp0x10 = calc_freq_prog(arfcn, rx); + if (rx == 1) { + TSP_TO_RF_24(sp0x10 | magic2_byte | MODE2); + *TP_Ptr++ = TPU_WAIT(1); + TSP_TO_RF_16(0x8A18 | rf_path[rf_index].rf_chip_band); + TSP_TO_RF_24(sp0x10 | magic2_byte | MODE2); } else { - TSP_TO_RF(rfdiv | REG_PLL); - *TP_Ptr++ = TPU_FAT(0x12FD); - TSP_TO_RF(0x023A | rf_chip_band); + sp0x14 = calc_tx_magic(arfcn); + TSP_TO_ABB(0x80); + *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x17); + TSP_TO_RF_16(0x0518 | rf_path[rf_index].rf_chip_band); + TSP_TO_RF_24(sp0x10 | magic2_byte | MODE2); + *TP_Ptr++ = TPU_FAT(0x1280); + TSP_TO_ABB(0xC0); + *TP_Ptr++ = TPU_FAT(0x128B); + TSP_TO_RF_16(sp0x14 | MODE5); + *TP_Ptr++ = TPU_FAT(0x12F7); + TSP_TO_RF_24(0x140973); + *TP_Ptr++ = TPU_FAT(0x1305); + TSP_TO_ABB(0x80); } -#endif return(t); } @@ -569,25 +610,18 @@ void l1dmacro_agc(SYS_UWORD16 radio_freq, WORD8 gain, UWORD8 lna_off) { int agc_table_index; - UWORD16 rf_data; -#if 0 - agc_table_index = gain - 2; + agc_table_index = gain - 6; if (agc_table_index < 0) agc_table_index++; agc_table_index >>= 1; - if (gain >= 42) - agc_table_index = 19; - if (gain < 16) - agc_table_index = 6; - *TP_Ptr++ = TPU_FAT(0x1334); - rf_data = REG_RX; - if (!lna_off) - rf_data |= RF_GAIN; - rf_data |= AGC_TABLE[agc_table_index] << 11; - rf_data |= RX_CAL_MODE; - TSP_TO_RF(rf_data); -#endif + if (agc_table_index >= 27) + agc_table_index = 26; + if (agc_table_index < 0) + agc_table_index = 0; + *TP_Ptr++ = TPU_FAT(0x1313); + TSP_TO_RF_16(AGC_TABLE[agc_table_index] << 11 | 0x3B9); + lna_off_flag = (lna_off & 1) << 15; } /*------------------------------------------*/ @@ -635,18 +669,18 @@ /*------------------------------------------*/ void l1dmacro_rx_up (void) { -#if 0 - *TP_Ptr++ = TPU_FAT(0x1377); - TSP_TO_RF(0x0A3A | rf_chip_band); - *TP_Ptr++ = TPU_FAT(0x137E); + *TP_Ptr++ = TPU_FAT(0x1321); + TSP_TO_RF_16(0x9A18 | rf_path[rf_index].rf_chip_band); + *TP_Ptr++ = TPU_FAT(7); + TSP_TO_RF_16(0x0238 | rf_path[rf_index].rf_chip_band | lna_off_flag); + *TP_Ptr++ = TPU_WAIT(5); TSP_TO_ABB(0x10); - *TP_Ptr++ = TPU_FAT(0x1383); + *TP_Ptr++ = TPU_FAT(0x1B); TSP_TO_ABB(0x18); - *TP_Ptr++ = TPU_FAT(58); - *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_up | RF_SER_ON); + *TP_Ptr++ = TPU_FAT(0x36); + *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_up | 0x09); *TP_Ptr++ = TPU_FAT(62); TSP_TO_ABB(0x14); -#endif } /*------------------------------------------*/ @@ -659,13 +693,11 @@ /*------------------------------------------*/ void l1dmacro_rx_down (WORD32 t) { -#if 0 - *TP_Ptr++ = TPU_FAT(t - 37); - TSP_TO_RF(0x003A); - *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_ON); + *TP_Ptr++ = TPU_FAT(t - 36); + TSP_TO_RF_16(0x8018); + *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | 0x09); *TP_Ptr++ = TPU_FAT(t - 4); TSP_TO_ABB(0x00); -#endif } /*------------------------------------------*/ @@ -678,35 +710,16 @@ /*------------------------------------------*/ void l1dmacro_tx_up (void) { -#if 0 - if (l1_config.std.id == DCS1800 || - rfband == MULTI_BAND2 && - (l1_config.std.id == DUAL || l1_config.std.id == DUALEXT)) { - *TP_Ptr++ = TPU_FAT(0x127E); - TSP_TO_RF(0x0007); - *TP_Ptr++ = TPU_FAT(0x1288); - TSP_TO_RF(0xC00B); - *TP_Ptr++ = TPU_FAT(0x1292); - TSP_TO_RF(0x3077); - } else { - *TP_Ptr++ = TPU_FAT(0x127E); - TSP_TO_RF(0xC003); - } - *TP_Ptr++ = TPU_FAT(0x12C6); - TSP_TO_ABB(0x80); - *TP_Ptr++ = TPU_FAT(0x12E3); - TSP_TO_RF(0x243A | rf_chip_band); - *TP_Ptr++ = TPU_FAT(0x1302); - TSP_TO_ABB(0xC0); - *TP_Ptr++ = TPU_FAT(0x1352); - TSP_TO_ABB(0x80); + *TP_Ptr++ = TPU_FAT(0x1309); + TSP_TO_RF_16(0x0558 | rf_path[rf_index].rf_chip_band); + *TP_Ptr++ = TPU_FAT(0x133A); + TSP_TO_RF_24(0x140753); *TP_Ptr++ = TPU_FAT(0x1384); TSP_TO_ABB(0xA0); *TP_Ptr++ = TPU_FAT(16); - *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_up | RF_SER_ON); - *TP_Ptr++ = TPU_FAT(21); - *TP_Ptr++ = TPU_MOVE(TSP_ACTX, 0x0F); -#endif + *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_up | 0x01); + *TP_Ptr++ = TPU_FAT(24); + *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_up | 0x21); } /*-------------------------------------------*/ @@ -719,19 +732,18 @@ /*-------------------------------------------*/ void l1dmacro_tx_down (WORD32 t, BOOL tx_flag, UWORD8 adc_active) { -#if 0 if (adc_active == ACTIVE) l1dmacro_adc_read_tx(t - 44); *TP_Ptr++ = TPU_FAT(t - 4); TSP_TO_ABB(0x80); + *TP_Ptr++ = TPU_FAT(t + 13); + *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_down | 0x21); *TP_Ptr++ = TPU_FAT(t + 22); - *TP_Ptr++ = TPU_MOVE(TSP_ACTX, 0x00); - *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_down | RF_SER_ON); - *TP_Ptr++ = TPU_FAT(t + 25); - TSP_TO_RF(0x003A); - *TP_Ptr++ = TPU_FAT(t + 31); + *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_down | 0x01); + TSP_TO_RF_8(0x18); + *TP_Ptr++ = TPU_FAT(t + 29); TSP_TO_ABB(0x00); -#endif + *TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_down | 0x09); } /* @@ -874,11 +886,6 @@ TPU_Reset(0); TP_Ptr = (UWORD16 *) TPU_RAM; -#if 0 - *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON); - *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON | FEM_OFF); -#endif - *TP_Ptr++ = TPU_OFFSET(servingCellOffset); } @@ -975,25 +982,16 @@ TP_Ptr = (UWORD16 *) TPU_RAM; -#if 0 - // Set FEM to inactive state before turning ON the RF Board - // At this point the RF regulators are still OFF. Thus the - // FEM command is not inverted yet => Must use the FEM "SLEEP programming" - *TP_Ptr++ = TPU_MOVE(TSP_ACT, FEM_SLEEP | RF_SER_ON); -#endif - // TPU_SLEEP l1dmacro_idle(); *TP_Ptr++ = TPU_AT(t); *TP_Ptr++ = TPU_SYNC(0); -#if 0 /* from disassembly, differs from LoCosto version */ *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET1, 0x20); *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET2, 0x06); *TP_Ptr++ = TPU_MOVE(TSP_SPI_SET3, 0x00); -#endif t = 1000; // arbitrary start time @@ -1020,7 +1018,8 @@ *TP_Ptr++ = TPU_AT(t); // t = 1000; // arbitrary start time // - t = rf_init_light(t); // Initialize RF Board // + /* D-Sample 20020917 fw does full rf_init() here */ + t = rf_init(t); // Initialize RF Board // *TP_Ptr++ = TPU_AT(t); // l1dmacro_idle(); //