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.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/io-module/mts-io.c b/io-module/mts-io.c
index ef28a7c..63d695b 100644
--- a/io-module/mts-io.c
+++ b/io-module/mts-io.c
@@ -156,8 +156,8 @@ bool sent_extra_long = false;
* by a numeric, we have no modem.
* All other cases, we have a modem.
*/
-static int
-has_radio(const char *product_id, size_t len)
+int
+mts_has_radio(const char *product_id, size_t len)
{
char *p;
if (!product_id || ! *product_id)
@@ -194,6 +194,7 @@ has_radio(const char *product_id, size_t len)
log_debug("Undefined product-id - has modem");
return 1; /* Product id invalid or empty, so instantiate a radio anyway */
}
+EXPORT_SYMBOL(mts_has_radio);
/* active-low socket modem reset */
static ssize_t mts_attr_store_radio_reset(struct device *dev,
@@ -519,7 +520,7 @@ static ssize_t mts_attr_show_product_info(struct device *dev,
value = sprintf(buf, "%.32s\n", id_eeprom.product_id);
} else if (strcmp(attr->attr.name, "has-radio") == 0) {
value = sprintf(buf, "%1d\n",
- has_radio(id_eeprom.product_id,sizeof id_eeprom.product_id));
+ mts_has_radio(id_eeprom.product_id,sizeof id_eeprom.product_id));
} 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) {
@@ -612,7 +613,7 @@ static int get_radio_model_from_product_id(void) {
#include "machine/mtcap.c"
#include "machine/mtr.c"
#include "machine/mths.c"
-#include "machine/mtcdt3.c"
+#include "machine/mtcpm.c"
/* include capabilities sub-directory support */
#include "mts_capab.c"
@@ -641,15 +642,19 @@ mts_id_eeprom_load(void)
log_info("Platform EEPROM contents loaded");
} else {
log_error("Invalid platform EEPROM length (%d)", fw->size);
+ return -EINVAL;
}
-
release_firmware(fw);
} else {
log_error("Unable to load EEPROM contents (%d)", ret);
+ return -ENODEV;
}
- noradio = ! has_radio(id_eeprom.product_id,sizeof id_eeprom.product_id);
- log_debug("mts_id_eeprom: noradio=%d",noradio);
+ // If we are an MTCPM, the base board sets the radio existance.
+ if (strncmp(id_eeprom.hw_version,HW_VERSION_MTCPM_DASH,sizeof HW_VERSION_MTCPM_DASH) != 0) {
+ noradio = ! mts_has_radio(id_eeprom.product_id,sizeof id_eeprom.product_id);
+ log_debug("mts_id_eeprom: noradio=%d",noradio);
+ }
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) ||
@@ -823,16 +828,12 @@ mts_id_eeprom_load(void)
}
set_buttons(default_buttons);
log_info("detected board %s", tmp);
- } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTCDT3_0_0, strlen(HW_VERSION_MTCDT3_0_0)) == 0) {
- /* Capabilities */
- if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA)) {
- attr_group_lora = &mtcdt3_lora_attribute_group;
- }
- attr_group = &mtcdt3_platform_attribute_group;
- gpio_pins = gpio_pins_mtcdt3;
+ } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTCPM_0_0, strlen(HW_VERSION_MTCPM_0_0)) == 0) {
+ attr_group = &mtcpm_platform_attribute_group;
+ gpio_pins = gpio_pins_mtcpm;
set_buttons(default_buttons);
- mts_hw_version = HW_VERSION_MTCDT3_0_0;
- log_info("detected board %s", HW_VERSION_MTCDT3_0_0);
+ mts_hw_version = MTCPM_0_0;
+ log_info("detected board %s", HW_VERSION_MTCPM_0_0);
} else {
if(noradio) {
struct attribute **ap = mtcdt_platform_attribute_group.attrs;
@@ -877,8 +878,10 @@ 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");
- log_info("capa-lora: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_LORA) ? "yes" : "no");
- log_info("capa-battery: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_BATTERY) ? "yes" : "no");
+ if (!(mts_hw_version != 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-battery: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_BATTERY) ? "yes" : "no");
+
if (DEVICE_CAPA(id_eeprom.capa, CAPA_BLUETOOTH)) {
log_info("mac-bluetooth: %02X:%02X:%02X:%02X:%02X:%02X",
@@ -935,6 +938,7 @@ static void cleanup(void)
}
mts_capab_dir_delete();
+ mts_cpu_dir_delete();
}
static int __init mts_io_init(void)
@@ -980,7 +984,7 @@ static int __init mts_io_init(void)
mts_load_lora_port();
}
- ret = mts_capab_dir_create();
+ ret = mts_capab_dir_create(mts_hw_version);
if (ret) {
cleanup();
return ret;
@@ -999,6 +1003,10 @@ static int __init mts_io_init(void)
log_debug("could not request pin %s (%d) but it could have already been requested under a different pin name", pin->name, ret);
}
}
+
+ // Create CPU directory if approprate (only MTCDT3 for now)
+ ret = mts_cpu_dir_create(mts_hw_version);
+
// start general buttons processing
init_buttons();