summaryrefslogtreecommitdiff
path: root/io-module/machine/mtcdt.c
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/mtcdt.c
parentace6855ee90434b77bdf99f915804584251a6ea1 (diff)
downloadmts-io-937d21665a614dee618e48b51389d3a1e27709bf.tar.gz
mts-io-937d21665a614dee618e48b51389d3a1e27709bf.tar.bz2
mts-io-937d21665a614dee618e48b51389d3a1e27709bf.zip
Support mtcpm CPU board4.3.0
Diffstat (limited to 'io-module/machine/mtcdt.c')
-rw-r--r--io-module/machine/mtcdt.c481
1 files changed, 481 insertions, 0 deletions
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);
+}