162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later 262306a36Sopenharmony_ci * 362306a36Sopenharmony_ci * DMI based code to deal with broken DSDTs on X86 tablets which ship with 462306a36Sopenharmony_ci * Android as (part of) the factory image. The factory kernels shipped on these 562306a36Sopenharmony_ci * devices typically have a bunch of things hardcoded, rather than specified 662306a36Sopenharmony_ci * in their DSDT. 762306a36Sopenharmony_ci * 862306a36Sopenharmony_ci * Copyright (C) 2021-2023 Hans de Goede <hdegoede@redhat.com> 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci#ifndef __PDX86_X86_ANDROID_TABLETS_H 1162306a36Sopenharmony_ci#define __PDX86_X86_ANDROID_TABLETS_H 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include <linux/gpio_keys.h> 1462306a36Sopenharmony_ci#include <linux/i2c.h> 1562306a36Sopenharmony_ci#include <linux/irqdomain_defs.h> 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cistruct gpio_desc; 1862306a36Sopenharmony_cistruct gpiod_lookup_table; 1962306a36Sopenharmony_cistruct platform_device_info; 2062306a36Sopenharmony_cistruct software_node; 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci/* 2362306a36Sopenharmony_ci * Helpers to get Linux IRQ numbers given a description of the IRQ source 2462306a36Sopenharmony_ci * (either IOAPIC index, or GPIO chip name + pin-number). 2562306a36Sopenharmony_ci */ 2662306a36Sopenharmony_cienum x86_acpi_irq_type { 2762306a36Sopenharmony_ci X86_ACPI_IRQ_TYPE_NONE, 2862306a36Sopenharmony_ci X86_ACPI_IRQ_TYPE_APIC, 2962306a36Sopenharmony_ci X86_ACPI_IRQ_TYPE_GPIOINT, 3062306a36Sopenharmony_ci X86_ACPI_IRQ_TYPE_PMIC, 3162306a36Sopenharmony_ci}; 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_cistruct x86_acpi_irq_data { 3462306a36Sopenharmony_ci char *chip; /* GPIO chip label (GPIOINT) or PMIC ACPI path (PMIC) */ 3562306a36Sopenharmony_ci enum x86_acpi_irq_type type; 3662306a36Sopenharmony_ci enum irq_domain_bus_token domain; 3762306a36Sopenharmony_ci int index; 3862306a36Sopenharmony_ci int trigger; /* ACPI_EDGE_SENSITIVE / ACPI_LEVEL_SENSITIVE */ 3962306a36Sopenharmony_ci int polarity; /* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */ 4062306a36Sopenharmony_ci}; 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci/* Structs to describe devices to instantiate */ 4362306a36Sopenharmony_cistruct x86_i2c_client_info { 4462306a36Sopenharmony_ci struct i2c_board_info board_info; 4562306a36Sopenharmony_ci char *adapter_path; 4662306a36Sopenharmony_ci struct x86_acpi_irq_data irq_data; 4762306a36Sopenharmony_ci}; 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_cistruct x86_serdev_info { 5062306a36Sopenharmony_ci const char *ctrl_hid; 5162306a36Sopenharmony_ci const char *ctrl_uid; 5262306a36Sopenharmony_ci const char *ctrl_devname; 5362306a36Sopenharmony_ci /* 5462306a36Sopenharmony_ci * ATM the serdev core only supports of or ACPI matching; and sofar all 5562306a36Sopenharmony_ci * Android x86 tablets DSDTs have usable serdev nodes, but sometimes 5662306a36Sopenharmony_ci * under the wrong controller. So we just tie the existing serdev ACPI 5762306a36Sopenharmony_ci * node to the right controller. 5862306a36Sopenharmony_ci */ 5962306a36Sopenharmony_ci const char *serdev_hid; 6062306a36Sopenharmony_ci}; 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_cistruct x86_gpio_button { 6362306a36Sopenharmony_ci struct gpio_keys_button button; 6462306a36Sopenharmony_ci const char *chip; 6562306a36Sopenharmony_ci int pin; 6662306a36Sopenharmony_ci}; 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_cistruct x86_dev_info { 6962306a36Sopenharmony_ci char *invalid_aei_gpiochip; 7062306a36Sopenharmony_ci const char * const *modules; 7162306a36Sopenharmony_ci const struct software_node *bat_swnode; 7262306a36Sopenharmony_ci struct gpiod_lookup_table * const *gpiod_lookup_tables; 7362306a36Sopenharmony_ci const struct x86_i2c_client_info *i2c_client_info; 7462306a36Sopenharmony_ci const struct platform_device_info *pdev_info; 7562306a36Sopenharmony_ci const struct x86_serdev_info *serdev_info; 7662306a36Sopenharmony_ci const struct x86_gpio_button *gpio_button; 7762306a36Sopenharmony_ci int i2c_client_count; 7862306a36Sopenharmony_ci int pdev_count; 7962306a36Sopenharmony_ci int serdev_count; 8062306a36Sopenharmony_ci int gpio_button_count; 8162306a36Sopenharmony_ci int (*init)(void); 8262306a36Sopenharmony_ci void (*exit)(void); 8362306a36Sopenharmony_ci}; 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ciint x86_android_tablet_get_gpiod(const char *label, int pin, struct gpio_desc **desc); 8662306a36Sopenharmony_ciint x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data); 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci/* 8962306a36Sopenharmony_ci * Extern declarations of x86_dev_info structs so there can be a single 9062306a36Sopenharmony_ci * MODULE_DEVICE_TABLE(dmi, ...), while splitting the board descriptions. 9162306a36Sopenharmony_ci */ 9262306a36Sopenharmony_ciextern const struct x86_dev_info acer_b1_750_info; 9362306a36Sopenharmony_ciextern const struct x86_dev_info advantech_mica_071_info; 9462306a36Sopenharmony_ciextern const struct x86_dev_info asus_me176c_info; 9562306a36Sopenharmony_ciextern const struct x86_dev_info asus_tf103c_info; 9662306a36Sopenharmony_ciextern const struct x86_dev_info chuwi_hi8_info; 9762306a36Sopenharmony_ciextern const struct x86_dev_info cyberbook_t116_info; 9862306a36Sopenharmony_ciextern const struct x86_dev_info czc_p10t; 9962306a36Sopenharmony_ciextern const struct x86_dev_info lenovo_yogabook_x90_info; 10062306a36Sopenharmony_ciextern const struct x86_dev_info lenovo_yogabook_x91_info; 10162306a36Sopenharmony_ciextern const struct x86_dev_info lenovo_yoga_tab2_830_1050_info; 10262306a36Sopenharmony_ciextern const struct x86_dev_info lenovo_yt3_info; 10362306a36Sopenharmony_ciextern const struct x86_dev_info medion_lifetab_s10346_info; 10462306a36Sopenharmony_ciextern const struct x86_dev_info nextbook_ares8_info; 10562306a36Sopenharmony_ciextern const struct x86_dev_info nextbook_ares8a_info; 10662306a36Sopenharmony_ciextern const struct x86_dev_info peaq_c1010_info; 10762306a36Sopenharmony_ciextern const struct x86_dev_info whitelabel_tm800a550l_info; 10862306a36Sopenharmony_ciextern const struct x86_dev_info xiaomi_mipad2_info; 10962306a36Sopenharmony_ciextern const struct dmi_system_id x86_android_tablet_ids[]; 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci#endif 112