diff options
author | Mike Fiore <mfiore@multitech.com> | 2014-08-25 12:59:56 -0500 |
---|---|---|
committer | Mike Fiore <mfiore@multitech.com> | 2014-08-25 12:59:56 -0500 |
commit | 19018dbbb35bd2940721ea6f04400a58c9644839 (patch) | |
tree | 8fcf138a00231d0a338e5d228f2ac768835e440d /io-module/mts_io.c | |
parent | f8a371233d759309cd58672192294180c7f8842e (diff) | |
download | mts-io-19018dbbb35bd2940721ea6f04400a58c9644839.tar.gz mts-io-19018dbbb35bd2940721ea6f04400a58c9644839.tar.bz2 mts-io-19018dbbb35bd2940721ea6f04400a58c9644839.zip |
initial support for MTR2D2 hardware
Diffstat (limited to 'io-module/mts_io.c')
-rw-r--r-- | io-module/mts_io.c | 86 |
1 files changed, 52 insertions, 34 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c index e578941..bf0332a 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -59,19 +59,24 @@ extern uint8_t mts_id_eeprom[512]; static struct mts_id_eeprom_layout id_eeprom; -/* daughter card EEPROM */ +/* accessory card EEPROMs */ #ifdef MTOCGD2 -extern uint8_t mts_dc_eeprom[512]; +extern uint8_t mts_ap1_eeprom[512]; +extern uint8_t mts_ap2_eeprom[512]; #else -uint8_t mts_dc_eeprom[512] = {}; +uint8_t mts_ap1_eeprom[512] = {}; +uint8_t mts_ap2_eeprom[512] = {}; #endif -static struct mts_dc_eeprom_layout dc_eeprom; +static struct mts_ap_eeprom_layout ap1_eeprom; +static struct mts_ap_eeprom_layout ap2_eeprom; -bool daughter_card_capable = false; -bool has_daughter_card = false; +bool accessory_card_capable = false; +bool has_accessory_card_port_1 = false; +bool has_accessory_card_port_2 = false; static uint8_t mts_product_id; -static uint8_t mts_dc_product_id; +static uint8_t mts_ap1_product_id; +static uint8_t mts_ap2_product_id; static uint8_t has_spi_sout; static uint8_t has_spi_din; static uint8_t has_spi_dout; @@ -402,38 +407,42 @@ static DEVICE_ATTR_RO_MTS(dev_attr_eth_mac, "mac-eth", /* include per-device pins and attributes */ #include "mtr2.c" #include "mtr.c" +#include "mtr2d2.c" /* currently not supported #include "mtcdp.c" #include "mt100eocg.c" */ -static int mts_dc_eeprom_load(void) +/* reorg this function to load and log both accessory card EEPROMs + * should be able to handle either or both slots being empty + */ +static int mts_ap_eeprom_load(void) { - memcpy(&dc_eeprom, mts_dc_eeprom, sizeof(mts_dc_eeprom)); + memcpy(&ap1_eeprom, mts_ap1_eeprom, sizeof(mts_ap1_eeprom)); - if (mts_dc_eeprom[0] == 0xFF) { + if (mts_ap1_eeprom[0] == 0xFF) { log_error("uninitialized eeprom on daughter card"); return -EIO; - } else if (mts_dc_eeprom[0] == 0x00) { + } else if (mts_ap1_eeprom[0] == 0x00) { log_info("no daughter card inserted"); return 0; } - has_daughter_card = true; + has_accessory_card_port_1 = true; - log_info("daughter card vendor-id: %.32s", dc_eeprom.vendor_id); - log_info("daughter card product-id: %.32s", dc_eeprom.product_id); - log_info("daughter card device-id: %.32s", dc_eeprom.device_id); - log_info("daughter card hw-version: %.32s", dc_eeprom.hw_version); + log_info("daughter card vendor-id: %.32s", ap1_eeprom.vendor_id); + log_info("daughter card product-id: %.32s", ap1_eeprom.product_id); + log_info("daughter card device-id: %.32s", ap1_eeprom.device_id); + log_info("daughter card hw-version: %.32s", ap1_eeprom.hw_version); /* 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]); + ap1_eeprom.mac_addr[0], + ap1_eeprom.mac_addr[1], + ap1_eeprom.mac_addr[2], + ap1_eeprom.mac_addr[3], + ap1_eeprom.mac_addr[4], + ap1_eeprom.mac_addr[5]); return 0; } @@ -478,7 +487,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; + accessory_card_capable = true; has_spi_sout = 0; has_spi_din = 0; has_spi_dout = 0; @@ -506,7 +515,7 @@ static int mts_id_eeprom_load(void) attr_group = &mtr2_platform_attribute_group; gpio_pins = gpio_pins_mtr2_0_0; mts_product_id = MTOCGD2_0_0; - daughter_card_capable = true; + accessory_card_capable = true; has_spi_sout = 0; has_spi_din = 0; has_spi_dout = 0; @@ -530,6 +539,15 @@ static int mts_id_eeprom_load(void) has_spi_dout = 0; has_spi_temp = 0; log_info("detected board %s", HW_VERSION_MTOCGD_0_1); + } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTR2D2_0_0, strlen(HW_VERSION_MTR2D2_0_0)) == 0) { + attr_group = &mtr2d2_platform_attribute_group; + gpio_pins = gpio_pins_mtr2d2_0_0; + mts_product_id = MTR2D2_0_0; + has_spi_sout = 0; + has_spi_din = 0; + has_spi_dout = 0; + has_spi_temp = 0; + log_info("detected board %s", HW_VERSION_MTR2D2_0_0); /* } else { attr_group = &mtcdp_platform_attribute_group; @@ -592,21 +610,21 @@ static int __init mts_io_init(void) goto error1; } - if (daughter_card_capable) { - mts_dc_product_id = MTDC_NONE; - ret = mts_dc_eeprom_load(); + if (accessory_card_capable) { + mts_ap1_product_id = MTDC_NONE; + ret = mts_ap_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) { + } else if (has_accessory_card_port_1) { /* no error and we have a daughter card */ - if (strstr(dc_eeprom.product_id, PRODUCT_ID_MTDC_GPIOB)) { - mts_dc_product_id = MTDC_GPIOB_0_0; + if (strstr(ap1_eeprom.product_id, PRODUCT_ID_MTDC_GPIOB)) { + mts_ap1_product_id = MTDC_GPIOB_0_0; } - switch(mts_dc_product_id) { + switch(mts_ap1_product_id) { case MTDC_GPIOB_0_0: log_debug("adding GPIO daughter card attributes"); if (! mtr2_add_daughter_card_attributes()) { @@ -640,7 +658,7 @@ static int __init mts_io_init(void) break; default: - log_info("daughter card '%s' currently unsupported", dc_eeprom.product_id); + log_info("daughter card '%s' currently unsupported", ap1_eeprom.product_id); } } } @@ -795,8 +813,8 @@ static void __exit mts_io_exit(void) if (has_spi_sout) spi_unregister_driver(&mts_spi_sout_driver); - if (has_daughter_card) { - switch (mts_dc_product_id) { + if (has_accessory_card_port_1) { + switch (mts_ap1_product_id) { case MTDC_GPIOB_0_0: spi_unregister_driver(&mts_spi_dc_dout_driver); spi_unregister_driver(&mts_spi_dc_din_driver); |