summaryrefslogtreecommitdiff
path: root/io-module/machine
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2020-02-25 13:06:26 -0600
committerJohn Klug <john.klug@multitech.com>2020-02-25 13:06:26 -0600
commit937d21665a614dee618e48b51389d3a1e27709bf (patch)
treeb20a98b3d3c0778c6e3c2e2a919a10d4fae063e3 /io-module/machine
parentace6855ee90434b77bdf99f915804584251a6ea1 (diff)
downloadmts-io-4.3.0.tar.gz
mts-io-4.3.0.tar.bz2
mts-io-4.3.0.zip
Support mtcpm CPU board4.3.0
Diffstat (limited to 'io-module/machine')
-rw-r--r--io-module/machine/mtcap.c536
-rw-r--r--io-module/machine/mtcdt.c481
-rw-r--r--io-module/machine/mtcpm.c297
-rw-r--r--io-module/machine/mths.c883
-rw-r--r--io-module/machine/mtr.c2001
5 files changed, 4198 insertions, 0 deletions
diff --git a/io-module/machine/mtcap.c b/io-module/machine/mtcap.c
new file mode 100644
index 0000000..bd08d5a
--- /dev/null
+++ b/io-module/machine/mtcap.c
@@ -0,0 +1,536 @@
+#include "at91gpio.h"
+/* Used for both MTCAP 0.0 and 0.1 */
+static struct gpio_pin gpio_pins_mtcap_0_0[] = {
+ {
+ .name = "ETH_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC6, // NETH_RST
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "eth-reset",
+ },
+ },
+ {
+ .name = "RADIO_POWER_MONITOR",
+ .pin = {
+ .gpio = AT91_PIN_PD21, // PWRMON
+ .flags = GPIOF_IN,
+ .label = "radio-power-monitor",
+ },
+ },
+ {
+ .name = "RADIO_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PA22, // 3G_RST
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "radio-reset",
+ },
+ },
+ {
+ .name = "RADIO_POWER",
+ .pin = {
+ .gpio = AT91_PIN_PA21, // 3G_ONOFF
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "radio-power",
+ },
+ },
+ {
+ .name = "DEVICE_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC4, // OPT_RST
+ .flags = GPIOF_IN,
+ .label = "reset",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LORA_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PA8, // LORA_RST
+ .flags = GPIOF_OUT_INIT_LOW,
+ .label = "lora/reset",
+ },
+ .capability = CAPA_LORA,
+ .active_low = 1,
+ },
+ { // gpio 1 for LORA 1.5 ref design
+ .name = "LORA_CDONE",
+ .pin = {
+ .gpio = AT91_PIN_PA6,
+ .flags = GPIOF_IN,
+ .label = "lora/cdone",
+ },
+ .capability = CAPA_LORA,
+ },
+ { // gpio 2 for LORA 1.5 ref design
+ .name = "LORA_CRESET",
+ .pin = {
+ .gpio = AT91_PIN_PA29,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "lora/creset",
+ },
+ .capability = CAPA_LORA,
+ },
+
+
+ /* LEDs */
+ {
+ .name = "STATUS_LED", // DEV_LED_GN
+ .pin = {
+ .gpio = AT91_PIN_PC25,
+ .flags = GPIOF_OUT_INIT_LOW,
+ .label = "led-status",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED2", // LED2 is for LoRa status
+ .pin = {
+ .gpio = AT91_PIN_PC15,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-lora",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED3", // LED3 is for Cellular status (Modem can directly enable it)
+ .pin = {
+ .gpio = AT91_PIN_PC16,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-cd",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED4", // LED4 is for WiFi status
+ .pin = {
+ .gpio = AT91_PIN_PC20,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-wifi",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "WLAN_EN",
+ .pin = {
+ .gpio = AT91_PIN_PA4,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "wlan-en",
+ },
+ },
+ {
+ .name = "WLAN_RST",
+ .pin = {
+ .gpio = AT91_PIN_PA3,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "wlan-rst",
+ },
+ },
+ { },
+};
+
+static int radio_unconditional_shutdown_mtcap(void)
+{
+ struct gpio_pin *rst_pin = gpio_pin_by_attr_name("radio-reset");
+ struct gpio_pin *pwrmon_pin = gpio_pin_by_attr_name("radio-power-monitor");
+ int value;
+ int i;
+
+ if (!rst_pin || !pwrmon_pin) {
+ return -ENODEV;
+ }
+
+ // To unconditionally shutdown the LE910, the pad HW_SHUTDOWN* must
+ // be tied low for at least 200 milliseconds and then released.
+ reset_gpio_pin(rst_pin, 500, 0);
+
+ msleep(100);
+
+ // Wait for the power off
+ for (i = 0; i < 5; i++) {
+ value = gpio_get_value(pwrmon_pin->pin.gpio);
+ if (value != 0) {
+ log_warning("radio is still on.");
+ msleep(500);
+ continue;
+ }
+ log_warning("radio has been shutdown unconditionally");
+ break;
+ }
+
+ return 0;
+}
+
+
+/* radio control (power/reset) for mtcap */
+static int radio_off_mtcap(int radio_model)
+{
+ // ref: Telit_LE910_Hardware_User_Guide_r6.pdf (4.3.2 Hardware Shutdown)
+ struct gpio_pin *pwrmon_pin = gpio_pin_by_attr_name("radio-power-monitor");
+ struct gpio_pin *onoff_pin = gpio_pin_by_attr_name("radio-power");
+ struct gpio_pin *rst_pin = gpio_pin_by_attr_name("radio-reset");
+ unsigned int hold_time;
+ int value;
+ int i;
+
+ if (!onoff_pin || !pwrmon_pin || !rst_pin) {
+ return -ENODEV;
+ }
+
+ value = gpio_get_value(pwrmon_pin->pin.gpio);
+ if(value == 0) {
+ log_warning("cell radio is already off");
+ return 0;
+ }
+
+ log_info("turning off cell radio");
+
+ // To turn OFF LE910 the pad ON/OFF# must be tied low for at least 2 seconds and then
+ // released. Same circuitry and timing for the power on must be used. When the hold
+ // time of ON/OFF# is above 2 seconds, LE910 goes into the finalization state and
+ // finally will shut down PWRMON at the end of this state. The period of the
+ // finalization state can differ according to the situation in which the LE910 is so it
+ // cannot be fixed definitely. Normally it will be above 15 seconds later from releasing
+ // ON/OFF# and DTE should monitor the status of PWRMON to see the actual power off.
+ hold_time = 2500;
+ if (radio_model == RADIO_LNA3 || radio_model == RADIO_LEU3) {
+
+ // To turn OFF the LE910 V2 the pad ON_OFF* must be tied low for at least 3 seconds and then released.
+ // ref: Telit_LE910_V2_Hardware_User_Guide_r7.pdf
+ hold_time = 3500;
+ }
+
+ reset_gpio_pin(onoff_pin, hold_time, 0);
+ msleep(200); // Give time for pin to change state before inspection.
+
+ value = 0;
+ for (i = 0; i < 15; i++) {
+ // check that power is low
+ value = gpio_get_value(pwrmon_pin->pin.gpio);
+ if (value != 0) {
+ log_info("cell radio is still on. keep waiting...");
+ msleep(2000);
+ continue;
+ }
+ break;
+ }
+
+ if (value == 0) {
+ log_info("cell radio has been shut down");
+ }
+ else {
+ log_warning("cell radio is still on. performing unconditional shutdown...");
+ radio_unconditional_shutdown_mtcap();
+ }
+
+ return 0;
+}
+
+static int radio_on_mtcap(int radio_model)
+{
+ // ref: Telit_LE910_Hardware_User_Guide_r6.pdf
+ struct gpio_pin *pwrmon_pin = gpio_pin_by_attr_name("radio-power-monitor");
+ struct gpio_pin *onoff_pin = gpio_pin_by_attr_name("radio-power");
+ struct gpio_pin *rst_pin = gpio_pin_by_attr_name("radio-reset");
+ unsigned int hold_time;
+ int value;
+
+ if (!onoff_pin || !pwrmon_pin || !rst_pin) {
+ return -ENODEV;
+ }
+
+ value = gpio_get_value(pwrmon_pin->pin.gpio);
+ if(value != 0) {
+ log_warning("cell radio is already on");
+ return 0;
+ }
+
+ log_info("turning on cell radio");
+
+ // for LEU1 (ref: Telit_LE910_Hardware_User_Guide_r6.pdf)
+ hold_time = 1500;
+ if (radio_model == RADIO_LNA3 || radio_model == RADIO_LEU3) {
+
+ // To turn on the LE910 V2 the pad ON_OFF* must be tied low for at least 5 seconds and then released.
+ // ref: Telit_LE910_V2_Hardware_User_Guide_r7.pdf
+ // ref:Telit_LE910_V2_Hardware_User_Guide_r9.pdf
+ // pg 32: When USB is connected or after firmware updating,
+ // delay must be equal at least to 10 seconds.
+ hold_time = 10500;
+ }
+
+ // drive on/off pin high for at least 1 seconoff_pin
+ gpio_set_value(onoff_pin->pin.gpio, 1);
+ msleep(1000);
+
+ // ON_OFF must be tied low and then released
+ reset_gpio_pin(onoff_pin, hold_time, 0);
+ msleep(200); // Make sure modem has had time to move the status pin
+ // check that power is high
+ value = gpio_get_value(pwrmon_pin->pin.gpio);
+ if(value == 0) {
+ log_warning("cell radio is still off.");
+ } else {
+ log_info("cell radio has been turned on");
+ }
+
+ return 0;
+}
+
+static int radio_reset_mtcap(int radio_model)
+{
+ // ref: Telit_LE910_Hardware_User_Guide_r6.pdf
+ struct gpio_pin *rst_pin = gpio_pin_by_attr_name("radio-reset");
+ struct gpio_pin *onoff_pin = gpio_pin_by_attr_name("radio-power");
+ unsigned int hold_time;
+
+ if (!rst_pin || !onoff_pin) {
+ return -ENODEV;
+ }
+
+ //
+ // Unconditional shutdown
+ //
+
+ log_info("performing unconditional cell radio shutdown");
+
+ radio_unconditional_shutdown_mtcap();
+
+ //
+ // Turning on radio
+ //
+ log_info("turning on cell radio for reset");
+
+ // for LEU1 (ref: Telit_LE910_Hardware_User_Guide_r6.pdf)
+ hold_time = 1500;
+ if (radio_model == RADIO_LNA3 || radio_model == RADIO_LEU3) {
+ // To turn on the LE910 V2 the pad ON_OFF* must be tied low for at least 5 seconds and then released.
+ // ref: Telit_LE910_V2_Hardware_User_Guide_r7.pdf
+ // ref:Telit_LE910_V2_Hardware_User_Guide_r9.pdf
+ // pg 32: When USB is connected or after firmware updating,
+ // delay must be equal at least to 10 seconds.
+ //
+ // Note that a hold time of 5.5 seconds on MTCAP
+ // with Verizon Firmware 20.00.12 will cause a
+ // radio-reset to power the LE910-NA1 off until
+ // a reload of the mts-io driver, or a reboot.
+ hold_time = 10500;
+ }
+
+ // drive on/off pin high for at least 1 sec
+ gpio_set_value(onoff_pin->pin.gpio, 1);
+ msleep(1000);
+
+
+ // drive on/off pin low for < 2 sec
+ // drive on/off pin high
+ log_info("turning off cell radio for reset");
+ reset_gpio_pin(onoff_pin, hold_time, 0);
+ log_info("Reset is complete. Wait for power monitor pin");
+ msleep(200); // Make sure modem has had time to move the status pin
+ return 0;
+}
+
+static ssize_t mts_attr_store_radio_power_mtcap(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ int value;
+ int err;
+ int radio_model = get_radio_model_from_product_id();
+
+ if (sscanf(buf, "%i", &value) != 1) {
+ return -EINVAL;
+ }
+
+ mutex_lock(&mts_io_mutex);
+ if (value == 0) {
+ err = radio_off_mtcap(radio_model);
+ } else {
+ err = radio_on_mtcap(radio_model);
+ }
+ mutex_unlock(&mts_io_mutex);
+
+ if (err) {
+ return err;
+ }
+
+ return count;
+}
+
+static ssize_t mts_attr_store_radio_reset_mtcap(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count)
+{
+ int value; /* 0 = normal reset; -1 = forced reset */
+ int err;
+ int radio_model = get_radio_model_from_product_id();
+
+ if (sscanf(buf, "%i", &value) != 1) {
+ return -EINVAL;
+ }
+
+ if (value != 0 && value != -1) {
+ return -EINVAL;
+ }
+
+ /* check reset timings is enabled */
+ if (value != -1 && NULL != timings_data) {
+ /* check reset timer is started */
+ if (radio_reset_timer_is_start == 1) {
+ log_info("cell radio reset timer is running. \n");
+ return count;
+ }
+
+ /* check reset timer available is started */
+ if (radio_reset_available_timer_is_start == 1) {
+ del_timer(&radio_reset_available_timer);
+ radio_reset_available_timer_is_start = 0;
+ }
+
+ /* reset timer not started, start it */
+ mod_timer(&radio_reset_timer, jiffies + msecs_to_jiffies((timings_data[timings_data_index]) * 1000));
+ //log_info("radio reset timer is start = [%d]\n", time_now_secs());
+ /* save timings_data_stop_seconds */
+ timings_data_stop_seconds = timings_data[timings_data_index] + time_now_secs();
+ radio_reset_timer_is_start = 1;
+ }
+
+ mutex_lock(&mts_io_mutex);
+
+ err = radio_reset_mtcap(radio_model);
+
+ mutex_unlock(&mts_io_mutex);
+
+ if (err) {
+ return err;
+ }
+
+ return count;
+}
+
+static ssize_t mts_attr_show_radio_power_mtcap(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ int value;
+ struct gpio_pin *pwrmon_pin = gpio_pin_by_attr_name("radio-power-monitor");
+
+ if ( !pwrmon_pin ) {
+ return -ENODEV;
+ }
+
+ value = gpio_get_value(pwrmon_pin->pin.gpio);
+ return sprintf(buf, "%d\n", value);
+}
+
+static DEVICE_ATTR_MTS(dev_attr_radio_reset_mtcap, "radio-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_radio_reset_mtcap);
+
+static DEVICE_ATTR_MTS(dev_attr_radio_power_mtcap, "radio-power",
+ mts_attr_show_radio_power_mtcap, mts_attr_store_radio_power_mtcap);
+
+static DEVICE_ATTR_MTS(dev_attr_eth_reset_mtcap, "eth-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+
+static DEVICE_ATTR_MTS(dev_attr_led_lora_gpio_mtcap, "led-lora",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+
+static DEVICE_ATTR_MTS(dev_attr_led_wifi_gpio_mtcap, "led-wifi",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+
+static DEVICE_ATTR_MTS(dev_attr_wlan_en_gpio_mtcap, "wlan-en",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+
+static DEVICE_ATTR_MTS(dev_attr_wlan_rst_gpio_mtcap, "wlan-rst",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+
+static struct attribute *mtcap_0_0_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_eth_reset_mtcap.attr,
+ &dev_attr_led_status.attr,
+ &dev_attr_led_cd_gpio.attr,
+ &dev_attr_led_lora_gpio_mtcap.attr,
+ &dev_attr_led_wifi_gpio_mtcap.attr,
+
+ &dev_attr_wlan_en_gpio_mtcap.attr,
+ &dev_attr_wlan_rst_gpio_mtcap.attr,
+
+ /* Set to NULL if no radio -- should be 1st radio attribute */
+ &dev_attr_radio_power_mtcap.attr,
+ &dev_attr_radio_reset_mtcap.attr,
+
+ &dev_attr_radio_reset_backoffs.attr,
+ &dev_attr_radio_reset_backoff_index.attr,
+ &dev_attr_radio_reset_backoff_seconds.attr,
+
+ NULL,
+};
+
+static int
+is_radio_power_attr_mtcap(struct attribute *attr)
+{
+ return (attr == &dev_attr_radio_power_mtcap.attr);
+}
+
+static struct attribute_group mtcap_0_0_platform_attribute_group = {
+ .attrs = mtcap_0_0_platform_attributes
+};
+
+
+//
+// on-board LORA attributes are to be stored in the lora/ sub-directory
+//
+//
+static DEVICE_ATTR_MTS(dev_attr_lora_reset_mtcap, "reset",
+ mts_attr_show_lora_gpio_pin, mts_attr_store_lora_gpio_pin);
+
+static DEVICE_ATTR_RO_MTS(dev_attr_lora_cdone_mtcap, "cdone",
+ mts_attr_show_lora_gpio_pin);
+
+static DEVICE_ATTR_MTS(dev_attr_lora_creset_mtcap, "creset",
+ mts_attr_show_lora_gpio_pin, mts_attr_store_lora_gpio_pin);
+
+static DEVICE_ATTR_RO_MTS(dev_attr_lora_eui_mtcap, "eui",
+ mts_attr_show_lora_product_info);
+
+static DEVICE_ATTR_RO_MTS(dev_attr_lora_product_id_mtcap, "product-id",
+ mts_attr_show_lora_product_info);
+
+static DEVICE_ATTR_RO_MTS(dev_attr_lora_hw_version_mtcap, "hw-version",
+ mts_attr_show_lora_product_info);
+
+static struct attribute *mtcap_0_0_lora_attributes[] = {
+ &dev_attr_lora_eui_mtcap.attr,
+ &dev_attr_lora_product_id_mtcap.attr,
+ &dev_attr_lora_hw_version_mtcap.attr,
+ &dev_attr_lora_reset_mtcap.attr,
+ &dev_attr_lora_cdone_mtcap.attr,
+ &dev_attr_lora_creset_mtcap.attr,
+ NULL,
+};
+
+static struct attribute_group mtcap_0_0_lora_attribute_group = {
+ .attrs = mtcap_0_0_lora_attributes
+};
+
+// Reset for LoRa firmware is done using the I2C bus
+// on the MTCDTIPHP LoRa board.
+static struct attribute *mtcdtiphp_0_0_lora_attributes[] = {
+ &dev_attr_lora_eui_mtcap.attr,
+ &dev_attr_lora_product_id_mtcap.attr,
+ &dev_attr_lora_hw_version_mtcap.attr,
+ NULL,
+};
+
+static struct attribute_group mtcdtiphp_0_0_lora_attribute_group = {
+ .attrs = mtcdtiphp_0_0_lora_attributes
+};
diff --git a/io-module/machine/mtcdt.c b/io-module/machine/mtcdt.c
new file mode 100644
index 0000000..575dd1e
--- /dev/null
+++ b/io-module/machine/mtcdt.c
@@ -0,0 +1,481 @@
+#include "at91gpio.h"
+/*
+ * 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_mtcdt_0_0[] = {
+ {
+ .name = "RADIO_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC3,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "radio-reset",
+ },
+ },
+ {
+ .name = "RADIO_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC3,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "radio-power",
+ },
+ },
+ {
+ .name = "DEVICE_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC2,
+ .flags = GPIOF_IN,
+ .label = "reset",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "ETH_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC4,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "eth-reset",
+ }
+ },
+ {
+ .name = "LS_LED", /* LED7 */
+ .pin = {
+ .gpio = AT91_PIN_PA14,
+#if LED_LS_CONTROLLABLE
+ .flags = GPIOF_OUT_INIT_HIGH,
+#else
+ .flags = GPIOF_IN,
+#endif
+ .label = "led-ls",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "STATUS_LED", /* LED2 */
+ .pin = {
+ .gpio = AT91_PIN_PA24,
+ .flags = GPIOF_OUT_INIT_LOW,
+ .label = "led-status",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED5",
+ .pin = {
+ .gpio = AT91_PIN_PA25,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-cd",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED5",
+ .pin = {
+ .gpio = AT91_PIN_PA25,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-a",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED1",
+ .pin = {
+ .gpio = AT91_PIN_PA26,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig1",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED1",
+ .pin = {
+ .gpio = AT91_PIN_PA26,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-b",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED4",
+ .pin = {
+ .gpio = AT91_PIN_PA27,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig2",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED4",
+ .pin = {
+ .gpio = AT91_PIN_PA27,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-c",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED3",
+ .pin = {
+ .gpio = AT91_PIN_PA28,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig3",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED3",
+ .pin = {
+ .gpio = AT91_PIN_PA28,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-d",
+ },
+ .active_low = 1,
+ },
+};
+
+static struct gpio_pin gpio_pins_mtcdt_0_1[] = {
+ {
+ .name = "RADIO_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC3,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "radio-reset",
+ },
+ },
+ {
+ .name = "RADIO_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC3,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "radio-power",
+ },
+ },
+ {
+ .name = "DEVICE_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC2,
+ .flags = GPIOF_IN,
+ .label = "reset",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LS_LED", /* LED7 */
+ .pin = {
+ .gpio = AT91_PIN_PA14,
+#if LED_LS_CONTROLLABLE
+ .flags = GPIOF_OUT_INIT_HIGH,
+#else
+ .flags = GPIOF_IN,
+#endif
+ .label = "led-ls",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "STATUS_LED", /* LED2 */
+ .pin = {
+ .gpio = AT91_PIN_PA24,
+ .flags = GPIOF_OUT_INIT_LOW,
+ .label = "led-status",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED5",
+ .pin = {
+ .gpio = AT91_PIN_PA25,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-cd",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED5",
+ .pin = {
+ .gpio = AT91_PIN_PA25,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-a",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED1",
+ .pin = {
+ .gpio = AT91_PIN_PA26,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig1",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED1",
+ .pin = {
+ .gpio = AT91_PIN_PA26,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-b",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED4",
+ .pin = {
+ .gpio = AT91_PIN_PA27,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig2",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED4",
+ .pin = {
+ .gpio = AT91_PIN_PA27,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-c",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED3",
+ .pin = {
+ .gpio = AT91_PIN_PA28,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-sig3",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "LED3",
+ .pin = {
+ .gpio = AT91_PIN_PA28,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "led-d",
+ },
+ .active_low = 1,
+ },
+ {
+ .name = "ETH_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PC4,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "eth-reset",
+ }
+ },
+ {
+ .name = "WIFI_BT_ULPWKUP",
+ .pin = {
+ .gpio = AT91_PIN_PA0,
+ .flags = GPIOF_IN,
+ .label = "wifi-bt-ulpwkup",
+ },
+ .capability = CAPA_WIFI,
+ },
+ {
+ .name = "WIFI_BT_LPWKUP",
+ .pin = {
+ .gpio = AT91_PIN_PA6,
+ .flags = GPIOF_IN,
+ .label = "wifi-bt-lpwkup",
+ },
+ .capability = CAPA_WIFI,
+ },
+ {
+ .name = "WIFI_BT_INT",
+ .pin = {
+ .gpio = AT91_PIN_PB11,
+ .flags = GPIOF_IN,
+ .label = "wifi-bt-int",
+ },
+ .capability = CAPA_WIFI,
+ },
+ {
+ .name = "WIFI_BT_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PD14,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "wifi-bt-reset",
+ },
+ .capability = CAPA_WIFI,
+ },
+ {
+ .name = "GNSS_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PD15,
+ .flags = GPIOF_OUT_INIT_LOW, /* Keep GPS quiet during boot for EXAR */
+ .label = "gnss-reset",
+ },
+ .capability = CAPA_GPS,
+ },
+ {
+ .name = "SECURE_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PD16,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "secure-reset",
+ }
+ },
+ {
+ .name = "MTQ_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PD17,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "mtq-reset",
+ }
+ },
+ {
+ .name = "USBHUB_RESET",
+ .pin = {
+ .gpio = AT91_PIN_PD18,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "usbhub-reset",
+ }
+ },
+ {
+ .name = "GNSS_INT",
+ .pin = {
+ .gpio = AT91_PIN_PD19,
+ .flags = GPIOF_OUT_INIT_HIGH,
+ .label = "gnss-int",
+ },
+ .capability = CAPA_GPS,
+ },
+ {
+ .name = "WIFI_BT_LPMODE",
+ .pin = {
+ .gpio = AT91_PIN_PD20,
+ .flags = GPIOF_IN,
+ .label = "wifi-bt-lpmode",
+ },
+ .capability = CAPA_WIFI,
+ },
+ { },
+};
+
+static DEVICE_ATTR_MTS(dev_attr_wifi_bt_lpwkup, "wifi-bt-lpwkup",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_wifi_bt_ulpwkup, "wifi-bt-ulpwkup",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_wifi_bt_reset, "wifi-bt-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_RO_MTS(dev_attr_wifi_bt_lpmode, "wifi-bt-lpmode",
+ mts_attr_show_gpio_pin);
+static DEVICE_ATTR_RO_MTS(dev_attr_wifi_bt_int, "wifi-bt-int",
+ mts_attr_show_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_gnss_reset, "gnss-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_usbhub_reset, "usbhub-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_eth_reset, "eth-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_gnss_int, "gnss-int",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_RO_MTS(dev_attr_wifi_mac, "mac-wifi",
+ mts_attr_show_product_info);
+static DEVICE_ATTR_RO_MTS(dev_attr_bluetooth_mac, "mac-bluetooth",
+ mts_attr_show_product_info);
+
+static struct attribute *mtcdt_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_led_a_gpio.attr,
+ &dev_attr_led_b_gpio.attr,
+ &dev_attr_led_c_gpio.attr,
+ &dev_attr_led_d_gpio.attr,
+ &dev_attr_eth_reset.attr,
+
+ &dev_attr_radio_power.attr,
+ &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,
+ NULL,
+};
+
+static struct attribute *mtcdt_0_1_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_led_a_gpio.attr,
+ &dev_attr_led_b_gpio.attr,
+ &dev_attr_led_c_gpio.attr,
+ &dev_attr_led_d_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,
+
+ NULL,
+};
+
+static struct attribute *mtcdt_0_1_wifi_bt_attributes[] = {
+ &dev_attr_wifi_bt_lpwkup.attr,
+ &dev_attr_wifi_bt_ulpwkup.attr,
+ &dev_attr_wifi_bt_reset.attr,
+ &dev_attr_wifi_bt_lpmode.attr,
+ &dev_attr_wifi_bt_int.attr,
+ &dev_attr_bluetooth_mac.attr,
+ &dev_attr_wifi_mac.attr,
+};
+
+static struct attribute *mtcdt_0_1_gnss_attributes[] = {
+ &dev_attr_gnss_reset.attr,
+ &dev_attr_gnss_int.attr,
+};
+
+
+static struct attribute_group mtcdt_platform_attribute_group = {
+ .attrs = mtcdt_platform_attributes
+};
+static struct attribute_group mtcdt_0_1_platform_attribute_group = {
+ .attrs = mtcdt_0_1_platform_attributes
+};
+
+
+static int
+is_radio_power_attr_mtcdt(struct attribute *attr)
+{
+ return (attr == &dev_attr_radio_power.attr);
+}
diff --git a/io-module/machine/mtcpm.c b/io-module/machine/mtcpm.c
new file mode 100644
index 0000000..8167218
--- /dev/null
+++ b/io-module/machine/mtcpm.c
@@ -0,0 +1,297 @@
+#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_mtcpm[] = {
+ {
+ .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 = 1,
+ },
+ {
+ .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_mtcpm, "wlan-enabled",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_bt_reset_mtcpm, "bt-enabled",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_RO_MTS(dev_attr_wifi_bt_int_mtcpm, "wifi-bt-int",
+ mts_attr_show_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_gnss_reset_mtcpm, "gnss-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_usbhub_reset_mtcpm, "usbhub-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_eth_reset_mtcpm, "eth-reset",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_gnss_int_mtcpm, "gnss-int",
+ mts_attr_show_gpio_pin, mts_attr_store_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_lora_reset_mtcpm, "reset",
+ mts_attr_show_lora_gpio_pin, mts_attr_store_lora_gpio_pin);
+static DEVICE_ATTR_RO_MTS(dev_attr_lora_cdone_mtcpm, "cdone",
+ mts_attr_show_lora_gpio_pin);
+static DEVICE_ATTR_MTS(dev_attr_lora_creset_mtcpm, "creset",
+ mts_attr_show_lora_gpio_pin, mts_attr_store_lora_gpio_pin);
+static DEVICE_ATTR_RO_MTS(dev_attr_lora_eui_mtcpm, "eui",
+ mts_attr_show_lora_product_info);
+static DEVICE_ATTR_RO_MTS(dev_attr_lora_product_id_mtcpm, "product-id",
+ mts_attr_show_lora_product_info);
+static DEVICE_ATTR_RO_MTS(dev_attr_lora_hw_version_mtcpm, "hw-version",
+ mts_attr_show_lora_product_info);
+static DEVICE_ATTR_RO_MTS(dev_attr_wifi_mac_mtcpm, "mac-wifi",
+ mts_attr_show_product_info);
+static DEVICE_ATTR_RO_MTS(dev_attr_bluetooth_mac_mtcpm, "mac-bluetooth",
+ mts_attr_show_product_info);
+
+static struct attribute *mtcpm_platform_attributes[] = {
+ &dev_attr_imei.attr,
+ &dev_attr_eth_mac.attr,
+ &dev_attr_reset.attr,
+ &dev_attr_reset_monitor.attr,
+ &dev_attr_reset_monitor_in