diff options
-rw-r--r-- | io-module/mts-io.c | 50 |
1 files changed, 29 insertions, 21 deletions
diff --git a/io-module/mts-io.c b/io-module/mts-io.c index 7726b34..64886a0 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -44,7 +44,7 @@ #include <linux/ctype.h> #include <linux/io.h> #include <linux/module.h> - +#include <linux/firmware.h> #include "mts_io_module.h" #include "mts_io.h" #include "buttons.h" @@ -54,9 +54,7 @@ #define LED_LS_CONTROLLABLE 0 /* on-board EEPROM */ -extern uint8_t mts_id_eeprom[512]; static struct mts_id_eeprom_layout id_eeprom; - static uint8_t mts_hw_version; struct platform_device *mts_io_platform_device; EXPORT_SYMBOL(mts_io_platform_device); @@ -574,18 +572,27 @@ mts_id_eeprom_load(void) int current_blength; // Current length in bytes of attribute array int current_count; // Number of items in array struct attribute **all_attrs = NULL; - char *tmp; - int noradio; - - //The mts_id_eeprom buffer is initialize once on boot - //reloading the mts_io.ko module will not reinitialize this buffer - //only rebooting will reinitialize this buffer - memcpy(&id_eeprom, mts_id_eeprom, sizeof(mts_id_eeprom)); - - if (mts_id_eeprom[0] == 0xFF) { - log_error("uninitialized eeprom"); - return -EIO; - } + char *tmp; + int noradio; + int ret; + const struct firmware* fw = NULL; + + /* Attempt to load the mts-io driver */ + if((ret = request_firmware(&fw, "mts_eeprom.bin", &mts_io_platform_device->dev)) == 0) { + if(fw->size == sizeof(id_eeprom)) + { + memcpy(&id_eeprom, fw->data, sizeof(id_eeprom)); + log_info("Platform EEPROM contents loaded"); + } + else + { + log_error("Invalid platform EEPROM length (%d)", fw->size); + } + + release_firmware(fw); + } else { + log_error("Unable to load EEPROM contents (%d)", ret); + } noradio = ! has_radio(id_eeprom.product_id,sizeof id_eeprom.product_id); log_debug("mts_id_eeprom: noradio=%d",noradio); @@ -860,18 +867,19 @@ static int __init mts_io_init(void) log_info("init: " DRIVER_VERSION); - ret = mts_id_eeprom_load(); - if (ret) { - cleanup(); - return ret; - } - mts_io_platform_device = platform_device_alloc(PLATFORM_NAME, -1); if (!mts_io_platform_device) { cleanup(); return -ENOMEM; } + /* request_firmware() requires a device, so call after device allocated */ + ret = mts_id_eeprom_load(); + if (ret) { + cleanup(); + return ret; + } + ret = platform_device_add(mts_io_platform_device); if (ret) { cleanup(); |