aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-sysmo/main.c
diff options
context:
space:
mode:
authorNicolas J. Bouliane <nicolas.bouliane@nutaq.com>2013-07-10 08:25:50 -0400
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-16 19:13:46 +0200
commitad10f0f533e6e702e03faffa5dd48a0044d224f3 (patch)
tree9f3b1bd2a72b379ec017366b5d8faece0a4e1a1c /src/osmo-bts-sysmo/main.c
parentfbf97e35ebf985eafcf79cc5db2598a7535108d4 (diff)
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 <nicolas.bouliane@nutaq.com>
Diffstat (limited to 'src/osmo-bts-sysmo/main.c')
-rw-r--r--src/osmo-bts-sysmo/main.c28
1 files changed, 28 insertions, 0 deletions
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);