xref: /linux/drivers/platform/x86/x86-android-tablets/x86-android-tablets.h (revision 772cbba5a877eb7c528f3659415373c40e48a057)
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 
13e2200d3fSHans de Goede #include <linux/gpio_keys.h>
1462a5f689SHans de Goede #include <linux/i2c.h>
1562a5f689SHans de Goede #include <linux/irqdomain_defs.h>
1662a5f689SHans de Goede 
1762a5f689SHans de Goede struct gpio_desc;
1862a5f689SHans de Goede struct gpiod_lookup_table;
1962a5f689SHans de Goede struct platform_device_info;
2062a5f689SHans de Goede struct software_node;
2162a5f689SHans de Goede 
2262a5f689SHans de Goede /*
2362a5f689SHans de Goede  * Helpers to get Linux IRQ numbers given a description of the IRQ source
2462a5f689SHans de Goede  * (either IOAPIC index, or GPIO chip name + pin-number).
2562a5f689SHans de Goede  */
2662a5f689SHans de Goede enum x86_acpi_irq_type {
2762a5f689SHans de Goede 	X86_ACPI_IRQ_TYPE_NONE,
2862a5f689SHans de Goede 	X86_ACPI_IRQ_TYPE_APIC,
2962a5f689SHans de Goede 	X86_ACPI_IRQ_TYPE_GPIOINT,
3062a5f689SHans de Goede 	X86_ACPI_IRQ_TYPE_PMIC,
3162a5f689SHans de Goede };
3262a5f689SHans de Goede 
3362a5f689SHans de Goede struct x86_acpi_irq_data {
3462a5f689SHans de Goede 	char *chip;   /* GPIO chip label (GPIOINT) or PMIC ACPI path (PMIC) */
3562a5f689SHans de Goede 	enum x86_acpi_irq_type type;
3662a5f689SHans de Goede 	enum irq_domain_bus_token domain;
3762a5f689SHans de Goede 	int index;
3862a5f689SHans de Goede 	int trigger;  /* ACPI_EDGE_SENSITIVE / ACPI_LEVEL_SENSITIVE */
3962a5f689SHans de Goede 	int polarity; /* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */
4062a5f689SHans de Goede };
4162a5f689SHans de Goede 
4262a5f689SHans de Goede /* Structs to describe devices to instantiate */
4362a5f689SHans de Goede struct x86_i2c_client_info {
4462a5f689SHans de Goede 	struct i2c_board_info board_info;
4562a5f689SHans de Goede 	char *adapter_path;
4662a5f689SHans de Goede 	struct x86_acpi_irq_data irq_data;
4762a5f689SHans de Goede };
4862a5f689SHans de Goede 
4962a5f689SHans de Goede struct x86_serdev_info {
5062a5f689SHans de Goede 	const char *ctrl_hid;
5162a5f689SHans de Goede 	const char *ctrl_uid;
5262a5f689SHans de Goede 	const char *ctrl_devname;
5362a5f689SHans de Goede 	/*
5462a5f689SHans de Goede 	 * ATM the serdev core only supports of or ACPI matching; and sofar all
5562a5f689SHans de Goede 	 * Android x86 tablets DSDTs have usable serdev nodes, but sometimes
5662a5f689SHans de Goede 	 * under the wrong controller. So we just tie the existing serdev ACPI
5762a5f689SHans de Goede 	 * node to the right controller.
5862a5f689SHans de Goede 	 */
5962a5f689SHans de Goede 	const char *serdev_hid;
6062a5f689SHans de Goede };
6162a5f689SHans de Goede 
62e2200d3fSHans de Goede struct x86_gpio_button {
63e2200d3fSHans de Goede 	struct gpio_keys_button button;
64e2200d3fSHans de Goede 	const char *chip;
65e2200d3fSHans de Goede 	int pin;
66e2200d3fSHans de Goede };
67e2200d3fSHans de Goede 
6862a5f689SHans de Goede struct x86_dev_info {
6962a5f689SHans de Goede 	char *invalid_aei_gpiochip;
7062a5f689SHans de Goede 	const char * const *modules;
7162a5f689SHans de Goede 	const struct software_node *bat_swnode;
7262a5f689SHans de Goede 	struct gpiod_lookup_table * const *gpiod_lookup_tables;
7362a5f689SHans de Goede 	const struct x86_i2c_client_info *i2c_client_info;
7462a5f689SHans de Goede 	const struct platform_device_info *pdev_info;
7562a5f689SHans de Goede 	const struct x86_serdev_info *serdev_info;
76e2200d3fSHans de Goede 	struct x86_gpio_button *gpio_button;
7762a5f689SHans de Goede 	int i2c_client_count;
7862a5f689SHans de Goede 	int pdev_count;
7962a5f689SHans de Goede 	int serdev_count;
8062a5f689SHans de Goede 	int (*init)(void);
8162a5f689SHans de Goede 	void (*exit)(void);
8262a5f689SHans de Goede };
8362a5f689SHans de Goede 
8462a5f689SHans de Goede int x86_android_tablet_get_gpiod(const char *label, int pin, struct gpio_desc **desc);
8562a5f689SHans de Goede int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data);
8662a5f689SHans de Goede 
873a75d169SHans de Goede /*
883a75d169SHans de Goede  * Extern declarations of x86_dev_info structs so there can be a single
893a75d169SHans de Goede  * MODULE_DEVICE_TABLE(dmi, ...), while splitting the board descriptions.
903a75d169SHans de Goede  */
913a75d169SHans de Goede extern const struct x86_dev_info acer_b1_750_info;
923a75d169SHans de Goede extern const struct x86_dev_info advantech_mica_071_info;
933a75d169SHans de Goede extern const struct x86_dev_info asus_me176c_info;
943a75d169SHans de Goede extern const struct x86_dev_info asus_tf103c_info;
953a75d169SHans de Goede extern const struct x86_dev_info chuwi_hi8_info;
963a75d169SHans de Goede extern const struct x86_dev_info czc_p10t;
973a75d169SHans de Goede extern const struct x86_dev_info lenovo_yogabook_x9x_info;
983a75d169SHans de Goede /* Not const as this gets modified by its init callback */
993a75d169SHans de Goede extern struct x86_dev_info lenovo_yoga_tab2_830_1050_info;
1003a75d169SHans de Goede extern const struct x86_dev_info lenovo_yt3_info;
1013a75d169SHans de Goede extern const struct x86_dev_info medion_lifetab_s10346_info;
1023a75d169SHans de Goede extern const struct x86_dev_info nextbook_ares8_info;
103*772cbba5SHans de Goede extern const struct x86_dev_info peaq_c1010_info;
1043a75d169SHans de Goede extern const struct x86_dev_info whitelabel_tm800a550l_info;
1053a75d169SHans de Goede extern const struct x86_dev_info xiaomi_mipad2_info;
1063a75d169SHans de Goede extern const struct dmi_system_id x86_android_tablet_ids[];
1073a75d169SHans de Goede 
10862a5f689SHans de Goede #endif
109