From 5f3cb79dab7939c27b77c427c5f1e333f9e857ce Mon Sep 17 00:00:00 2001 From: James Maki Date: Thu, 9 Sep 2010 16:33:33 -0500 Subject: copy the eeprom from the platform file instead of overwriting it. --- io-module/mts_io.c | 57 +++++++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/io-module/mts_io.c b/io-module/mts_io.c index 199c723..318a9b7 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -268,21 +268,22 @@ struct gpio_pin *gpio_pin_by_name(const char *name) { } extern uint8_t mts_id_eeprom[512]; -static struct mts_id_eeprom_layout *id_eeprom = - (struct mts_id_eeprom_layout *) mts_id_eeprom; +static struct mts_id_eeprom_layout id_eeprom; static int mts_id_eeprom_load(void) { - if (id_eeprom->vendor_id[0] == 0xFF) { + memcpy(&id_eeprom, mts_id_eeprom, sizeof(mts_id_eeprom)); + + if (mts_id_eeprom[0] == 0xFF) { log_error("uninitialized eeprom"); return -EIO; - } else if (id_eeprom->vendor_id[0] == 0x00) { - strncpy(id_eeprom->vendor_id, VENDOR_ID_MULTITECH, sizeof(id_eeprom->vendor_id) - 1); - strncpy(id_eeprom->product_id, PRODUCT_ID_MTCDP_E1_DK, sizeof(id_eeprom->product_id) - 1); - strncpy(id_eeprom->device_id, "", sizeof(id_eeprom->device_id) - 1); - strncpy(id_eeprom->hw_version, HW_VERSION_MTCDP_0_0, sizeof(id_eeprom->hw_version) - 1); + } else if (mts_id_eeprom[0] == 0x00) { + strncpy(id_eeprom.vendor_id, VENDOR_ID_MULTITECH, sizeof(id_eeprom.vendor_id) - 1); + strncpy(id_eeprom.product_id, PRODUCT_ID_MTCDP_E1_DK, sizeof(id_eeprom.product_id) - 1); + strncpy(id_eeprom.device_id, "", sizeof(id_eeprom.device_id) - 1); + strncpy(id_eeprom.hw_version, HW_VERSION_MTCDP_0_0, sizeof(id_eeprom.hw_version) - 1); - DEVICE_CAPA_SET(id_eeprom->capa, CAPA_GPS); + DEVICE_CAPA_SET(id_eeprom.capa, CAPA_GPS); gpio_pins = gpio_pins_mtcdp_0_0; } else { @@ -290,22 +291,22 @@ static int mts_id_eeprom_load(void) } log_info("sizeof: %lu", (unsigned long) sizeof(struct mts_id_eeprom_layout)); - log_info("vendor-id: %.32s", id_eeprom->vendor_id); - log_info("product-id: %.32s", id_eeprom->product_id); - log_info("device-id: %.32s", id_eeprom->device_id); - log_info("hw-version: %.32s", id_eeprom->hw_version); + log_info("vendor-id: %.32s", id_eeprom.vendor_id); + log_info("product-id: %.32s", id_eeprom.product_id); + log_info("device-id: %.32s", id_eeprom.device_id); + log_info("hw-version: %.32s", id_eeprom.hw_version); log_info("mac-addr: %02X:%02X:%02X:%02X:%02X:%02X", - id_eeprom->mac_addr[0], - id_eeprom->mac_addr[1], - id_eeprom->mac_addr[2], - id_eeprom->mac_addr[3], - id_eeprom->mac_addr[4], - id_eeprom->mac_addr[5]); - log_info("imei: %.32s", id_eeprom->imei); - log_info("capa-gps: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_GPS) ? "yes" : "no"); - log_info("capa-din: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_DIN) ? "yes" : "no"); - log_info("capa-dout: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_DOUT) ? "yes" : "no"); - log_info("capa-adc: %s", DEVICE_CAPA(id_eeprom->capa, CAPA_ADC) ? "yes" : "no"); + id_eeprom.mac_addr[0], + id_eeprom.mac_addr[1], + id_eeprom.mac_addr[2], + id_eeprom.mac_addr[3], + id_eeprom.mac_addr[4], + id_eeprom.mac_addr[5]); + log_info("imei: %.32s", id_eeprom.imei); + log_info("capa-gps: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_GPS) ? "yes" : "no"); + log_info("capa-din: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_DIN) ? "yes" : "no"); + log_info("capa-dout: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_DOUT) ? "yes" : "no"); + log_info("capa-adc: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_ADC) ? "yes" : "no"); return 0; } @@ -1348,7 +1349,7 @@ static ssize_t mts_attr_show_adc(struct device *dev, int offset; u32 value; - if (!strcmp(id_eeprom->hw_version, HW_VERSION_MTCDP_0_0)) { + if (!strcmp(id_eeprom.hw_version, HW_VERSION_MTCDP_0_0)) { log_debug("ADC not available on 0.0 hw"); return -ENODEV; } @@ -1513,7 +1514,7 @@ static int __devinit mts_spi_dout_probe(struct spi_device *spi) { int tmp; - if (!strcmp(id_eeprom->hw_version, HW_VERSION_MTCDP_0_0)) { + if (!strcmp(id_eeprom.hw_version, HW_VERSION_MTCDP_0_0)) { log_debug("digital outputs not available on 0.0 hw"); return -ENODEV; } @@ -1557,7 +1558,7 @@ static int __devinit mts_spi_din_probe(struct spi_device *spi) { int tmp; - if (!strcmp(id_eeprom->hw_version, HW_VERSION_MTCDP_0_0)) { + if (!strcmp(id_eeprom.hw_version, HW_VERSION_MTCDP_0_0)) { log_debug("digital inputs not available on 0.0 hw"); return -ENODEV; } @@ -1693,7 +1694,7 @@ static int __init mts_io_init(void) ADC_CONVERT_RESET(adc_base); writel(ADC_MODE_DEFAULT, adc_base + ADC_MR_OFFSET); writel(0x000F0F0F, adc_base + ADC_IDR_OFFSET); - if (!strcmp(id_eeprom->hw_version, HW_VERSION_MTCDP_0_0)) { + if (!strcmp(id_eeprom.hw_version, HW_VERSION_MTCDP_0_0)) { writel(0x0F, adc_base + ADC_CHDR_OFFSET); } else { writel(0x0F, adc_base + ADC_CHER_OFFSET); -- cgit v1.2.3