diff options
Diffstat (limited to 'io-module/mts-io.c')
-rw-r--r-- | io-module/mts-io.c | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/io-module/mts-io.c b/io-module/mts-io.c index f224777..af77ed6 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -4,6 +4,7 @@ * Copyright (C) 2014 by Multi-Tech Systems * Copyright (C) 2016 by Multi-Tech Systems * 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 @@ -20,7 +21,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ - +#include <linux/clk.h> #include <linux/delay.h> #include <linux/ioctl.h> #include <linux/input.h> @@ -35,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> @@ -71,6 +71,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 @@ -83,7 +88,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) @@ -104,8 +113,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); @@ -128,6 +135,8 @@ static time_t time_now_secs(void); /* generic GPIO support */ #include "gpio.c" +#include "spi.c" + /* generic Button support */ //#include "buttons.c" @@ -622,6 +631,7 @@ static int get_radio_model_from_product_id(void) { #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" @@ -686,7 +696,7 @@ mts_id_eeprom_load(void) } attr_group = &mtcap_0_0_platform_attribute_group; gpio_pins = gpio_pins_mtcap_0_0; - set_buttons(default_buttons); + set_buttons(default_buttons); if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA)) { attr_group_lora = &mtcap_0_0_lora_attribute_group; } @@ -863,11 +873,17 @@ mts_id_eeprom_load(void) 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); + 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; @@ -1009,6 +1025,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(); } @@ -1052,6 +1085,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); |