From 88c747744d74a808ab5de0e6232327918c70ecbd Mon Sep 17 00:00:00 2001 From: Volodymyr Vorobiov Date: Mon, 28 Oct 2019 17:06:38 +0200 Subject: Initial commit of mt100eocg suport --- io-module/mts-io.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'io-module/mts-io.c') diff --git a/io-module/mts-io.c b/io-module/mts-io.c index 5e557fd..6899aac 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -134,6 +134,8 @@ static void radio_reset_timer_callback(unsigned long data); /* generic GPIO support */ #include "gpio.c" +#include "spi.c" + /* generic Button support */ //#include "buttons.c" @@ -610,7 +612,7 @@ static int get_radio_model_from_product_id(void) { #include "mtcap.c" #include "mtr.c" #include "mths.c" - +#include "mt100eocg.c" /* include capabilities sub-directory support */ #include "mts_capab.c" @@ -819,6 +821,12 @@ mts_id_eeprom_load(void) } 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 { if(noradio) { struct attribute **ap = mtcdt_platform_attribute_group.attrs; -- cgit v1.2.3 From 0f09f38ceaed0ce4f676facb02046095724fb4bf Mon Sep 17 00:00:00 2001 From: Volodymyr Vorobiov Date: Tue, 29 Oct 2019 18:17:27 +0200 Subject: Add mt100eocg spi io --- io-module/mts-io.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'io-module/mts-io.c') diff --git a/io-module/mts-io.c b/io-module/mts-io.c index 6899aac..489f0d5 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -969,6 +969,23 @@ static int __init mts_io_init(void) return ret; } + if (DEVICE_CAPA(id_eeprom.capa, CAPA_DOUT)) { + ret = spi_register_driver(&mts_spi_dout_driver); + if (ret) { + printk(KERN_ERR "mts-io:mts-io-dout: probe failed: %d\n", ret); + } + } + if (DEVICE_CAPA(id_eeprom.capa, CAPA_DIN)) { + ret = spi_register_driver(&mts_spi_din_driver); + if (ret) { + printk(KERN_ERR "mts-io:mts-io-din: probe failed: %d\n", ret); + } + } + ret = spi_register_driver(&mts_spi_board_temp_driver); + if (ret) { + printk(KERN_ERR "mts-io:mts-io-board-temp: probe failed: %d\n", ret); + } + if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA) && attr_group_lora) { mts_load_lora_port(); } @@ -1004,6 +1021,14 @@ static int __init mts_io_init(void) static void __exit mts_io_exit(void) { + if (DEVICE_CAPA(id_eeprom.capa, CAPA_DOUT)) { + spi_unregister_driver(&mts_spi_dout_driver); + } + if (DEVICE_CAPA(id_eeprom.capa, CAPA_DIN)) { + spi_unregister_driver(&mts_spi_din_driver); + } + spi_unregister_driver(&mts_spi_board_temp_driver); + struct gpio_pin *pin; /* delete radio_reset_timer */ del_timer(&radio_reset_timer); -- cgit v1.2.3 From 57651686d90c05a186604a27a532834fa7979c15 Mon Sep 17 00:00:00 2001 From: Volodymyr Vorobiov Date: Fri, 13 Dec 2019 15:40:14 +0200 Subject: Add ADC to mts-io --- io-module/mts-io.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'io-module/mts-io.c') diff --git a/io-module/mts-io.c b/io-module/mts-io.c index 489f0d5..8c35f74 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -23,7 +23,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ - +#include #include #include #include @@ -74,6 +74,11 @@ static const struct of_device_id mts_io_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, mts_io_dt_ids); +/* on-board EEPROM */ +static struct mts_id_eeprom_layout id_eeprom; + +#include "adc.c" + /* * We must call platform_set_drvdata, or else the * devres_head for the driver has junk in it, and @@ -86,7 +91,11 @@ MODULE_DEVICE_TABLE(of, mts_io_dt_ids); */ static int mts_io_probe(struct platform_device *pdev) { - return 0; + int ret = 0; + if (!DEVICE_CAPA(id_eeprom.capa, CAPA_ADC)) { + ret = mts_io_board_adc_probe(pdev); + } + return ret; } static int mts_io_remove(struct platform_device *pdev) @@ -107,8 +116,6 @@ static struct platform_driver mts_io_driver = { }; -/* on-board EEPROM */ -static struct mts_id_eeprom_layout id_eeprom; static uint8_t mts_hw_version; struct platform_device *mts_io_platform_device; EXPORT_SYMBOL(mts_io_platform_device); -- cgit v1.2.3 From ce0d4983a61b0fed699bf67cf4c1f6472cc92d87 Mon Sep 17 00:00:00 2001 From: John Klug Date: Wed, 24 Jul 2019 16:44:35 -0500 Subject: New 4.19 kernel replaced setup_timer with timer_setup (cherry picked from commit a0c2b0390d8a92d89fcda252f9e09275446d01dd) --- io-module/mts-io.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'io-module/mts-io.c') diff --git a/io-module/mts-io.c b/io-module/mts-io.c index 8c35f74..66ded86 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -135,8 +135,8 @@ 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); +static void radio_reset_available_timer_callback(struct timer_list *list); +static void radio_reset_timer_callback(struct timer_list *list); /* generic GPIO support */ #include "gpio.c" @@ -283,7 +283,7 @@ static time_t time_now_secs(void) return ts.tv_sec; } -static void radio_reset_available_timer_callback( unsigned long data ) +static void radio_reset_available_timer_callback( struct timer_list *data ) { /* do your timer stuff here */ //log_info("radio_reset_available_timer_callback\n"); @@ -295,7 +295,7 @@ static void radio_reset_available_timer_callback( unsigned long data ) radio_reset_available_timer_is_start = 0; } -static void radio_reset_timer_callback( unsigned long data ) +static void radio_reset_timer_callback( struct timer_list *data ) { /* do your timer stuff here */ //log_info("radio_reset_timer_callback\n"); @@ -1020,9 +1020,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; } -- cgit v1.2.3 From 0a4a5f96dd649a5c5e18d43d7bd206f35845e1cb Mon Sep 17 00:00:00 2001 From: Mike Nicholson Date: Tue, 6 Aug 2019 15:50:30 -0500 Subject: Add correct timer cb proto for kernel < 4.15.0 (cherry picked from commit 9cae1b197308e0ed093596c984bae21ded4e7ec8) --- io-module/mts-io.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'io-module/mts-io.c') diff --git a/io-module/mts-io.c b/io-module/mts-io.c index 66ded86..154d120 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -135,9 +135,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(struct timer_list *list); -static void radio_reset_timer_callback(struct timer_list *list); - /* generic GPIO support */ #include "gpio.c" @@ -283,7 +280,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"); @@ -295,7 +296,11 @@ static void radio_reset_available_timer_callback( struct timer_list *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"); -- cgit v1.2.3 From 62f1d67abe1f4e79542c3cca683b40beb2eeda02 Mon Sep 17 00:00:00 2001 From: John Klug Date: Tue, 25 Feb 2020 17:55:49 -0600 Subject: mts-io based on thud/4.19 kernel for mt100eocg --- io-module/mts-io.c | 118 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 82 insertions(+), 36 deletions(-) (limited to 'io-module/mts-io.c') 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 - * Jesse Gilles - * Mike Fiore + * 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 #include #include -#include #include #include #include @@ -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;iname, ret); } } + + // Create CPU directory if approprate (only MTCDT3 for now) + ret = mts_cpu_dir_create(mts_hw_version); + // start general buttons processing init_buttons(); -- cgit v1.2.3