From ad10f0f533e6e702e03faffa5dd48a0044d224f3 Mon Sep 17 00:00:00 2001 From: "Nicolas J. Bouliane" Date: Wed, 10 Jul 2013 08:25:50 -0400 Subject: sysmobts: Set the clock calibration to the value read from the eeprom By default read the clock calibration from the EEPROM. It is still possible to set it using the cli. Signed-off-by: Nicolas J. Bouliane --- src/osmo-bts-sysmo/main.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/osmo-bts-sysmo/main.c') diff --git a/src/osmo-bts-sysmo/main.c b/src/osmo-bts-sysmo/main.c index 595a6ebc..a6760810 100644 --- a/src/osmo-bts-sysmo/main.c +++ b/src/osmo-bts-sysmo/main.c @@ -48,6 +48,7 @@ #define SYSMOBTS_RF_LOCK_PATH "/var/lock/bts_rf_lock" +#include "eeprom.h" #include "l1_if.h" /* FIXME: read from real hardware */ @@ -80,6 +81,31 @@ int bts_model_init(struct gsm_bts *bts) return 0; } +/* Set the clock calibration to the value + * read from the eeprom. + */ +void clk_cal_use_eeprom(struct gsm_bts *bts) +{ + int rc; + struct femtol1_hdl *hdl; + eeprom_RfClockCal_t rf_clk; + + hdl = bts->c0->role_bts.l1h; + + if (!hdl || !hdl->clk_use_eeprom) + return; + + rc = eeprom_ReadRfClockCal(&rf_clk); + if (rc != EEPROM_SUCCESS) { + LOGP(DL1C, LOGL_ERROR, "Failed to read from EEPROM.\n"); + return; + } + + hdl->clk_cal = rf_clk.iClkCor; + LOGP(DL1C, LOGL_NOTICE, + "Read clock calibration(%d) from EEPROM.\n", hdl->clk_cal); +} + struct ipabis_link *link_init(struct gsm_bts *bts, const char *ip) { struct ipabis_link *link = talloc_zero(bts, struct ipabis_link); @@ -286,6 +312,8 @@ int main(int argc, char **argv) exit(1); } + clk_cal_use_eeprom(bts); + if (stat(SYSMOBTS_RF_LOCK_PATH, &st) == 0) { LOGP(DL1C, LOGL_NOTICE, "Not starting BTS due to RF_LOCK file present\n"); exit(23); -- cgit v1.2.3