1*62a5f689SHans de Goede /* SPDX-License-Identifier: GPL-2.0-or-later 2*62a5f689SHans de Goede * 3*62a5f689SHans de Goede * DMI based code to deal with broken DSDTs on X86 tablets which ship with 4*62a5f689SHans de Goede * Android as (part of) the factory image. The factory kernels shipped on these 5*62a5f689SHans de Goede * devices typically have a bunch of things hardcoded, rather than specified 6*62a5f689SHans de Goede * in their DSDT. 7*62a5f689SHans de Goede * 8*62a5f689SHans de Goede * Copyright (C) 2021-2023 Hans de Goede <hdegoede@redhat.com> 9*62a5f689SHans de Goede */ 10*62a5f689SHans de Goede #ifndef __PDX86_X86_ANDROID_TABLETS_H 11*62a5f689SHans de Goede #define __PDX86_X86_ANDROID_TABLETS_H 12*62a5f689SHans de Goede 13*62a5f689SHans de Goede #include <linux/i2c.h> 14*62a5f689SHans de Goede #include <linux/irqdomain_defs.h> 15*62a5f689SHans de Goede 16*62a5f689SHans de Goede struct gpio_desc; 17*62a5f689SHans de Goede struct gpiod_lookup_table; 18*62a5f689SHans de Goede struct platform_device_info; 19*62a5f689SHans de Goede struct software_node; 20*62a5f689SHans de Goede 21*62a5f689SHans de Goede /* 22*62a5f689SHans de Goede * Helpers to get Linux IRQ numbers given a description of the IRQ source 23*62a5f689SHans de Goede * (either IOAPIC index, or GPIO chip name + pin-number). 24*62a5f689SHans de Goede */ 25*62a5f689SHans de Goede enum x86_acpi_irq_type { 26*62a5f689SHans de Goede X86_ACPI_IRQ_TYPE_NONE, 27*62a5f689SHans de Goede X86_ACPI_IRQ_TYPE_APIC, 28*62a5f689SHans de Goede X86_ACPI_IRQ_TYPE_GPIOINT, 29*62a5f689SHans de Goede X86_ACPI_IRQ_TYPE_PMIC, 30*62a5f689SHans de Goede }; 31*62a5f689SHans de Goede 32*62a5f689SHans de Goede struct x86_acpi_irq_data { 33*62a5f689SHans de Goede char *chip; /* GPIO chip label (GPIOINT) or PMIC ACPI path (PMIC) */ 34*62a5f689SHans de Goede enum x86_acpi_irq_type type; 35*62a5f689SHans de Goede enum irq_domain_bus_token domain; 36*62a5f689SHans de Goede int index; 37*62a5f689SHans de Goede int trigger; /* ACPI_EDGE_SENSITIVE / ACPI_LEVEL_SENSITIVE */ 38*62a5f689SHans de Goede int polarity; /* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */ 39*62a5f689SHans de Goede }; 40*62a5f689SHans de Goede 41*62a5f689SHans de Goede /* Structs to describe devices to instantiate */ 42*62a5f689SHans de Goede struct x86_i2c_client_info { 43*62a5f689SHans de Goede struct i2c_board_info board_info; 44*62a5f689SHans de Goede char *adapter_path; 45*62a5f689SHans de Goede struct x86_acpi_irq_data irq_data; 46*62a5f689SHans de Goede }; 47*62a5f689SHans de Goede 48*62a5f689SHans de Goede struct x86_serdev_info { 49*62a5f689SHans de Goede const char *ctrl_hid; 50*62a5f689SHans de Goede const char *ctrl_uid; 51*62a5f689SHans de Goede const char *ctrl_devname; 52*62a5f689SHans de Goede /* 53*62a5f689SHans de Goede * ATM the serdev core only supports of or ACPI matching; and sofar all 54*62a5f689SHans de Goede * Android x86 tablets DSDTs have usable serdev nodes, but sometimes 55*62a5f689SHans de Goede * under the wrong controller. So we just tie the existing serdev ACPI 56*62a5f689SHans de Goede * node to the right controller. 57*62a5f689SHans de Goede */ 58*62a5f689SHans de Goede const char *serdev_hid; 59*62a5f689SHans de Goede }; 60*62a5f689SHans de Goede 61*62a5f689SHans de Goede struct x86_dev_info { 62*62a5f689SHans de Goede char *invalid_aei_gpiochip; 63*62a5f689SHans de Goede const char * const *modules; 64*62a5f689SHans de Goede const struct software_node *bat_swnode; 65*62a5f689SHans de Goede struct gpiod_lookup_table * const *gpiod_lookup_tables; 66*62a5f689SHans de Goede const struct x86_i2c_client_info *i2c_client_info; 67*62a5f689SHans de Goede const struct platform_device_info *pdev_info; 68*62a5f689SHans de Goede const struct x86_serdev_info *serdev_info; 69*62a5f689SHans de Goede int i2c_client_count; 70*62a5f689SHans de Goede int pdev_count; 71*62a5f689SHans de Goede int serdev_count; 72*62a5f689SHans de Goede int (*init)(void); 73*62a5f689SHans de Goede void (*exit)(void); 74*62a5f689SHans de Goede }; 75*62a5f689SHans de Goede 76*62a5f689SHans de Goede int x86_android_tablet_get_gpiod(const char *label, int pin, struct gpio_desc **desc); 77*62a5f689SHans de Goede int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data); 78*62a5f689SHans de Goede 79*62a5f689SHans de Goede #endif 80