summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--io-module/mtr2d2.c215
-rw-r--r--io-module/mts_eeprom.h4
-rw-r--r--io-module/mts_io.c86
-rw-r--r--io-module/mts_io.h3
-rw-r--r--io-module/spi.c12
5 files changed, 278 insertions, 42 deletions
diff --git a/io-module/mtr2d2.c b/io-module/mtr2d2.c
new file mode 100644
index 0000000..58aeb03
--- /dev/null
+++ b/io-module/mtr2d2.c
@@ -0,0 +1,215 @@
+
+static struct gpio_pin gpio_pins_mtr2d2_0_0[] = {
+ {
+ .name = "RADIO_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC5,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "radio-reset",
+ },
+ },
+ {
+ .name = "RADIO_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC5,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "radio-power",
+ },
+ },
+ {
+ .name = "DEVICE_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC4,
+ .flags = GPIOF_IN,
+ .label = "reset",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LS_LED",
+ .pin = {
+ .gpio = AT91_PIN_PA14,
+#if LED_LS_CONTROLLABLE
+ .flags = GPIOF_OUT_INIT_HIGH,
+#else
+ .flags = GPIOF_IN,
+#endif
+ .label = "led-ls",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "STATUS_LED",
+ .pin = {
+ .gpio = AT91_PIN_PA24,
+ .flags = GPIOF_OUT_INIT_LOW,
+ .label = "led-status",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "STATUS_LED",
+ .pin = {
+ .gpio = AT91_PIN_PA24,
+ .flags = GPIOF_OUT_INIT_LOW,
+ .label = "led-a",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED7",
+ .pin = {
+ .gpio = AT91_PIN_PA25,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-cd",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED7",
+ .pin = {
+ .gpio = AT91_PIN_PA25,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-c",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED10",
+ .pin = {
+ .gpio = AT91_PIN_PA26,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig1",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED10",
+ .pin = {
+ .gpio = AT91_PIN_PA26,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-d",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED11",
+ .pin = {
+ .gpio = AT91_PIN_PA27,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig2",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED11",
+ .pin = {
+ .gpio = AT91_PIN_PA27,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-e",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED12",
+ .pin = {
+ .gpio = AT91_PIN_PA28,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig3",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED12",
+ .pin = {
+ .gpio = AT91_PIN_PA28,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-f",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED13",
+ .pin = {
+ .gpio = AT91_PIN_PA29,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-wifi",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED13",
+ .pin = {
+ .gpio = AT91_PIN_PA29,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-b",
+ },
+ .active_low = 1,
+ },
+ { },
+};
+
+static struct attribute *mtr2d2_platform_attributes[] = {
+ &dev_attr_vendor_id.attr,
+ &dev_attr_product_id.attr,
+ &dev_attr_device_id.attr,
+ &dev_attr_hw_version.attr,
+ &dev_attr_imei.attr,
+ &dev_attr_eth_mac.attr,
+ &dev_attr_reset.attr,
+ &dev_attr_reset_monitor.attr,
+ &dev_attr_radio_power.attr,
+ &dev_attr_radio_reset.attr,
+
+ &dev_attr_led_status.attr,
+ &dev_attr_led_wifi_gpio.attr,
+ &dev_attr_led_cd_gpio.attr,
+ &dev_attr_led_sig1_gpio.attr,
+ &dev_attr_led_sig2_gpio.attr,
+ &dev_attr_led_sig3_gpio.attr,
+
+ &dev_attr_led_a_gpio.attr,
+ &dev_attr_led_b_gpio.attr,
+ &dev_attr_led_c_gpio.attr,
+ &dev_attr_led_d_gpio.attr,
+ &dev_attr_led_e_gpio.attr,
+ &dev_attr_led_f_gpio.attr,
+
+ &dev_attr_board_temperature.attr,
+
+ /* extra space for the accessory card attributes */
+ NULL, // index 23
+ NULL, // index 24
+ NULL, // index 25
+ NULL, // index 26
+ NULL, // index 27
+ NULL, // index 28
+ NULL, // index 29
+ NULL, // index 30
+ NULL, // index 31
+ NULL, // index 32
+ NULL, // index 33
+ NULL, // index 34
+ NULL, // index 35
+ NULL, // index 36
+ NULL, // index 37
+ NULL, // index 38
+ NULL, // index 39
+ NULL, // index 40
+ NULL, // index 41
+ NULL, // index 42
+ NULL, // index 43
+ NULL, // index 44
+ NULL, // index 45
+ NULL, // index 46
+ NULL, // index 47
+ NULL, // index 48
+ NULL, // index 49
+ NULL, // index 50
+ NULL, // index 51
+ NULL,
+};
+
+static struct attribute_group mtr2d2_platform_attribute_group = {
+ .attrs = mtr2d2_platform_attributes
+};
diff --git a/io-module/mts_eeprom.h b/io-module/mts_eeprom.h
index d6c3bd3..2e42008 100644
--- a/io-module/mts_eeprom.h
+++ b/io-module/mts_eeprom.h
@@ -23,8 +23,8 @@ struct mts_id_eeprom_layout {
uint8_t reserved[302];
};
-/* daughter card EEPROM */
-struct mts_dc_eeprom_layout {
+/* accessory card EEPROM */
+struct mts_ap_eeprom_layout {
char vendor_id[32];
char product_id[32];
char device_id[32];
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);
diff --git a/io-module/mts_io.h b/io-module/mts_io.h
index 0842f25..fc37ac5 100644
--- a/io-module/mts_io.h
+++ b/io-module/mts_io.h
@@ -46,6 +46,7 @@ struct device_attribute _dev_name = { \
#define PRODUCT_ID_MTR "MTR"
#define PRODUCT_ID_MTOCGD2 "MTOCGD2"
#define PRODUCT_ID_MTOCGD "MTOCGD"
+#define PRODUCT_ID_MTR2D2 "MTR2D2"
#define PRODUCT_ID_MTDC_GPIOB "MTDC-GPIOB"
@@ -60,6 +61,7 @@ struct device_attribute _dev_name = { \
#define HW_VERSION_MTOCGD2_0_0 "MTOCGD2-0.0"
#define HW_VERSION_MTOCGD_0_0 "MTOCGD-0.0"
#define HW_VERSION_MTOCGD_0_1 "MTOCGD-0.1"
+#define HW_VERSION_MTR2D2_0_0 "MTR2D2-0.0"
enum {
MTCDP_E1_DK_0_0,
@@ -71,6 +73,7 @@ enum {
MTOCGD2_0_0,
MTOCGD_0_0,
MTOCGD_0_1,
+ MTR2D2_0_0,
};
enum {
diff --git a/io-module/spi.c b/io-module/spi.c
index 2da3f05..dfbdfe2 100644
--- a/io-module/spi.c
+++ b/io-module/spi.c
@@ -599,8 +599,8 @@ static int mts_spi_dc_dout_probe(struct spi_device *spi)
{
int tmp;
- if (! has_daughter_card || mts_dc_product_id != MTDC_GPIOB_0_0) {
- log_error("daughter card digital outputs not available");
+ if (! has_accessory_card_port_1 || mts_ap1_product_id != MTDC_GPIOB_0_0) {
+ log_error("accessory card digital outputs not available");
return -ENODEV;
}
@@ -645,8 +645,8 @@ static int mts_spi_dc_din_probe(struct spi_device *spi)
{
int tmp;
- if (! has_daughter_card || mts_dc_product_id != MTDC_GPIOB_0_0) {
- log_error("daughter card digital inputs not available");
+ if (! has_accessory_card_port_1 || mts_ap1_product_id != MTDC_GPIOB_0_0) {
+ log_error("accessory card digital inputs not available");
return -ENODEV;
}
@@ -688,8 +688,8 @@ static int mts_spi_dc_adc_probe(struct spi_device *spi)
{
int tmp;
- if (! has_daughter_card || mts_dc_product_id != MTDC_GPIOB_0_0) {
- log_error("daughter card analog to digital not available");
+ if (! has_accessory_card_port_1 || mts_ap1_product_id != MTDC_GPIOB_0_0) {
+ log_error("accessory card analog to digital not available");
return -ENODEV;
}