diff options
author | John Klug <john.klug@multitech.com> | 2020-02-25 17:55:49 -0600 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2020-02-25 17:55:49 -0600 |
commit | 62f1d67abe1f4e79542c3cca683b40beb2eeda02 (patch) | |
tree | 554b675f8a972c73961dd615bd50093d8cd9a9f7 | |
parent | 0a4a5f96dd649a5c5e18d43d7bd206f35845e1cb (diff) | |
download | mts-io-62f1d67abe1f4e79542c3cca683b40beb2eeda02.tar.gz mts-io-62f1d67abe1f4e79542c3cca683b40beb2eeda02.tar.bz2 mts-io-62f1d67abe1f4e79542c3cca683b40beb2eeda02.zip |
mts-io based on thud/4.19 kernel for mt100eocg4.3.1
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | io-module/machine/mt100eocg.c (renamed from io-module/mt100eocg.c) | 0 | ||||
-rw-r--r-- | io-module/machine/mtcap.c (renamed from io-module/mtcap.c) | 0 | ||||
-rw-r--r-- | io-module/machine/mtcdt.c (renamed from io-module/mtcdt.c) | 10 | ||||
-rw-r--r-- | io-module/machine/mtcpm.c | 297 | ||||
-rw-r--r-- | io-module/machine/mths.c (renamed from io-module/mths.c) | 8 | ||||
-rw-r--r-- | io-module/machine/mtr.c (renamed from io-module/mtr.c) | 13 | ||||
-rw-r--r-- | io-module/mts-io.c | 118 | ||||
-rw-r--r-- | io-module/mts_capab.c | 38 | ||||
-rw-r--r-- | io-module/mts_eeprom.h | 1 | ||||
-rw-r--r-- | io-module/mts_io.h | 1 | ||||
-rw-r--r-- | io-module/mts_io_module.h | 14 | ||||
-rwxr-xr-x | io-tool/mts-io-sysfs | 2 | ||||
-rw-r--r-- | io-tool/mts-io-sysfs-inc.sh | 2 |
14 files changed, 443 insertions, 63 deletions
diff --git a/configure.ac b/configure.ac index e5e16b0..fbb7973 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([mts-io], [1.6.0]) +AC_INIT([mts-io], [4.3.1]) AC_CONFIG_SRCDIR([util/mts_util_lora2_reset.c]) AM_INIT_AUTOMAKE AM_CONFIG_HEADER([config.h]) diff --git a/io-module/mt100eocg.c b/io-module/machine/mt100eocg.c index 749b85a..749b85a 100644 --- a/io-module/mt100eocg.c +++ b/io-module/machine/mt100eocg.c diff --git a/io-module/mtcap.c b/io-module/machine/mtcap.c index bd08d5a..bd08d5a 100644 --- a/io-module/mtcap.c +++ b/io-module/machine/mtcap.c diff --git a/io-module/mtcdt.c b/io-module/machine/mtcdt.c index 69f87f7..575dd1e 100644 --- a/io-module/mtcdt.c +++ b/io-module/machine/mtcdt.c @@ -302,7 +302,7 @@ static struct gpio_pin gpio_pins_mtcdt_0_1[] = { .name = "GNSS_RESET", .pin = { .gpio = AT91_PIN_PD15, - .flags = GPIOF_OUT_INIT_LOW, /* Keep GPS quiet during boot */ + .flags = GPIOF_OUT_INIT_LOW, /* Keep GPS quiet during boot for EXAR */ .label = "gnss-reset", }, .capability = CAPA_GPS, @@ -370,8 +370,10 @@ static DEVICE_ATTR_MTS(dev_attr_eth_reset, "eth-reset", mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); static DEVICE_ATTR_MTS(dev_attr_gnss_int, "gnss-int", mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); - - +static DEVICE_ATTR_RO_MTS(dev_attr_wifi_mac, "mac-wifi", + mts_attr_show_product_info); +static DEVICE_ATTR_RO_MTS(dev_attr_bluetooth_mac, "mac-bluetooth", + mts_attr_show_product_info); static struct attribute *mtcdt_platform_attributes[] = { &dev_attr_vendor_id.attr, @@ -454,6 +456,8 @@ static struct attribute *mtcdt_0_1_wifi_bt_attributes[] = { &dev_attr_wifi_bt_reset.attr, &dev_attr_wifi_bt_lpmode.attr, &dev_attr_wifi_bt_int.attr, + &dev_attr_bluetooth_mac.attr, + &dev_attr_wifi_mac.attr, }; static struct attribute *mtcdt_0_1_gnss_attributes[] = { diff --git a/io-module/machine/mtcpm.c b/io-module/machine/mtcpm.c new file mode 100644 index 0000000..8167218 --- /dev/null +++ b/io-module/machine/mtcpm.c @@ -0,0 +1,297 @@ +#include "mts_io.h" + +#define OMAP_GPIO(BANK, GPIO) ((BANK*32)+GPIO) +/* + * Within a struct gpio_pin, there is only one + * occurrence of each pin, so there is only one + * pin label set for each gpio pin. + */ +static struct gpio_pin gpio_pins_mtcpm[] = { + { + .name = "RADIO_RESET", + .pin = { + .gpio = OMAP_GPIO(5,9), /* 5_9 */ + .flags = GPIOF_OUT_INIT_HIGH, + .label = "radio-reset", + }, + }, +#if 0 + /* This goes through the PMIC for now */ + { + .name = "RADIO_POWER", + .pin = { + .gpio = 0, + .flags = GPIOF_OUT_INIT_HIGH, + .label = "radio-power", + }, + }, +#endif + { + .name = "DEVICE_RESET", + .pin = { + .gpio = OMAP_GPIO(1,29), + .flags = GPIOF_IN, + .label = "reset", + }, + .active_low = 1, + }, + { + .name = "WIFI_BT_INT", + .pin = { + .gpio = OMAP_GPIO(4,12), /* 4_12 */ + .flags = GPIOF_IN, + .label = "wifi-bt-int", + }, + .capability = CAPA_BLUETOOTH, + }, + { + .name = "WIFI_RESET", + .pin = { + .gpio = OMAP_GPIO(4,11), /* 4_11 */ + .flags = GPIOF_OUT_INIT_HIGH, + .label = "wlan-enabled", + }, + .capability = CAPA_WIFI, + .active_low = 0, + }, + { + .name = "BT_RESET", + .pin = { + .gpio = OMAP_GPIO(4,10), /* 4_10 */ + .flags = GPIOF_OUT_INIT_HIGH, + .label = "bt-enabled", + }, + .capability = CAPA_BLUETOOTH, + .active_low = 0, + }, + { + .name = "USBHUB_RESET", + .pin = { + .gpio = OMAP_GPIO(3, 15), + .flags = GPIOF_OUT_INIT_HIGH, + .label = "usbhub-reset", + }, + .active_low = 0, + }, + { + .name = "ETH_RESET", + .pin = { + .gpio = OMAP_GPIO(4,7), /* 4_7 */ + .flags = GPIOF_OUT_INIT_HIGH, + .label = "eth-reset", + }, + .active_low = 0, + }, + { + .name = "GNSS_INT", + .pin = { + .gpio = OMAP_GPIO(5,12), /* 5_12 */ + .flags = GPIOF_OUT_INIT_HIGH, + .label = "gnss-int", + }, + .capability = CAPA_GPS, + }, + { + .name = "GNSS_RESET", + .pin = { + .gpio = OMAP_GPIO(5,10), /* 5_10 */ + .flags = GPIOF_OUT_INIT_HIGH, + .label = "gnss-reset", + }, + .capability = CAPA_GPS, + .active_low = 0, + }, +#if 0 + /* Link status comes directly from the MTQ out to the baseboard */ + { + .name = "LS_LED", + .pin = { + .gpio = 0, + .flags = GPIOF_IN, + .label = "led-ls", + }, + .active_low = 1, + }, +#endif + { + .name = "STATUS_LED", + .pin = { + .gpio = OMAP_GPIO(0, 20), + .flags = GPIOF_OUT_INIT_LOW, + .label = "led-status", + }, + }, + { + .name = "CD", + .pin = { + .gpio = OMAP_GPIO(0, 21), + .flags = GPIOF_OUT_INIT_HIGH, + .label = "led-cd", + }, + }, + { + .name = "LED1", + .pin = { + .gpio = OMAP_GPIO(4, 26), + .flags = GPIOF_OUT_INIT_LOW, + .label = "led-sig1", + }, + }, + { + .name = "LED2", + .pin = { + .gpio = OMAP_GPIO(4, 27), + .flags = GPIOF_OUT_INIT_LOW, + .label = "led-sig2", + }, + }, + { + .name = "LED3", + .pin = { + .gpio = OMAP_GPIO(4, 28), + .flags = GPIOF_OUT_INIT_LOW, + .label = "led-sig3", + }, + }, + { }, +}; + +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_mtcpm, "bt-enabled", + mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); +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_mtcpm, "gnss-reset", + mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); +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_mtcpm, "eth-reset", + mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); +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_mtcpm, "reset", + mts_attr_show_lora_gpio_pin, mts_attr_store_lora_gpio_pin); +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_mtcpm, "creset", + mts_attr_show_lora_gpio_pin, mts_attr_store_lora_gpio_pin); +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_mtcpm, "product-id", + mts_attr_show_lora_product_info); +static DEVICE_ATTR_RO_MTS(dev_attr_lora_hw_version_mtcpm, "hw-version", + mts_attr_show_lora_product_info); +static DEVICE_ATTR_RO_MTS(dev_attr_wifi_mac_mtcpm, "mac-wifi", + mts_attr_show_product_info); +static DEVICE_ATTR_RO_MTS(dev_attr_bluetooth_mac_mtcpm, "mac-bluetooth", + mts_attr_show_product_info); + +static struct attribute *mtcpm_platform_attributes[] = { + &dev_attr_imei.attr, + &dev_attr_eth_mac.attr, + &dev_attr_reset.attr, + &dev_attr_reset_monitor.attr, + &dev_attr_reset_monitor_intervals.attr, + + &dev_attr_led_status.attr, + &dev_attr_led_cd_gpio.attr, + &dev_attr_led_sig1_gpio.attr, + &dev_attr_led_sig2_gpio.attr, + &dev_attr_led_sig3_gpio.attr, + + &dev_attr_usbhub_reset.attr, + &dev_attr_eth_reset.attr, + + // radio feature is last to be able to + // easily remove radio. + // is_radio_power_attr_mtcdt() searches + // for this for truncation. + &dev_attr_radio_power.attr, /* Must be first radio attribute */ + &dev_attr_radio_reset.attr, + + &dev_attr_radio_reset_backoffs.attr, + &dev_attr_radio_reset_backoff_index.attr, + &dev_attr_radio_reset_backoff_seconds.attr, + + &dev_attr_wifi_reset_mtcpm.attr, + &dev_attr_bt_reset_mtcpm.attr, + &dev_attr_wifi_bt_int_mtcpm.attr, + + &dev_attr_gnss_reset_mtcpm.attr, + &dev_attr_gnss_int_mtcpm.attr, + &dev_attr_wifi_mac_mtcpm.attr, + &dev_attr_bluetooth_mac_mtcpm.attr, + NULL, +}; + + + +static struct attribute_group mtcpm_platform_attribute_group = { + .attrs = mtcpm_platform_attributes +}; + +static int +is_radio_power_attr_mtcpm(struct attribute *attr) +{ + return (attr == &dev_attr_radio_power.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 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/mths.c b/io-module/machine/mths.c index a51380c..c19598d 100644 --- a/io-module/mths.c +++ b/io-module/machine/mths.c @@ -230,7 +230,7 @@ static struct gpio_pin gpio_pins_mths_0_0[] = { .name = "GNSS_RESET", .pin = { .gpio = AT91_PIN_PC6, - .flags = GPIOF_OUT_INIT_HIGH, + .flags = GPIOF_OUT_INIT_LOW, .label = "gnss-reset", } }, @@ -461,7 +461,7 @@ static struct gpio_pin gpio_pins_mths_0_1[] = { .name = "GNSS_RESET", .pin = { .gpio = AT91_PIN_PC6, - .flags = GPIOF_OUT_INIT_HIGH, + .flags = GPIOF_OUT_INIT_LOW, .label = "gnss-reset", } }, @@ -795,6 +795,9 @@ static DEVICE_ATTR_MTS(dev_attr_led_f_gpio_mths, "led-f", static DEVICE_ATTR_RO_MTS(dev_attr_wifi_mac_mths, "mac-wifi", mts_attr_show_product_info); +static DEVICE_ATTR_RO_MTS(dev_attr_bluetooth_mac_mths, "mac-bluetooth", + mts_attr_show_product_info); + static DEVICE_ATTR_MTS(dev_attr_wifi_bt_lpwkup_mths, "wifi-bt-lpwkup", mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); @@ -829,6 +832,7 @@ static struct attribute *mths_0_0_platform_attributes[] = { &dev_attr_hw_version.attr, &dev_attr_imei.attr, &dev_attr_wifi_mac_mths.attr, + &dev_attr_bluetooth_mac_mths.attr, &dev_attr_has_radio.attr, &dev_attr_reset.attr, diff --git a/io-module/mtr.c b/io-module/machine/mtr.c index e47beae..8664984 100644 --- a/io-module/mtr.c +++ b/io-module/machine/mtr.c @@ -885,7 +885,7 @@ static struct gpio_pin gpio_pins_mtrv1_0_1[] = { .name = "GNSS_RESET", .pin = { .gpio = AT91_PIN_PD15, - .flags = GPIOF_OUT_INIT_HIGH, + .flags = GPIOF_OUT_INIT_LOW, .label = "gnss-reset", } }, @@ -1158,7 +1158,7 @@ static struct gpio_pin gpio_pins_mtrv1_0_2[] = { .name = "GNSS_RESET", .pin = { .gpio = AT91_PIN_PD15, - .flags = GPIOF_OUT_INIT_HIGH, + .flags = GPIOF_OUT_INIT_LOW, .label = "gnss-reset", } }, @@ -1412,7 +1412,7 @@ static struct gpio_pin gpio_pins_mtrv1_0_3[] = { .name = "GNSS_RESET", .pin = { .gpio = AT91_PIN_PD15, - .flags = GPIOF_OUT_INIT_HIGH, + .flags = GPIOF_OUT_INIT_LOW, .label = "gnss-reset", } }, @@ -1740,6 +1740,9 @@ static DEVICE_ATTR_MTS(dev_attr_extserial_dcd_gpio_mtr, "extserial-dcd", static DEVICE_ATTR_RO_MTS(dev_attr_wifi_mac_mtr, "mac-wifi", mts_attr_show_product_info); +static DEVICE_ATTR_RO_MTS(dev_attr_bluetooth_mac_mtr, "mac-bluetooth", + mts_attr_show_product_info); + static DEVICE_ATTR_MTS(dev_attr_wifi_bt_lpwkup_mtr, "wifi-bt-lpwkup", mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); @@ -1778,6 +1781,7 @@ static struct attribute *mtr_platform_attributes[] = { &dev_attr_eth_mac.attr, &dev_attr_has_radio.attr, &dev_attr_wifi_mac_mtr.attr, + &dev_attr_bluetooth_mac_mtr.attr, &dev_attr_reset.attr, &dev_attr_reset_monitor.attr, &dev_attr_reset_monitor_intervals.attr, @@ -1831,6 +1835,7 @@ static struct attribute *mtrv1_0_1_platform_attributes[] = { &dev_attr_eth_mac.attr, &dev_attr_has_radio.attr, &dev_attr_wifi_mac_mtr.attr, + &dev_attr_bluetooth_mac_mtr.attr, &dev_attr_reset.attr, &dev_attr_reset_monitor.attr, @@ -1887,6 +1892,7 @@ static struct attribute *mtrv1_0_2_platform_attributes[] = { &dev_attr_eth_mac.attr, &dev_attr_has_radio.attr, &dev_attr_wifi_mac_mtr.attr, + &dev_attr_bluetooth_mac_mtr.attr, &dev_attr_reset.attr, &dev_attr_reset_monitor.attr, @@ -1946,6 +1952,7 @@ static struct attribute *mtrv1_0_3_platform_attributes[] = { &dev_attr_eth_mac.attr, &dev_attr_has_radio.attr, &dev_attr_wifi_mac_mtr.attr, + &dev_attr_bluetooth_mac_mtr.attr, &dev_attr_reset.attr, &dev_attr_reset_monitor.attr, diff --git a/io-module/mts-io.c b/io-module/mts-io.c index 154d120..7c8a873 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -3,10 +3,8 @@ * * Copyright (C) 2014 by Multi-Tech Systems * Copyright (C) 2016 by Multi-Tech Systems - * - * Authors: James Maki <jmaki@multitech.com> - * Jesse Gilles <jgilles@multitech.com> - * Mike Fiore <mfiore@multitech.com> + * Copyright (C) 2019 by Multi-Tech Systems + * Copyright (C) 2020 by Multi-Tech Systems * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,7 +36,6 @@ #include <linux/platform_device.h> #include <linux/device.h> #include <linux/bitops.h> -#include <linux/spi/spi.h> #include <linux/kmod.h> #include <linux/ctype.h> #include <linux/io.h> @@ -168,8 +165,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) @@ -206,6 +203,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, @@ -531,7 +529,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) { @@ -561,7 +559,15 @@ static ssize_t mts_attr_show_product_info(struct device *dev, id_eeprom.mac_wifi[3], id_eeprom.mac_wifi[4], id_eeprom.mac_wifi[5]); - } else if (strcmp(attr->attr.name, "mac-eth") == 0) { + } else if (strcmp(attr->attr.name, "mac-bluetooth") == 0) { + value = sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X\n", + id_eeprom.mac_bluetooth[0], + id_eeprom.mac_bluetooth[1], + id_eeprom.mac_bluetooth[2], + id_eeprom.mac_bluetooth[3], + id_eeprom.mac_bluetooth[4], + id_eeprom.mac_bluetooth[5]); + } else if (strcmp(attr->attr.name, "mac-eth") == 0) { value = sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X\n", id_eeprom.mac_addr[0], id_eeprom.mac_addr[1], @@ -620,11 +626,13 @@ static int get_radio_model_from_product_id(void) { #include "mts_lora.c" /* include per-device pins and attributes */ -#include "mtcdt.c" -#include "mtcap.c" -#include "mtr.c" -#include "mths.c" -#include "mt100eocg.c" +#include "machine/mtcdt.c" +#include "machine/mtcap.c" +#include "machine/mtr.c" +#include "machine/mths.c" +#include "machine/mtcpm.c" +#include "machine/mt100eocg.c" + /* include capabilities sub-directory support */ #include "mts_capab.c" @@ -652,18 +660,24 @@ 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)) { + ((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)) { /* 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; @@ -785,7 +799,7 @@ mts_id_eeprom_load(void) attr_group = &mtcdt_0_1_platform_attribute_group; gpio_pins = gpio_pins_mtcdt_0_1; - set_buttons(default_buttons); + set_buttons(default_buttons); log_info("detected board %s", tmp); } else if ((tmp=HW_VERSION_MTCDTIPHP_0_0),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) { current_blength = attr_blength = sizeof mtcdt_0_1_platform_attributes; @@ -831,15 +845,9 @@ mts_id_eeprom_load(void) if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA)) { attr_group_lora = &mtcdtiphp_0_0_lora_attribute_group; } - set_buttons(default_buttons); + set_buttons(default_buttons); log_info("detected board %s", tmp); - } else if (strncmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG, strlen(PRODUCT_ID_MT100EOCG)) == 0) { - attr_group = &mt100eocg_platform_attribute_group; - gpio_pins = gpio_pins_mt100eocg_0_0; - mts_hw_version = MT100EOCG_0_0; - set_buttons(default_buttons); - log_info("detected board %s", HW_VERSION_MT100EOCG_0_0); - } else { + } else if ((tmp=HW_VERSION_MTCDT_0_0),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) { if(noradio) { struct attribute **ap = mtcdt_platform_attribute_group.attrs; while(1) { @@ -859,9 +867,41 @@ mts_id_eeprom_load(void) attr_group = &mtcdt_platform_attribute_group; gpio_pins = gpio_pins_mtcdt_0_0; mts_hw_version = MTCDT_0_0; - set_buttons(default_buttons); - log_info("detected board %s", HW_VERSION_MTCDT_0_0); - } + set_buttons(default_buttons); + log_info("detected board %s", tmp); + + } 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 = MTCPM_0_0; + log_info("detected board %s", HW_VERSION_MTCPM_0_0); + } else if (strncmp(id_eeprom.product_id, PRODUCT_ID_MT100EOCG, strlen(PRODUCT_ID_MT100EOCG)) == 0) { + attr_group = &mt100eocg_platform_attribute_group; + gpio_pins = gpio_pins_mt100eocg_0_0; + mts_hw_version = MT100EOCG_0_0; + set_buttons(default_buttons); + log_info("detected board %s", HW_VERSION_MT100EOCG_0_0); + } else { + int i; + + for(i=0;i<sizeof id_eeprom.hw_version;i++) { + if(! id_eeprom.hw_version[i]) + /* Found NULL so done */ + break; + if(! isprint(id_eeprom.hw_version[i])) + break; + } + log_alert("Unsupported EEPROM settings or device"); + + if(i) + log_alert("Found unsupported EEPROM HW_VERSION: %.*s",i,id_eeprom.hw_version); + log_alert("Check log for HW_VERSION dump"); + + print_hex_dump_bytes("HW_VERSION: ", DUMP_PREFIX_OFFSET, id_eeprom.hw_version, sizeof id_eeprom.hw_version); + + return -ENODEV; + } log_info("sizeof: %lu", (unsigned long) sizeof(struct mts_id_eeprom_layout)); log_info("vendor-id: %.32s", id_eeprom.vendor_id); @@ -883,7 +923,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"); + 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", @@ -940,6 +983,7 @@ static void cleanup(void) } mts_capab_dir_delete(); + mts_cpu_dir_delete(); } static int __init mts_io_init(void) @@ -963,21 +1007,19 @@ static int __init mts_io_init(void) platform_driver_unregister(&mts_io_driver); mts_io_platform_device = platform_device_alloc(PLATFORM_NAME, -1); - if (!mts_io_platform_device) { - cleanup(); + if (!mts_io_platform_device) return -ENOMEM; - } /* request_firmware() requires a device, so call after device allocated */ ret = mts_id_eeprom_load(); if (ret) { - cleanup(); + kfree(mts_io_platform_device); return ret; } ret = platform_device_add(mts_io_platform_device); if (ret) { - cleanup(); + kfree(mts_io_platform_device); return ret; } @@ -1002,7 +1044,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; @@ -1021,6 +1063,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 8495d87..38e8442 100644 --- a/io-module/mts_capab.c +++ b/io-module/mts_capab.c @@ -25,6 +25,7 @@ static struct capab_map_s capabilities_map[] = { { CAPA_BLUETOOTH, "bluetooth"}, { CAPA_WIFI, "wifi"}, { CAPA_LORA, "lora"}, + { CAPA_BATTERY, "battery"}, }; static ssize_t capab_show_value(struct device *dev, struct device_attribute *at, char *buf) { @@ -48,6 +49,7 @@ static DEVICE_ATTR_RO_MTS(capa_attr_adc, "adc", capab_show_value); 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 struct attribute *mts_capa_attributes[] = { &capa_attr_gps.attr, @@ -57,6 +59,7 @@ static struct attribute *mts_capa_attributes[] = { &capa_attr_bt.attr, &capa_attr_wifi.attr, &capa_attr_lora.attr, + &capa_attr_battery.attr, NULL, }; @@ -65,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_eeprom.h b/io-module/mts_eeprom.h index 478a107..8e1d76c 100644 --- a/io-module/mts_eeprom.h +++ b/io-module/mts_eeprom.h @@ -64,4 +64,5 @@ do { \ /* Used for rs9113 detection in Conduit 0.1 and others */ #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 #endif /* __MTS_EEPROM_H */ 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 41a27e5..2c5976a 100644 --- a/io-module/mts_io_module.h +++ b/io-module/mts_io_module.h @@ -5,13 +5,13 @@ * MTAC cards. */ -#define DRIVER_VERSION "v4.1.3" -#define DRIVER_AUTHOR "James Maki <jmaki@multitech.com>" +#define DRIVER_VERSION "v4.3.1" +#define DRIVER_AUTHOR "Multitech Systems" #define DRIVER_DESC "MTS-IO Controller" #define DRIVER_NAME "mts-io" #define DEBUG 0 - +/* Atmel AT91 Platforms */ #define PRODUCT_ID_MTCDP_E1_DK "MTCDP-E1-DK" #define PRODUCT_ID_MT100EOCG "MT100EOCG" #define PRODUCT_ID_MTR "MTR" @@ -37,9 +37,16 @@ #define HW_VERSION_MTCDTIPHP_0_0 "MTCDTIPHP-0.0" #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_MTHS_0_0 "MTHS-0.0" #define HW_VERSION_MTHS_0_1 "MTHS-0.1" +/* TI OMAP Platforms */ +#define PRODUCT_ID_MTCPM "MTCPM" + +#define HW_VERSION_MTCPM_DASH "MTCPM-" +#define HW_VERSION_MTCPM_0_0 "MTCPM-0.0" + enum { MTCDP_E1_DK_0_0, MTCDP_E1_DK_1_0, @@ -57,6 +64,7 @@ enum { MTCAP_0_1, MTHS_0_0, MTHS_0_1, + MTCPM_0_0, }; enum { diff --git a/io-tool/mts-io-sysfs b/io-tool/mts-io-sysfs index a7f7455..db1e6eb 100755 --- a/io-tool/mts-io-sysfs +++ b/io-tool/mts-io-sysfs @@ -4,8 +4,6 @@ # # Copyright (C) 2010 by Multi-Tech Systems # -# Author: James Maki <jmaki@multitech.com> -# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or diff --git a/io-tool/mts-io-sysfs-inc.sh b/io-tool/mts-io-sysfs-inc.sh index cec9943..3731b1b 100644 --- a/io-tool/mts-io-sysfs-inc.sh +++ b/io-tool/mts-io-sysfs-inc.sh @@ -4,8 +4,6 @@ # # Copyright (C) 2010 by Multi-Tech Systems # -# Author: James Maki <jmaki@multitech.com> -# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or |