diff options
author | John Klug <john.klug@multitech.com> | 2021-08-10 17:41:33 -0500 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2021-08-10 18:38:46 -0500 |
commit | bc918398a517f618ac102cde2ade494924a85a0c (patch) | |
tree | 326f7cfa35c7fc20463076f06d180b4088392171 /io-module/mts-io.c | |
parent | aa29d434b31002c0946036a4f3de14a7de4cfb27 (diff) | |
download | mts-io-bc918398a517f618ac102cde2ade494924a85a0c.tar.gz mts-io-bc918398a517f618ac102cde2ade494924a85a0c.tar.bz2 mts-io-bc918398a517f618ac102cde2ade494924a85a0c.zip |
MTCAP3-0.0 mts-io version 4.6.04.6.0
Diffstat (limited to 'io-module/mts-io.c')
-rw-r--r-- | io-module/mts-io.c | 60 |
1 files changed, 46 insertions, 14 deletions
diff --git a/io-module/mts-io.c b/io-module/mts-io.c index cb1c48e..e4290a6 100644 --- a/io-module/mts-io.c +++ b/io-module/mts-io.c @@ -85,7 +85,7 @@ static int mts_io_probe(struct platform_device *pdev) { return 0; } - + static int mts_io_remove(struct platform_device *pdev) { return 0; @@ -672,13 +672,14 @@ static int get_radio_model_from_product_id(void) { #include "machine/mths.c" #include "machine/mtcpm.c" #include "machine/mt100eocg.c" +#include "machine/mtcap3.c" /* include capabilities sub-directory support */ #include "mts_capab.c" struct attribute **freelater = NULL; // Storage to free when driver is unloaded. -static int +static int mts_id_eeprom_load(void) { int i, j = 0; @@ -695,7 +696,7 @@ mts_id_eeprom_load(void) int ret; const struct firmware* fw = NULL; - /* Attempt to load the mts-io driver */ + /* Attempt to load the mts-io driver */ if((ret = request_firmware_direct(&fw, "0-0056/eeprom", &mts_io_platform_device->dev)) == 0) { if(fw->size == sizeof(id_eeprom)) { memcpy(&id_eeprom, fw->data, sizeof(id_eeprom)); @@ -704,13 +705,13 @@ mts_id_eeprom_load(void) 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; } - + /* If we are an MTCPM-0.0, the base board sets the radio existance, and we always * add the radio-reset, etc */ if (strncmp(id_eeprom.hw_version,HW_VERSION_MTCPM_0_0,sizeof HW_VERSION_MTCPM_0_0) != 0) { @@ -722,7 +723,7 @@ mts_id_eeprom_load(void) } log_debug("mts_id_eeprom_load: noradio=%d",noradio); } - + if (((tmp=HW_VERSION_MTCAP_0_0),(mts_hw_version=MTCAP_0_0),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) || ((tmp=HW_VERSION_MTCAP_0_1),(mts_hw_version=MTCAP_0_1),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) || ((tmp=HW_VERSION_MTCAP_0_2),(mts_hw_version=MTCAP_0_2),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) || @@ -803,6 +804,37 @@ mts_id_eeprom_load(void) attr_group_lora = &mtcap_0_0_lora_attribute_group; } log_info("detected board %s", tmp); + } else if ((tmp=HW_VERSION_MTCAP3_0_0),strncmp(id_eeprom.hw_version, tmp, strlen(tmp)) == 0) { + current_blength = attr_blength = sizeof mtcap3_0_0_platform_attributes; + current_blength -= sizeof(struct attribute *); /* Length without terminating NULL */ + + if(noradio) { + struct attribute **ap = mtcap3_0_0_platform_attribute_group.attrs; + while(1) { + if(ap[j] == NULL) { + log_info("Did not find radio reset attribute. Possible driver fault."); + break; + } + j++; + if (is_radio_power_attr_mtcap3(ap[j])) { + log_info("Pruning radio feature from mts-io",j); + ap[j] = NULL; + current_blength = j * sizeof (ap[j]); /* Size without NULL */ + attr_blength += sizeof (ap[j]); /* Size of attr array with NULL */ + break; + } + } + } + + if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA)) { + attr_group_lora = &mtcap3_0_0_lora_attribute_group; + } + + attr_group = &mtcap3_0_0_platform_attribute_group; + gpio_pins = gpio_pins_mtcap3_0_0; + set_buttons(default_buttons); + mts_hw_version = MTCAP3_0_0; + log_info("detected board %s", HW_VERSION_MTCAP3_0_0); } else if (strncmp(id_eeprom.hw_version, HW_VERSION_MTRE, strlen(HW_VERSION_MTRE)) == 0) { attr_group = &mtre_0_0_platform_attribute_group; gpio_pins = gpio_pins_mtre_0_0; @@ -955,7 +987,7 @@ mts_id_eeprom_load(void) all_attrs[current_count] = (struct attribute *)NULL; mtcdt_0_1_platform_attribute_group.attrs = all_attrs; } - + attr_group = &mtcdt_0_1_platform_attribute_group; gpio_pins = gpio_pins_mtcdt_0_1; if (DEVICE_CAPA(id_eeprom.capa, CAPA_LORA)) { @@ -1056,7 +1088,7 @@ mts_id_eeprom_load(void) 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); + log_info("detected board %s", HW_VERSION_MT100EOCG_0_0); } else { int i; @@ -1188,7 +1220,7 @@ static int __init mts_io_init(void) if (ret) printk(KERN_ERR "mts-io: probe failed: %d\n", ret); platform_driver_unregister(&mts_io_driver); - + mts_io_platform_device = platform_device_alloc(PLATFORM_NAME, -1); if (!mts_io_platform_device) return -ENOMEM; @@ -1211,7 +1243,7 @@ static int __init mts_io_init(void) 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) { @@ -1250,10 +1282,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(); @@ -1277,7 +1309,7 @@ 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); } @@ -1292,7 +1324,7 @@ static void __exit mts_io_exit(void) 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 supercap monitor worker if SUPERCAP CAPA is true |