From 08958c7881357a502ea80a13e4f9e45eb61bffcb Mon Sep 17 00:00:00 2001 From: John Klug Date: Fri, 1 Sep 2017 18:02:57 -0500 Subject: Remove radio-reset on MTCAP when radio not preesnt. Add MTCDTIP --- io-module/mtcap.c | 21 ++++++++++++++------- io-module/mts_io.c | 43 +++++++++++++++++++++++++++++++++++++------ io-module/mts_io.h | 3 +++ 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/io-module/mtcap.c b/io-module/mtcap.c index f8b7d4b..804b364 100644 --- a/io-module/mtcap.c +++ b/io-module/mtcap.c @@ -440,7 +440,15 @@ static struct attribute *mtcap_0_0_platform_attributes[] = { &dev_attr_reset_monitor_intervals.attr, &dev_attr_eth_reset_mtcap.attr, + &dev_attr_led_status.attr, + &dev_attr_led_cd_gpio.attr, + &dev_attr_led_lora_gpio_mtcap.attr, + &dev_attr_led_wifi_gpio_mtcap.attr, + &dev_attr_wlan_en_gpio_mtcap.attr, + &dev_attr_wlan_rst_gpio_mtcap.attr, + + /* Set to NULL if no radio -- should be 1st radio attribute */ &dev_attr_radio_power_mtcap.attr, &dev_attr_radio_reset_mtcap.attr, @@ -448,16 +456,15 @@ static struct attribute *mtcap_0_0_platform_attributes[] = { &dev_attr_radio_reset_backoff_index.attr, &dev_attr_radio_reset_backoff_seconds.attr, - &dev_attr_led_status.attr, - &dev_attr_led_cd_gpio.attr, - &dev_attr_led_lora_gpio_mtcap.attr, - &dev_attr_led_wifi_gpio_mtcap.attr, - - &dev_attr_wlan_en_gpio_mtcap.attr, - &dev_attr_wlan_rst_gpio_mtcap.attr, NULL, }; +static int +is_radio_power_attr(struct attribute *attr) +{ + return (attr == &dev_attr_radio_power_mtcap.attr); +} + static struct attribute_group mtcap_0_0_platform_attribute_group = { .attrs = mtcap_0_0_platform_attributes }; diff --git a/io-module/mts_io.c b/io-module/mts_io.c index de59a50..a28fb42 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -74,6 +74,7 @@ static struct mts_id_eeprom_layout id_eeprom; #define NUM_AP 0 #endif +static uint8_t mts_hw_version; static struct platform_device *mts_io_platform_device; static struct attribute_group *attr_group; static struct attribute_group *attr_group_lora; // on-board lora peripheral to be stored in the lora/ sub-directory @@ -813,7 +814,8 @@ static void teardown_ports(void) struct attribute *freelater = NULL; // Storage to free when driver is unloaded. -static int mts_id_eeprom_load() +static int +mts_id_eeprom_load(void) { int i; char buf[64] = {0}; @@ -831,15 +833,34 @@ static int mts_id_eeprom_load() if (mts_id_eeprom[0] == 0xFF) { log_error("uninitialized eeprom"); return -EIO; - } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTCAP_0_0, strlen(HW_VERSION_MTCAP_0_0)) == 0) { + } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTCAP_0_0, strlen(HW_VERSION_MTCAP_0_0)) == 0) { attr_group = &mtcap_0_0_platform_attribute_group; gpio_pins = gpio_pins_mtcap_0_0; if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA)) { attr_group_lora = &mtcap_0_0_lora_attribute_group; } + mts_hw_version = MTCAP_0_0; log_info("detected board %s", HW_VERSION_MTCAP_0_0); - } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTCAP_0_1, strlen(HW_VERSION_MTCAP_0_1)) == 0) - { + } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTCAP_0_1, strlen(HW_VERSION_MTCAP_0_1)) == 0) { + int j=0; + /* See if we have no radio, and if so, prune out the stuff that follows */ + if((strncmp(id_eeprom.product_id, PRODUCT_ID_MTCAP, sizeof PRODUCT_ID_MTCAP - 1) == 0) && + (id_eeprom.product_id[sizeof PRODUCT_ID_MTCAP-1] == '-') && + isdigit(id_eeprom.product_id[sizeof PRODUCT_ID_MTCAP])) { + struct attribute **ap = mtcap_0_0_platform_attribute_group.attrs; + while(1) { + if(ap[j] == NULL) { + log_info("Did not find radio power attribute. Possible driver fault."); + break; + } + j++; + if (is_radio_power_attr(ap[j])) { + log_info("Pruning radio feature from mts-io",j); + ap[j] = NULL; + break; + } + } + } attr_group = &mtcap_0_0_platform_attribute_group; gpio_pins = gpio_pins_mtcap_0_0; if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA)) { @@ -849,20 +870,26 @@ static int mts_id_eeprom_load() } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTR_0_0, strlen(HW_VERSION_MTR_0_0)) == 0) { attr_group = &mtr_platform_attribute_group; gpio_pins = gpio_pins_mtr_0_0; + mts_hw_version = MTR_0_0; log_info("detected board %s", HW_VERSION_MTR_0_0); } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTR_0_1, strlen(HW_VERSION_MTR_0_1)) == 0) { attr_group = &mtr_platform_attribute_group; gpio_pins = gpio_pins_mtr_0_1; + mts_hw_version = MTR_0_1; log_info("detected board %s", HW_VERSION_MTR_0_1); } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTRV1_0_0, strlen(HW_VERSION_MTRV1_0_0)) == 0) { attr_group = &mtr_platform_attribute_group; gpio_pins = gpio_pins_mtrv1_0_0; + mts_hw_version = MTRV1_0_0; log_info("detected board %s", HW_VERSION_MTRV1_0_0); } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTRV1_0_1, strlen(HW_VERSION_MTRV1_0_1)) == 0) { attr_group = &mtrv1_0_1_platform_attribute_group; gpio_pins = gpio_pins_mtrv1_0_1; + mts_hw_version = MTRV1_0_1; log_info("detected board %s", HW_VERSION_MTRV1_0_1); - } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTCDT_0_1, strlen(HW_VERSION_MTCDT_0_1)) == 0) { + } else if ((strncmp(id_eeprom.hw_version, HW_VERSION_MTCDT_0_1, strlen(HW_VERSION_MTCDT_0_1)) == 0) || + (strncmp(id_eeprom.hw_version, HW_VERSION_MTCDTIP_0_0, strlen(HW_VERSION_MTCDTIP_0_0) == 0))) + { attr_blength = sizeof mtcdt_0_1_platform_attributes; if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI)) { attr_blength += sizeof mtcdt_0_1_wifi_bt_attributes; @@ -890,10 +917,14 @@ static int mts_id_eeprom_load() attr_group = &mtcdt_0_1_platform_attribute_group; gpio_pins = gpio_pins_mtcdt_0_1; - log_info("detected board %s", HW_VERSION_MTCDT_0_1); + if(strncmp(id_eeprom.hw_version, HW_VERSION_MTCDT_0_1, strlen(HW_VERSION_MTCDT_0_1)) == 0) + log_info("detected board %s", HW_VERSION_MTCDT_0_1); + else + log_info("detected board %s", HW_VERSION_MTCDTIP_0_0); } else { attr_group = &mtcdt_platform_attribute_group; gpio_pins = gpio_pins_mtcdt_0_0; + mts_hw_version = MTCDT_0_0; log_info("detected board %s", HW_VERSION_MTCDT_0_0); } diff --git a/io-module/mts_io.h b/io-module/mts_io.h index 35bb76e..068e594 100644 --- a/io-module/mts_io.h +++ b/io-module/mts_io.h @@ -44,6 +44,8 @@ struct device_attribute _dev_name = { \ #define PRODUCT_ID_MT100EOCG "MT100EOCG" #define PRODUCT_ID_MTR "MTR" #define PRODUCT_ID_MTCDT "MTCDT" +#define PRODUCT_ID_MTCAP "MTCAP" +#define PRODCUT_ID_MTCDTIP "MTCDTIP" #define PRODUCT_ID_MTAC_GPIOB "MTAC-GPIOB" #define PRODUCT_ID_MTAC_MFSER "MTAC-MFSER" @@ -69,6 +71,7 @@ struct device_attribute _dev_name = { \ #define HW_VERSION_MTRV1_0_1 "MTRV1-0.1" #define HW_VERSION_MTCDT_0_0 "MTCDT-0.0" #define HW_VERSION_MTCDT_0_1 "MTCDT-0.1" +#define HW_VERSION_MTCDTIP_0_0 "MTCDTIP-0.0" #define HW_VERSION_MTCAP_0_0 "MTCAP-0.0" #define HW_VERSION_MTCAP_0_1 "MTCAP-0.1" -- cgit v1.2.3