diff options
Diffstat (limited to 'io-module/mts-io.c')
-rw-r--r-- | io-module/mts-io.c | 84 |
1 files changed, 60 insertions, 24 deletions
diff --git a/io-module/mts-io.c b/io-module/mts-io.c index 79c579f..f4cd136 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -709,6 +709,7 @@ static int get_radio_model_from_product_id(void) { #include "mts_capab.c" struct attribute **freelater = NULL; // Storage to free when driver is unloaded. +struct attribute **lora_freelater = NULL; // Lora storage to free when driver is unloaded. static int mts_id_eeprom_load(void) @@ -720,10 +721,15 @@ mts_id_eeprom_load(void) int current_blength; // Current length in bytes of attribute array int current_count; // Number of items in array struct attribute **all_attrs = NULL; + int attr_lora_blength; // Byte length of base attribute lora array + int current_lora_blength; // Current length in bytes of attribute lora array + int current_lora_count; // Number of items in lora array + struct attribute **all_lora_attrs = NULL; char *tmp; int noradio = 0; // MTCPM-0.0 does not trim off radio-reset, etc. int has_cellular_capaflag = 0; int need_append; + int need_lora_append; int ret; const struct firmware* fw = NULL; @@ -835,29 +841,51 @@ mts_id_eeprom_load(void) attr_group_lora = &mtcap_0_0_lora_attribute_group; } log_info("detected board %s", tmp); - } else if ((tmp=HW_VERSION_MTCAP3_0_0),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) { - current_blength = attr_blength = sizeof mtcap3_0_0_platform_attributes; - current_blength -= sizeof(struct attribute *); /* Length without terminating NULL */ - - if(noradio) { - struct attribute **ap = mtcap3_0_0_platform_attribute_group.attrs; - while(1) { - if(ap[j] == NULL) { - log_info("Did not find radio reset attribute. Possible driver fault."); - break; - } - j++; - if (is_radio_power_attr_mtcap3(ap[j])) { - log_info("Pruning radio feature from mts-io",j); - ap[j] = NULL; - current_blength = j * sizeof (ap[j]); /* Size without NULL */ - attr_blength += sizeof (ap[j]); /* Size of attr array with NULL */ - break; - } - } - } + } else if ((tmp=HW_VERSION_MTCAP3_0_0),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) { + current_blength = attr_blength = sizeof mtcap3_0_0_platform_attributes; + current_blength -= sizeof(struct attribute *); /* Length without terminating NULL */ + + if (noradio) { + struct attribute **ap = mtcap3_0_0_platform_attribute_group.attrs; + while(1) { + if (ap[j] == NULL) { + log_info("Did not find radio reset attribute. Possible driver fault."); + break; + } + j++; + if (is_radio_power_attr_mtcap3(ap[j])) { + log_info("Pruning radio feature from mts-io",j); + ap[j] = NULL; + current_blength = j * sizeof (ap[j]); /* Size without NULL */ + attr_blength += sizeof (ap[j]); /* Size of attr array with NULL */ + break; + } + } + } + + if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA)) { + need_lora_append = 0; + current_lora_blength = attr_lora_blength = sizeof mtcap3_0_0_lora_attributes; + current_lora_blength -= sizeof(struct attribute *); /* Length without terminating NULL */ + + if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA_LBT)) { + attr_lora_blength += sizeof mtcap3_0_0_lora_lbt_attributes; + need_lora_append = 1; + } + + if (need_lora_append) { + lora_freelater = all_lora_attrs = kmalloc(attr_lora_blength, GFP_KERNEL); + current_lora_count = current_lora_blength/(sizeof (struct attribute *)); + memcpy(all_lora_attrs, mtcap3_0_0_lora_attributes, current_lora_blength); + if (DEVICE_CAPA (id_eeprom.capa, CAPA_LORA_LBT)) { + log_info("Adding lora-lbt to mts-io driver"); + memcpy(all_lora_attrs + current_lora_count, mtcap3_0_0_lora_lbt_attributes, sizeof mtcap3_0_0_lora_lbt_attributes); + current_lora_count += sizeof mtcap3_0_0_lora_lbt_attributes / (sizeof (struct attribute *)); + } - if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA)) { + all_lora_attrs[current_lora_count] = (struct attribute *)NULL; + mtcap3_0_0_lora_attribute_group.attrs = all_lora_attrs; + } attr_group_lora = &mtcap3_0_0_lora_attribute_group; } @@ -865,7 +893,7 @@ mts_id_eeprom_load(void) gpio_pins = gpio_pins_mtcap3_0_0; set_buttons(default_buttons); mts_hw_version = MTCAP3_0_0; - log_info("detected board %s", HW_VERSION_MTCAP3_0_0); + log_info("detected board %s", HW_VERSION_MTCAP3_0_0); } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTRE, strlen(HW_VERSION_MTRE)) == 0) { attr_group = &mtre_0_0_platform_attribute_group; gpio_pins = gpio_pins_mtre_0_0; @@ -1226,8 +1254,11 @@ mts_id_eeprom_load(void) log_info("capa-adc: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_ADC) ? "yes" : "no"); log_info("capa-wifi: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI) ? "yes" : "no"); log_info("capa-bluetooth: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_BLUETOOTH) ? "yes" : "no"); - if (!(mts_hw_version != MTCPM_0_0)) /* Moved to mtcdt3b driver in MTCDT3 baseboard hardware */ + if (!(mts_hw_version != MTCPM_0_0)) { + /* Moved to mtcdt3b driver in MTCDT3 baseboard hardware */ log_info("capa-lora: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_LORA) ? "yes" : "no"); + log_info("capa-lora-lbt: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_LORA_LBT) ? "yes" : "no"); + } log_info("capa-battery: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_BATTERY) ? "yes" : "no"); log_info("capa-supercap: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_SUPERCAP) ? "yes" : "no"); if(has_cellular_capaflag) @@ -1291,6 +1322,11 @@ static void cleanup(void) freelater = NULL; } + if(lora_freelater) { + kfree(lora_freelater); + lora_freelater = NULL; + } + mts_capab_dir_delete(); mts_cpu_dir_delete(); } |