diff options
author | John Klug <john.klug@multitech.com> | 2020-02-25 17:55:49 -0600 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2020-02-25 17:55:49 -0600 |
commit | 62f1d67abe1f4e79542c3cca683b40beb2eeda02 (patch) | |
tree | 554b675f8a972c73961dd615bd50093d8cd9a9f7 /io-module/machine/mtcpm.c | |
parent | 0a4a5f96dd649a5c5e18d43d7bd206f35845e1cb (diff) | |
download | mts-io-4.3.1.tar.gz mts-io-4.3.1.tar.bz2 mts-io-4.3.1.zip |
mts-io based on thud/4.19 kernel for mt100eocg4.3.1
Diffstat (limited to 'io-module/machine/mtcpm.c')
-rw-r--r-- | io-module/machine/mtcpm.c | 297 |
1 files changed, 297 insertions, 0 deletions
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_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_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, + + &dev_attr_wifi_reset_mtcpm.attr, + &dev_attr_bt_reset_mtcpm.attr, + &dev_attr_wifi_bt_int_mtcpm.attr, + + &dev_attr_gnss_reset_mtcpm.attr, + &dev_attr_gnss_int_mtcpm.attr, + &dev_attr_wifi_mac_mtcpm.attr, + &dev_attr_bluetooth_mac_mtcpm.attr, + NULL, +}; + + + +static struct attribute_group mtcpm_platform_attribute_group = { + .attrs = mtcpm_platform_attributes +}; + +static int +is_radio_power_attr_mtcpm(struct attribute *attr) +{ + return (attr == &dev_attr_radio_power.attr); +} + +static struct attribute *mtcpm_lora_attributes[] = { + &dev_attr_lora_eui_mtcpm.attr, + &dev_attr_lora_product_id_mtcpm.attr, + &dev_attr_lora_hw_version_mtcpm.attr, + &dev_attr_lora_reset_mtcpm.attr, + &dev_attr_lora_cdone_mtcpm.attr, + &dev_attr_lora_creset_mtcpm.attr, + NULL, +}; + +static struct attribute_group mtcpm_lora_attribute_group = { + .attrs = mtcpm_lora_attributes +}; + +static struct attribute *mtcpm_cpu_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, + NULL, +}; + + +static struct attribute_group mtcpm_cpu_attribute_group = { + .attrs = mtcpm_cpu_attributes +}; + +static struct kobject *mts_cpu_kobject = NULL; + +static int mts_cpu_dir_create(uint8_t hw_version) +{ + if (hw_version != MTCPM_0_0) + return 0; + + mts_cpu_kobject = kobject_create_and_add("cpu", &mts_io_platform_device->dev.kobj); + if (!mts_cpu_kobject) { + log_error("kobject_create_and_add for cpu directory failed"); + return -ENOMEM; + } + + if (sysfs_create_group(mts_cpu_kobject, &mtcpm_cpu_attribute_group)) { + log_error("sysfs_create_group failed to create cpu group"); + return -ENOMEM; + } + + return 0; +} + +static void mts_cpu_dir_delete(void) +{ + if (mts_cpu_kobject) { + kobject_put(mts_cpu_kobject); + mts_cpu_kobject = NULL; + } +} + |