diff options
-rw-r--r-- | io-module/mtac.c | 22 | ||||
-rw-r--r-- | io-module/mtac_lora.c | 33 | ||||
-rw-r--r-- | io-module/mts_eeprom.h | 3 | ||||
-rw-r--r-- | io-module/mts_io.c | 14 | ||||
-rw-r--r-- | io-module/mts_io.h | 6 |
5 files changed, 67 insertions, 11 deletions
diff --git a/io-module/mtac.c b/io-module/mtac.c index 6a80576..43436f8 100644 --- a/io-module/mtac.c +++ b/io-module/mtac.c @@ -72,6 +72,16 @@ static ssize_t ap_show_product_info(struct kobject *kobj, struct kobj_attribute ap_eeprom[port_index].mac_addr[3], ap_eeprom[port_index].mac_addr[4], ap_eeprom[port_index].mac_addr[5]); + } else if (! strcmp(attr->attr.name, "eui")) { + value = sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", + ap_eeprom[port_index].eui[0], + ap_eeprom[port_index].eui[1], + ap_eeprom[port_index].eui[2], + ap_eeprom[port_index].eui[3], + ap_eeprom[port_index].eui[4], + ap_eeprom[port_index].eui[5], + ap_eeprom[port_index].eui[6], + ap_eeprom[port_index].eui[7]); } else { log_error("attribute [%s] not found", attr->attr.name); value = -1; @@ -98,8 +108,20 @@ static bool ap_add_product_info_attributes(int port, int type, struct attribute* case MTAC_GPIOB_0_0: case MTAC_MFSER_0_0: + break; + case MTAC_LORA_0_0: + case MTAC_LORA_1_0: + sprintf(buf, "eui"); + kobj_attr = create_attribute(buf, MTS_ATTR_MODE_RO); + if (! kobj_attr) { + log_error("failed to create attribute [%s] in port %d", buf, port); + return false; + } + kobj_attr->show = ap_show_product_info; + attrs[(*index)++] = &kobj_attr->attr; break; + default: log_error("invalid accessory card type"); return false; diff --git a/io-module/mtac_lora.c b/io-module/mtac_lora.c index b546003..8616d21 100644 --- a/io-module/mtac_lora.c +++ b/io-module/mtac_lora.c @@ -23,8 +23,10 @@ static char* lora_gpio_pin_name_by_attr_name(const char* name, int port) { // 1 product-id // 1 device-id // 1 hw-version +// 1 eui +// 1 reset // NULL -static size_t ap_lora_attrs_size = 6; +static size_t ap_lora_attrs_size = 8; static bool lora_setup(enum ap port) { int i; @@ -35,6 +37,7 @@ static bool lora_setup(enum ap port) { char buf[32]; struct kobj_attribute* attr; struct attribute **attrs; + int lora_hw_version; log_info("loading LORA accessory card in port %d", port); @@ -73,18 +76,30 @@ static bool lora_setup(enum ap port) { return false; } - sprintf(buf, "reset"); - attr = create_attribute(buf, MTS_ATTR_MODE_RW); - if (! attr) { - log_error("failed to create attribute [%s] for LORA in port %d", buf, port); + if (strncmp(ap_eeprom[port_index].hw_version, HW_VERSION_MTAC_LORA_0_0, strlen(HW_VERSION_MTAC_LORA_0_0)) == 0) + lora_hw_version = MTAC_LORA_0_0; + else if (strncmp(ap_eeprom[port_index].hw_version, HW_VERSION_MTAC_LORA_1_0, strlen(HW_VERSION_MTAC_LORA_1_0)) == 0) + lora_hw_version = MTAC_LORA_1_0; + else { + log_error("Unknown hw-version in port %d", port); return false; } - attr->show = mts_attr_show_ap_gpio_pin; - attr->store = mts_attr_store_ap_gpio_pin; - attrs[index++] = &attr->attr; + + // add reset line attribute for MTAC_LORA_0_0 + if (lora_hw_version == MTAC_LORA_0_0) { + sprintf(buf, "reset"); + attr = create_attribute(buf, MTS_ATTR_MODE_RW); + if (! attr) { + log_error("failed to create attribute [%s] for LORA in port %d", buf, port); + return false; + } + attr->show = mts_attr_show_ap_gpio_pin; + attr->store = mts_attr_store_ap_gpio_pin; + attrs[index++] = &attr->attr; + } // add attributes for eeprom contents - if (! ap_add_product_info_attributes(port, MTAC_LORA_0_0, attrs, &index)) { + if (! ap_add_product_info_attributes(port, lora_hw_version, attrs, &index)) { log_error("failed to add product info attributes for LORA in port %d", port); return false; } diff --git a/io-module/mts_eeprom.h b/io-module/mts_eeprom.h index 2e42008..640f749 100644 --- a/io-module/mts_eeprom.h +++ b/io-module/mts_eeprom.h @@ -30,7 +30,8 @@ struct mts_ap_eeprom_layout { char device_id[32]; char hw_version[32]; uint8_t mac_addr[6]; - uint8_t reserved[378]; + uint8_t eui[8]; + uint8_t reserved[370]; }; #define DEVICE_CAPA_INDEX(c) (((c) & 0xFF) >> 3) diff --git a/io-module/mts_io.c b/io-module/mts_io.c index 3b2e130..1ae85e6 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -45,7 +45,7 @@ #include "mts_io.h" -#define DRIVER_VERSION "v0.9.1" +#define DRIVER_VERSION "v1.1.1" #define DRIVER_AUTHOR "James Maki <jmaki@multitech.com>" #define DRIVER_DESC "MTS-IO Controller" #define DRIVER_NAME "mts-io" @@ -433,6 +433,18 @@ static bool load_port(int port) { ap_eeprom[port_index].mac_addr[4], ap_eeprom[port_index].mac_addr[5]); } + if (strncmp(ap_eeprom[port_index].product_id, PRODUCT_ID_MTAC_LORA, strlen(PRODUCT_ID_MTAC_LORA)) == 0) { + log_info("accessory card %d eui: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X", + port, + ap_eeprom[port_index].eui[0], + ap_eeprom[port_index].eui[1], + ap_eeprom[port_index].eui[2], + ap_eeprom[port_index].eui[3], + ap_eeprom[port_index].eui[4], + ap_eeprom[port_index].eui[5], + ap_eeprom[port_index].eui[6], + ap_eeprom[port_index].eui[7]); + } if (! port_info[port_index]->setup(port)) { log_error("accessory port %d setup failed", port); diff --git a/io-module/mts_io.h b/io-module/mts_io.h index 216cc92..24a1760 100644 --- a/io-module/mts_io.h +++ b/io-module/mts_io.h @@ -50,6 +50,11 @@ struct device_attribute _dev_name = { \ #define PRODUCT_ID_MTAC_ETH "MTAC-ETH" #define PRODUCT_ID_MTAC_LORA "MTAC-LORA" +/* MTAC-LORA with native SPI or FTDI FT4222 */ +#define HW_VERSION_MTAC_LORA_0_0 "MTAC-LORA-0.0" +/* MTAC-LORA2 with FTDI FT232H */ +#define HW_VERSION_MTAC_LORA_1_0 "MTAC-LORA-1.0" + #define HW_VERSION_MTCBA2_2_0 "MTCBA2-2.0" #define HW_VERSION_MTCDP_0_0 "MTCDP-0.0" #define HW_VERSION_MTCDP_1_0 "MTCDP-1.0" @@ -73,6 +78,7 @@ enum { MTAC_MFSER_0_0, MTAC_ETH_0_0, MTAC_LORA_0_0, + MTAC_LORA_1_0, }; // GPIO pin types:input, output, open drain (1 = high Z, 0 = output low) |