summaryrefslogtreecommitdiff
path: root/io-module/mts_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io-module/mts_io.c')
-rw-r--r--io-module/mts_io.c99
1 files changed, 93 insertions, 6 deletions
diff --git a/io-module/mts_io.c b/io-module/mts_io.c
index ebb1b22..fba83de 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.16"
+#define DRIVER_VERSION "v2.0.0"
#define DRIVER_AUTHOR "James Maki <jmaki@multitech.com>"
#define DRIVER_DESC "MTS-IO Controller"
#define DRIVER_NAME "mts-io"
@@ -817,7 +817,7 @@ struct attribute *freelater = NULL; // Storage to free when driver is unloaded.
static int
mts_id_eeprom_load(void)
{
- int i;
+ int i, j = 0;
char buf[64] = {0};
char* ptr;
int attr_blength; // Byte length of base attribute array
@@ -836,7 +836,6 @@ mts_id_eeprom_load(void)
return -EIO;
} else if (((tmp=HW_VERSION_MTCAP_0_0),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) ||
((tmp=HW_VERSION_MTCAP_0_1),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 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] == '-') &&
@@ -883,23 +882,46 @@ mts_id_eeprom_load(void)
log_info("detected board %s", HW_VERSION_MTRV1_0_1);
} else if (((tmp=HW_VERSION_MTCDT_0_1),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) ||
((tmp=HW_VERSION_MTCDTIP_0_0),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0)) {
- attr_blength = sizeof mtcdt_0_1_platform_attributes;
+ current_blength = attr_blength = sizeof mtcdt_0_1_platform_attributes;
+ current_blength -= sizeof(struct attribute *); /* Length without terminating NULL */
+
+ /* See if we have no radio, and if so, prune out the stuff that follows */
+ if((strncmp(id_eeprom.product_id, PRODUCT_ID_MTCDT, sizeof PRODUCT_ID_MTCDT - 1) == 0) &&
+ (id_eeprom.product_id[sizeof PRODUCT_ID_MTCDT-1] == '-') &&
+ isdigit(id_eeprom.product_id[sizeof PRODUCT_ID_MTCDT])) {
+ struct attribute **ap = mtcdt_0_1_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_mtcdt(ap[j])) {
+ log_info("Pruning radio feature from mts-io",j);
+ ap[j] = NULL;
+ current_blength = attr_blength = j * sizeof (ap[j]);
+ break;
+ }
+ }
+ }
+
if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI)) {
attr_blength += sizeof mtcdt_0_1_wifi_bt_attributes;
}
if(DEVICE_CAPA(id_eeprom.capa, CAPA_GPS)) {
attr_blength += sizeof mtcdt_0_1_gnss_attributes;
}
- if (attr_blength != sizeof mtcdt_0_1_platform_attributes) {
+ if (current_blength+(sizeof(struct attribute *)) != attr_blength) {
freelater = all_attrs = kmalloc(attr_blength,GFP_KERNEL);
- current_blength = sizeof mtcdt_0_1_platform_attributes - sizeof (struct attribute *);
current_count = current_blength/(sizeof (struct attribute *));
memcpy(all_attrs,mtcdt_0_1_platform_attributes,current_blength);
if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI)) {
+ log_info("Adding WiFi/BT to mts-io driver");
memcpy(all_attrs + current_count,mtcdt_0_1_wifi_bt_attributes,sizeof mtcdt_0_1_wifi_bt_attributes);
current_count += sizeof mtcdt_0_1_wifi_bt_attributes / (sizeof (struct attribute *));
}
if(DEVICE_CAPA(id_eeprom.capa, CAPA_GPS)) {
+ log_info("Adding GPS to mts-io driver");
attr_blength += sizeof mtcdt_0_1_gnss_attributes;
memcpy(all_attrs + current_count,mtcdt_0_1_gnss_attributes,sizeof mtcdt_0_1_gnss_attributes);
current_count += sizeof mtcdt_0_1_gnss_attributes / (sizeof (struct attribute *));
@@ -911,7 +933,72 @@ mts_id_eeprom_load(void)
attr_group = &mtcdt_0_1_platform_attribute_group;
gpio_pins = gpio_pins_mtcdt_0_1;
log_info("detected board %s", tmp);
+ } else if ((tmp=HW_VERSION_MTCDTIPHP_0_0),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) {
+ current_blength = attr_blength = sizeof mtcdt_0_1_platform_attributes;
+ current_blength -= sizeof(struct attribute *); /* Length without terminating NULL */
+
+ /* See if we have no radio, and if so, prune out the stuff that follows */
+ if((strncmp(id_eeprom.product_id, PRODUCT_ID_MTCDTIPHP, sizeof PRODUCT_ID_MTCDTIPHP - 1) == 0) &&
+ (id_eeprom.product_id[sizeof PRODUCT_ID_MTCDTIPHP-1] == '-') &&
+ isdigit(id_eeprom.product_id[sizeof PRODUCT_ID_MTCDTIPHP])) {
+ struct attribute **ap = mtcdt_0_1_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_mtcdt(ap[j])) {
+ log_info("Pruning radio feature from mts-io",j);
+ ap[j] = NULL;
+ current_blength = attr_blength = j * sizeof (ap[j]);
+ break;
+ }
+ }
+ }
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI)) {
+ attr_blength += sizeof mtcdt_0_1_wifi_bt_attributes;
+ }
+ if (current_blength+(sizeof(struct attribute *)) != attr_blength) {
+ freelater = all_attrs = kmalloc(attr_blength,GFP_KERNEL);
+ current_count = current_blength/(sizeof (struct attribute *));
+ memcpy(all_attrs,mtcdt_0_1_platform_attributes,current_blength);
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI)) {
+ log_info("Adding WiFi/BT to mts-io driver");
+ memcpy(all_attrs + current_count,mtcdt_0_1_wifi_bt_attributes,sizeof mtcdt_0_1_wifi_bt_attributes);
+ current_count += sizeof mtcdt_0_1_wifi_bt_attributes / (sizeof (struct attribute *));
+ }
+ /* MTCDTIPHP does not have GPS reset/interrupt tied to the CPU
+ * so do not instantiate the GPS attributes */
+ all_attrs[current_count] = (struct attribute *)NULL;
+ mtcdt_0_1_platform_attribute_group.attrs = all_attrs;
+ }
+
+ attr_group = &mtcdt_0_1_platform_attribute_group;
+ gpio_pins = gpio_pins_mtcdt_0_1;
+ if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA)) {
+ attr_group_lora = &mtcdtiphp_0_0_lora_attribute_group;
+ }
+ log_info("detected board %s", tmp);
} else {
+ if((strncmp(id_eeprom.product_id, PRODUCT_ID_MTCDT, sizeof PRODUCT_ID_MTCDT - 1) == 0) &&
+ (id_eeprom.product_id[sizeof PRODUCT_ID_MTCDT-1] == '-') &&
+ isdigit(id_eeprom.product_id[sizeof PRODUCT_ID_MTCDT])) {
+ struct attribute **ap = mtcdt_0_1_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_mtcdt(ap[j])) {
+ log_info("Pruning radio feature from mts-io",j);
+ ap[j] = NULL;
+ break;
+ }
+ }
+ }
+
attr_group = &mtcdt_platform_attribute_group;
gpio_pins = gpio_pins_mtcdt_0_0;
mts_hw_version = MTCDT_0_0;