#include <linux/acpi.h>
#include <linux/gpio/machine.h>
#include <linux/gpio/property.h>
#include <linux/input-event-codes.h>
#include <linux/leds.h>
#include <linux/pci.h>
#include <linux/platform_device.h>
#include <linux/pwm.h>
#include <dt-bindings/leds/common.h>
#include "shared-psy-info.h"
#include "x86-android-tablets.h"
static const struct software_node advantech_mica_071_gpio_keys_node = {
.name = "prog1_key",
};
static const struct property_entry advantech_mica_071_prog1_key_props[] = {
PROPERTY_ENTRY_U32("linux,code", KEY_PROG1),
PROPERTY_ENTRY_STRING("label", "prog1_key"),
PROPERTY_ENTRY_GPIO("gpios", &baytrail_gpiochip_nodes[0], 2, GPIO_ACTIVE_LOW),
PROPERTY_ENTRY_U32("debounce-interval", 50),
{ }
};
static const struct software_node advantech_mica_071_prog1_key_node = {
.parent = &advantech_mica_071_gpio_keys_node,
.properties = advantech_mica_071_prog1_key_props,
};
static const struct software_node *advantech_mica_071_button_swnodes[] = {
&advantech_mica_071_gpio_keys_node,
&advantech_mica_071_prog1_key_node,
NULL
};
const struct x86_dev_info advantech_mica_071_info __initconst = {
.gpio_button_swnodes = advantech_mica_071_button_swnodes,
.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
};
static const struct property_entry chuwi_hi8_gsl1680_props[] = {
PROPERTY_ENTRY_U32("touchscreen-size-x", 1665),
PROPERTY_ENTRY_U32("touchscreen-size-y", 1140),
PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
PROPERTY_ENTRY_BOOL("silead,home-button"),
PROPERTY_ENTRY_STRING("firmware-name", "gsl1680-chuwi-hi8.fw"),
{ }
};
static const struct software_node chuwi_hi8_gsl1680_node = {
.properties = chuwi_hi8_gsl1680_props,
};
static const char * const chuwi_hi8_mount_matrix[] = {
"1", "0", "0",
"0", "-1", "0",
"0", "0", "1"
};
static const struct property_entry chuwi_hi8_bma250e_props[] = {
PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", chuwi_hi8_mount_matrix),
{ }
};
static const struct software_node chuwi_hi8_bma250e_node = {
.properties = chuwi_hi8_bma250e_props,
};
static const struct x86_i2c_client_info chuwi_hi8_i2c_clients[] __initconst = {
{
.board_info = {
.type = "gsl1680",
.addr = 0x40,
.swnode = &chuwi_hi8_gsl1680_node,
},
.adapter_path = "\\_SB_.I2C4",
.irq_data = {
.type = X86_ACPI_IRQ_TYPE_APIC,
.index = 0x44,
.trigger = ACPI_EDGE_SENSITIVE,
.polarity = ACPI_ACTIVE_HIGH,
},
}, {
.board_info = {
.type = "bma250e",
.addr = 0x18,
.swnode = &chuwi_hi8_bma250e_node,
},
.adapter_path = "\\_SB_.I2C3",
.irq_data = {
.type = X86_ACPI_IRQ_TYPE_GPIOINT,
.chip = "INT33FC:02",
.index = 23,
.trigger = ACPI_LEVEL_SENSITIVE,
.polarity = ACPI_ACTIVE_HIGH,
.con_id = "bma250e_irq",
},
},
};
static int __init chuwi_hi8_init(struct device *dev)
{
if (acpi_dev_present("MSSL0001", NULL, 1))
return -ENODEV;
return 0;
}
const struct x86_dev_info chuwi_hi8_info __initconst = {
.i2c_client_info = chuwi_hi8_i2c_clients,
.i2c_client_count = ARRAY_SIZE(chuwi_hi8_i2c_clients),
.init = chuwi_hi8_init,
};
static const struct software_node cyberbook_t116_gpio_keys_node = {
.name = "prog_keys",
};
static const struct property_entry cyberbook_t116_prog1_key_props[] = {
PROPERTY_ENTRY_U32("linux,code", KEY_PROG1),
PROPERTY_ENTRY_STRING("label", "prog1_key"),
PROPERTY_ENTRY_GPIO("gpios", &cherryview_gpiochip_nodes[0], 30, GPIO_ACTIVE_LOW),
PROPERTY_ENTRY_U32("debounce-interval", 50),
{ }
};
static const struct software_node cyberbook_t116_prog1_key_node = {
.parent = &cyberbook_t116_gpio_keys_node,
.properties = cyberbook_t116_prog1_key_props,
};
static const struct property_entry cyberbook_t116_prog2_key_props[] = {
PROPERTY_ENTRY_U32("linux,code", KEY_PROG2),
PROPERTY_ENTRY_STRING("label", "prog2_key"),
PROPERTY_ENTRY_GPIO("gpios", &cherryview_gpiochip_nodes[3], 48, GPIO_ACTIVE_LOW),
PROPERTY_ENTRY_U32("debounce-interval", 50),
{ }
};
static const struct software_node cyberbook_t116_prog2_key_node = {
.parent = &cyberbook_t116_gpio_keys_node,
.properties = cyberbook_t116_prog2_key_props,
};
static const struct software_node *cyberbook_t116_buttons_swnodes[] = {
&cyberbook_t116_gpio_keys_node,
&cyberbook_t116_prog1_key_node,
&cyberbook_t116_prog2_key_node,
NULL
};
const struct x86_dev_info cyberbook_t116_info __initconst = {
.gpio_button_swnodes = cyberbook_t116_buttons_swnodes,
.gpiochip_type = X86_GPIOCHIP_CHERRYVIEW,
};
#define CZC_EC_EXTRA_PORT 0x68
#define CZC_EC_ANDROID_KEYS 0x63
static int __init czc_p10t_init(struct device *dev)
{
outb(CZC_EC_ANDROID_KEYS, CZC_EC_EXTRA_PORT);
return 0;
}
const struct x86_dev_info czc_p10t __initconst = {
.init = czc_p10t_init,
};
static const char * const medion_lifetab_s10346_accel_mount_matrix[] = {
"0", "1", "0",
"1", "0", "0",
"0", "0", "1"
};
static const struct property_entry medion_lifetab_s10346_accel_props[] = {
PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", medion_lifetab_s10346_accel_mount_matrix),
{ }
};
static const struct software_node medion_lifetab_s10346_accel_node = {
.properties = medion_lifetab_s10346_accel_props,
};
static const struct property_entry medion_lifetab_s10346_touchscreen_props[] = {
PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
PROPERTY_ENTRY_GPIO("reset-gpios", &baytrail_gpiochip_nodes[1], 26, GPIO_ACTIVE_HIGH),
PROPERTY_ENTRY_GPIO("irq-gpios", &baytrail_gpiochip_nodes[2], 3, GPIO_ACTIVE_HIGH),
{ }
};
static const struct software_node medion_lifetab_s10346_touchscreen_node = {
.properties = medion_lifetab_s10346_touchscreen_props,
};
static const struct x86_i2c_client_info medion_lifetab_s10346_i2c_clients[] __initconst = {
{
.board_info = {
.type = "kxtj21009",
.addr = 0x0f,
.dev_name = "kxtj21009",
.swnode = &medion_lifetab_s10346_accel_node,
},
.adapter_path = "\\_SB_.I2C3",
.irq_data = {
.type = X86_ACPI_IRQ_TYPE_GPIOINT,
.chip = "INT33FC:02",
.index = 23,
.trigger = ACPI_EDGE_SENSITIVE,
.polarity = ACPI_ACTIVE_HIGH,
.con_id = "kxtj21009_irq",
},
}, {
.board_info = {
.type = "GDIX1001:00",
.addr = 0x14,
.dev_name = "goodix_ts",
.swnode = &medion_lifetab_s10346_touchscreen_node,
},
.adapter_path = "\\_SB_.I2C4",
.irq_data = {
.type = X86_ACPI_IRQ_TYPE_APIC,
.index = 0x44,
.trigger = ACPI_EDGE_SENSITIVE,
.polarity = ACPI_ACTIVE_LOW,
},
},
};
const struct x86_dev_info medion_lifetab_s10346_info __initconst = {
.i2c_client_info = medion_lifetab_s10346_i2c_clients,
.i2c_client_count = ARRAY_SIZE(medion_lifetab_s10346_i2c_clients),
.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
};
static const char * const nextbook_ares8_accel_mount_matrix[] = {
"0", "-1", "0",
"-1", "0", "0",
"0", "0", "1"
};
static const struct property_entry nextbook_ares8_accel_props[] = {
PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", nextbook_ares8_accel_mount_matrix),
{ }
};
static const struct software_node nextbook_ares8_accel_node = {
.properties = nextbook_ares8_accel_props,
};
static const struct property_entry nextbook_ares8_touchscreen_props[] = {
PROPERTY_ENTRY_U32("touchscreen-size-x", 800),
PROPERTY_ENTRY_U32("touchscreen-size-y", 1280),
{ }
};
static const struct software_node nextbook_ares8_touchscreen_node = {
.properties = nextbook_ares8_touchscreen_props,
};
static const struct x86_i2c_client_info nextbook_ares8_i2c_clients[] __initconst = {
{
.board_info = {
.type = "mma8653",
.addr = 0x1d,
.dev_name = "mma8653",
.swnode = &nextbook_ares8_accel_node,
},
.adapter_path = "\\_SB_.I2C3",
}, {
.board_info = {
.type = "edt-ft5x06",
.addr = 0x38,
.dev_name = "ft5416",
.swnode = &nextbook_ares8_touchscreen_node,
},
.adapter_path = "\\_SB_.I2C4",
.irq_data = {
.type = X86_ACPI_IRQ_TYPE_GPIOINT,
.chip = "INT33FC:02",
.index = 3,
.trigger = ACPI_EDGE_SENSITIVE,
.polarity = ACPI_ACTIVE_LOW,
.con_id = "ft5416_irq",
},
},
};
const struct x86_dev_info nextbook_ares8_info __initconst = {
.i2c_client_info = nextbook_ares8_i2c_clients,
.i2c_client_count = ARRAY_SIZE(nextbook_ares8_i2c_clients),
.pdev_info = int3496_pdevs,
.pdev_count = 1,
.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
};
static const char * const nextbook_ares8a_accel_mount_matrix[] = {
"1", "0", "0",
"0", "-1", "0",
"0", "0", "1"
};
static const struct property_entry nextbook_ares8a_accel_props[] = {
PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", nextbook_ares8a_accel_mount_matrix),
{ }
};
static const struct software_node nextbook_ares8a_accel_node = {
.properties = nextbook_ares8a_accel_props,
};
static const struct property_entry nextbook_ares8a_ft5416_props[] = {
PROPERTY_ENTRY_U32("touchscreen-size-x", 800),
PROPERTY_ENTRY_U32("touchscreen-size-y", 1280),
PROPERTY_ENTRY_GPIO("reset-gpios", &cherryview_gpiochip_nodes[1], 25, GPIO_ACTIVE_LOW),
{ }
};
static const struct software_node nextbook_ares8a_ft5416_node = {
.properties = nextbook_ares8a_ft5416_props,
};
static const struct x86_i2c_client_info nextbook_ares8a_i2c_clients[] __initconst = {
{
.board_info = {
.type = "mma8653",
.addr = 0x1d,
.dev_name = "mma8653",
.swnode = &nextbook_ares8a_accel_node,
},
.adapter_path = "\\_SB_.PCI0.I2C3",
}, {
.board_info = {
.type = "edt-ft5x06",
.addr = 0x38,
.dev_name = "ft5416",
.swnode = &nextbook_ares8a_ft5416_node,
},
.adapter_path = "\\_SB_.PCI0.I2C6",
.irq_data = {
.type = X86_ACPI_IRQ_TYPE_GPIOINT,
.chip = "INT33FF:01",
.index = 17,
.trigger = ACPI_EDGE_SENSITIVE,
.polarity = ACPI_ACTIVE_LOW,
.con_id = "ft5416_irq",
},
},
};
const struct x86_dev_info nextbook_ares8a_info __initconst = {
.i2c_client_info = nextbook_ares8a_i2c_clients,
.i2c_client_count = ARRAY_SIZE(nextbook_ares8a_i2c_clients),
.gpiochip_type = X86_GPIOCHIP_CHERRYVIEW,
};
static const struct software_node peaq_c1010_gpio_keys_node = {
.name = "gpio_keys",
};
static const struct property_entry peaq_c1010_dolby_key_props[] = {
PROPERTY_ENTRY_U32("linux,code", KEY_SOUND),
PROPERTY_ENTRY_STRING("label", "dolby_key"),
PROPERTY_ENTRY_GPIO("gpios", &baytrail_gpiochip_nodes[0], 3, GPIO_ACTIVE_LOW),
PROPERTY_ENTRY_U32("debounce-interval", 50),
{ }
};
static const struct software_node peaq_c1010_dolby_key_node = {
.parent = &peaq_c1010_gpio_keys_node,
.properties = peaq_c1010_dolby_key_props,
};
static const struct software_node *peaq_c1010_button_swnodes[] = {
&peaq_c1010_gpio_keys_node,
&peaq_c1010_dolby_key_node,
NULL
};
const struct x86_dev_info peaq_c1010_info __initconst = {
.gpio_button_swnodes = peaq_c1010_button_swnodes,
.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
};
static const char * const whitelabel_tm800a550l_accel_mount_matrix[] = {
"-1", "0", "0",
"0", "1", "0",
"0", "0", "1"
};
static const struct property_entry whitelabel_tm800a550l_accel_props[] = {
PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", whitelabel_tm800a550l_accel_mount_matrix),
{ }
};
static const struct software_node whitelabel_tm800a550l_accel_node = {
.properties = whitelabel_tm800a550l_accel_props,
};
static const struct property_entry whitelabel_tm800a550l_goodix_props[] = {
PROPERTY_ENTRY_STRING("firmware-name", "gt912-tm800a550l.fw"),
PROPERTY_ENTRY_STRING("goodix,config-name", "gt912-tm800a550l.cfg"),
PROPERTY_ENTRY_U32("goodix,main-clk", 54),
PROPERTY_ENTRY_GPIO("reset-gpios", &baytrail_gpiochip_nodes[1], 26, GPIO_ACTIVE_HIGH),
PROPERTY_ENTRY_GPIO("irq-gpios", &baytrail_gpiochip_nodes[2], 3, GPIO_ACTIVE_HIGH),
{ }
};
static const struct software_node whitelabel_tm800a550l_goodix_node = {
.properties = whitelabel_tm800a550l_goodix_props,
};
static const struct x86_i2c_client_info whitelabel_tm800a550l_i2c_clients[] __initconst = {
{
.board_info = {
.type = "GDIX1001:00",
.addr = 0x14,
.dev_name = "goodix_ts",
.swnode = &whitelabel_tm800a550l_goodix_node,
},
.adapter_path = "\\_SB_.I2C2",
.irq_data = {
.type = X86_ACPI_IRQ_TYPE_APIC,
.index = 0x44,
.trigger = ACPI_EDGE_SENSITIVE,
.polarity = ACPI_ACTIVE_HIGH,
},
}, {
.board_info = {
.type = "kxcj91008",
.addr = 0x0f,
.dev_name = "kxcj91008",
.swnode = &whitelabel_tm800a550l_accel_node,
},
.adapter_path = "\\_SB_.I2C3",
},
};
const struct x86_dev_info whitelabel_tm800a550l_info __initconst = {
.i2c_client_info = whitelabel_tm800a550l_i2c_clients,
.i2c_client_count = ARRAY_SIZE(whitelabel_tm800a550l_i2c_clients),
.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
};
static const struct property_entry vexia_edu_atla10_5v_touchscreen_props[] = {
PROPERTY_ENTRY_U32("hid-descr-addr", 0x0000),
PROPERTY_ENTRY_U32("post-reset-deassert-delay-ms", 120),
PROPERTY_ENTRY_GPIO("reset-gpios", &baytrail_gpiochip_nodes[1], 26, GPIO_ACTIVE_LOW),
{ }
};
static const struct software_node vexia_edu_atla10_5v_touchscreen_node = {
.properties = vexia_edu_atla10_5v_touchscreen_props,
};
static const struct x86_i2c_client_info vexia_edu_atla10_5v_i2c_clients[] __initconst = {
{
.board_info = {
.type = "kxcjk1013",
.addr = 0x0f,
.dev_name = "kxcjk1013",
},
.adapter_path = "\\_SB_.I2C3",
}, {
.board_info = {
.type = "hid-over-i2c",
.addr = 0x38,
.dev_name = "FTSC1000",
.swnode = &vexia_edu_atla10_5v_touchscreen_node,
},
.adapter_path = "\\_SB_.I2C4",
.irq_data = {
.type = X86_ACPI_IRQ_TYPE_APIC,
.index = 0x44,
.trigger = ACPI_LEVEL_SENSITIVE,
.polarity = ACPI_ACTIVE_HIGH,
},
}
};
const struct x86_dev_info vexia_edu_atla10_5v_info __initconst = {
.i2c_client_info = vexia_edu_atla10_5v_i2c_clients,
.i2c_client_count = ARRAY_SIZE(vexia_edu_atla10_5v_i2c_clients),
.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
};
static const char * const crystal_cove_pwrsrc_psy[] = { "crystal_cove_pwrsrc" };
static const struct property_entry vexia_edu_atla10_9v_ulpmc_props[] = {
PROPERTY_ENTRY_STRING_ARRAY("supplied-from", crystal_cove_pwrsrc_psy),
{ }
};
static const struct software_node vexia_edu_atla10_9v_ulpmc_node = {
.properties = vexia_edu_atla10_9v_ulpmc_props,
};
static const char * const vexia_edu_atla10_9v_accel_mount_matrix[] = {
"0", "-1", "0",
"1", "0", "0",
"0", "0", "1"
};
static const struct property_entry vexia_edu_atla10_9v_accel_props[] = {
PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", vexia_edu_atla10_9v_accel_mount_matrix),
{ }
};
static const struct software_node vexia_edu_atla10_9v_accel_node = {
.properties = vexia_edu_atla10_9v_accel_props,
};
static const struct property_entry vexia_edu_atla10_9v_touchscreen_props[] = {
PROPERTY_ENTRY_U32("hid-descr-addr", 0x0000),
PROPERTY_ENTRY_U32("post-reset-deassert-delay-ms", 120),
PROPERTY_ENTRY_GPIO("reset-gpios", &baytrail_gpiochip_nodes[0], 60, GPIO_ACTIVE_LOW),
{ }
};
static const struct software_node vexia_edu_atla10_9v_touchscreen_node = {
.properties = vexia_edu_atla10_9v_touchscreen_props,
};
static const struct property_entry vexia_edu_atla10_9v_pmic_props[] = {
PROPERTY_ENTRY_BOOL("linux,register-pwrsrc-power_supply"),
{ }
};
static const struct software_node vexia_edu_atla10_9v_pmic_node = {
.properties = vexia_edu_atla10_9v_pmic_props,
};
static const struct x86_i2c_client_info vexia_edu_atla10_9v_i2c_clients[] __initconst = {
{
.board_info = {
.type = "vexia_atla10_ec",
.addr = 0x76,
.dev_name = "ulpmc",
.swnode = &vexia_edu_atla10_9v_ulpmc_node,
},
.adapter_path = "0000:00:18.1",
}, {
.board_info = {
.type = "rt5640",
.addr = 0x1c,
.dev_name = "rt5640",
},
.adapter_path = "0000:00:18.2",
.irq_data = {
.type = X86_ACPI_IRQ_TYPE_GPIOINT,
.chip = "INT33FC:02",
.index = 4,
.trigger = ACPI_EDGE_SENSITIVE,
.polarity = ACPI_ACTIVE_HIGH,
.con_id = "rt5640_irq",
},
}, {
.board_info = {
.type = "kxtj21009",
.addr = 0x0f,
.dev_name = "kxtj21009",
.swnode = &vexia_edu_atla10_9v_accel_node,
},
.adapter_path = "0000:00:18.5",
}, {
.board_info = {
.type = "hid-over-i2c",
.addr = 0x38,
.dev_name = "FTSC1000",
.swnode = &vexia_edu_atla10_9v_touchscreen_node,
},
.adapter_path = "0000:00:18.6",
.irq_data = {
.type = X86_ACPI_IRQ_TYPE_APIC,
.index = 0x45,
.trigger = ACPI_LEVEL_SENSITIVE,
.polarity = ACPI_ACTIVE_HIGH,
},
}, {
.board_info = {
.type = "intel_soc_pmic_crc",
.addr = 0x6e,
.dev_name = "intel_soc_pmic_crc",
.swnode = &vexia_edu_atla10_9v_pmic_node,
},
.adapter_path = "0000:00:18.7",
.irq_data = {
.type = X86_ACPI_IRQ_TYPE_APIC,
.index = 0x43,
.trigger = ACPI_LEVEL_SENSITIVE,
.polarity = ACPI_ACTIVE_HIGH,
},
}
};
static const struct x86_serdev_info vexia_edu_atla10_9v_serdevs[] __initconst = {
{
.ctrl.pci.devfn = PCI_DEVFN(0x1e, 3),
.ctrl_devname = "serial0",
.serdev_hid = "OBDA8723",
},
};
static int __init vexia_edu_atla10_9v_init(struct device *dev)
{
struct pci_dev *pdev;
int ret;
ret = x86_android_tablet_get_gpiod("INT33FC:02", 20, "wifi_enable",
false, GPIOD_OUT_HIGH, NULL);
if (ret)
return ret;
pdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0x11, 0));
if (!pdev) {
pr_warn("Could not get PCI SDIO at devfn 0x%02x\n", PCI_DEVFN(0x11, 0));
return 0;
}
ret = device_reprobe(&pdev->dev);
if (ret)
pci_warn(pdev, "Reprobing error: %d\n", ret);
pci_dev_put(pdev);
return 0;
}
const struct x86_dev_info vexia_edu_atla10_9v_info __initconst = {
.i2c_client_info = vexia_edu_atla10_9v_i2c_clients,
.i2c_client_count = ARRAY_SIZE(vexia_edu_atla10_9v_i2c_clients),
.serdev_info = vexia_edu_atla10_9v_serdevs,
.serdev_count = ARRAY_SIZE(vexia_edu_atla10_9v_serdevs),
.init = vexia_edu_atla10_9v_init,
.use_pci = true,
.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
};
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("label", "mipad2:rgb:indicator"),
PROPERTY_ENTRY_STRING("linux,default-trigger", "bq27520-0-charging-orange-full-green"),
{ }
};
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_red_led_node,
&ktd2026_green_led_node,
&ktd2026_blue_led_node,
NULL
};
#define XIAOMI_MIPAD2_LED_PERIOD_NS 19200
#define XIAOMI_MIPAD2_LED_MAX_DUTY_NS 6000
static struct pwm_device *xiaomi_mipad2_led_pwm;
static int xiaomi_mipad2_brightness_set(struct led_classdev *led_cdev,
enum led_brightness val)
{
struct pwm_state state = {
.period = XIAOMI_MIPAD2_LED_PERIOD_NS,
.duty_cycle = XIAOMI_MIPAD2_LED_MAX_DUTY_NS * val / LED_FULL,
.enabled = true,
};
return pwm_apply_might_sleep(xiaomi_mipad2_led_pwm, &state);
}
static int __init xiaomi_mipad2_init(struct device *dev)
{
struct led_classdev *led_cdev;
xiaomi_mipad2_led_pwm = devm_pwm_get(dev, "pwm_soc_lpss_2");
if (IS_ERR(xiaomi_mipad2_led_pwm))
return dev_err_probe(dev, PTR_ERR(xiaomi_mipad2_led_pwm), "getting pwm\n");
led_cdev = devm_kzalloc(dev, sizeof(*led_cdev), GFP_KERNEL);
if (!led_cdev)
return -ENOMEM;
led_cdev->name = "mipad2:white:touch-buttons-backlight";
led_cdev->max_brightness = LED_FULL;
led_cdev->default_trigger = "input-events";
led_cdev->brightness_set_blocking = xiaomi_mipad2_brightness_set;
led_cdev->flags = LED_CORE_SUSPENDRESUME;
return devm_led_classdev_register(dev, led_cdev);
}
static const struct x86_i2c_client_info xiaomi_mipad2_i2c_clients[] __initconst = {
{
.board_info = {
.type = "bq27520",
.addr = 0x55,
.dev_name = "bq27520",
.swnode = &fg_bq25890_supply_node,
},
.adapter_path = "\\_SB_.PCI0.I2C1",
}, {
.board_info = {
.type = "ktd2026",
.addr = 0x30,
.dev_name = "ktd2026",
.swnode = &ktd2026_node,
},
.adapter_path = "\\_SB_.PCI0.I2C3",
},
};
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),
.swnode_group = ktd2026_node_group,
.init = xiaomi_mipad2_init,
};