From da7d2d1c6f19debc412c7b9d03a0eb6b8513cd59 Mon Sep 17 00:00:00 2001 From: Jeff Hatch Date: Thu, 22 Jun 2017 09:13:32 -0500 Subject: Allow reset of the radio modem any time when needed, not dependent on the radio-reset backoff timers. Without this change the backoff timer feature doesn't allow reset of the radio modem more than once per backoff timeout (ie. once in 600s, 900s, etc.) --- io-module/mtcap.c | 6 +++--- io-module/mtr.c | 6 +++--- io-module/mts_io.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/io-module/mtcap.c b/io-module/mtcap.c index 048a59e..490bee2 100644 --- a/io-module/mtcap.c +++ b/io-module/mtcap.c @@ -343,7 +343,7 @@ static ssize_t mts_attr_store_radio_power_mtcap(struct device *dev, static ssize_t mts_attr_store_radio_reset_mtcap(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int value; + int value; /* 0 = normal reset; -1 = forced reset */ int err; int radio_model = get_radio_model_from_product_id(); @@ -351,12 +351,12 @@ static ssize_t mts_attr_store_radio_reset_mtcap(struct device *dev, return -EINVAL; } - if (value != 0) { + if (value != 0 && value != -1) { return -EINVAL; } /* check reset timings is enabled */ - if (NULL != timings_data) { + if (value != -1 && NULL != timings_data) { /* check reset timer is started */ if (radio_reset_timer_is_start == 1) { log_info("cell radio reset timer is running. \n"); diff --git a/io-module/mtr.c b/io-module/mtr.c index 712dc62..4e44988 100644 --- a/io-module/mtr.c +++ b/io-module/mtr.c @@ -1070,18 +1070,18 @@ static ssize_t mts_attr_store_radio_power_mtr(struct device *dev, static ssize_t mts_attr_store_radio_reset_mtr(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int value; + int value; /* 0 = normal reset; -1 = forced reset */ int err; if (sscanf(buf, "%i", &value) != 1) { return -EINVAL; } - if (value != 0) { + if (value != 0 && value != -1) { return -EINVAL; } /* check reset timings is enabled */ - if (NULL != timings_data) { + if (value != -1 && NULL != timings_data) { /* check reset timer is started */ if (radio_reset_timer_is_start == 1) { log_info("radio reset timer is running. \n"); diff --git a/io-module/mts_io.c b/io-module/mts_io.c index f47e2ea..aad181f 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -253,19 +253,19 @@ static DEVICE_ATTR_RO_MTS(dev_attr_reset, "reset", mts_attr_show_gpio_pin); static ssize_t mts_attr_store_radio_reset(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int value; + int value; /* 0 = normal reset; -1 = forced reset */ int err; struct gpio_pin *pin; if (sscanf(buf, "%i", &value) != 1) { return -EINVAL; } - if (value != 0) { + if (value != 0 && value != -1) { return -EINVAL; } /* check reset timings is enabled */ - if (NULL != timings_data) { + if (value != -1 && NULL != timings_data) { /* check reset timer is started */ if (radio_reset_timer_is_start == 1) { log_info("radio reset timer is running. \n"); -- cgit v1.2.3 From 3dbb21250b47990a815514382e6a9bb876516f70 Mon Sep 17 00:00:00 2001 From: John Klug Date: Thu, 20 Jul 2017 16:33:31 -0500 Subject: Bump the driver level --- io-module/mts_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io-module/mts_io.c b/io-module/mts_io.c index aad181f..f4e4e51 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -47,7 +47,7 @@ #include "mts_io.h" -#define DRIVER_VERSION "v1.5.12" +#define DRIVER_VERSION "v1.5.13" #define DRIVER_AUTHOR "James Maki " #define DRIVER_DESC "MTS-IO Controller" #define DRIVER_NAME "mts-io" -- cgit v1.2.3 From 22a9fd546f9020dabd8c9272412cefd941adf020 Mon Sep 17 00:00:00 2001 From: John Klug Date: Wed, 23 Aug 2017 14:37:16 -0500 Subject: MTCAP_0_1 changes --- io-module/mtcap.c | 1 + io-module/mts_io.c | 21 ++++++++++----------- io-module/mts_io.h | 13 +------------ 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/io-module/mtcap.c b/io-module/mtcap.c index 490bee2..f8b7d4b 100644 --- a/io-module/mtcap.c +++ b/io-module/mtcap.c @@ -1,3 +1,4 @@ +/* Used for both MTCAP 0.0 and 0.1 */ static struct gpio_pin gpio_pins_mtcap_0_0[] = { { .name = "ETH_RESET", diff --git a/io-module/mts_io.c b/io-module/mts_io.c index f4e4e51..de59a50 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -47,7 +47,7 @@ #include "mts_io.h" -#define DRIVER_VERSION "v1.5.13" +#define DRIVER_VERSION "v1.5.14" #define DRIVER_AUTHOR "James Maki " #define DRIVER_DESC "MTS-IO Controller" #define DRIVER_NAME "mts-io" @@ -74,7 +74,6 @@ 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 @@ -823,7 +822,6 @@ static int mts_id_eeprom_load() int current_blength; // Current length in bytes of attribute array int current_count; // Number of items in array struct attribute **all_attrs = NULL; - mts_hw_version = MTCDT_0_0; //The mts_id_eeprom buffer is initialize once on boot //reloading the mts_io.ko module will not reinitialize this buffer @@ -833,33 +831,36 @@ 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) + { + 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; + } + log_info("detected board %s", HW_VERSION_MTCAP_0_1); } 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) { attr_blength = sizeof mtcdt_0_1_platform_attributes; @@ -889,12 +890,10 @@ static int mts_id_eeprom_load() attr_group = &mtcdt_0_1_platform_attribute_group; gpio_pins = gpio_pins_mtcdt_0_1; - mts_hw_version = MTCDT_0_1; log_info("detected board %s", HW_VERSION_MTCDT_0_1); } 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 99bfcbb..35bb76e 100644 --- a/io-module/mts_io.h +++ b/io-module/mts_io.h @@ -70,19 +70,8 @@ struct device_attribute _dev_name = { \ #define HW_VERSION_MTCDT_0_0 "MTCDT-0.0" #define HW_VERSION_MTCDT_0_1 "MTCDT-0.1" #define HW_VERSION_MTCAP_0_0 "MTCAP-0.0" +#define HW_VERSION_MTCAP_0_1 "MTCAP-0.1" -enum { - MTCDP_E1_DK_0_0, - MTCDP_E1_DK_1_0, - MT100EOCG_0_0, - MTR_0_0, - MTR_0_1, - MTRV1_0_0, - MTRV1_0_1, - MTCDT_0_0, - MTCDT_0_1, - MTCAP_0_0, -}; enum { MTAC_NONE, -- cgit v1.2.3 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 From d867fce779ccaa6ad8a9cc26e476c0686fc6bed0 Mon Sep 17 00:00:00 2001 From: John Klug Date: Fri, 1 Sep 2017 18:04:59 -0500 Subject: Bump the level --- io-module/mts_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io-module/mts_io.c b/io-module/mts_io.c index a28fb42..8ec9d9c 100644 --- a/io-module/mts_io.c +++ b/io-module/mts_io.c @@ -47,7 +47,7 @@ #include "mts_io.h" -#define DRIVER_VERSION "v1.5.14" +#define DRIVER_VERSION "v1.5.15" #define DRIVER_AUTHOR "James Maki " #define DRIVER_DESC "MTS-IO Controller" #define DRIVER_NAME "mts-io" -- cgit v1.2.3 From 39bd6b41dfbd1d8eb9debc654edefa8bd1fbb455 Mon Sep 17 00:00:00 2001 From: John Klug Date: Tue, 5 Sep 2017 10:15:03 -0500 Subject: Mistakenly removed the enum list --- io-module/mts_io.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/io-module/mts_io.h b/io-module/mts_io.h index 068e594..7c2a969 100644 --- a/io-module/mts_io.h +++ b/io-module/mts_io.h @@ -75,6 +75,19 @@ struct device_attribute _dev_name = { \ #define HW_VERSION_MTCAP_0_0 "MTCAP-0.0" #define HW_VERSION_MTCAP_0_1 "MTCAP-0.1" +enum { + MTCDP_E1_DK_0_0, + MTCDP_E1_DK_1_0, + MT100EOCG_0_0, + MTR_0_0, + MTR_0_1, + MTRV1_0_0, + MTRV1_0_1, + MTCDT_0_0, + MTCDT_0_1, + MTCAP_0_0, + MTCAP_0_1, +}; enum { MTAC_NONE, -- cgit v1.2.3