summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2019-11-21 19:00:08 -0600
committerJohn Klug <john.klug@multitech.com>2019-11-21 19:00:08 -0600
commiteb3b20bf2faf4db51ca769039db3c952333b919a (patch)
tree56b738755cf966b7583eada736991efbacc813dd
parentf02df06f6314c0566070571e190d08c6ea270813 (diff)
downloadmts-io-eb3b20bf2faf4db51ca769039db3c952333b919a.tar.gz
mts-io-eb3b20bf2faf4db51ca769039db3c952333b919a.tar.bz2
mts-io-eb3b20bf2faf4db51ca769039db3c952333b919a.zip
Remove device-id and product-id from the top level directory in mts-io4.2.0
-rw-r--r--configure.ac2
-rw-r--r--io-module/machine/mtcpm.c (renamed from io-module/machine/mtcdt3.c)116
-rw-r--r--io-module/mts-io.c46
-rw-r--r--io-module/mts_capab.c35
-rw-r--r--io-module/mts_io.h1
-rw-r--r--io-module/mts_io_module.h8
6 files changed, 136 insertions, 72 deletions
diff --git a/configure.ac b/configure.ac
index 97499a3..ca6635a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([mts-io], [4.1.4])
+AC_INIT([mts-io], [4.2.0])
AC_CONFIG_SRCDIR([util/mts_util_lora2_reset.c])
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER([config.h])
diff --git a/io-module/machine/mtcdt3.c b/io-module/machine/mtcpm.c
index 373fc47..7052b51 100644
--- a/io-module/machine/mtcdt3.c
+++ b/io-module/machine/mtcpm.c
@@ -6,7 +6,7 @@
* occurrence of each pin, so there is only one
* pin label set for each gpio pin.
*/
-static struct gpio_pin gpio_pins_mtcdt3[] = {
+static struct gpio_pin gpio_pins_mtcpm[] = {
{
.name = "RADIO_RESET",
.pin = {
@@ -156,42 +156,36 @@ static struct gpio_pin gpio_pins_mtcdt3[] = {
{ },
};
-static DEVICE_ATTR_MTS(dev_attr_wifi_reset_mtcdt3, "wlan-enabled",
+static DEVICE_ATTR_MTS(dev_attr_wifi_reset_mtcpm, "wlan-enabled",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_bt_reset_mtcdt3, "bt-enabled",
+static DEVICE_ATTR_MTS(dev_attr_bt_reset_mtcpm, "bt-enabled",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_RO_MTS(dev_attr_wifi_bt_int_mtcdt3, "wifi-bt-int",
+static DEVICE_ATTR_RO_MTS(dev_attr_wifi_bt_int_mtcpm, "wifi-bt-int",
mts_attr_show_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_gnss_reset_mtcdt3, "gnss-reset",
+static DEVICE_ATTR_MTS(dev_attr_gnss_reset_mtcpm, "gnss-reset",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_usbhub_reset_mtcdt3, "usbhub-reset",
+static DEVICE_ATTR_MTS(dev_attr_usbhub_reset_mtcpm, "usbhub-reset",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_eth_reset_mtcdt3, "eth-reset",
+static DEVICE_ATTR_MTS(dev_attr_eth_reset_mtcpm, "eth-reset",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_gnss_int_mtcdt3, "gnss-int",
+static DEVICE_ATTR_MTS(dev_attr_gnss_int_mtcpm, "gnss-int",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_lora_reset_mtcdt3, "reset",
+static DEVICE_ATTR_MTS(dev_attr_lora_reset_mtcpm, "reset",
mts_attr_show_lora_gpio_pin, mts_attr_store_lora_gpio_pin);
-static DEVICE_ATTR_RO_MTS(dev_attr_lora_cdone_mtcdt3, "cdone",
+static DEVICE_ATTR_RO_MTS(dev_attr_lora_cdone_mtcpm, "cdone",
mts_attr_show_lora_gpio_pin);
-static DEVICE_ATTR_MTS(dev_attr_lora_creset_mtcdt3, "creset",
+static DEVICE_ATTR_MTS(dev_attr_lora_creset_mtcpm, "creset",
mts_attr_show_lora_gpio_pin, mts_attr_store_lora_gpio_pin);
-static DEVICE_ATTR_RO_MTS(dev_attr_lora_eui_mtcdt3, "eui",
+static DEVICE_ATTR_RO_MTS(dev_attr_lora_eui_mtcpm, "eui",
mts_attr_show_lora_product_info);
-static DEVICE_ATTR_RO_MTS(dev_attr_lora_product_id_mtcdt3, "product-id",
+static DEVICE_ATTR_RO_MTS(dev_attr_lora_product_id_mtcpm, "product-id",
mts_attr_show_lora_product_info);
-static DEVICE_ATTR_RO_MTS(dev_attr_lora_hw_version_mtcdt3, "hw-version",
+static DEVICE_ATTR_RO_MTS(dev_attr_lora_hw_version_mtcpm, "hw-version",
mts_attr_show_lora_product_info);
-static struct attribute *mtcdt3_platform_attributes[] = {
- &dev_attr_vendor_id.attr,
- &dev_attr_product_id.attr,
- &dev_attr_device_id.attr,
- &dev_attr_uuid.attr,
- &dev_attr_hw_version.attr,
+static struct attribute *mtcpm_platform_attributes[] = {
&dev_attr_imei.attr,
&dev_attr_eth_mac.attr,
- &dev_attr_has_radio.attr,
&dev_attr_reset.attr,
&dev_attr_reset_monitor.attr,
&dev_attr_reset_monitor_intervals.attr,
@@ -216,37 +210,83 @@ static struct attribute *mtcdt3_platform_attributes[] = {
&dev_attr_radio_reset_backoff_index.attr,
&dev_attr_radio_reset_backoff_seconds.attr,
- &dev_attr_wifi_reset_mtcdt3.attr,
- &dev_attr_bt_reset_mtcdt3.attr,
- &dev_attr_wifi_bt_int_mtcdt3.attr,
+ &dev_attr_wifi_reset_mtcpm.attr,
+ &dev_attr_bt_reset_mtcpm.attr,
+ &dev_attr_wifi_bt_int_mtcpm.attr,
- &dev_attr_gnss_reset_mtcdt3.attr,
- &dev_attr_gnss_int_mtcdt3.attr,
+ &dev_attr_gnss_reset_mtcpm.attr,
+ &dev_attr_gnss_int_mtcpm.attr,
NULL,
};
-static struct attribute_group mtcdt3_platform_attribute_group = {
- .attrs = mtcdt3_platform_attributes
+
+
+static struct attribute_group mtcpm_platform_attribute_group = {
+ .attrs = mtcpm_platform_attributes
};
static int
-is_radio_power_attr_mtcdt3(struct attribute *attr)
+is_radio_power_attr_mtcpm(struct attribute *attr)
{
return (attr == &dev_attr_radio_power.attr);
}
-static struct attribute *mtcdt3_lora_attributes[] = {
- &dev_attr_lora_eui_mtcdt3.attr,
- &dev_attr_lora_product_id_mtcdt3.attr,
- &dev_attr_lora_hw_version_mtcdt3.attr,
- &dev_attr_lora_reset_mtcdt3.attr,
- &dev_attr_lora_cdone_mtcdt3.attr,
- &dev_attr_lora_creset_mtcdt3.attr,
+static struct attribute *mtcpm_lora_attributes[] = {
+ &dev_attr_lora_eui_mtcpm.attr,
+ &dev_attr_lora_product_id_mtcpm.attr,
+ &dev_attr_lora_hw_version_mtcpm.attr,
+ &dev_attr_lora_reset_mtcpm.attr,
+ &dev_attr_lora_cdone_mtcpm.attr,
+ &dev_attr_lora_creset_mtcpm.attr,
NULL,
};
-static struct attribute_group mtcdt3_lora_attribute_group = {
- .attrs = mtcdt3_lora_attributes
+static struct attribute_group mtcpm_lora_attribute_group = {
+ .attrs = mtcpm_lora_attributes
};
+static struct attribute *mtcpm_cpu_attributes[] = {
+ &dev_attr_vendor_id.attr,
+ &dev_attr_product_id.attr,
+ &dev_attr_device_id.attr,
+ &dev_attr_uuid.attr,
+ &dev_attr_hw_version.attr,
+ &dev_attr_imei.attr,
+ NULL,
+};
+
+
+static struct attribute_group mtcpm_cpu_attribute_group = {
+ .attrs = mtcpm_cpu_attributes
+};
+
+static struct kobject *mts_cpu_kobject = NULL;
+
+static int mts_cpu_dir_create(uint8_t hw_version)
+{
+ if (hw_version != MTCPM_0_0)
+ return 0;
+
+ mts_cpu_kobject = kobject_create_and_add("cpu", &mts_io_platform_device->dev.kobj);
+ if (!mts_cpu_kobject) {
+ log_error("kobject_create_and_add for cpu directory failed");
+ return -ENOMEM;
+ }
+
+ if (sysfs_create_group(mts_cpu_kobject, &mtcpm_cpu_attribute_group)) {
+ log_error("sysfs_create_group failed to create cpu group");
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
+static void mts_cpu_dir_delete(void)
+{
+ if (mts_cpu_kobject) {
+ kobject_put(mts_cpu_kobject);
+ mts_cpu_kobject = NULL;
+ }
+}
+
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();
diff --git a/io-module/mts_capab.c b/io-module/mts_capab.c
index 17c505a..38e8442 100644
--- a/io-module/mts_capab.c
+++ b/io-module/mts_capab.c
@@ -68,21 +68,34 @@ static struct attribute_group mts_capa_attr_group = {
};
static struct kobject *mts_capa_kobject = NULL;
+EXPORT_SYMBOL(mts_capa_kobject);
-static int mts_capab_dir_create(void)
+static int mts_capab_dir_create(uint8_t hw_version)
{
- mts_capa_kobject = kobject_create_and_add("capability", &mts_io_platform_device->dev.kobj);
- if (!mts_capa_kobject) {
- log_error("kobject_create_and_add for capability directory failed");
- return -ENOMEM;
- }
+ int i,j;
+
+ if (hw_version == MTCPM_0_0) {
+ for (i=0; mts_capa_attributes[i]; i++) {
+ /* Remove capa_lora for MTCPM mts-io driver */
+ if (mts_capa_attributes[i] == &capa_attr_lora.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) {
+ log_error("kobject_create_and_add for capability directory failed");
+ return -ENOMEM;
+ }
- if (sysfs_create_group(mts_capa_kobject, &mts_capa_attr_group)) {
- log_error("sysfs_create_group failed to create capability group");
- return -ENOMEM;
- }
+ if (sysfs_create_group(mts_capa_kobject, &mts_capa_attr_group)) {
+ log_error("sysfs_create_group failed to create capability group");
+ return -ENOMEM;
+ }
- return 0;
+ return 0;
}
static void mts_capab_dir_delete(void)
diff --git a/io-module/mts_io.h b/io-module/mts_io.h
index 5e83879..12647fb 100644
--- a/io-module/mts_io.h
+++ b/io-module/mts_io.h
@@ -49,6 +49,7 @@ struct gpio_pin {
uint8_t capability;
};
+extern int mts_has_radio(const char *product_id, size_t len);
#endif /* __MTS_IO_H */
diff --git a/io-module/mts_io_module.h b/io-module/mts_io_module.h
index e946e6e..4bcf31d 100644
--- a/io-module/mts_io_module.h
+++ b/io-module/mts_io_module.h
@@ -5,7 +5,7 @@
* MTAC cards.
*/
-#define DRIVER_VERSION "v4.1.10"
+#define DRIVER_VERSION "v4.2.0"
#define DRIVER_AUTHOR "Multitech Systems"
#define DRIVER_DESC "MTS-IO Controller"
#define DRIVER_NAME "mts-io"
@@ -42,9 +42,10 @@
#define HW_VERSION_MTHS_0_1 "MTHS-0.1"
/* TI OMAP Platforms */
-#define PRODUCT_ID_MTCDT3 "MTCDT3"
+#define PRODUCT_ID_MTCPM "MTCPM"
-#define HW_VERSION_MTCDT3_0_0 "MTCDT3-0.0"
+#define HW_VERSION_MTCPM_DASH "MTCPM-"
+#define HW_VERSION_MTCPM_0_0 "MTCPM-0.0"
enum {
MTCDP_E1_DK_0_0,
@@ -63,6 +64,7 @@ enum {
MTCAP_0_1,
MTHS_0_0,
MTHS_0_1,
+ MTCPM_0_0,
};
enum {