summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Nicholson <mike.nicholson@multitech.com>2020-08-28 16:36:45 -0500
committerMike Nicholson <mike.nicholson@multitech.com>2020-08-28 16:36:45 -0500
commit49ca346b1165e6def3e683802cfbb769d23c559a (patch)
treec0e99653ff017df25b27b905a1996297fa0eee1b
parentee7303faf58c120db4819dfa69b4597346115de4 (diff)
downloadmts-io-49ca346b1165e6def3e683802cfbb769d23c559a.tar.gz
mts-io-49ca346b1165e6def3e683802cfbb769d23c559a.tar.bz2
mts-io-49ca346b1165e6def3e683802cfbb769d23c559a.zip
MTCAP2, MTCDTIP2 support, initial revision4.3.4
-rw-r--r--io-module/machine/mtcap.c79
-rw-r--r--io-module/mts-io.c39
-rw-r--r--io-module/mts_capab.c3
-rw-r--r--io-module/mts_eeprom.h1
-rw-r--r--io-module/mts_io_module.h1
5 files changed, 117 insertions, 6 deletions
diff --git a/io-module/machine/mtcap.c b/io-module/machine/mtcap.c
index bd08d5a..f701e93 100644
--- a/io-module/machine/mtcap.c
+++ b/io-module/machine/mtcap.c
@@ -70,8 +70,53 @@ static struct gpio_pin gpio_pins_mtcap_0_0[] = {
},
.capability = CAPA_LORA,
},
-
-
+ {
+ .name = "GNSS_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PD15,
+ .flags = GPIOF_OUT_INIT_LOW,
+ .label = "gnss-reset",
+ },
+ .capability = CAPA_GPS,
+ },
+ {
+ .name = "GNSS_INT",
+ .pin = {
+ .gpio = AT91_PIN_PD19,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "gnss-int",
+ },
+ .capability = CAPA_GPS,
+ },
+ {
+ .name = "ALLOW_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC26,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "allow-reset",
+ },
+ .active_low = 1,
+ .capability = CAPA_SUPERCAP,
+ },
+ {
+ .name = "POWER_FAIL",
+ .pin = {
+ .gpio = AT91_PIN_PC14,
+ .flags = GPIOF_IN,
+ .label = "power-fail",
+ },
+ .active_low = 1,
+ .capability = CAPA_SUPERCAP,
+ },
+ {
+ .name = "SUPERCAP_FULL",
+ .pin = {
+ .gpio = AT91_PIN_PC27,
+ .flags = GPIOF_IN,
+ .label = "supercap-full",
+ },
+ .capability = CAPA_SUPERCAP,
+ },
/* LEDs */
{
.name = "STATUS_LED", // DEV_LED_GN
@@ -116,6 +161,7 @@ static struct gpio_pin gpio_pins_mtcap_0_0[] = {
.flags = GPIOF_OUT_INIT_HIGH,
.label = "wlan-en",
},
+ .capability = CAPA_WIFI,
},
{
.name = "WLAN_RST",
@@ -124,6 +170,7 @@ static struct gpio_pin gpio_pins_mtcap_0_0[] = {
.flags = GPIOF_OUT_INIT_HIGH,
.label = "wlan-rst",
},
+ .capability = CAPA_WIFI,
},
{ },
};
@@ -461,9 +508,6 @@ static struct attribute *mtcap_0_0_platform_attributes[] = {
&dev_attr_led_lora_gpio_mtcap.attr,
&dev_attr_led_wifi_gpio_mtcap.attr,
- &dev_attr_wlan_en_gpio_mtcap.attr,
- &dev_attr_wlan_rst_gpio_mtcap.attr,
-
/* Set to NULL if no radio -- should be 1st radio attribute */
&dev_attr_radio_power_mtcap.attr,
&dev_attr_radio_reset_mtcap.attr,
@@ -534,3 +578,28 @@ static struct attribute *mtcdtiphp_0_0_lora_attributes[] = {
static struct attribute_group mtcdtiphp_0_0_lora_attribute_group = {
.attrs = mtcdtiphp_0_0_lora_attributes
};
+
+static struct attribute *mtcap_0_3_gnss_attributes[] = {
+ &dev_attr_gnss_reset.attr,
+ &dev_attr_gnss_int.attr,
+};
+
+static DEVICE_ATTR_MTS(dev_attr_supercap_allow_reset_mtcap, "allow-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+
+static DEVICE_ATTR_RO_MTS(dev_attr_supercap_power_fail_mtcap, "power-fail",
+ mts_attr_show_gpio_pin);
+
+static DEVICE_ATTR_RO_MTS(dev_attr_supercap_supercap_full_mtcap, "supercap-full",
+ mts_attr_show_gpio_pin);
+
+static struct attribute *mtcap_0_3_supercap_attributes[] = {
+ &dev_attr_supercap_allow_reset_mtcap.attr,
+ &dev_attr_supercap_power_fail_mtcap.attr,
+ &dev_attr_supercap_supercap_full_mtcap.attr,
+};
+
+static struct attribute *mtcap_0_0_wifi_attributes[] = {
+ &dev_attr_wlan_en_gpio_mtcap.attr,
+ &dev_attr_wlan_rst_gpio_mtcap.attr,
+};
diff --git a/io-module/mts-io.c b/io-module/mts-io.c
index 5897da7..0477f2e 100644
--- a/io-module/mts-io.c
+++ b/io-module/mts-io.c
@@ -664,7 +664,10 @@ mts_id_eeprom_load(void)
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) ||
- ((tmp=HW_VERSION_MTCAP_0_2),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0)) {
+ ((tmp=HW_VERSION_MTCAP_0_2),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) ||
+ ((tmp=HW_VERSION_MTCAP_0_3),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0)) {
+ current_blength = attr_blength = sizeof mtcap_0_0_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(noradio) {
struct attribute **ap = mtcap_0_0_platform_attribute_group.attrs;
@@ -677,10 +680,43 @@ mts_id_eeprom_load(void)
if (is_radio_power_attr_mtcap(ap[j])) {
log_info("Pruning radio feature from mts-io",j);
ap[j] = NULL;
+ current_blength = attr_blength = j * sizeof (ap[j]);
+ /* account for removed attributes in table length */
break;
}
}
}
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_GPS)) {
+ attr_blength += sizeof mtcap_0_3_gnss_attributes;
+ }
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_SUPERCAP)) {
+ attr_blength += sizeof mtcap_0_3_supercap_attributes;
+ }
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI)) {
+ attr_blength += sizeof mtcap_0_0_wifi_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,mtcap_0_0_platform_attributes,current_blength);
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_GPS)) {
+ log_info("Adding GPS to mts-io driver");
+ memcpy(all_attrs + current_count,mtcap_0_3_gnss_attributes,sizeof mtcap_0_3_gnss_attributes);
+ current_count += sizeof mtcap_0_3_gnss_attributes / (sizeof (struct attribute *));
+ }
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_SUPERCAP)) {
+ log_info("Adding supercap to mts-io driver");
+ memcpy(all_attrs + current_count,mtcap_0_3_supercap_attributes,sizeof mtcap_0_3_supercap_attributes);
+ current_count += sizeof mtcap_0_3_supercap_attributes / (sizeof (struct attribute *));
+ }
+ if(DEVICE_CAPA(id_eeprom.capa, CAPA_WIFI)) {
+ log_info("Adding Wi-Fi to mts-io driver");
+ memcpy(all_attrs + current_count,mtcap_0_0_wifi_attributes,sizeof mtcap_0_0_wifi_attributes);
+ current_count += sizeof mtcap_0_0_wifi_attributes / (sizeof (struct attribute *));
+ }
+ all_attrs[current_count] = (struct attribute *)NULL;
+ mtcap_0_0_platform_attribute_group.attrs = all_attrs;
+ }
attr_group = &mtcap_0_0_platform_attribute_group;
gpio_pins = gpio_pins_mtcap_0_0;
set_buttons(default_buttons);
@@ -913,6 +949,7 @@ mts_id_eeprom_load(void)
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");
+ log_info("capa-supercap: %s", DEVICE_CAPA(id_eeprom.capa, CAPA_SUPERCAP) ? "yes" : "no");
if (DEVICE_CAPA(id_eeprom.capa, CAPA_BLUETOOTH)) {
diff --git a/io-module/mts_capab.c b/io-module/mts_capab.c
index 38e8442..f22c70b 100644
--- a/io-module/mts_capab.c
+++ b/io-module/mts_capab.c
@@ -26,6 +26,7 @@ static struct capab_map_s capabilities_map[] = {
{ CAPA_WIFI, "wifi"},
{ CAPA_LORA, "lora"},
{ CAPA_BATTERY, "battery"},
+ { CAPA_SUPERCAP, "supercap"},
};
static ssize_t capab_show_value(struct device *dev, struct device_attribute *at, char *buf) {
@@ -50,6 +51,7 @@ static DEVICE_ATTR_RO_MTS(capa_attr_bt, "bluetooth", capab_show_value);
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 struct attribute *mts_capa_attributes[] = {
&capa_attr_gps.attr,
@@ -60,6 +62,7 @@ static struct attribute *mts_capa_attributes[] = {
&capa_attr_wifi.attr,
&capa_attr_lora.attr,
&capa_attr_battery.attr,
+ &capa_attr_supercap.attr,
NULL,
};
diff --git a/io-module/mts_eeprom.h b/io-module/mts_eeprom.h
index 8e1d76c..5ad2b8b 100644
--- a/io-module/mts_eeprom.h
+++ b/io-module/mts_eeprom.h
@@ -65,4 +65,5 @@ do { \
#define CAPA_WIFI DEVICE_CAPA_VALUE(1, 6)
#define CAPA_LORA DEVICE_CAPA_VALUE(1, 3) // on-board lora
#define CAPA_BATTERY DEVICE_CAPA_VALUE(1, 4) // 1st battery type
+#define CAPA_SUPERCAP DEVICE_CAPA_VALUE(1, 5)
#endif /* __MTS_EEPROM_H */
diff --git a/io-module/mts_io_module.h b/io-module/mts_io_module.h
index 5cccb13..cb9b30c 100644
--- a/io-module/mts_io_module.h
+++ b/io-module/mts_io_module.h
@@ -38,6 +38,7 @@
#define HW_VERSION_MTCAP_0_0 "MTCAP-0.0"
#define HW_VERSION_MTCAP_0_1 "MTCAP-0.1"
#define HW_VERSION_MTCAP_0_2 "MTCAP-0.2"
+#define HW_VERSION_MTCAP_0_3 "MTCAP-0.3"
#define HW_VERSION_MTHS_0_0 "MTHS-0.0"
#define HW_VERSION_MTHS_0_1 "MTHS-0.1"