diff options
-rw-r--r-- | src/osmo-bts-sysmo/Makefile.am | 5 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/misc/sysmobts_eeprom.h | 2 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/misc/sysmobts_par.c | 18 | ||||
-rw-r--r-- | src/osmo-bts-sysmo/misc/sysmobts_util.c | 28 |
4 files changed, 42 insertions, 11 deletions
diff --git a/src/osmo-bts-sysmo/Makefile.am b/src/osmo-bts-sysmo/Makefile.am index bb101bde..e36593af 100644 --- a/src/osmo-bts-sysmo/Makefile.am +++ b/src/osmo-bts-sysmo/Makefile.am @@ -26,8 +26,9 @@ sysmobts_mgr_SOURCES = \ misc/sysmobts_mgr_2050.c \ misc/sysmobts_mgr_vty.c \ misc/sysmobts_mgr_nl.c \ - misc/sysmobts_mgr_temp.c + misc/sysmobts_mgr_temp.c \ + eeprom.c sysmobts_mgr_LDADD = $(LIBOSMOCORE_LIBS) $(LIBOSMOVTY_LIBS) -sysmobts_util_SOURCES = misc/sysmobts_util.c misc/sysmobts_par.c +sysmobts_util_SOURCES = misc/sysmobts_util.c misc/sysmobts_par.c eeprom.c sysmobts_util_LDADD = $(LIBOSMOCORE_LIBS) diff --git a/src/osmo-bts-sysmo/misc/sysmobts_eeprom.h b/src/osmo-bts-sysmo/misc/sysmobts_eeprom.h index 8af97fae..e9828a1c 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_eeprom.h +++ b/src/osmo-bts-sysmo/misc/sysmobts_eeprom.h @@ -6,7 +6,7 @@ struct sysmobts_eeprom { /* offset */ uint8_t eth_mac[6]; /* 0-5 */ uint8_t _pad0[10]; /* 6-15 */ - uint16_t clk_cal_fact; /* 16-17 */ + uint16_t unused1; /* 16-17 */ uint8_t temp1_max; /* 18 */ uint8_t temp2_max; /* 19 */ uint32_t serial_nr; /* 20-23 */ diff --git a/src/osmo-bts-sysmo/misc/sysmobts_par.c b/src/osmo-bts-sysmo/misc/sysmobts_par.c index d3d9e26f..6800fded 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_par.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_par.c @@ -33,6 +33,7 @@ #include "sysmobts_eeprom.h" #include "sysmobts_par.h" +#include "eeprom.h" #define EEPROM_PATH "/sys/devices/platform/i2c_davinci.1/i2c-1/1-0050/eeprom" @@ -119,6 +120,8 @@ int sysmobts_par_is_int(enum sysmobts_par par) int sysmobts_par_get_int(enum sysmobts_par par, int *ret) { + eeprom_RfClockCal_t rf_clk; + eeprom_Error_t err; struct sysmobts_eeprom *ee = get_eeprom(0); if (!ee) @@ -129,7 +132,10 @@ int sysmobts_par_get_int(enum sysmobts_par par, int *ret) switch (par) { case SYSMOBTS_PAR_CLK_FACTORY: - *ret = ee->clk_cal_fact; + err = eeprom_ReadRfClockCal(&rf_clk); + if (err != EEPROM_SUCCESS) + return -EIO; + *ret = rf_clk.iClkCor; break; case SYSMOBTS_PAR_TEMP_DIG_MAX: *ret = ee->temp1_max; @@ -164,6 +170,8 @@ int sysmobts_par_get_int(enum sysmobts_par par, int *ret) int sysmobts_par_set_int(enum sysmobts_par par, int val) { + eeprom_RfClockCal_t rf_clk; + eeprom_Error_t err; struct sysmobts_eeprom *ee = get_eeprom(1); if (!ee) @@ -174,7 +182,13 @@ int sysmobts_par_set_int(enum sysmobts_par par, int val) switch (par) { case SYSMOBTS_PAR_CLK_FACTORY: - ee->clk_cal_fact = val; + err = eeprom_ReadRfClockCal(&rf_clk); + if (err != EEPROM_SUCCESS) + return -EIO; + rf_clk.iClkCor = val; + err = eeprom_WriteRfClockCal(&rf_clk); + if (err != EEPROM_SUCCESS) + return -EIO; break; case SYSMOBTS_PAR_TEMP_DIG_MAX: ee->temp1_max = val; diff --git a/src/osmo-bts-sysmo/misc/sysmobts_util.c b/src/osmo-bts-sysmo/misc/sysmobts_util.c index 611e96fe..d2b09a81 100644 --- a/src/osmo-bts-sysmo/misc/sysmobts_util.c +++ b/src/osmo-bts-sysmo/misc/sysmobts_util.c @@ -35,12 +35,13 @@ enum act { static enum act action; static char *write_arg; +static int void_warranty; static void print_help() { const struct value_string *par = sysmobts_par_names; - printf("sysmobts-util [-r | -w value] param_name\n"); + printf("sysmobts-util [--void-warranty -r | -w value] param_name\n"); printf("Possible param names:\n"); for (; par->str != NULL; par += 1) { @@ -52,10 +53,21 @@ static void print_help() static int parse_options(int argc, char **argv) { - int opt; - - while ((opt = getopt(argc, argv, "rw:h")) != -1) { - switch (opt) { + while (1) { + int option_idx = 0, c; + static const struct option long_options[] = { + { "help", 0, 0, 'h' }, + { "read", 0, 0, 'r' }, + { "void-warranty", 0, 0, 1000}, + { "write", 1, 0, 'w' }, + { 0, 0, 0, 0 } + }; + + c = getopt_long(argc, argv, "rw:h", + long_options, &option_idx); + if (c == -1) + break; + switch (c) { case 'r': action = ACT_GET; break; @@ -67,6 +79,10 @@ static int parse_options(int argc, char **argv) print_help(); return -1; break; + case 1000: + printf("Will void warranty on write.\n"); + void_warranty = 1; + break; default: return -1; } @@ -113,7 +129,7 @@ int main(int argc, char **argv) fprintf(stderr, "Error %d\n", rc); goto err; } - if (val != 0xFFFF && val != 0xFF && val != 0xFFFFFFFF) { + if (val != 0xFFFF && val != 0xFF && val != 0xFFFFFFFF && !void_warranty) { fprintf(stderr, "Parameter is already set!\r\n"); goto err; } |