summaryrefslogtreecommitdiff
path: root/io-module/mts_io.c
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2017-09-01 18:02:57 -0500
committerJohn Klug <john.klug@multitech.com>2017-09-06 09:51:23 -0500
commitced6639aecb9f093e36ee0a6d676c3dde363ce59 (patch)
tree304dff48edd1041a282929bb00a973dd503f60e2 /io-module/mts_io.c
parenta447551d0421c5dab50a8493d52f3f2635c89661 (diff)
downloadmts-io-ced6639aecb9f093e36ee0a6d676c3dde363ce59.tar.gz
mts-io-ced6639aecb9f093e36ee0a6d676c3dde363ce59.tar.bz2
mts-io-ced6639aecb9f093e36ee0a6d676c3dde363ce59.zip
Remove radio-reset on MTCAP when radio not preesnt. Add MTCDTIP
Diffstat (limited to 'io-module/mts_io.c')
-rw-r--r--io-module/mts_io.c43
1 files changed, 37 insertions, 6 deletions
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);
}