diff options
author | Serhii Voloshynov <serhii.voloshynov@globallogic.com> | 2022-10-11 10:27:14 +0300 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2022-10-11 09:40:01 -0500 |
commit | b3c804673044d9e92c4f181f73d21fceca115191 (patch) | |
tree | cc741695ebf083619e32491959f09e1bab82be25 | |
parent | 1321122774add144ab42a3bcf9d3900be5766cbd (diff) | |
download | mts-io-b3c804673044d9e92c4f181f73d21fceca115191.tar.gz mts-io-b3c804673044d9e92c4f181f73d21fceca115191.tar.bz2 mts-io-b3c804673044d9e92c4f181f73d21fceca115191.zip |
If the device is MTR, the system shall assume that the radio modem is always present4.9.12
-rw-r--r-- | io-module/mts-io.c | 41 | ||||
-rw-r--r-- | io-module/mts_io_module.h | 152 |
2 files changed, 111 insertions, 82 deletions
diff --git a/io-module/mts-io.c b/io-module/mts-io.c index 7c33ea4..df52a12 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -201,6 +201,8 @@ static time64_t time_now_secs(void); bool sent_extra_long = false; +int is_mtr(void); + /* * For EEPROM layout after version 0, we use the * CAPA_CELLULAR flag to determine if we have a cellular @@ -222,6 +224,11 @@ bool sent_extra_long = false; * If the B is the last character we have a modem. * If the modem field starts with IN, we have an * India LoRa channel plan with no cellular modem. + * + * If the device is an MTR it always has a Cellular radio. + * It is indended to fix wrongly written EEPROM values. + * mts_has_radio has to have its own check, because it is exported. + * * All other cases, we have a modem. * * TRUE: 1 for return result @@ -231,7 +238,10 @@ int mts_has_radio(const char *product_id, size_t len) { char *p; - int found_i = 0; + int found_i = 0; + if (is_mtr()) { + return 1; + } if (!product_id || ! *product_id) return 1; /* No Product ID? */ p = memchr(product_id,'-',len); @@ -282,6 +292,14 @@ mts_has_radio(const char *product_id, size_t len) } EXPORT_SYMBOL(mts_has_radio); +int is_mtr(void) { + if ((strncmp(id_eeprom.hw_version, HW_VERSION_MTR_DASH, strlen(HW_VERSION_MTR_DASH)) == 0)|| + (strncmp(id_eeprom.hw_version, HW_VERSION_MTRV1_DASH, strlen(HW_VERSION_MTRV1_DASH)) == 0)) { + return 1; + } + return 0; +} + /* active-low socket modem reset */ static ssize_t mts_attr_store_radio_reset(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -632,12 +650,16 @@ static ssize_t mts_attr_show_product_info(struct device *dev, } else if (strcmp(attr->attr.name, "product-id") == 0) { value = sprintf(buf, "%.32s\n", id_eeprom.product_id); } else if (strcmp(attr->attr.name, "has-radio") == 0) { - if(id_eeprom.eeprom_layout_version == 0) - value = sprintf(buf, "%d\n", - mts_has_radio(id_eeprom.product_id,sizeof id_eeprom.product_id)); - else - /* Newer EEPROM version with CAPA_CELLULAR */ - value = sprintf(buf, "%1d\n",DEVICE_CAPA(id_eeprom.capa, CAPA_CELLULAR) ? 1 : 0); + if (is_mtr()) { + value = sprintf(buf, "1\n"); // MTRs always have cellular + } else { + if(id_eeprom.eeprom_layout_version == 0) + value = sprintf(buf, "%d\n", + mts_has_radio(id_eeprom.product_id,sizeof id_eeprom.product_id)); + else + /* Newer EEPROM version with CAPA_CELLULAR */ + value = sprintf(buf, "%1d\n",DEVICE_CAPA(id_eeprom.capa, CAPA_CELLULAR) ? 1 : 0); + } } else if (strcmp(attr->attr.name, "device-id") == 0) { value = sprintf(buf, "%.32s\n", id_eeprom.device_id); } else if (strcmp(attr->attr.name, "uuid") == 0) { @@ -828,6 +850,11 @@ mts_id_eeprom_load(void) has_cellular_capaflag = 1; noradio = ! DEVICE_CAPA(id_eeprom.capa, CAPA_CELLULAR); } + + if (is_mtr()) { + noradio = 0; + } + log_debug("mts_id_eeprom_load: noradio=%d",noradio); if (found_board(HW_VERSION_MTCAP_0_0,MTCAP_0_0,&hw_version_str,&mts_hw_version) || diff --git a/io-module/mts_io_module.h b/io-module/mts_io_module.h index 6a0a5a1..73acb40 100644 --- a/io-module/mts_io_module.h +++ b/io-module/mts_io_module.h @@ -5,98 +5,100 @@ * MTAC cards. */ -#define DEBUG 0 +#define DEBUG 0 /* Atmel AT91 Platforms */ -#define PRODUCT_ID_MTCDP_E1_DK "MTCDP-E1-DK" -#define PRODUCT_ID_MT100EOCG "MT100EOCG" -#define PRODUCT_ID_MTR "MTR" -#define PRODUCT_ID_MTRE "MTRE" -#define PRODUCT_ID_MTCDT "MTCDT" -#define PRODUCT_ID_MTCAP "MTCAP" -#define PRODUCT_ID_MTCDTIP "MTCDTIP" -#define PRODUCT_ID_MTCDTIPHP "MTCDTIPHP" -#define PRODUCT_ID_MTHS "MTHS" +#define PRODUCT_ID_MTCDP_E1_DK "MTCDP-E1-DK" +#define PRODUCT_ID_MT100EOCG "MT100EOCG" +#define PRODUCT_ID_MTR "MTR" +#define PRODUCT_ID_MTRE "MTRE" +#define PRODUCT_ID_MTCDT "MTCDT" +#define PRODUCT_ID_MTCAP "MTCAP" +#define PRODUCT_ID_MTCDTIP "MTCDTIP" +#define PRODUCT_ID_MTCDTIPHP "MTCDTIPHP" +#define PRODUCT_ID_MTHS "MTHS" -#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" -#define HW_VERSION_MT100EOCG_0_0 "MT100EOCG-0.0" -#define HW_VERSION_MTR_0_0 "MTR-0.0" -#define HW_VERSION_MTR_0_1 "MTR-0.1" -#define HW_VERSION_MTRV1_0_0 "MTRV1-0.0" -#define HW_VERSION_MTRV1_0_1 "MTRV1-0.1" -#define HW_VERSION_MTRV1_0_2 "MTRV1-0.2" // Cat M -#define HW_VERSION_MTRV1_0_3 "MTRV1-0.3" // MTR-MTQ -#define HW_VERSION_MTRV1_0_4 "MTRV1-0.4" // MTR No USB hub -#define HW_VERSION_MTRE "MTRE-0.0" -#define HW_VERSION_MTCDT_0_0 "MTCDT-0.0" // No GPS or WiFi Capability -#define HW_VERSION_MTCDT_0_1 "MTCDT-0.1" // Conduit refresh with GPS and WiFi possible -#define HW_VERSION_MTCDT_0_2 "MTCDT-0.2" // Atmel Serial and PCA9557 -#define HW_VERSION_MTCDTIP_0_0 "MTCDTIP-0.0" -#define HW_VERSION_MTCDTIP_0_1 "MTCDTIP-0.1" // Atmel Serial and PCA9557 -#define HW_VERSION_MTCDTIPHP_0_0 "MTCDTIPHP-0.0" // Also known as LoRa 2.1 -#define HW_VERSION_MTCAP_0_0 "MTCAP-0.0" -#define HW_VERSION_MTCAP_0_1 "MTCAP-0.1" -#define HW_VERSION_MTCAP_0_2 "MTCAP-0.2" // MTCAP 2 with POE -#define HW_VERSION_MTCAP_0_3 "MTCAP-0.3" // MTCDTIP2 with super-cap -#define HW_VERSION_MTHS_0_0 "MTHS-0.0" // Never released -#define HW_VERSION_MTHS_0_1 "MTHS-0.1" +#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" +#define HW_VERSION_MT100EOCG_0_0 "MT100EOCG-0.0" +#define HW_VERSION_MTR_0_0 "MTR-0.0" +#define HW_VERSION_MTR_0_1 "MTR-0.1" +#define HW_VERSION_MTR_DASH "MTR-" +#define HW_VERSION_MTRV1_0_0 "MTRV1-0.0" +#define HW_VERSION_MTRV1_0_1 "MTRV1-0.1" +#define HW_VERSION_MTRV1_0_2 "MTRV1-0.2" // Cat M +#define HW_VERSION_MTRV1_0_3 "MTRV1-0.3" // MTR-MTQ +#define HW_VERSION_MTRV1_0_4 "MTRV1-0.4" // MTR No USB hub +#define HW_VERSION_MTRV1_DASH "MTRV1-" +#define HW_VERSION_MTRE "MTRE-0.0" +#define HW_VERSION_MTCDT_0_0 "MTCDT-0.0" // No GPS or WiFi Capability +#define HW_VERSION_MTCDT_0_1 "MTCDT-0.1" // Conduit refresh with GPS and WiFi possible +#define HW_VERSION_MTCDT_0_2 "MTCDT-0.2" // Atmel Serial and PCA9557 +#define HW_VERSION_MTCDTIP_0_0 "MTCDTIP-0.0" +#define HW_VERSION_MTCDTIP_0_1 "MTCDTIP-0.1" // Atmel Serial and PCA9557 +#define HW_VERSION_MTCDTIPHP_0_0 "MTCDTIPHP-0.0" // Also known as LoRa 2.1 +#define HW_VERSION_MTCAP_0_0 "MTCAP-0.0" +#define HW_VERSION_MTCAP_0_1 "MTCAP-0.1" +#define HW_VERSION_MTCAP_0_2 "MTCAP-0.2" // MTCAP 2 with POE +#define HW_VERSION_MTCAP_0_3 "MTCAP-0.3" // MTCDTIP2 with super-cap +#define HW_VERSION_MTHS_0_0 "MTHS-0.0" // Never released +#define HW_VERSION_MTHS_0_1 "MTHS-0.1" // NXP i.MX Platforms */ -#define HW_VERSION_MTCAP3_0_0 "MTCAP3-0.0" +#define HW_VERSION_MTCAP3_0_0 "MTCAP3-0.0" /* TI OMAP Platforms */ -#define PRODUCT_ID_MTCPM "MTCPM" +#define PRODUCT_ID_MTCPM "MTCPM" -#define HW_VERSION_MTCPM_DASH "MTCPM-" -#define HW_VERSION_MTCPM_0_0 "MTCPM-0.0" // Lora-16 CPU -#define HW_VERSION_MTCPM_0_1 "MTCPM-0.1" // MTCDT3AC CPU, GPS on CDC ACM driver -#define HW_VERSION_MTCPM_0_2 "MTCPM-0.2" +#define HW_VERSION_MTCPM_DASH "MTCPM-" +#define HW_VERSION_MTCPM_0_0 "MTCPM-0.0" // Lora-16 CPU +#define HW_VERSION_MTCPM_0_1 "MTCPM-0.1" // MTCDT3AC CPU, GPS on CDC ACM driver +#define HW_VERSION_MTCPM_0_2 "MTCPM-0.2" enum { - MTHWUNKNOWN, - 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, - MTRV1_0_2, - MTRV1_0_3, - MTRV1_0_4, - MTRE_0_0, - MTCDT_0_0, - MTCDT_0_1, - MTCDTIP_0_0, - MTCDTIPHP_0_0, - MTCAP_0_0, - MTCAP_0_1, - MTCAP_0_2, - MTCAP_0_3, - MTHS_0_0, - MTHS_0_1, - MTCPM_0_0, - MTCPM_0_1, - MTCPM_0_2, - MTCAP3_0_0, - MTCDT_0_2, - MTCDTIP_0_1, // MTCDTIP revision + MTHWUNKNOWN, + 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, + MTRV1_0_2, + MTRV1_0_3, + MTRV1_0_4, + MTRE_0_0, + MTCDT_0_0, + MTCDT_0_1, + MTCDTIP_0_0, + MTCDTIPHP_0_0, + MTCAP_0_0, + MTCAP_0_1, + MTCAP_0_2, + MTCAP_0_3, + MTHS_0_0, + MTHS_0_1, + MTCPM_0_0, + MTCPM_0_1, + MTCPM_0_2, + MTCAP3_0_0, + MTCDT_0_2, + MTCDTIP_0_1, // MTCDTIP revision }; /* Commented because it is not used. Сonflicts with <linux/leds.h> */ /*enum { - LED_OFF, - LED_ON, - LED_FLASHING, + LED_OFF, + LED_ON, + LED_FLASHING, };*/ enum { - RADIO_UNKNOWN, - RADIO_LEU1, // LE910-EUG - RADIO_LEU3, // LE910-EU1 - RADIO_LNA3, // LE910-NA1 + RADIO_UNKNOWN, + RADIO_LEU1, // LE910-EUG + RADIO_LEU3, // LE910-EU1 + RADIO_LNA3, // LE910-NA1 }; extern struct mutex mts_io_mutex; |