summaryrefslogtreecommitdiff
path: root/io-module/mts_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io-module/mts_io.c')
-rw-r--r--io-module/mts_io.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index 89e1e0e..8c38119 100644
--- a/io-module/mts_io.c
+++ b/io-module/mts_io.c
@@ -83,9 +83,17 @@ static int led_mode_status = LED_OFF;
#define SOUT_LED_SIG3_BIT BIT(6)
#define SOUT_EXTSERIAL_DCD_BIT BIT(7)
+/* on-board EEPROM */
extern uint8_t mts_id_eeprom[512];
static struct mts_id_eeprom_layout id_eeprom;
+/* daughter card EEPROM */
+extern uint8_t mts_dc_eeprom[512];
+static struct mts_dc_eeprom_layout dc_eeprom;
+
+bool daughter_card_capable = false;
+bool has_daughter_card = false;
+
static uint8_t mts_product_id;
static uint8_t has_spi_sout;
static uint8_t has_spi_din;
@@ -2863,6 +2871,35 @@ static struct spi_driver mts_spi_board_temp_driver = {
.remove = __devexit_p(mts_spi_board_temp_remove),
};
+static int mts_dc_eeprom_load(void)
+{
+ memcpy(&dc_eeprom, mts_dc_eeprom, sizeof(mts_dc_eeprom));
+
+ if (mts_dc_eeprom[0] == 0xFF) {
+ log_error("uninitialized eeprom on daughter card");
+ return -EIO;
+ } else if (mts_dc_eeprom[0] == 0x00) {
+ log_info("no daughter card inserted");
+ return 0;
+ }
+
+ has_daughter_card = true;
+
+ log_info("daughter card serial: %.32s", dc_eeprom.serial);
+ log_info("daughter card hardware version: %.32s", dc_eeprom.hw_rev);
+ log_info("daughter card product id: %.32s", dc_eeprom.product_id);
+ /* TODO: only show the mac address if this is the ethernet card */
+ log_info("daughter card mac-addr: %02X:%02X:%02X:%02X:%02X:%02X",
+ dc_eeprom.mac_addr[0],
+ dc_eeprom.mac_addr[1],
+ dc_eeprom.mac_addr[2],
+ dc_eeprom.mac_addr[3],
+ dc_eeprom.mac_addr[4],
+ dc_eeprom.mac_addr[5]);
+
+ return 0;
+}
+
static int mts_id_eeprom_load(void)
{
memcpy(&id_eeprom, mts_id_eeprom, sizeof(mts_id_eeprom));
@@ -2901,6 +2938,7 @@ static int mts_id_eeprom_load(void)
attr_group = &mtr2_platform_attribute_group;
gpio_pins = gpio_pins_mtr2_0_0;
mts_product_id = MTR2_0_0;
+ daughter_card_capable = true;
has_spi_sout = 0;
has_spi_din = 0;
has_spi_dout = 0;
@@ -2928,6 +2966,7 @@ static int mts_id_eeprom_load(void)
attr_group = &mtr2_platform_attribute_group;
gpio_pins = gpio_pins_mtr2_0_0;
mts_product_id = MTOCGD3_0_0;
+ daughter_card_capable = true;
has_spi_sout = 0;
has_spi_din = 0;
has_spi_dout = 0;
@@ -3011,6 +3050,21 @@ static int __init mts_io_init(void)
goto error1;
}
+ if (daughter_card_capable) {
+ ret = mts_dc_eeprom_load();
+ if (ret) {
+ /* error reading the EEPROM from the daughter card */
+ log_error("error reading daughter card eeprom: %d", ret);
+ log_error("unable to initialize daughter card");
+ goto error1;
+ } else if (! has_daughter_card) {
+ /* boolean flag wasn't set, no card */
+ log_info("no daughter card is inserted");
+ } else {
+ /* TODO: handle daughter card specific configuration here */
+ }
+ }
+
mts_io_platform_device = platform_device_alloc(PLATFORM_NAME, -1);
if (!mts_io_platform_device) {
ret = -ENOMEM;