162a5f689SHans de Goede /* SPDX-License-Identifier: GPL-2.0-or-later 262a5f689SHans de Goede * 362a5f689SHans de Goede * DMI based code to deal with broken DSDTs on X86 tablets which ship with 462a5f689SHans de Goede * Android as (part of) the factory image. The factory kernels shipped on these 562a5f689SHans de Goede * devices typically have a bunch of things hardcoded, rather than specified 662a5f689SHans de Goede * in their DSDT. 762a5f689SHans de Goede * 862a5f689SHans de Goede * Copyright (C) 2021-2023 Hans de Goede <hdegoede@redhat.com> 962a5f689SHans de Goede */ 1062a5f689SHans de Goede #ifndef __PDX86_X86_ANDROID_TABLETS_H 1162a5f689SHans de Goede #define __PDX86_X86_ANDROID_TABLETS_H 1262a5f689SHans de Goede 134014ae23SHans de Goede #include <linux/gpio/consumer.h> 14e2200d3fSHans de Goede #include <linux/gpio_keys.h> 1562a5f689SHans de Goede #include <linux/i2c.h> 1662a5f689SHans de Goede #include <linux/irqdomain_defs.h> 1770505ea6SHans de Goede #include <linux/spi/spi.h> 1862a5f689SHans de Goede 1962a5f689SHans de Goede struct gpio_desc; 2062a5f689SHans de Goede struct gpiod_lookup_table; 2162a5f689SHans de Goede struct platform_device_info; 2262a5f689SHans de Goede struct software_node; 2362a5f689SHans de Goede 2462a5f689SHans de Goede /* 2562a5f689SHans de Goede * Helpers to get Linux IRQ numbers given a description of the IRQ source 2662a5f689SHans de Goede * (either IOAPIC index, or GPIO chip name + pin-number). 2762a5f689SHans de Goede */ 2862a5f689SHans de Goede enum x86_acpi_irq_type { 2962a5f689SHans de Goede X86_ACPI_IRQ_TYPE_NONE, 3062a5f689SHans de Goede X86_ACPI_IRQ_TYPE_APIC, 3162a5f689SHans de Goede X86_ACPI_IRQ_TYPE_GPIOINT, 3262a5f689SHans de Goede X86_ACPI_IRQ_TYPE_PMIC, 3362a5f689SHans de Goede }; 3462a5f689SHans de Goede 3562a5f689SHans de Goede struct x86_acpi_irq_data { 3662a5f689SHans de Goede char *chip; /* GPIO chip label (GPIOINT) or PMIC ACPI path (PMIC) */ 3762a5f689SHans de Goede enum x86_acpi_irq_type type; 3862a5f689SHans de Goede enum irq_domain_bus_token domain; 3962a5f689SHans de Goede int index; 4062a5f689SHans de Goede int trigger; /* ACPI_EDGE_SENSITIVE / ACPI_LEVEL_SENSITIVE */ 4162a5f689SHans de Goede int polarity; /* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */ 42bd8905d7SHans de Goede bool free_gpio; /* Release GPIO after getting IRQ (for TYPE_GPIOINT) */ 434014ae23SHans de Goede const char *con_id; 4462a5f689SHans de Goede }; 4562a5f689SHans de Goede 4662a5f689SHans de Goede /* Structs to describe devices to instantiate */ 4762a5f689SHans de Goede struct x86_i2c_client_info { 4862a5f689SHans de Goede struct i2c_board_info board_info; 4962a5f689SHans de Goede char *adapter_path; 5062a5f689SHans de Goede struct x86_acpi_irq_data irq_data; 5162a5f689SHans de Goede }; 5262a5f689SHans de Goede 5370505ea6SHans de Goede struct x86_spi_dev_info { 5470505ea6SHans de Goede struct spi_board_info board_info; 5570505ea6SHans de Goede char *ctrl_path; 5670505ea6SHans de Goede struct x86_acpi_irq_data irq_data; 5770505ea6SHans de Goede }; 5870505ea6SHans de Goede 5962a5f689SHans de Goede struct x86_serdev_info { 6062a5f689SHans de Goede const char *ctrl_hid; 6162a5f689SHans de Goede const char *ctrl_uid; 6262a5f689SHans de Goede const char *ctrl_devname; 6362a5f689SHans de Goede /* 6462a5f689SHans de Goede * ATM the serdev core only supports of or ACPI matching; and so far all 6562a5f689SHans de Goede * Android x86 tablets DSDTs have usable serdev nodes, but sometimes 6662a5f689SHans de Goede * under the wrong controller. So we just tie the existing serdev ACPI 6762a5f689SHans de Goede * node to the right controller. 6862a5f689SHans de Goede */ 6962a5f689SHans de Goede const char *serdev_hid; 7062a5f689SHans de Goede }; 7162a5f689SHans de Goede 72e2200d3fSHans de Goede struct x86_gpio_button { 73e2200d3fSHans de Goede struct gpio_keys_button button; 74e2200d3fSHans de Goede const char *chip; 75e2200d3fSHans de Goede int pin; 76e2200d3fSHans de Goede }; 77e2200d3fSHans de Goede 7862a5f689SHans de Goede struct x86_dev_info { 7962a5f689SHans de Goede const char * const *modules; 8062a5f689SHans de Goede const struct software_node *bat_swnode; 8162a5f689SHans de Goede struct gpiod_lookup_table * const *gpiod_lookup_tables; 8262a5f689SHans de Goede const struct x86_i2c_client_info *i2c_client_info; 8370505ea6SHans de Goede const struct x86_spi_dev_info *spi_dev_info; 8462a5f689SHans de Goede const struct platform_device_info *pdev_info; 8562a5f689SHans de Goede const struct x86_serdev_info *serdev_info; 866dc6c0c1SHans de Goede const struct x86_gpio_button *gpio_button; 8762a5f689SHans de Goede int i2c_client_count; 8870505ea6SHans de Goede int spi_dev_count; 8962a5f689SHans de Goede int pdev_count; 9062a5f689SHans de Goede int serdev_count; 916dc6c0c1SHans de Goede int gpio_button_count; 92*492b1194SHans de Goede int (*init)(struct device *dev); 9362a5f689SHans de Goede void (*exit)(void); 9462a5f689SHans de Goede }; 9562a5f689SHans de Goede 964014ae23SHans de Goede int x86_android_tablet_get_gpiod(const char *chip, int pin, const char *con_id, 974014ae23SHans de Goede bool active_low, enum gpiod_flags dflags, 984014ae23SHans de Goede struct gpio_desc **desc); 9962a5f689SHans de Goede int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data); 10062a5f689SHans de Goede 1013a75d169SHans de Goede /* 1023a75d169SHans de Goede * Extern declarations of x86_dev_info structs so there can be a single 1033a75d169SHans de Goede * MODULE_DEVICE_TABLE(dmi, ...), while splitting the board descriptions. 1043a75d169SHans de Goede */ 1053a75d169SHans de Goede extern const struct x86_dev_info acer_b1_750_info; 1063a75d169SHans de Goede extern const struct x86_dev_info advantech_mica_071_info; 1073a75d169SHans de Goede extern const struct x86_dev_info asus_me176c_info; 1083a75d169SHans de Goede extern const struct x86_dev_info asus_tf103c_info; 1093a75d169SHans de Goede extern const struct x86_dev_info chuwi_hi8_info; 11024f7b9a0SHans de Goede extern const struct x86_dev_info cyberbook_t116_info; 1113a75d169SHans de Goede extern const struct x86_dev_info czc_p10t; 112c69fec50SHans de Goede extern const struct x86_dev_info lenovo_yogabook_x90_info; 1135f250f8aSHans de Goede extern const struct x86_dev_info lenovo_yogabook_x91_info; 11401862d01SHans de Goede extern const struct x86_dev_info lenovo_yoga_tab2_830_1050_info; 1153eee73adSHans de Goede extern const struct x86_dev_info lenovo_yoga_tab2_1380_info; 1163a75d169SHans de Goede extern const struct x86_dev_info lenovo_yt3_info; 1173a75d169SHans de Goede extern const struct x86_dev_info medion_lifetab_s10346_info; 1183a75d169SHans de Goede extern const struct x86_dev_info nextbook_ares8_info; 119c9105066SHans de Goede extern const struct x86_dev_info nextbook_ares8a_info; 120772cbba5SHans de Goede extern const struct x86_dev_info peaq_c1010_info; 1213a75d169SHans de Goede extern const struct x86_dev_info whitelabel_tm800a550l_info; 1223a75d169SHans de Goede extern const struct x86_dev_info xiaomi_mipad2_info; 1233a75d169SHans de Goede extern const struct dmi_system_id x86_android_tablet_ids[]; 1243a75d169SHans de Goede 12562a5f689SHans de Goede #endif 126