diff options
-rw-r--r-- | io-module/buttons.h | 4 | ||||
-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) | 2 | ||||
-rw-r--r-- | io-module/machine/mtcdt3.c | 252 | ||||
-rw-r--r-- | io-module/machine/mths.c (renamed from io-module/mths.c) | 4 | ||||
-rw-r--r-- | io-module/machine/mtr.c (renamed from io-module/mtr.c) | 6 | ||||
-rw-r--r-- | io-module/mts-io.c | 36 | ||||
-rw-r--r-- | io-module/mts_io_module.h | 10 |
8 files changed, 297 insertions, 17 deletions
diff --git a/io-module/buttons.h b/io-module/buttons.h index c9cd198..ef80f34 100644 --- a/io-module/buttons.h +++ b/io-module/buttons.h @@ -27,6 +27,10 @@ #include <linux/ctype.h> #include <linux/io.h> #include <linux/module.h> +#include <linux/version.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0) +#include <linux/signalfd.h> +#endif #include "mts_io_module.h" #include "mts_io.h" 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..095a120 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, diff --git a/io-module/machine/mtcdt3.c b/io-module/machine/mtcdt3.c new file mode 100644 index 0000000..373fc47 --- /dev/null +++ b/io-module/machine/mtcdt3.c @@ -0,0 +1,252 @@ +#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/mths.c b/io-module/machine/mths.c index a51380c..16d43d7 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", } }, diff --git a/io-module/mtr.c b/io-module/machine/mtr.c index e47beae..c12eacf 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", } }, diff --git a/io-module/mts-io.c b/io-module/mts-io.c index 954da63..ef28a7c 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -125,9 +125,6 @@ static volatile int radio_reset_timer_is_start = 0; static struct timer_list radio_reset_available_timer; static volatile int radio_reset_available_timer_is_start = 0; static time_t time_now_secs(void); -static void radio_reset_available_timer_callback(unsigned long data); -static void radio_reset_timer_callback(unsigned long data); - /* generic GPIO support */ #include "gpio.c" @@ -271,7 +268,11 @@ static time_t time_now_secs(void) return ts.tv_sec; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0) +static void radio_reset_available_timer_callback( struct timer_list *data ) +#else static void radio_reset_available_timer_callback( unsigned long data ) +#endif { /* do your timer stuff here */ //log_info("radio_reset_available_timer_callback\n"); @@ -283,7 +284,11 @@ static void radio_reset_available_timer_callback( unsigned long data ) radio_reset_available_timer_is_start = 0; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0) +static void radio_reset_timer_callback( struct timer_list *data ) +#else static void radio_reset_timer_callback( unsigned long data ) +#endif { /* do your timer stuff here */ //log_info("radio_reset_timer_callback\n"); @@ -603,10 +608,11 @@ 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 "machine/mtcdt.c" +#include "machine/mtcap.c" +#include "machine/mtr.c" +#include "machine/mths.c" +#include "machine/mtcdt3.c" /* include capabilities sub-directory support */ #include "mts_capab.c" @@ -817,6 +823,16 @@ 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; + set_buttons(default_buttons); + mts_hw_version = HW_VERSION_MTCDT3_0_0; + log_info("detected board %s", HW_VERSION_MTCDT3_0_0); } else { if(noradio) { struct attribute **ap = mtcdt_platform_attribute_group.attrs; @@ -987,9 +1003,13 @@ static int __init mts_io_init(void) init_buttons(); /* init timers */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0) + timer_setup(&radio_reset_timer, radio_reset_timer_callback, 0); + timer_setup(&radio_reset_available_timer, radio_reset_available_timer_callback, 0); +#else setup_timer(&radio_reset_timer, radio_reset_timer_callback, 0); setup_timer(&radio_reset_available_timer, radio_reset_available_timer_callback, 0); - +#endif return 0; } diff --git a/io-module/mts_io_module.h b/io-module/mts_io_module.h index 6a84d4c..65a072a 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.4" +#define DRIVER_VERSION "v4.1.10" #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,10 +37,14 @@ #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_MTCDT3 "MTCDT3" + +#define HW_VERSION_MTCDT3_0_0 "MTCDT3-0.0" + enum { MTCDP_E1_DK_0_0, MTCDP_E1_DK_1_0, |