1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * DMI based code to deal with broken DSDTs on X86 tablets which ship with
4 * Android as (part of) the factory image. The factory kernels shipped on these
5 * devices typically have a bunch of things hardcoded, rather than specified
11 #include <linux/acpi.h>
12 #include <linux/gpio/machine.h>
13 #include <linux/input.h>
14 #include <linux/platform_device.h>
16 #include "shared-psy-info.h"
17 #include "x86-android-tablets.h"
19 /* Acer Iconia One 7 B1-750 has an Android factory img with everything hardcoded */
20 static const char * const acer_b1_750_mount_matrix[] = {
26 static const struct property_entry acer_b1_750_bma250e_props[] = {
27 PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", acer_b1_750_mount_matrix),
31 static const struct software_node acer_b1_750_bma250e_node = {
32 .properties = acer_b1_750_bma250e_props,
35 static const struct x86_i2c_client_info acer_b1_750_i2c_clients[] __initconst = {
37 /* Novatek NVT-ts touchscreen */
43 .adapter_path = "\\_SB_.I2C4",
45 .type = X86_ACPI_IRQ_TYPE_GPIOINT,
48 .trigger = ACPI_EDGE_SENSITIVE,
49 .polarity = ACPI_ACTIVE_LOW,
52 /* BMA250E accelerometer */
56 .swnode = &acer_b1_750_bma250e_node,
58 .adapter_path = "\\_SB_.I2C3",
60 .type = X86_ACPI_IRQ_TYPE_GPIOINT,
63 .trigger = ACPI_LEVEL_SENSITIVE,
64 .polarity = ACPI_ACTIVE_HIGH,
69 static struct gpiod_lookup_table acer_b1_750_goodix_gpios = {
70 .dev_id = "i2c-NVT-ts",
72 GPIO_LOOKUP("INT33FC:01", 26, "reset", GPIO_ACTIVE_LOW),
77 static struct gpiod_lookup_table * const acer_b1_750_gpios[] = {
78 &acer_b1_750_goodix_gpios,
79 &int3496_reference_gpios,
83 const struct x86_dev_info acer_b1_750_info __initconst = {
84 .i2c_client_info = acer_b1_750_i2c_clients,
85 .i2c_client_count = ARRAY_SIZE(acer_b1_750_i2c_clients),
86 .pdev_info = int3496_pdevs,
88 .gpiod_lookup_tables = acer_b1_750_gpios,
93 * This is a standard Windows tablet, but it has an extra "quick launch" button
94 * which is not described in the ACPI tables in anyway.
95 * Use the x86-android-tablets infra to create a gpio-button device for this.
97 static struct x86_gpio_button advantech_mica_071_button = {
104 .debounce_interval = 50,
106 .chip = "INT33FC:00",
110 const struct x86_dev_info advantech_mica_071_info __initconst = {
111 .gpio_button = &advantech_mica_071_button,
115 * When booted with the BIOS set to Android mode the Chuwi Hi8 (CWI509) DSDT
116 * contains a whole bunch of bogus ACPI I2C devices and is missing entries
117 * for the touchscreen and the accelerometer.
119 static const struct property_entry chuwi_hi8_gsl1680_props[] = {
120 PROPERTY_ENTRY_U32("touchscreen-size-x", 1665),
121 PROPERTY_ENTRY_U32("touchscreen-size-y", 1140),
122 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
123 PROPERTY_ENTRY_BOOL("silead,home-button"),
124 PROPERTY_ENTRY_STRING("firmware-name", "gsl1680-chuwi-hi8.fw"),
128 static const struct software_node chuwi_hi8_gsl1680_node = {
129 .properties = chuwi_hi8_gsl1680_props,
132 static const char * const chuwi_hi8_mount_matrix[] = {
138 static const struct property_entry chuwi_hi8_bma250e_props[] = {
139 PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", chuwi_hi8_mount_matrix),
143 static const struct software_node chuwi_hi8_bma250e_node = {
144 .properties = chuwi_hi8_bma250e_props,
147 static const struct x86_i2c_client_info chuwi_hi8_i2c_clients[] __initconst = {
149 /* Silead touchscreen */
153 .swnode = &chuwi_hi8_gsl1680_node,
155 .adapter_path = "\\_SB_.I2C4",
157 .type = X86_ACPI_IRQ_TYPE_APIC,
159 .trigger = ACPI_EDGE_SENSITIVE,
160 .polarity = ACPI_ACTIVE_HIGH,
163 /* BMA250E accelerometer */
167 .swnode = &chuwi_hi8_bma250e_node,
169 .adapter_path = "\\_SB_.I2C3",
171 .type = X86_ACPI_IRQ_TYPE_GPIOINT,
172 .chip = "INT33FC:02",
174 .trigger = ACPI_LEVEL_SENSITIVE,
175 .polarity = ACPI_ACTIVE_HIGH,
180 static int __init chuwi_hi8_init(void)
183 * Avoid the acpi_unregister_gsi() call in x86_acpi_irq_helper_get()
184 * breaking the touchscreen + logging various errors when the Windows
187 if (acpi_dev_present("MSSL0001", NULL, 1))
193 const struct x86_dev_info chuwi_hi8_info __initconst = {
194 .i2c_client_info = chuwi_hi8_i2c_clients,
195 .i2c_client_count = ARRAY_SIZE(chuwi_hi8_i2c_clients),
196 .init = chuwi_hi8_init,
199 #define CZC_EC_EXTRA_PORT 0x68
200 #define CZC_EC_ANDROID_KEYS 0x63
202 static int __init czc_p10t_init(void)
205 * The device boots up in "Windows 7" mode, when the home button sends a
206 * Windows specific key sequence (Left Meta + D) and the second button
207 * sends an unknown one while also toggling the Radio Kill Switch.
208 * This is a surprising behavior when the second button is labeled "Back".
210 * The vendor-supplied Android-x86 build switches the device to a "Android"
211 * mode by writing value 0x63 to the I/O port 0x68. This just seems to just
212 * set bit 6 on address 0x96 in the EC region; switching the bit directly
213 * seems to achieve the same result. It uses a "p10t_switcher" to do the
214 * job. It doesn't seem to be able to do anything else, and no other use
215 * of the port 0x68 is known.
217 * In the Android mode, the home button sends just a single scancode,
218 * which can be handled in Linux userspace more reasonably and the back
219 * button only sends a scancode without toggling the kill switch.
220 * The scancode can then be mapped either to Back or RF Kill functionality
221 * in userspace, depending on how the button is labeled on that particular
224 outb(CZC_EC_ANDROID_KEYS, CZC_EC_EXTRA_PORT);
228 const struct x86_dev_info czc_p10t __initconst = {
229 .init = czc_p10t_init,
232 /* Medion Lifetab S10346 tablets have an Android factory img with everything hardcoded */
233 static const char * const medion_lifetab_s10346_accel_mount_matrix[] = {
239 static const struct property_entry medion_lifetab_s10346_accel_props[] = {
240 PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", medion_lifetab_s10346_accel_mount_matrix),
244 static const struct software_node medion_lifetab_s10346_accel_node = {
245 .properties = medion_lifetab_s10346_accel_props,
248 /* Note the LCD panel is mounted upside down, this is correctly indicated in the VBT */
249 static const struct property_entry medion_lifetab_s10346_touchscreen_props[] = {
250 PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
251 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
255 static const struct software_node medion_lifetab_s10346_touchscreen_node = {
256 .properties = medion_lifetab_s10346_touchscreen_props,
259 static const struct x86_i2c_client_info medion_lifetab_s10346_i2c_clients[] __initconst = {
261 /* kxtj21009 accel */
265 .dev_name = "kxtj21009",
266 .swnode = &medion_lifetab_s10346_accel_node,
268 .adapter_path = "\\_SB_.I2C3",
270 .type = X86_ACPI_IRQ_TYPE_GPIOINT,
271 .chip = "INT33FC:02",
273 .trigger = ACPI_EDGE_SENSITIVE,
274 .polarity = ACPI_ACTIVE_HIGH,
277 /* goodix touchscreen */
279 .type = "GDIX1001:00",
281 .dev_name = "goodix_ts",
282 .swnode = &medion_lifetab_s10346_touchscreen_node,
284 .adapter_path = "\\_SB_.I2C4",
286 .type = X86_ACPI_IRQ_TYPE_APIC,
288 .trigger = ACPI_EDGE_SENSITIVE,
289 .polarity = ACPI_ACTIVE_LOW,
294 static struct gpiod_lookup_table medion_lifetab_s10346_goodix_gpios = {
295 .dev_id = "i2c-goodix_ts",
297 GPIO_LOOKUP("INT33FC:01", 26, "reset", GPIO_ACTIVE_HIGH),
298 GPIO_LOOKUP("INT33FC:02", 3, "irq", GPIO_ACTIVE_HIGH),
303 static struct gpiod_lookup_table * const medion_lifetab_s10346_gpios[] = {
304 &medion_lifetab_s10346_goodix_gpios,
308 const struct x86_dev_info medion_lifetab_s10346_info __initconst = {
309 .i2c_client_info = medion_lifetab_s10346_i2c_clients,
310 .i2c_client_count = ARRAY_SIZE(medion_lifetab_s10346_i2c_clients),
311 .gpiod_lookup_tables = medion_lifetab_s10346_gpios,
314 /* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */
315 static const char * const nextbook_ares8_accel_mount_matrix[] = {
321 static const struct property_entry nextbook_ares8_accel_props[] = {
322 PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", nextbook_ares8_accel_mount_matrix),
326 static const struct software_node nextbook_ares8_accel_node = {
327 .properties = nextbook_ares8_accel_props,
330 static const struct property_entry nextbook_ares8_touchscreen_props[] = {
331 PROPERTY_ENTRY_U32("touchscreen-size-x", 800),
332 PROPERTY_ENTRY_U32("touchscreen-size-y", 1280),
336 static const struct software_node nextbook_ares8_touchscreen_node = {
337 .properties = nextbook_ares8_touchscreen_props,
340 static const struct x86_i2c_client_info nextbook_ares8_i2c_clients[] __initconst = {
342 /* Freescale MMA8653FC accel */
346 .dev_name = "mma8653",
347 .swnode = &nextbook_ares8_accel_node,
349 .adapter_path = "\\_SB_.I2C3",
351 /* FT5416DQ9 touchscreen controller */
353 .type = "edt-ft5x06",
355 .dev_name = "ft5416",
356 .swnode = &nextbook_ares8_touchscreen_node,
358 .adapter_path = "\\_SB_.I2C4",
360 .type = X86_ACPI_IRQ_TYPE_GPIOINT,
361 .chip = "INT33FC:02",
363 .trigger = ACPI_EDGE_SENSITIVE,
364 .polarity = ACPI_ACTIVE_LOW,
369 static struct gpiod_lookup_table * const nextbook_ares8_gpios[] = {
370 &int3496_reference_gpios,
374 const struct x86_dev_info nextbook_ares8_info __initconst = {
375 .i2c_client_info = nextbook_ares8_i2c_clients,
376 .i2c_client_count = ARRAY_SIZE(nextbook_ares8_i2c_clients),
377 .pdev_info = int3496_pdevs,
379 .gpiod_lookup_tables = nextbook_ares8_gpios,
380 .invalid_aei_gpiochip = "INT33FC:02",
385 * This is a standard Windows tablet, but it has a special Dolby button.
386 * This button has a WMI interface, but that is broken. Instead of trying to
387 * use the broken WMI interface, instantiate a gpio_keys device for this.
389 static struct x86_gpio_button peaq_c1010_button = {
396 .debounce_interval = 50,
398 .chip = "INT33FC:00",
402 const struct x86_dev_info peaq_c1010_info __initconst = {
403 .gpio_button = &peaq_c1010_button,
405 * Move the ACPI event handler used by the broken WMI interface out of
406 * the way. This is the only event handler on INT33FC:00.
408 .invalid_aei_gpiochip = "INT33FC:00",
412 * Whitelabel (sold as various brands) TM800A550L tablets.
413 * These tablet's DSDT contains a whole bunch of bogus ACPI I2C devices
414 * (removed through acpi_quirk_skip_i2c_client_enumeration()) and
415 * the touchscreen fwnode has the wrong GPIOs.
417 static const char * const whitelabel_tm800a550l_accel_mount_matrix[] = {
423 static const struct property_entry whitelabel_tm800a550l_accel_props[] = {
424 PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", whitelabel_tm800a550l_accel_mount_matrix),
428 static const struct software_node whitelabel_tm800a550l_accel_node = {
429 .properties = whitelabel_tm800a550l_accel_props,
432 static const struct property_entry whitelabel_tm800a550l_goodix_props[] = {
433 PROPERTY_ENTRY_STRING("firmware-name", "gt912-tm800a550l.fw"),
434 PROPERTY_ENTRY_STRING("goodix,config-name", "gt912-tm800a550l.cfg"),
435 PROPERTY_ENTRY_U32("goodix,main-clk", 54),
439 static const struct software_node whitelabel_tm800a550l_goodix_node = {
440 .properties = whitelabel_tm800a550l_goodix_props,
443 static const struct x86_i2c_client_info whitelabel_tm800a550l_i2c_clients[] __initconst = {
445 /* goodix touchscreen */
447 .type = "GDIX1001:00",
449 .dev_name = "goodix_ts",
450 .swnode = &whitelabel_tm800a550l_goodix_node,
452 .adapter_path = "\\_SB_.I2C2",
454 .type = X86_ACPI_IRQ_TYPE_APIC,
456 .trigger = ACPI_EDGE_SENSITIVE,
457 .polarity = ACPI_ACTIVE_HIGH,
460 /* kxcj91008 accel */
464 .dev_name = "kxcj91008",
465 .swnode = &whitelabel_tm800a550l_accel_node,
467 .adapter_path = "\\_SB_.I2C3",
471 static struct gpiod_lookup_table whitelabel_tm800a550l_goodix_gpios = {
472 .dev_id = "i2c-goodix_ts",
474 GPIO_LOOKUP("INT33FC:01", 26, "reset", GPIO_ACTIVE_HIGH),
475 GPIO_LOOKUP("INT33FC:02", 3, "irq", GPIO_ACTIVE_HIGH),
480 static struct gpiod_lookup_table * const whitelabel_tm800a550l_gpios[] = {
481 &whitelabel_tm800a550l_goodix_gpios,
485 const struct x86_dev_info whitelabel_tm800a550l_info __initconst = {
486 .i2c_client_info = whitelabel_tm800a550l_i2c_clients,
487 .i2c_client_count = ARRAY_SIZE(whitelabel_tm800a550l_i2c_clients),
488 .gpiod_lookup_tables = whitelabel_tm800a550l_gpios,
492 * If the EFI bootloader is not Xiaomi's own signed Android loader, then the
493 * Xiaomi Mi Pad 2 X86 tablet sets OSID in the DSDT to 1 (Windows), causing
494 * a bunch of devices to be hidden.
496 * This takes care of instantiating the hidden devices manually.
498 static const struct x86_i2c_client_info xiaomi_mipad2_i2c_clients[] __initconst = {
500 /* BQ27520 fuel-gauge */
504 .dev_name = "bq27520",
505 .swnode = &fg_bq25890_supply_node,
507 .adapter_path = "\\_SB_.PCI0.I2C1",
509 /* KTD2026 RGB notification LED controller */
513 .dev_name = "ktd2026",
515 .adapter_path = "\\_SB_.PCI0.I2C3",
519 const struct x86_dev_info xiaomi_mipad2_info __initconst = {
520 .i2c_client_info = xiaomi_mipad2_i2c_clients,
521 .i2c_client_count = ARRAY_SIZE(xiaomi_mipad2_i2c_clients),