summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Pientsov <andrii.pientsov@globallogic.com>2022-01-21 10:00:26 +0200
committerJohn Klug <john.klug@multitech.com>2022-02-16 16:12:24 -0600
commitd9ce6b6e66f44a844307719c6a67852b186b27a4 (patch)
tree7611a8f279775202f7fbdb2339cd1b901c4e668c
parent1e8f15e4a6d38678f289b9557d9c665afb70df3f (diff)
downloadmts-io-d9ce6b6e66f44a844307719c6a67852b186b27a4.tar.gz
mts-io-d9ce6b6e66f44a844307719c6a67852b186b27a4.tar.bz2
mts-io-d9ce6b6e66f44a844307719c6a67852b186b27a4.zip
MTX-4356 mPower R.6.0.x: MTCAP3 - GP-1352, PP-477 : need --capa-lora-lbt for MTCAP3 in mts-id-eeprom
-rw-r--r--io-module/machine/mtcap3.c7
-rw-r--r--io-module/mts-io.c84
-rw-r--r--io-module/mts_capab.c12
-rw-r--r--io-module/mts_eeprom.h1
4 files changed, 78 insertions, 26 deletions
diff --git a/io-module/machine/mtcap3.c b/io-module/machine/mtcap3.c
index 8f6668f..5b2871a 100644
--- a/io-module/machine/mtcap3.c
+++ b/io-module/machine/mtcap3.c
@@ -80,7 +80,7 @@ static struct gpio_pin gpio_pins_mtcap3_0_0[] = {
.flags = GPIOF_OUT_INIT_LOW,
.label = "lora/lbt-reset",
},
- .capability = CAPA_LORA,
+ .capability = CAPA_LORA_LBT,
.active_low = 1,
},
/* LEDs */
@@ -466,10 +466,13 @@ static struct attribute *mtcap3_0_0_lora_attributes[] = {
&dev_attr_lora_product_id_mtcap3.attr,
&dev_attr_lora_hw_version_mtcap3.attr,
&dev_attr_lora_reset_mtcap3.attr,
- &dev_attr_lora_lbt_reset_mtcap3.attr,
NULL,
};
static struct attribute_group mtcap3_0_0_lora_attribute_group = {
.attrs = mtcap3_0_0_lora_attributes
};
+
+static struct attribute *mtcap3_0_0_lora_lbt_attributes[] = {
+ &dev_attr_lora_lbt_reset_mtcap3.attr,
+};
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();
}
diff --git a/io-module/mts_capab.c b/io-module/mts_capab.c
index f22c70b..08bcff1 100644
--- a/io-module/mts_capab.c
+++ b/io-module/mts_capab.c
@@ -27,6 +27,7 @@ static struct capab_map_s capabilities_map[] = {
{ CAPA_LORA, "lora"},
{ CAPA_BATTERY, "battery"},
{ CAPA_SUPERCAP, "supercap"},
+ { CAPA_LORA_LBT, "lora-lbt"},
};
static ssize_t capab_show_value(struct device *dev, struct device_attribute *at, char *buf) {
@@ -52,6 +53,7 @@ static DEVICE_ATTR_RO_MTS(capa_attr_wifi, "wifi", capab_show_value);
static DEVICE_ATTR_RO_MTS(capa_attr_lora, "lora", capab_show_value);
static DEVICE_ATTR_RO_MTS(capa_attr_battery, "battery", capab_show_value);
static DEVICE_ATTR_RO_MTS(capa_attr_supercap, "supercap", capab_show_value);
+static DEVICE_ATTR_RO_MTS(capa_attr_lora_lbt, "lora-lbt", capab_show_value);
static struct attribute *mts_capa_attributes[] = {
&capa_attr_gps.attr,
@@ -63,6 +65,7 @@ static struct attribute *mts_capa_attributes[] = {
&capa_attr_lora.attr,
&capa_attr_battery.attr,
&capa_attr_supercap.attr,
+ &capa_attr_lora_lbt.attr,
NULL,
};
@@ -86,6 +89,15 @@ static int mts_capab_dir_create(uint8_t hw_version)
break;
}
}
+
+ for (i=0; mts_capa_attributes[i]; i++) {
+ /* Remove capa_lora_lbt for MTCPM mts-io driver */
+ if (mts_capa_attributes[i] == &capa_attr_lora_lbt.attr) {
+ for(j=i; mts_capa_attributes[j]; j++)
+ mts_capa_attributes[j] = mts_capa_attributes[j+1];
+ break;
+ }
+ }
}
mts_capa_kobject = kobject_create_and_add("capability", &mts_io_platform_device->dev.kobj);
if (!mts_capa_kobject) {
diff --git a/io-module/mts_eeprom.h b/io-module/mts_eeprom.h
index 2a86ebd..4da1f44 100644
--- a/io-module/mts_eeprom.h
+++ b/io-module/mts_eeprom.h
@@ -78,4 +78,5 @@ do { \
#define CAPA_BATTERY DEVICE_CAPA_VALUE(1, 4) // 1st battery type
#define CAPA_SUPERCAP DEVICE_CAPA_VALUE(1, 5)
#define CAPA_CELLULAR DEVICE_CAPA_VALUE(1,2) // Only valid if eeprom_layout_version > 0
+#define CAPA_LORA_LBT DEVICE_CAPA_VALUE(1, 1) // on-board lora lbt
#endif /* __MTS_EEPROM_H */