summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Fiore <mfiore@multitech.com>2014-01-30 12:34:47 -0600
committerMike Fiore <mfiore@multitech.com>2014-01-30 12:34:47 -0600
commit37fa7696793110153cb75182554d0fd2313ada00 (patch)
tree00c2ef811155babdc5699e4b2fa352add6a8c384
parent9b57404a2b91e356dbed48b266036c57d8a8c62f (diff)
downloadmts-io-37fa7696793110153cb75182554d0fd2313ada00.tar.gz
mts-io-37fa7696793110153cb75182554d0fd2313ada00.tar.bz2
mts-io-37fa7696793110153cb75182554d0fd2313ada00.zip
MTR2 hardware detects daughter card, tries to read EEPROM, and logs contents
-rw-r--r--io-module/mts_io.c54
-rw-r--r--io-module/mts_io.h12
2 files changed, 66 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;
diff --git a/io-module/mts_io.h b/io-module/mts_io.h
index f2ff2b4..86ab32e 100644
--- a/io-module/mts_io.h
+++ b/io-module/mts_io.h
@@ -81,6 +81,9 @@ do { \
#define CAPA_BLUETOOTH DEVICE_CAPA_VALUE(1, 7)
#define CAPA_WIFI DEVICE_CAPA_VALUE(1, 6)
+#define DAUGHTER_CARD_GPIO "MTDC-GPIOB"
+
+/* on-board EEPROM */
struct mts_id_eeprom_layout {
char vendor_id[32];
char product_id[32];
@@ -94,6 +97,15 @@ struct mts_id_eeprom_layout {
uint8_t reserved[302];
};
+/* daughter card EEPROM */
+struct mts_dc_eeprom_layout {
+ char serial[32];
+ char hw_rev[32];
+ char product_id[32];
+ uint8_t mac_addr[6];
+ uint8_t reserved[410];
+};
+
// GPIO pin types:input, output, open drain (1 = high Z, 0 = output low)
enum {
GPIO_DIR_INPUT,