diff options
author | Mike Nicholson <mike.nicholson@multitech.com> | 2021-10-26 08:37:02 -0500 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2021-11-22 15:39:28 -0600 |
commit | c4d11d25f6f64a5178121b1f458d5ce6743abe2b (patch) | |
tree | dba7c574bafd6fbc07f65834bb36250afc8b2587 | |
parent | 4caa55839f3b41b0ac85eafac5938ecfc019182f (diff) | |
download | mts-io-c4d11d25f6f64a5178121b1f458d5ce6743abe2b.tar.gz mts-io-c4d11d25f6f64a5178121b1f458d5ce6743abe2b.tar.bz2 mts-io-c4d11d25f6f64a5178121b1f458d5ce6743abe2b.zip |
Revision A hardware support
-rw-r--r-- | io-module/machine/mtcap3.c | 111 |
1 files changed, 22 insertions, 89 deletions
diff --git a/io-module/machine/mtcap3.c b/io-module/machine/mtcap3.c index 587a024..8f6668f 100644 --- a/io-module/machine/mtcap3.c +++ b/io-module/machine/mtcap3.c @@ -7,9 +7,13 @@ static struct gpio_pin gpio_pins_mtcap3_0_0[] = { .name = "ETH_RESET", .pin = { .gpio = NXP_GPIO(1, 4), // ETH_NRST - has ext PU - .flags = GPIOF_OUT_INIT_HIGH, + .flags = GPIOF_OUT_INIT_HIGH, .label = "eth-reset", }, + // mts-io in init leaves eth-reset asserted even though it is really + // an nrst pin, and does this across boards. This is wrong logically, + // but active_low must be 0 as legacy and for this to function properly. + .active_low = 0, }, { .name = "RADIO_POWER_MONITOR", @@ -44,6 +48,14 @@ static struct gpio_pin gpio_pins_mtcap3_0_0[] = { }, }, { + .name = "RADIO_NETLIGHT", // LED4 is for cell network status + .pin = { + .gpio = NXP_GPIO(4, 25), + .flags = GPIOF_IN, + .label = "radio-netlight", + }, + }, + { .name = "DEVICE_RESET", .pin = { .gpio = NXP_GPIO(2, 13), // SWITCH_IN - has EXT PU @@ -55,7 +67,7 @@ static struct gpio_pin gpio_pins_mtcap3_0_0[] = { { .name = "LORA_RESET", .pin = { - .gpio = NXP_GPIO(1, 5), // LORA_RST + .gpio = NXP_GPIO(1, 25), // LORA_RST .flags = GPIOF_OUT_INIT_LOW, .label = "lora/reset", }, @@ -83,7 +95,7 @@ static struct gpio_pin gpio_pins_mtcap3_0_0[] = { { .name = "LED2", // LED2 is for LoRa status .pin = { - .gpio = NXP_GPIO(3, 27), + .gpio = NXP_GPIO(3, 21), .flags = GPIOF_OUT_INIT_LOW, .label = "led-lora", }, @@ -91,35 +103,17 @@ static struct gpio_pin gpio_pins_mtcap3_0_0[] = { { .name = "LED3", // LED3 is for Cellular status (Modem can directly enable it) .pin = { - .gpio = NXP_GPIO(5, 5), + .gpio = NXP_GPIO(3, 22), .flags = GPIOF_OUT_INIT_HIGH, .label = "led-cd", }, - // Procesor side is hooked up to drain; module on gate - .active_low = 1, }, { .name = "LED4", // LED4 is for power status .pin = { - .gpio = NXP_GPIO(3, 28), + .gpio = NXP_GPIO(3, 23), .flags = GPIOF_OUT_INIT_LOW, - .label = "led-extra", - }, - }, - { - .name = "LORA_VCORE", // LoRa Core Voltage - comes up and goes down before vio - .pin = { - .gpio = NXP_GPIO(2, 12), - .flags = GPIOF_OUT_INIT_HIGH, - .label = "lora/vcore-enable", - }, - }, - { - .name = "LORA_VIO", // LoRa IO Voltage; goes up and comes down after vcore - .pin = { - .gpio = NXP_GPIO(2, 14), - .flags = GPIOF_OUT_INIT_HIGH, - .label = "lora/vio-enable", + .label = "led-power", }, }, // NXP_GPIO(3, 28), LED_EXTRA on the Rev 0 schem., is always on power @@ -296,63 +290,6 @@ static ssize_t mts_attr_show_radio_enable_mtcap3(struct device *dev, return sprintf(buf, "%d\n", 1); } -static ssize_t mts_attr_store_lora_power_mtcap3(struct device *dev, - struct device_attribute *attr, const char *buf, size_t count) -{ - int value; - int err; - struct gpio_pin *vcore_pin = gpio_pin_by_attr_name("lora/vcore-enable"); - struct gpio_pin *vio_pin = gpio_pin_by_attr_name("lora/vio-enable"); - - if ( !vcore_pin || !vio_pin) { - return -ENODEV; - } - - if (sscanf(buf, "%i", &value) != 1) { - return -EINVAL; - } - - mutex_lock(&mts_io_mutex); - if (value == 0) { - gpio_set_value(vio_pin->pin.gpio, 0); - msleep(20); - gpio_set_value(vcore_pin->pin.gpio, 0); - log_info("LoRa VCORE/VIO disabled"); - } else if (value == 1) { - gpio_set_value(vcore_pin->pin.gpio, 1); - msleep(20); - gpio_set_value(vio_pin->pin.gpio, 1); - log_info("LoRa VCORE/VIO enabled"); - } else { - err = -EINVAL; - } - mutex_unlock(&mts_io_mutex); - - if (err) { - return err; - } - - return count; -} - -static ssize_t mts_attr_show_lora_power_mtcap3(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - int value; - struct gpio_pin *vcore_pin = gpio_pin_by_attr_name("lora/vcore-enable"); - struct gpio_pin *vio_pin = gpio_pin_by_attr_name("lora/vio-enable"); - - if ( !vcore_pin || !vio_pin) { - return -ENODEV; - } - - value = gpio_get_value(vcore_pin->pin.gpio); - value += gpio_get_value(vio_pin->pin.gpio) * 2; - - return sprintf(buf, "%d\n", value); -} - static ssize_t mts_attr_store_radio_reset_mtcap3(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { @@ -451,13 +388,13 @@ static DEVICE_ATTR_MTS(dev_attr_eth_reset_mtcap3, "eth-reset", static DEVICE_ATTR_MTS(dev_attr_led_lora_gpio_mtcap3, "led-lora", mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); -static DEVICE_ATTR_MTS(dev_attr_led_extra_gpio_mtcap3, "led-extra", - mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); - // here to maintain compatiblility static DEVICE_ATTR_MTS(dev_attr_radio_enable_mtcap3, "radio-enable", mts_attr_show_radio_enable_mtcap3, mts_attr_store_radio_enable_mtcap3); +static DEVICE_ATTR_MTS(dev_attr_led_power_gpio_mtcap3, "led-power", + mts_attr_show_gpio_pin, mts_attr_store_gpio_pin); + static struct attribute *mtcap3_0_0_platform_attributes[] = { &dev_attr_vendor_id.attr, @@ -476,7 +413,7 @@ static struct attribute *mtcap3_0_0_platform_attributes[] = { &dev_attr_led_status.attr, &dev_attr_led_cd_gpio.attr, &dev_attr_led_lora_gpio_mtcap3.attr, - &dev_attr_led_extra_gpio_mtcap3.attr, + &dev_attr_led_power_gpio_mtcap3.attr, /* Set to NULL if no radio -- should be 1st radio attribute */ &dev_attr_radio_reset_mtcap3.attr, @@ -515,9 +452,6 @@ static DEVICE_ATTR_MTS(dev_attr_lora_reset_mtcap3, "reset", static DEVICE_ATTR_MTS(dev_attr_lora_lbt_reset_mtcap3, "lbt-reset", mts_attr_show_lora_gpio_pin, mts_attr_store_lora_gpio_pin); -static DEVICE_ATTR_MTS(dev_attr_lora_power_enable_mtcap3, "power-enable", - mts_attr_show_lora_power_mtcap3, mts_attr_store_lora_power_mtcap3); - static DEVICE_ATTR_RO_MTS(dev_attr_lora_eui_mtcap3, "eui", mts_attr_show_lora_product_info); @@ -533,7 +467,6 @@ static struct attribute *mtcap3_0_0_lora_attributes[] = { &dev_attr_lora_hw_version_mtcap3.attr, &dev_attr_lora_reset_mtcap3.attr, &dev_attr_lora_lbt_reset_mtcap3.attr, - &dev_attr_lora_power_enable_mtcap3.attr, NULL, }; |