/* * 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 = ~0U, .flags = GPIOD_OUT_HIGH, .label = "radio-reset", }, .do_gpio_desc = 1 }, #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 = ~0U, .flags = GPIOD_IN, .label = "reset", }, .do_gpio_desc = 1, .active_low = 1, }, { .name = "WIFI_BT_INT", .pin = { .gpio = ~0U, .flags = GPIOD_IN, .label = "wifi-bt-int", }, .do_gpio_desc = 1, .capability = CAPA_BLUETOOTH, }, { .name = "WIFI_RESET", .pin = { .gpio = ~0U, .flags = GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, .label = "wlan-enabled", }, .do_gpio_desc = 1, .capability = CAPA_WIFI, .active_low = 0, }, { .name = "BT_RESET", .pin = { .gpio = ~0U, .flags = GPIOD_OUT_HIGH, .label = "bt-enabled", }, .do_gpio_desc = 1, .capability = CAPA_BLUETOOTH, .active_low = 0, }, { .name = "USBHUB_RESET", .pin = { .gpio = ~0U, .flags = GPIOD_OUT_HIGH, .label = "usbhub-reset", }, .do_gpio_desc = 1, .active_low = 0, }, { .name = "ETH_RESET", .pin = { .gpio = ~0U, .flags = GPIOD_OUT_HIGH, .label = "eth-reset", }, .do_gpio_desc = 1, .active_low = 0, }, { .name = "GNSS_INT", .pin = { .gpio = ~0U, .flags = GPIOD_OUT_HIGH, .label = "gnss-int", }, .do_gpio_desc = 1, .capability = CAPA_GPS, }, { .name = "GNSS_RESET", .pin = { .gpio = ~0U, /* 5_10 */ .flags = GPIOD_OUT_HIGH, .label = "gnss-reset", }, .do_gpio_desc = 1, .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 { }, }; static struct mts_led mtcpmhs_leds[] = { {.label = "led-cd",}, /* (cellular) Link Status */ {.label = "led-sig1",}, /* (cellular) Link Quality */ {.label = "led-sig2",}, /* (cellular) Link Quality */ {.label = "led-sig3",}, /* (cellular) Link Quality */ {.label = "led-status",}, /* (cellular) Device Status */ {} }; 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_MTS(dev_attr_led_cd_mtcpm, "led-cd", mts_attr_show_led, mts_attr_store_led); static DEVICE_ATTR_MTS(dev_attr_led_sig1_mtcpm, "led-sig1", mts_attr_show_led, mts_attr_store_led); static DEVICE_ATTR_MTS(dev_attr_led_sig2_mtcpm, "led-sig2", mts_attr_show_led, mts_attr_store_led); static DEVICE_ATTR_MTS(dev_attr_led_sig3_mtcpm, "led-sig3", mts_attr_show_led, mts_attr_store_led); static DEVICE_ATTR_MTS(dev_attr_led_status_mtcpm, "led-status", mts_attr_show_led, mts_attr_store_led); 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_mtcpm.attr, &dev_attr_led_cd_mtcpm.attr, &dev_attr_led_sig1_mtcpm.attr, &dev_attr_led_sig2_mtcpm.attr, &dev_attr_led_sig3_mtcpm.attr, &dev_attr_usbhub_reset.attr, &dev_attr_eth_reset.attr, // radio-reset must be first for mtcdt3 &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, // UDEV notification of radio discovery &dev_attr_radio_udev_discovery.attr, &dev_attr_radio_reset_monitor.attr, NULL, }; static struct attribute *mtcpm_has_radio_attribute[] = { &dev_attr_has_radio.attr, }; static struct attribute *mtcpm_wifi_bt_attributes[] = { &dev_attr_wifi_reset_mtcpm.attr, &dev_attr_bt_reset_mtcpm.attr, &dev_attr_wifi_bt_int_mtcpm.attr, &dev_attr_wifi_mac_mtcpm.attr, &dev_attr_bluetooth_mac_mtcpm.attr, }; static struct attribute *mtcpm_gnss_attributes[] = { &dev_attr_gnss_reset_mtcpm.attr, &dev_attr_gnss_int_mtcpm.attr, }; static struct attribute_group mtcpm_platform_attribute_group = { .attrs = mtcpm_platform_attributes }; 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 && hw_version != MTCPM_0_1) 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; } } static int is_radio_reset_attr_mtcpm(struct attribute *attr) { return (attr == &dev_attr_radio_reset.attr); }