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.c78
1 files changed, 48 insertions, 30 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index 40381f7..229a8f7 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;
-/* accessory 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 accessory_card_capable = false;
-bool has_accessory_card = 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 accessory card");
return -EIO;
- } else if (mts_dc_eeprom[0] == 0x00) {
+ } else if (mts_ap1_eeprom[0] == 0x00) {
log_info("no accessory card inserted");
return 0;
}
- has_accessory_card = true;
+ has_accessory_card_port_1 = true;
- log_info("accessory card vendor-id: %.32s", dc_eeprom.vendor_id);
- log_info("accessory card product-id: %.32s", dc_eeprom.product_id);
- log_info("accessory card device-id: %.32s", dc_eeprom.device_id);
- log_info("accessory card hw-version: %.32s", dc_eeprom.hw_version);
+ log_info("accessory card vendor-id: %.32s", ap1_eeprom.vendor_id);
+ log_info("accessory card product-id: %.32s", ap1_eeprom.product_id);
+ log_info("accessory card device-id: %.32s", ap1_eeprom.device_id);
+ log_info("accessory card hw-version: %.32s", ap1_eeprom.hw_version);
/* TODO: only show the mac address if this is the ethernet card */
log_info("accessory 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;
}
@@ -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;
@@ -593,19 +611,19 @@ static int __init mts_io_init(void)
}
if (accessory_card_capable) {
- mts_dc_product_id = MTDC_NONE;
- ret = mts_dc_eeprom_load();
+ mts_ap1_product_id = MTDC_NONE;
+ ret = mts_ap_eeprom_load();
if (ret) {
/* error reading the EEPROM from the accessory card */
log_error("error reading accessory card eeprom: %d", ret);
log_error("unable to initialize accessory card");
- } else if (has_accessory_card) {
+ } else if (has_accessory_card_port_1) {
/* no error and we have a accessory 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 accessory card attributes");
if (! mtr2_add_accessory_card_attributes()) {
@@ -639,7 +657,7 @@ static int __init mts_io_init(void)
break;
default:
- log_info("accessory card '%s' currently unsupported", dc_eeprom.product_id);
+ log_info("accessory card '%s' currently unsupported", ap1_eeprom.product_id);
}
}
}
@@ -794,8 +812,8 @@ static void __exit mts_io_exit(void)
if (has_spi_sout)
spi_unregister_driver(&mts_spi_sout_driver);
- if (has_accessory_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);