summaryrefslogtreecommitdiff
path: root/io-module/mts-io.c
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2018-10-15 14:09:53 -0500
committerJohn Klug <john.klug@multitech.com>2018-10-15 14:09:53 -0500
commit75f812b964c388cd1e41d5dd77d48ad82b32ec38 (patch)
treea720efda2928df276fb382e890cab2ad947e24d0 /io-module/mts-io.c
parentd2a70d9285ca3339fa9df44b83cfe9bc0d5ce8b7 (diff)
downloadmts-io-75f812b964c388cd1e41d5dd77d48ad82b32ec38.tar.gz
mts-io-75f812b964c388cd1e41d5dd77d48ad82b32ec38.tar.bz2
mts-io-75f812b964c388cd1e41d5dd77d48ad82b32ec38.zip
Remove mtac cards. mts-io version 3.0.03.0.0
Diffstat (limited to 'io-module/mts-io.c')
-rw-r--r--io-module/mts-io.c679
1 files changed, 490 insertions, 189 deletions
diff --git a/io-module/mts-io.c b/io-module/mts-io.c
index d127fe2..da02ce8 100644
--- a/io-module/mts-io.c
+++ b/io-module/mts-io.c
@@ -45,33 +45,30 @@
#include <linux/io.h>
#include <linux/module.h>
+#include "mts_io_module.h"
#include "mts_io.h"
+/*
+#include "mtac.h"
+*/
#include "buttons.h"
#define PLATFORM_NAME "mts-io"
#define LED_LS_CONTROLLABLE 0
+int mtsio_reread_eeprom = 0;
+module_param(mtsio_reread_eeprom, int, S_IRUSR | S_IRGRP | S_IROTH);
+MODULE_PARM_DESC(mtsio_reread_eeprom, "Non-zero means re-read EEPROM");
+
/* on-board EEPROM */
extern uint8_t mts_id_eeprom[512];
static struct mts_id_eeprom_layout id_eeprom;
-// NUM_AP should be defined from the board code
-// it should be set to the value of CONFIG_MTS_NUM_ACCESSORY_PORTS
-// arch/arm/mach-at91/board-dt-sam9.c
-// if it is 0 or undefined, there is no accessory card support on this HW
-#ifdef CONFIG_MTS_NUM_ACCESSORY_PORTS
-
-#ifndef NUM_AP
-#define NUM_AP CONFIG_MTS_NUM_ACCESSORY_PORTS
-#endif
+uint8_t mts_hw_version;
-#else
-#define NUM_AP 0
-#endif
+struct platform_device *mts_io_platform_device;
+EXPORT_SYMBOL(mts_io_platform_device);
-static uint8_t mts_hw_version;
-static struct platform_device *mts_io_platform_device;
static struct attribute_group *attr_group;
static struct attribute_group *attr_group_lora; // on-board lora peripheral to be stored in the lora/ sub-directory
static struct gpio_pin *gpio_pins;
@@ -102,14 +99,7 @@ static void radio_reset_timer_callback(unsigned long data);
#define RESET_HOLD_COUNT (RESET_CHECK_PER_SEC * 3)
#define RESET_LONG_HOLD_COUNT (RESET_CHECK_PER_SEC * 30)
-static pid_t reset_pid = -1;
-static pid_t reset_count = 0;
bool sent_extra_long = false;
-static int reset_short_signal = SIGUSR1;
-static int reset_long_signal = SIGUSR2;
-static int reset_extra_long_signal = SIGHUP;
-static int reset_short_interval = RESET_HOLD_COUNT;
-static int reset_long_interval = RESET_LONG_HOLD_COUNT;
/*
* This function takes the product_id and tries to check
@@ -449,14 +439,6 @@ static DEVICE_ATTR_MTS(dev_attr_led_status, "led-status",
static DEVICE_ATTR_MTS(dev_attr_led_a_gpio, "led-a",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-#if LED_LS_CONTROLLABLE
-static DEVICE_ATTR_MTS(dev_attr_led_ls, "led-ls",
- mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
-#else
-static DEVICE_ATTR_RO_MTS(dev_attr_led_ls, "led-ls",
- mts_attr_show_gpio_pin);
-#endif
-
static DEVICE_ATTR_MTS(dev_attr_led_b_gpio, "led-b",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
@@ -477,6 +459,7 @@ static DEVICE_ATTR_MTS(dev_attr_led_d_gpio, "led-d",
static DEVICE_ATTR_MTS(dev_attr_led_e_gpio, "led-e",
mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+
/* eeprom info */
static ssize_t mts_attr_show_product_info(struct device *dev,
struct device_attribute *attr,
@@ -576,174 +559,490 @@ static int get_radio_model_from_product_id(void) {
return rc;
}
-
/* include on-board lora peripheral */
#include "mts_lora.c"
-/* include per-device pins and attributes */
-#include "mtcdt.c"
-#include "mtcap.c"
-#include "mtr.c"
-#include "mths.c"
-
-/* include capabilities sub-directory support */
-#include "mts_capab.c"
-
-
-#if NUM_AP > 0
-
-/* accessory card EEPROMs */
-extern uint8_t mts_ap_eeprom[NUM_AP][512];
-static struct mts_ap_eeprom_layout ap_eeprom[NUM_AP];
-/* kobject pointers for the apX subdirectories that correspond to the accessory ports */
-static struct kobject *ap_subdirs[NUM_AP];
-/* attribute groups for the accessory ports*/
-static struct attribute_group ap_attr_groups[NUM_AP];
-/* info for accessory port (contains function pointers for setup and teardown and and useful info) */
-static struct ap_info* port_info[NUM_AP];
-
-/* accessory card support */
-#include "mtac.c"
-#include "mtac_gpiob.c"
-#include "mtac_mfser.c"
-#include "mtac_eth.c"
-#include "mtac_lora.c"
-#include "mtac_pulse.c"
-
-static bool load_port(int port) {
- int port_index = port - 1;
- memcpy(&ap_eeprom[port_index], mts_ap_eeprom[port_index], sizeof(mts_ap_eeprom[port_index]));
-
- if (mts_ap_eeprom[port_index][0] == 0xFF) {
- log_error("uninitialized eeprom on accessory card %d", port);
- } else if (mts_ap_eeprom[port_index][0] == 0x00) {
- log_info("no accessory card inserted in port %d", port);
- } else {
- port_info[port_index] = kzalloc(sizeof(struct ap_info), GFP_KERNEL);
- if (! port_info[port_index]) {
- log_error("alloc of port info failed");
- return false;
- }
-
- if (strstr(ap_eeprom[port_index].product_id, PRODUCT_ID_MTAC_GPIOB)) {
- if (! set_gpiob_info(port_info[port_index])) {
- log_error("failed to set up gpiob port info");
- return false;
- }
- } else if (strstr(ap_eeprom[port_index].product_id, PRODUCT_ID_MTAC_MFSER)) {
- if (! set_mfser_info(port_info[port_index])) {
- log_error("failed to set up mfser port info");
- return false;
- }
- } else if (strstr(ap_eeprom[port_index].product_id, PRODUCT_ID_MTAC_ETH)) {
- if (! set_eth_info(port_info[port_index])) {
- log_error("failed to set up eth port info");
- return false;
- }
- } else if (strstr(ap_eeprom[port_index].product_id, PRODUCT_ID_MTAC_LORA)) {
- if (! set_lora_info(port_info[port_index])) {
- log_error("failed to set up lora port info");
- return false;
- }
- } else if (strstr(ap_eeprom[port_index].product_id, PRODUCT_ID_MTAC_PULSE)) {
- if (! set_pulse_info(port_info[port_index])) {
- log_error("failed to set up pulse port info");
- return false;
- }
- } else {
- log_error("unknown accessory card [%s] in port %d", ap_eeprom[port_index].product_id, port);
- kfree(port_info[port_index]);
- port_info[port_index] = NULL;
- return false;
+/* Start of mtcdt.c */
+/*
+ * Within a struct gpio_pin, there is only one
+ * occurance of each pin, so there is only one
+ * pin label set for each gpio pin.
+ */
+static struct gpio_pin gpio_pins_mtcdt_0_0[] = {
+ {
+ .name = "RADIO_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC3,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "radio-reset",
+ },
+ },
+ {
+ .name = "RADIO_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC3,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "radio-power",
+ },
+ },
+ {
+ .name = "DEVICE_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC2,
+ .flags = GPIOF_IN,
+ .label = "reset",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "ETH_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC4,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "eth-reset",
}
-
- log_info("accessory card %d vendor-id: %.32s", port, ap_eeprom[port_index].vendor_id);
- log_info("accessory card %d product-id: %.32s", port, ap_eeprom[port_index].product_id);
- log_info("accessory card %d device-id: %.32s", port, ap_eeprom[port_index].device_id);
- log_info("accessory card %d hw-version: %.32s", port, ap_eeprom[port_index].hw_version);
- if (strncmp(ap_eeprom[port_index].product_id, PRODUCT_ID_MTAC_ETH, strlen(PRODUCT_ID_MTAC_ETH)) == 0) {
- log_info("accessory card %d mac-addr: %02X:%02X:%02X:%02X:%02X:%02X",
- port,
- ap_eeprom[port_index].mac_addr[0],
- ap_eeprom[port_index].mac_addr[1],
- ap_eeprom[port_index].mac_addr[2],
- ap_eeprom[port_index].mac_addr[3],
- ap_eeprom[port_index].mac_addr[4],
- ap_eeprom[port_index].mac_addr[5]);
+ },
+ {
+ .name = "LS_LED", /* LED7 */
+ .pin = {
+ .gpio = AT91_PIN_PA14,
+#if LED_LS_CONTROLLABLE
+ .flags = GPIOF_OUT_INIT_HIGH,
+#else
+ .flags = GPIOF_IN,
+#endif
+ .label = "led-ls",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "STATUS_LED", /* LED2 */
+ .pin = {
+ .gpio = AT91_PIN_PA24,
+ .flags = GPIOF_OUT_INIT_LOW,
+ .label = "led-status",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED5",
+ .pin = {
+ .gpio = AT91_PIN_PA25,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-cd",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED5",
+ .pin = {
+ .gpio = AT91_PIN_PA25,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-a",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED1",
+ .pin = {
+ .gpio = AT91_PIN_PA26,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig1",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED1",
+ .pin = {
+ .gpio = AT91_PIN_PA26,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-b",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED4",
+ .pin = {
+ .gpio = AT91_PIN_PA27,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig2",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED4",
+ .pin = {
+ .gpio = AT91_PIN_PA27,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-c",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED3",
+ .pin = {
+ .gpio = AT91_PIN_PA28,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig3",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED3",
+ .pin = {
+ .gpio = AT91_PIN_PA28,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-d",
+ },
+ .active_low = 1,
+ },
+};
+
+
+static struct gpio_pin gpio_pins_mtcdt_0_1[] = {
+ {
+ .name = "RADIO_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC3,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "radio-reset",
+ },
+ },
+ {
+ .name = "RADIO_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC3,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "radio-power",
+ },
+ },
+ {
+ .name = "DEVICE_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC2,
+ .flags = GPIOF_IN,
+ .label = "reset",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LS_LED", /* LED7 */
+ .pin = {
+ .gpio = AT91_PIN_PA14,
+#if LED_LS_CONTROLLABLE
+ .flags = GPIOF_OUT_INIT_HIGH,
+#else
+ .flags = GPIOF_IN,
+#endif
+ .label = "led-ls",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "STATUS_LED", /* LED2 */
+ .pin = {
+ .gpio = AT91_PIN_PA24,
+ .flags = GPIOF_OUT_INIT_LOW,
+ .label = "led-status",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED5",
+ .pin = {
+ .gpio = AT91_PIN_PA25,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-cd",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED5",
+ .pin = {
+ .gpio = AT91_PIN_PA25,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-a",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED1",
+ .pin = {
+ .gpio = AT91_PIN_PA26,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig1",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED1",
+ .pin = {
+ .gpio = AT91_PIN_PA26,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-b",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED4",
+ .pin = {
+ .gpio = AT91_PIN_PA27,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig2",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED4",
+ .pin = {
+ .gpio = AT91_PIN_PA27,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-c",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED3",
+ .pin = {
+ .gpio = AT91_PIN_PA28,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig3",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED3",
+ .pin = {
+ .gpio = AT91_PIN_PA28,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-d",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "WIFI_BT_ULPWKUP",
+ .pin = {
+ .gpio = AT91_PIN_PA0,
+ .flags = GPIOF_IN,
+ .label = "wifi-bt-ulpwkup",
+ },
+ .capability = CAPA_WIFI,
+ },
+ {
+ .name = "WIFI_BT_LPWKUP",
+ .pin = {
+ .gpio = AT91_PIN_PA6,
+ .flags = GPIOF_IN,
+ .label = "wifi-bt-lpwkup",
+ },
+ .capability = CAPA_WIFI,
+ },
+ {
+ .name = "WIFI_BT_INT",
+ .pin = {
+ .gpio = AT91_PIN_PB11,
+ .flags = GPIOF_IN,
+ .label = "wifi-bt-int",
+ },
+ .capability = CAPA_WIFI,
+ },
+ {
+ .name = "WIFI_BT_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PD14,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "wifi-bt-reset",
+ },
+ .capability = CAPA_WIFI,
+ },
+ {
+ .name = "GNSS_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PD15,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "gnss-reset",
+ },
+ .capability = CAPA_GPS,
+ },
+ {
+ .name = "SECURE_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PD16,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "secure-reset",
}
- if (strncmp(ap_eeprom[port_index].product_id, PRODUCT_ID_MTAC_LORA, strlen(PRODUCT_ID_MTAC_LORA)) == 0) {
- log_info("accessory card %d eui: %02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X",
- port,
- ap_eeprom[port_index].eui[0],
- ap_eeprom[port_index].eui[1],
- ap_eeprom[port_index].eui[2],
- ap_eeprom[port_index].eui[3],
- ap_eeprom[port_index].eui[4],
- ap_eeprom[port_index].eui[5],
- ap_eeprom[port_index].eui[6],
- ap_eeprom[port_index].eui[7]);
+ },
+ {
+ .name = "MTQ_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PD17,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "mtq-reset",
}
-
- if (! port_info[port_index]->setup(port)) {
- log_error("accessory port %d setup failed", port);
- port_info[port_index]->teardown(port);
- kfree(port_info[port_index]);
- port_info[port_index] = NULL;
- return false;
+ },
+ {
+ .name = "USBHUB_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PD18,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "usbhub-reset",
}
- }
-
- return true;
-}
+ },
+ {
+ .name = "GNSS_INT",
+ .pin = {
+ .gpio = AT91_PIN_PD19,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "gnss-int",
+ },
+ .capability = CAPA_GPS,
+ },
+ {
+ .name = "WIFI_BT_LPMODE",
+ .pin = {
+ .gpio = AT91_PIN_PD20,
+ .flags = GPIOF_IN,
+ .label = "wifi-bt-lpmode",
+ },
+ .capability = CAPA_WIFI,
+ },
+ { },
+};
+
+static DEVICE_ATTR_MTS(dev_attr_wifi_bt_lpwkup, "wifi-bt-lpwkup",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_wifi_bt_ulpwkup, "wifi-bt-ulpwkup",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_wifi_bt_reset, "wifi-bt-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_RO_MTS(dev_attr_wifi_bt_lpmode, "wifi-bt-lpmode",
+ mts_attr_show_gpio_pin);
+static DEVICE_ATTR_RO_MTS(dev_attr_wifi_bt_int, "wifi-bt-int",
+ mts_attr_show_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_gnss_reset, "gnss-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_usbhub_reset, "usbhub-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+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 void init_accessory_ports(void)
-{
- int port_index;
- for (port_index = 0; port_index < NUM_AP; port_index++) {
- port_info[port_index] = NULL;
- if (! load_port(port_index+1)) {
- log_error("failed to load accessory card in port %d", port_index);
- }
- }
-}
-static void teardown_accessory_ports(void)
-{
- int port_index;
+static struct attribute *mtcdt_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_led_a_gpio.attr,
+ &dev_attr_led_b_gpio.attr,
+ &dev_attr_led_c_gpio.attr,
+ &dev_attr_led_d_gpio.attr,
+ &dev_attr_eth_reset.attr,
+
+ &dev_attr_radio_power.attr,
+ &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,
+ NULL,
+};
+
+static struct attribute *mtcdt_0_1_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_led_a_gpio.attr,
+ &dev_attr_led_b_gpio.attr,
+ &dev_attr_led_c_gpio.attr,
+ &dev_attr_led_d_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,
+
+ NULL,
+};
+
+static struct attribute *mtcdt_0_1_wifi_bt_attributes[] = {
+ &dev_attr_wifi_bt_lpwkup.attr,
+ &dev_attr_wifi_bt_ulpwkup.attr,
+ &dev_attr_wifi_bt_reset.attr,
+ &dev_attr_wifi_bt_lpmode.attr,
+ &dev_attr_wifi_bt_int.attr,
+};
+
+static struct attribute *mtcdt_0_1_gnss_attributes[] = {
+ &dev_attr_gnss_reset.attr,
+ &dev_attr_gnss_int.attr,
+};
+
+
+static struct attribute_group mtcdt_platform_attribute_group = {
+ .attrs = mtcdt_platform_attributes
+};
+static struct attribute_group mtcdt_0_1_platform_attribute_group = {
+ .attrs = mtcdt_0_1_platform_attributes
+};
- for (port_index = 0; port_index < NUM_AP; port_index++) {
- if (port_info[port_index]) {
- port_info[port_index]->teardown(port_index+1);
- kfree(port_info[port_index]);
- }
- }
-}
-#else /* NUM_AP > 0 */
-static void init_accessory_ports(void) {}
-static void teardown_accessory_ports(void) {}
-#endif
-static void init_ports(void)
+static int
+is_radio_power_attr_mtcdt(struct attribute *attr)
{
- if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA) && attr_group_lora) {
- mts_load_lora_port();
- }
-
- init_accessory_ports();
+ return (attr == &dev_attr_radio_power.attr);
}
+/* End of mths.c */
-static void teardown_ports(void)
-{
- if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA) && attr_group_lora) {
- mts_teardown_lora_port();
- }
+#include "mtcap.c"
+#include "mtr.c"
+#include "mths.c"
- teardown_accessory_ports();
-}
+/* include capabilities sub-directory support */
+#include "mts_capab.c"
-struct attribute *freelater = NULL; // Storage to free when driver is unloaded.
+struct attribute **freelater = NULL; // Storage to free when driver is unloaded.
static int
mts_id_eeprom_load(void)
@@ -1021,11 +1320,11 @@ mts_id_eeprom_load(void)
static void cleanup(void)
{
log_info("cleaning up....");
+
if (mts_io_platform_device) {
platform_device_unregister(mts_io_platform_device);
}
- teardown_ports();
if(freelater) {
kfree(freelater);
freelater = NULL;
@@ -1060,7 +1359,9 @@ static int __init mts_io_init(void)
return ret;
}
- init_ports();
+ if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA) && attr_group_lora) {
+ mts_load_lora_port();
+ }
ret = mts_capab_dir_create();
if (ret) {
@@ -1093,14 +1394,21 @@ static int __init mts_io_init(void)
static void __exit mts_io_exit(void)
{
+ struct gpio_pin *pin;
/* delete radio_reset_timer */
del_timer(&radio_reset_timer);
/* delete radio_reset_available_timer */
del_timer(&radio_reset_available_timer);
+ for (pin = gpio_pins; *pin->name; pin++)
+ if (pin->capability == 0 || DEVICE_CAPA(id_eeprom.capa,pin->capability))
+ gpio_free(pin->pin.gpio);
+
cleanup_buttons();
cleanup();
-
+ if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA) && attr_group_lora) {
+ mts_teardown_lora_port();
+ }
log_info("exiting");
}
@@ -1111,10 +1419,3 @@ MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_VERSION(DRIVER_VERSION);
MODULE_LICENSE("GPL");
-
-MODULE_ALIAS("mts-io-ap1-dout");
-MODULE_ALIAS("mts-io-ap1-din");
-MODULE_ALIAS("mts-io-ap1-adc");
-MODULE_ALIAS("mts-io-ap2-dout");
-MODULE_ALIAS("mts-io-ap2-din");
-MODULE_ALIAS("mts-io-ap2-adc");