calib: Add fixup for incompatible calib data / firmware version

For certain sysmoBTS units, a fixup to the calibration table is needed,
if the firmware is >= 3.3.0.
This commit is contained in:
Harald Welte 2013-06-22 18:41:11 +02:00
parent 2563267757
commit 40ca16766d
6 changed files with 173 additions and 9 deletions

View File

@ -9,7 +9,7 @@ EXTRA_DIST = misc/sysmobts_mgr.h misc/sysmobts_misc.h misc/sysmobts_par.h \
bin_PROGRAMS = sysmobts sysmobts-remote l1fwd-proxy sysmobts-mgr
COMMON_SOURCES = main.c femtobts.c l1_if.c oml.c sysmobts_vty.c tch.c hw_misc.c calib_file.c \
eeprom.c
eeprom.c calib_fixup.c
sysmobts_SOURCES = $(COMMON_SOURCES) l1_transp_hw.c
sysmobts_LDADD = $(top_builddir)/src/common/libbts.a $(LDADD)

View File

@ -132,6 +132,54 @@ static int read_int(FILE *in)
return i;
}
/* some particular units have calibration data that is incompatible with
* firmware >= 3.3, so we need to alter it as follows: */
static const float delta_by_band[Num_GsmL1_FreqBand] = {
[GsmL1_FreqBand_850] = -2.5f,
[GsmL1_FreqBand_900] = -2.0f,
[GsmL1_FreqBand_1800] = -8.0f,
[GsmL1_FreqBand_1900] = -12.0f,
};
extern const uint8_t fixup_macs[95][6];
static void calib_fixup_rx(struct femtol1_hdl *fl1h, SuperFemto_Prim_t *prim)
{
SuperFemto_SetRxCalibTblReq_t *rx = &prim->u.setRxCalibTblReq;
uint8_t macaddr[6];
int rc, i;
int fixup_needed = 0;
rc = eeprom_ReadEthAddr(macaddr);
if (rc != EEPROM_SUCCESS) {
LOGP(DL1C, LOGL_ERROR,
"Unable to read Ethenet MAC from EEPROM\n");
return;
}
if (fl1h->hw_info.dsp_version[0] < 3 ||
(fl1h->hw_info.dsp_version[0] == 3 &&
fl1h->hw_info.dsp_version[1] < 3)) {
LOGP(DL1C, LOGL_NOTICE, "No calibration table fix-up needed, "
"firmware < 3.3\n");
return;
}
for (i = 0; i < sizeof(fixup_macs)/6; i++) {
if (!memcmp(fixup_macs[i], macaddr, 6)) {
fixup_needed = 1;
break;
}
}
LOGP(DL1C, LOGL_NOTICE, "MAC Address is %02x:%02x:%02x:%02x:%02x:%02x -> %s\n",
macaddr[0], macaddr[1], macaddr[2], macaddr[3],
macaddr[4], macaddr[5], fixup_needed ? "FIXUP" : "NO FIXUP");
if (fixup_needed)
rx->fExtRxGain += delta_by_band[rx->freqBand];
}
static int calib_file_read(const char *path, const struct calib_file_desc *desc,
SuperFemto_Prim_t *prim)
{
@ -287,6 +335,7 @@ static int calib_file_send(struct femtol1_hdl *fl1h,
msgb_free(msg);
return rc;
}
calib_fixup_rx(fl1h, msgb_sysprim(msg));
return l1if_req_compl(fl1h, msg, calib_send_compl_cb);
}

View File

@ -0,0 +1,101 @@
/* AUTOGENERATED, DO NOT EDIT */
#include <stdint.h>
const uint8_t fixup_macs[95][6] = {
{ 0x00, 0x0D, 0xCC, 0x08, 0x02, 0x3B },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x31 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x32 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x33 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x34 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x35 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x36 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x37 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x38 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x39 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x3A },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x3C },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x3D },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x3E },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x40 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x41 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x42 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x43 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x44 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x45 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x46 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x47 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x48 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x49 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x4A },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x4B },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x4C },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x4D },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x4E },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x4F },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x50 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x51 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x52 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x53 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x55 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x56 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x57 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x58 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x59 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x5A },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x5B },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x5C },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x5D },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x5E },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0x5F },
{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00, 0xD0, 0xCC, 0x08, 0x02, 0xB3 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xB4 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xB5 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xB6 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xB7 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xB8 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xB9 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xBA },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xBB },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xBC },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xBE },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xBF },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xC0 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xC1 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xC3 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xC6 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xC7 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xC8 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xC9 },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xCA },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xCB },
{ 0x00, 0xD0, 0xCC, 0x08, 0x02, 0xCD },
};

View File

@ -298,6 +298,18 @@ eeprom_Error_t eeprom_ResetCfg( void )
}
eeprom_Error_t eeprom_ReadEthAddr( uint8_t *ethaddr )
{
int err;
err = eeprom_read(0, 6, ethaddr);
if ( err != 6 )
{
return EEPROM_ERR_DEVICE;
}
return EEPROM_SUCCESS;
}
/****************************************************************************
* Function : eeprom_ReadSysInfo
************************************************************************//**

View File

@ -132,6 +132,8 @@ typedef struct eeprom_RxCal
* Public functions *
****************************************************************************/
eeprom_Error_t eeprom_ReadEthAddr( uint8_t *ethaddr );
/****************************************************************************
* Function : eeprom_ResetCfg
************************************************************************//**

View File

@ -1116,6 +1116,14 @@ static int info_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp)
LOGP(DL1C, LOGL_FATAL, "BTS band %s not supported by hw\n",
gsm_band_name(trx->bts->band));
#if SUPERFEMTO_API_VERSION >= SUPERFEMTO_API(2,4,0)
/* load calibration tables (if we know their path) */
if (fl1h->calib_path)
calib_load(fl1h);
else
#endif
LOGP(DL1C, LOGL_NOTICE, "Operating without calibration tables!\n");
/* FIXME: clock related */
return 0;
}
@ -1156,14 +1164,6 @@ static int reset_compl_cb(struct gsm_bts_trx *trx, struct msgb *resp)
/* obtain version information on DSP/FPGA and band capabilities */
l1if_get_info(fl1h);
#if SUPERFEMTO_API_VERSION >= SUPERFEMTO_API(2,4,0)
/* load calibration tables (if we know their path) */
if (fl1h->calib_path)
calib_load(fl1h);
else
#endif
LOGP(DL1C, LOGL_NOTICE, "Operating without calibration tables!\n");
/* otherwise, request activation of RF board */
l1if_activate_rf(fl1h, 1);