126 lines · c
1/* SPDX-License-Identifier: GPL-2.0-or-later2 *3 * DMI based code to deal with broken DSDTs on X86 tablets which ship with4 * Android as (part of) the factory image. The factory kernels shipped on these5 * devices typically have a bunch of things hardcoded, rather than specified6 * in their DSDT.7 *8 * Copyright (C) 2021-2023 Hans de Goede <hdegoede@redhat.com>9 */10#ifndef __PDX86_X86_ANDROID_TABLETS_H11#define __PDX86_X86_ANDROID_TABLETS_H12 13#include <linux/gpio/consumer.h>14#include <linux/gpio_keys.h>15#include <linux/i2c.h>16#include <linux/irqdomain_defs.h>17#include <linux/spi/spi.h>18 19struct gpio_desc;20struct gpiod_lookup_table;21struct platform_device_info;22struct software_node;23 24/*25 * Helpers to get Linux IRQ numbers given a description of the IRQ source26 * (either IOAPIC index, or GPIO chip name + pin-number).27 */28enum x86_acpi_irq_type {29 X86_ACPI_IRQ_TYPE_NONE,30 X86_ACPI_IRQ_TYPE_APIC,31 X86_ACPI_IRQ_TYPE_GPIOINT,32 X86_ACPI_IRQ_TYPE_PMIC,33};34 35struct x86_acpi_irq_data {36 char *chip; /* GPIO chip label (GPIOINT) or PMIC ACPI path (PMIC) */37 enum x86_acpi_irq_type type;38 enum irq_domain_bus_token domain;39 int index;40 int trigger; /* ACPI_EDGE_SENSITIVE / ACPI_LEVEL_SENSITIVE */41 int polarity; /* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */42 bool free_gpio; /* Release GPIO after getting IRQ (for TYPE_GPIOINT) */43 const char *con_id;44};45 46/* Structs to describe devices to instantiate */47struct x86_i2c_client_info {48 struct i2c_board_info board_info;49 char *adapter_path;50 struct x86_acpi_irq_data irq_data;51};52 53struct x86_spi_dev_info {54 struct spi_board_info board_info;55 char *ctrl_path;56 struct x86_acpi_irq_data irq_data;57};58 59struct x86_serdev_info {60 const char *ctrl_hid;61 const char *ctrl_uid;62 const char *ctrl_devname;63 /*64 * ATM the serdev core only supports of or ACPI matching; and so far all65 * Android x86 tablets DSDTs have usable serdev nodes, but sometimes66 * under the wrong controller. So we just tie the existing serdev ACPI67 * node to the right controller.68 */69 const char *serdev_hid;70};71 72struct x86_gpio_button {73 struct gpio_keys_button button;74 const char *chip;75 int pin;76};77 78struct x86_dev_info {79 const char * const *modules;80 const struct software_node *bat_swnode;81 struct gpiod_lookup_table * const *gpiod_lookup_tables;82 const struct x86_i2c_client_info *i2c_client_info;83 const struct x86_spi_dev_info *spi_dev_info;84 const struct platform_device_info *pdev_info;85 const struct x86_serdev_info *serdev_info;86 const struct x86_gpio_button *gpio_button;87 int i2c_client_count;88 int spi_dev_count;89 int pdev_count;90 int serdev_count;91 int gpio_button_count;92 int (*init)(struct device *dev);93 void (*exit)(void);94};95 96int x86_android_tablet_get_gpiod(const char *chip, int pin, const char *con_id,97 bool active_low, enum gpiod_flags dflags,98 struct gpio_desc **desc);99int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data);100 101/*102 * Extern declarations of x86_dev_info structs so there can be a single103 * MODULE_DEVICE_TABLE(dmi, ...), while splitting the board descriptions.104 */105extern const struct x86_dev_info acer_b1_750_info;106extern const struct x86_dev_info advantech_mica_071_info;107extern const struct x86_dev_info asus_me176c_info;108extern const struct x86_dev_info asus_tf103c_info;109extern const struct x86_dev_info chuwi_hi8_info;110extern const struct x86_dev_info cyberbook_t116_info;111extern const struct x86_dev_info czc_p10t;112extern const struct x86_dev_info lenovo_yogabook_x90_info;113extern const struct x86_dev_info lenovo_yogabook_x91_info;114extern const struct x86_dev_info lenovo_yoga_tab2_830_1050_info;115extern const struct x86_dev_info lenovo_yoga_tab2_1380_info;116extern const struct x86_dev_info lenovo_yt3_info;117extern const struct x86_dev_info medion_lifetab_s10346_info;118extern const struct x86_dev_info nextbook_ares8_info;119extern const struct x86_dev_info nextbook_ares8a_info;120extern const struct x86_dev_info peaq_c1010_info;121extern const struct x86_dev_info whitelabel_tm800a550l_info;122extern const struct x86_dev_info xiaomi_mipad2_info;123extern const struct dmi_system_id x86_android_tablet_ids[];124 125#endif126