summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike <mikempls@noreply.github.com>2018-12-12 16:39:01 -0600
committerMike <mikempls@noreply.github.com>2018-12-12 16:39:01 -0600
commit0ed1e3654d7f468e7b546aaf9e45ab2e3bf2bfd3 (patch)
treea2be69380cb2a7bcf5c38e5925dd594714ad3c54
parentc0380040166366a290c5e44a977a8acb6e3120ab (diff)
downloadmtac-0ed1e3654d7f468e7b546aaf9e45ab2e3bf2bfd3.tar.gz
mtac-0ed1e3654d7f468e7b546aaf9e45ab2e3bf2bfd3.tar.bz2
mtac-0ed1e3654d7f468e7b546aaf9e45ab2e3bf2bfd3.zip
Load EEPROM via request_firmware
-rw-r--r--mtac.c27
-rw-r--r--mtac.h1
2 files changed, 26 insertions, 2 deletions
diff --git a/mtac.c b/mtac.c
index 2f31bbe..532545d 100644
--- a/mtac.c
+++ b/mtac.c
@@ -7,6 +7,7 @@
#include <linux/types.h>
#include <linux/gpio.h>
#include <linux/platform_device.h>
+#include <linux/firmware.h>
#include <linux/kmod.h>
#include <linux/bitops.h>
#include <linux/module.h>
@@ -16,7 +17,8 @@
#include "mtac.h"
/* accessory card EEPROMs, read outside of driver */
-extern uint8_t mts_ap_eeprom[NUM_AP][512];
+uint8_t mts_ap_eeprom[NUM_AP][512];
+EXPORT_SYMBOL(mts_ap_eeprom);
/* info for accessory port (contains function pointers for setup and teardown,
* gpio pin list for the device inserted into the port. */
@@ -467,10 +469,33 @@ EXPORT_SYMBOL(mtac_free);
static int __init mtac_init(void)
{
int port_index;
+#define MTS_IO_FWNAME_LEN (32)
+ char fwname[MTS_IO_FWNAME_LEN];
+ const struct firmware* fw = NULL;
+ int ret;
log_debug("init: " DRIVER_VERSION);
mutex_lock(&mtac_mutex);
+
for (port_index = 0; port_index < NUM_AP; port_index++) {
+ snprintf(fwname, MTS_IO_FWNAME_LEN, "mtac%d_eeprom.bin", port_index+1);
+ fwname[MTS_IO_FWNAME_LEN-1] = '\0';
+
+ mts_ap_eeprom[port_index][0] = 0x00; /* initialize to not present */
+ if((ret = request_firmware(&fw, fwname, &mts_io_platform_device->dev)) == 0) {
+ if(fw->size == sizeof(mts_ap_eeprom[0])) {
+ memcpy(mts_ap_eeprom[port_index], fw->data, sizeof(mts_ap_eeprom[0]));
+ log_info("EEPROM contents loaded (%s)", fwname);
+ }
+ else
+ {
+ log_error("EEPROM invalid size (%s:%d)", fwname, fw->size);
+ }
+ release_firmware(fw);
+ } else {
+ log_error("EEPROM unable to read (%s:%d)", fwname, ret);
+ }
+
if (mts_ap_eeprom[port_index][0] == 0xFF)
log_alert("uninitialized eeprom on accessory card %d", port_index);
else if (mts_ap_eeprom[port_index][0] == 0x0)
diff --git a/mtac.h b/mtac.h
index 03e6cd0..477dea4 100644
--- a/mtac.h
+++ b/mtac.h
@@ -69,7 +69,6 @@ struct ap_info {
extern struct platform_device *mts_io_platform_device;
-extern uint8_t mts_ap_eeprom[NUM_AP][512];
extern struct mutex mtac_mutex;
extern void mtac_clear_port_pins(int port_index);