]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
platform/x86: x86-android-tablets: Add swnode for Xiaomi pad2 indicator LED
authorKate Hsuan <hpa@redhat.com>
Fri, 22 Mar 2024 03:37:31 +0000 (11:37 +0800)
committerHans de Goede <hdegoede@redhat.com>
Mon, 8 Apr 2024 13:22:22 +0000 (15:22 +0200)
There is a KTD2026 LED controller to manage the indicator LED for Xiaomi
pad2. The ACPI for it is not properly made so the kernel can't get
a correct description of it.

This work adds a description for this RGB LED controller and also sets
a trigger to indicate the charging event (bq27520-0-charging). When it
is charging, the indicator LED will be turned on.

Signed-off-by: Kate Hsuan <hpa@redhat.com>
Link: https://lore.kernel.org/r/20240322033736.9344-2-hpa@redhat.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/x86-android-tablets/other.c

index 278402dcb808c5f2b7e25a894c117177867250d0..ce487b3c972cb02ffa268db598a8927f96f80c1a 100644 (file)
@@ -13,6 +13,8 @@
 #include <linux/input.h>
 #include <linux/platform_device.h>
 
+#include <dt-bindings/leds/common.h>
+
 #include "shared-psy-info.h"
 #include "x86-android-tablets.h"
 
@@ -593,6 +595,83 @@ const struct x86_dev_info whitelabel_tm800a550l_info __initconst = {
        .gpiod_lookup_tables = whitelabel_tm800a550l_gpios,
 };
 
+/*
+ * The fwnode for ktd2026 on Xaomi pad2. It composed of a RGB LED node
+ * with three subnodes for each color (B/G/R). The RGB LED node is named
+ * "multi-led" to align with the name in the device tree.
+ */
+
+/* main fwnode for ktd2026 */
+static const struct software_node ktd2026_node = {
+       .name = "ktd2026",
+};
+
+static const struct property_entry ktd2026_rgb_led_props[] = {
+       PROPERTY_ENTRY_U32("reg", 0),
+       PROPERTY_ENTRY_U32("color", LED_COLOR_ID_RGB),
+       PROPERTY_ENTRY_STRING("function", "indicator"),
+       PROPERTY_ENTRY_STRING("linux,default-trigger", "bq27520-0-charging"),
+       { }
+};
+
+static const struct software_node ktd2026_rgb_led_node = {
+       .name = "multi-led",
+       .properties = ktd2026_rgb_led_props,
+       .parent = &ktd2026_node,
+};
+
+static const struct property_entry ktd2026_blue_led_props[] = {
+       PROPERTY_ENTRY_U32("reg", 0),
+       PROPERTY_ENTRY_U32("color", LED_COLOR_ID_BLUE),
+       { }
+};
+
+static const struct software_node ktd2026_blue_led_node = {
+       .properties = ktd2026_blue_led_props,
+       .parent = &ktd2026_rgb_led_node,
+};
+
+static const struct property_entry ktd2026_green_led_props[] = {
+       PROPERTY_ENTRY_U32("reg", 1),
+       PROPERTY_ENTRY_U32("color", LED_COLOR_ID_GREEN),
+       { }
+};
+
+static const struct software_node ktd2026_green_led_node = {
+       .properties = ktd2026_green_led_props,
+       .parent = &ktd2026_rgb_led_node,
+};
+
+static const struct property_entry ktd2026_red_led_props[] = {
+       PROPERTY_ENTRY_U32("reg", 2),
+       PROPERTY_ENTRY_U32("color", LED_COLOR_ID_RED),
+       { }
+};
+
+static const struct software_node ktd2026_red_led_node = {
+       .properties = ktd2026_red_led_props,
+       .parent = &ktd2026_rgb_led_node,
+};
+
+static const struct software_node *ktd2026_node_group[] = {
+       &ktd2026_node,
+       &ktd2026_rgb_led_node,
+       &ktd2026_green_led_node,
+       &ktd2026_blue_led_node,
+       &ktd2026_red_led_node,
+       NULL
+};
+
+static int __init xiaomi_mipad2_init(void)
+{
+       return software_node_register_node_group(ktd2026_node_group);
+}
+
+static void xiaomi_mipad2_exit(void)
+{
+       software_node_unregister_node_group(ktd2026_node_group);
+}
+
 /*
  * If the EFI bootloader is not Xiaomi's own signed Android loader, then the
  * Xiaomi Mi Pad 2 X86 tablet sets OSID in the DSDT to 1 (Windows), causing
@@ -616,6 +695,7 @@ static const struct x86_i2c_client_info xiaomi_mipad2_i2c_clients[] __initconst
                        .type = "ktd2026",
                        .addr = 0x30,
                        .dev_name = "ktd2026",
+                       .swnode = &ktd2026_node,
                },
                .adapter_path = "\\_SB_.PCI0.I2C3",
        },
@@ -624,4 +704,6 @@ static const struct x86_i2c_client_info xiaomi_mipad2_i2c_clients[] __initconst
 const struct x86_dev_info xiaomi_mipad2_info __initconst = {
        .i2c_client_info = xiaomi_mipad2_i2c_clients,
        .i2c_client_count = ARRAY_SIZE(xiaomi_mipad2_i2c_clients),
+       .init = xiaomi_mipad2_init,
+       .exit = xiaomi_mipad2_exit,
 };