From eb3b20bf2faf4db51ca769039db3c952333b919a Mon Sep 17 00:00:00 2001 From: John Klug Date: Thu, 21 Nov 2019 19:00:08 -0600 Subject: Remove device-id and product-id from the top level directory in mts-io --- configure.ac | 2 +- io-module/machine/mtcdt3.c | 252 -------------------------------------- io-module/machine/mtcpm.c | 292 +++++++++++++++++++++++++++++++++++++++++++++ io-module/mts-io.c | 46 ++++--- io-module/mts_capab.c | 35 ++++-- io-module/mts_io.h | 1 + io-module/mts_io_module.h | 8 +- 7 files changed, 350 insertions(+), 286 deletions(-) delete mode 100644 io-module/machine/mtcdt3.c create mode 100644 io-module/machine/mtcpm.c 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/mtcdt3.c deleted file mode 100644 index 373fc47..0000000 --- a/io-module/machine/mtcdt3.c +++ /dev/null @@ -1,252 +0,0 @@ -#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_mtcdt3[] = { - { - .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 = 0, - }, - { - .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_mtcdt3, "wlan-enabled", - mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); -static DEVICE_ATTR_MTS(dev_attr_bt_reset_mtcdt3, "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", - mts_attr_show_gpio_pin); -static DEVICE_ATTR_MTS(dev_attr_gnss_reset_mtcdt3, "gnss-reset", - mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); -static DEVICE_ATTR_MTS(dev_attr_usbhub_reset_mtcdt3, "usbhub-reset", - mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); -static DEVICE_ATTR_MTS(dev_attr_eth_reset_mtcdt3, "eth-reset", - mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); -static DEVICE_ATTR_MTS(dev_attr_gnss_int_mtcdt3, "gnss-int", - mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); -static DEVICE_ATTR_MTS(dev_attr_lora_reset_mtcdt3, "reset", - mts_attr_show_lora_gpio_pin, mts_attr_store_lora_gpio_pin); -static DEVICE_ATTR_RO_MTS(dev_attr_lora_cdone_mtcdt3, "cdone", - mts_attr_show_lora_gpio_pin); -static DEVICE_ATTR_MTS(dev_attr_lora_creset_mtcdt3, "creset", - mts_attr_show_lora_gpio_pin, mts_attr_store_lora_gpio_pin); -static DEVICE_ATTR_RO_MTS(dev_attr_lora_eui_mtcdt3, "eui", - mts_attr_show_lora_product_info); -static DEVICE_ATTR_RO_MTS(dev_attr_lora_product_id_mtcdt3, "product-id", - mts_attr_show_lora_product_info); -static DEVICE_ATTR_RO_MTS(dev_attr_lora_hw_version_mtcdt3, "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, - &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, - - &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_mtcdt3.attr, - &dev_attr_bt_reset_mtcdt3.attr, - &dev_attr_wifi_bt_int_mtcdt3.attr, - - &dev_attr_gnss_reset_mtcdt3.attr, - &dev_attr_gnss_int_mtcdt3.attr, - - NULL, -}; - -static struct attribute_group mtcdt3_platform_attribute_group = { - .attrs = mtcdt3_platform_attributes -}; - -static int -is_radio_power_attr_mtcdt3(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, - NULL, -}; - -static struct attribute_group mtcdt3_lora_attribute_group = { - .attrs = mtcdt3_lora_attributes -}; - diff --git a/io-module/machine/mtcpm.c b/io-module/machine/mtcpm.c new file mode 100644 index 0000000..7052b51 --- /dev/null +++ b/io-module/machine/mtcpm.c @@ -0,0 +1,292 @@ +#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 = 0, + }, + { + .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 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, + + 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/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 { -- cgit v1.2.3