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,
50 .con_id = "NVT-ts_irq",
53 /* BMA250E accelerometer */
57 .swnode = &acer_b1_750_bma250e_node,
59 .adapter_path = "\\_SB_.I2C3",
61 .type = X86_ACPI_IRQ_TYPE_GPIOINT,
64 .trigger = ACPI_LEVEL_SENSITIVE,
65 .polarity = ACPI_ACTIVE_HIGH,
66 .con_id = "bma250e_irq",
71 static struct gpiod_lookup_table acer_b1_750_goodix_gpios = {
72 .dev_id = "i2c-NVT-ts",
74 GPIO_LOOKUP("INT33FC:01", 26, "reset", GPIO_ACTIVE_LOW),
79 static struct gpiod_lookup_table * const acer_b1_750_gpios[] = {
80 &acer_b1_750_goodix_gpios,
81 &int3496_reference_gpios,
85 const struct x86_dev_info acer_b1_750_info __initconst = {
86 .i2c_client_info = acer_b1_750_i2c_clients,
87 .i2c_client_count = ARRAY_SIZE(acer_b1_750_i2c_clients),
88 .pdev_info = int3496_pdevs,
90 .gpiod_lookup_tables = acer_b1_750_gpios,
95 * This is a standard Windows tablet, but it has an extra "quick launch" button
96 * which is not described in the ACPI tables in anyway.
97 * Use the x86-android-tablets infra to create a gpio-button device for this.
99 static const struct x86_gpio_button advantech_mica_071_button __initconst = {
106 .debounce_interval = 50,
108 .chip = "INT33FC:00",
112 const struct x86_dev_info advantech_mica_071_info __initconst = {
113 .gpio_button = &advantech_mica_071_button,
114 .gpio_button_count = 1,
118 * When booted with the BIOS set to Android mode the Chuwi Hi8 (CWI509) DSDT
119 * contains a whole bunch of bogus ACPI I2C devices and is missing entries
120 * for the touchscreen and the accelerometer.
122 static const struct property_entry chuwi_hi8_gsl1680_props[] = {
123 PROPERTY_ENTRY_U32("touchscreen-size-x", 1665),
124 PROPERTY_ENTRY_U32("touchscreen-size-y", 1140),
125 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
126 PROPERTY_ENTRY_BOOL("silead,home-button"),
127 PROPERTY_ENTRY_STRING("firmware-name", "gsl1680-chuwi-hi8.fw"),
131 static const struct software_node chuwi_hi8_gsl1680_node = {
132 .properties = chuwi_hi8_gsl1680_props,
135 static const char * const chuwi_hi8_mount_matrix[] = {
141 static const struct property_entry chuwi_hi8_bma250e_props[] = {
142 PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", chuwi_hi8_mount_matrix),
146 static const struct software_node chuwi_hi8_bma250e_node = {
147 .properties = chuwi_hi8_bma250e_props,
150 static const struct x86_i2c_client_info chuwi_hi8_i2c_clients[] __initconst = {
152 /* Silead touchscreen */
156 .swnode = &chuwi_hi8_gsl1680_node,
158 .adapter_path = "\\_SB_.I2C4",
160 .type = X86_ACPI_IRQ_TYPE_APIC,
162 .trigger = ACPI_EDGE_SENSITIVE,
163 .polarity = ACPI_ACTIVE_HIGH,
166 /* BMA250E accelerometer */
170 .swnode = &chuwi_hi8_bma250e_node,
172 .adapter_path = "\\_SB_.I2C3",
174 .type = X86_ACPI_IRQ_TYPE_GPIOINT,
175 .chip = "INT33FC:02",
177 .trigger = ACPI_LEVEL_SENSITIVE,
178 .polarity = ACPI_ACTIVE_HIGH,
179 .con_id = "bma250e_irq",
184 static int __init chuwi_hi8_init(void)
187 * Avoid the acpi_unregister_gsi() call in x86_acpi_irq_helper_get()
188 * breaking the touchscreen + logging various errors when the Windows
191 if (acpi_dev_present("MSSL0001", NULL, 1))
197 const struct x86_dev_info chuwi_hi8_info __initconst = {
198 .i2c_client_info = chuwi_hi8_i2c_clients,
199 .i2c_client_count = ARRAY_SIZE(chuwi_hi8_i2c_clients),
200 .init = chuwi_hi8_init,
204 * Cyberbook T116 Android version
205 * This comes in both Windows and Android versions and even on Android
206 * the DSDT is mostly sane. This tablet has 2 extra general purpose buttons
207 * in the button row with the power + volume-buttons labeled P and F.
208 * Use the x86-android-tablets infra to create a gpio-button device for these.
210 static const struct x86_gpio_button cyberbook_t116_buttons[] __initconst = {
218 .debounce_interval = 50,
220 .chip = "INT33FF:00",
230 .debounce_interval = 50,
232 .chip = "INT33FF:03",
237 const struct x86_dev_info cyberbook_t116_info __initconst = {
238 .gpio_button = cyberbook_t116_buttons,
239 .gpio_button_count = ARRAY_SIZE(cyberbook_t116_buttons),
242 #define CZC_EC_EXTRA_PORT 0x68
243 #define CZC_EC_ANDROID_KEYS 0x63
245 static int __init czc_p10t_init(void)
248 * The device boots up in "Windows 7" mode, when the home button sends a
249 * Windows specific key sequence (Left Meta + D) and the second button
250 * sends an unknown one while also toggling the Radio Kill Switch.
251 * This is a surprising behavior when the second button is labeled "Back".
253 * The vendor-supplied Android-x86 build switches the device to a "Android"
254 * mode by writing value 0x63 to the I/O port 0x68. This just seems to just
255 * set bit 6 on address 0x96 in the EC region; switching the bit directly
256 * seems to achieve the same result. It uses a "p10t_switcher" to do the
257 * job. It doesn't seem to be able to do anything else, and no other use
258 * of the port 0x68 is known.
260 * In the Android mode, the home button sends just a single scancode,
261 * which can be handled in Linux userspace more reasonably and the back
262 * button only sends a scancode without toggling the kill switch.
263 * The scancode can then be mapped either to Back or RF Kill functionality
264 * in userspace, depending on how the button is labeled on that particular
267 outb(CZC_EC_ANDROID_KEYS, CZC_EC_EXTRA_PORT);
271 const struct x86_dev_info czc_p10t __initconst = {
272 .init = czc_p10t_init,
275 /* Medion Lifetab S10346 tablets have an Android factory img with everything hardcoded */
276 static const char * const medion_lifetab_s10346_accel_mount_matrix[] = {
282 static const struct property_entry medion_lifetab_s10346_accel_props[] = {
283 PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", medion_lifetab_s10346_accel_mount_matrix),
287 static const struct software_node medion_lifetab_s10346_accel_node = {
288 .properties = medion_lifetab_s10346_accel_props,
291 /* Note the LCD panel is mounted upside down, this is correctly indicated in the VBT */
292 static const struct property_entry medion_lifetab_s10346_touchscreen_props[] = {
293 PROPERTY_ENTRY_BOOL("touchscreen-inverted-x"),
294 PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
298 static const struct software_node medion_lifetab_s10346_touchscreen_node = {
299 .properties = medion_lifetab_s10346_touchscreen_props,
302 static const struct x86_i2c_client_info medion_lifetab_s10346_i2c_clients[] __initconst = {
304 /* kxtj21009 accel */
308 .dev_name = "kxtj21009",
309 .swnode = &medion_lifetab_s10346_accel_node,
311 .adapter_path = "\\_SB_.I2C3",
313 .type = X86_ACPI_IRQ_TYPE_GPIOINT,
314 .chip = "INT33FC:02",
316 .trigger = ACPI_EDGE_SENSITIVE,
317 .polarity = ACPI_ACTIVE_HIGH,
318 .con_id = "kxtj21009_irq",
321 /* goodix touchscreen */
323 .type = "GDIX1001:00",
325 .dev_name = "goodix_ts",
326 .swnode = &medion_lifetab_s10346_touchscreen_node,
328 .adapter_path = "\\_SB_.I2C4",
330 .type = X86_ACPI_IRQ_TYPE_APIC,
332 .trigger = ACPI_EDGE_SENSITIVE,
333 .polarity = ACPI_ACTIVE_LOW,
338 static struct gpiod_lookup_table medion_lifetab_s10346_goodix_gpios = {
339 .dev_id = "i2c-goodix_ts",
341 GPIO_LOOKUP("INT33FC:01", 26, "reset", GPIO_ACTIVE_HIGH),
342 GPIO_LOOKUP("INT33FC:02", 3, "irq", GPIO_ACTIVE_HIGH),
347 static struct gpiod_lookup_table * const medion_lifetab_s10346_gpios[] = {
348 &medion_lifetab_s10346_goodix_gpios,
352 const struct x86_dev_info medion_lifetab_s10346_info __initconst = {
353 .i2c_client_info = medion_lifetab_s10346_i2c_clients,
354 .i2c_client_count = ARRAY_SIZE(medion_lifetab_s10346_i2c_clients),
355 .gpiod_lookup_tables = medion_lifetab_s10346_gpios,
358 /* Nextbook Ares 8 (BYT) tablets have an Android factory img with everything hardcoded */
359 static const char * const nextbook_ares8_accel_mount_matrix[] = {
365 static const struct property_entry nextbook_ares8_accel_props[] = {
366 PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", nextbook_ares8_accel_mount_matrix),
370 static const struct software_node nextbook_ares8_accel_node = {
371 .properties = nextbook_ares8_accel_props,
374 static const struct property_entry nextbook_ares8_touchscreen_props[] = {
375 PROPERTY_ENTRY_U32("touchscreen-size-x", 800),
376 PROPERTY_ENTRY_U32("touchscreen-size-y", 1280),
380 static const struct software_node nextbook_ares8_touchscreen_node = {
381 .properties = nextbook_ares8_touchscreen_props,
384 static const struct x86_i2c_client_info nextbook_ares8_i2c_clients[] __initconst = {
386 /* Freescale MMA8653FC accel */
390 .dev_name = "mma8653",
391 .swnode = &nextbook_ares8_accel_node,
393 .adapter_path = "\\_SB_.I2C3",
395 /* FT5416DQ9 touchscreen controller */
397 .type = "edt-ft5x06",
399 .dev_name = "ft5416",
400 .swnode = &nextbook_ares8_touchscreen_node,
402 .adapter_path = "\\_SB_.I2C4",
404 .type = X86_ACPI_IRQ_TYPE_GPIOINT,
405 .chip = "INT33FC:02",
407 .trigger = ACPI_EDGE_SENSITIVE,
408 .polarity = ACPI_ACTIVE_LOW,
409 .con_id = "ft5416_irq",
414 static struct gpiod_lookup_table * const nextbook_ares8_gpios[] = {
415 &int3496_reference_gpios,
419 const struct x86_dev_info nextbook_ares8_info __initconst = {
420 .i2c_client_info = nextbook_ares8_i2c_clients,
421 .i2c_client_count = ARRAY_SIZE(nextbook_ares8_i2c_clients),
422 .pdev_info = int3496_pdevs,
424 .gpiod_lookup_tables = nextbook_ares8_gpios,
427 /* Nextbook Ares 8A (CHT) tablets have an Android factory img with everything hardcoded */
428 static const char * const nextbook_ares8a_accel_mount_matrix[] = {
434 static const struct property_entry nextbook_ares8a_accel_props[] = {
435 PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", nextbook_ares8a_accel_mount_matrix),
439 static const struct software_node nextbook_ares8a_accel_node = {
440 .properties = nextbook_ares8a_accel_props,
443 static const struct x86_i2c_client_info nextbook_ares8a_i2c_clients[] __initconst = {
445 /* Freescale MMA8653FC accel */
449 .dev_name = "mma8653",
450 .swnode = &nextbook_ares8a_accel_node,
452 .adapter_path = "\\_SB_.PCI0.I2C3",
454 /* FT5416DQ9 touchscreen controller */
456 .type = "edt-ft5x06",
458 .dev_name = "ft5416",
459 .swnode = &nextbook_ares8_touchscreen_node,
461 .adapter_path = "\\_SB_.PCI0.I2C6",
463 .type = X86_ACPI_IRQ_TYPE_GPIOINT,
464 .chip = "INT33FF:01",
466 .trigger = ACPI_EDGE_SENSITIVE,
467 .polarity = ACPI_ACTIVE_LOW,
468 .con_id = "ft5416_irq",
473 static struct gpiod_lookup_table nextbook_ares8a_ft5416_gpios = {
474 .dev_id = "i2c-ft5416",
476 GPIO_LOOKUP("INT33FF:01", 25, "reset", GPIO_ACTIVE_LOW),
481 static struct gpiod_lookup_table * const nextbook_ares8a_gpios[] = {
482 &nextbook_ares8a_ft5416_gpios,
486 const struct x86_dev_info nextbook_ares8a_info __initconst = {
487 .i2c_client_info = nextbook_ares8a_i2c_clients,
488 .i2c_client_count = ARRAY_SIZE(nextbook_ares8a_i2c_clients),
489 .gpiod_lookup_tables = nextbook_ares8a_gpios,
494 * This is a standard Windows tablet, but it has a special Dolby button.
495 * This button has a WMI interface, but that is broken. Instead of trying to
496 * use the broken WMI interface, instantiate a gpio_keys device for this.
498 static const struct x86_gpio_button peaq_c1010_button __initconst = {
505 .debounce_interval = 50,
507 .chip = "INT33FC:00",
511 const struct x86_dev_info peaq_c1010_info __initconst = {
512 .gpio_button = &peaq_c1010_button,
513 .gpio_button_count = 1,
517 * Whitelabel (sold as various brands) TM800A550L tablets.
518 * These tablet's DSDT contains a whole bunch of bogus ACPI I2C devices
519 * (removed through acpi_quirk_skip_i2c_client_enumeration()) and
520 * the touchscreen fwnode has the wrong GPIOs.
522 static const char * const whitelabel_tm800a550l_accel_mount_matrix[] = {
528 static const struct property_entry whitelabel_tm800a550l_accel_props[] = {
529 PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", whitelabel_tm800a550l_accel_mount_matrix),
533 static const struct software_node whitelabel_tm800a550l_accel_node = {
534 .properties = whitelabel_tm800a550l_accel_props,
537 static const struct property_entry whitelabel_tm800a550l_goodix_props[] = {
538 PROPERTY_ENTRY_STRING("firmware-name", "gt912-tm800a550l.fw"),
539 PROPERTY_ENTRY_STRING("goodix,config-name", "gt912-tm800a550l.cfg"),
540 PROPERTY_ENTRY_U32("goodix,main-clk", 54),
544 static const struct software_node whitelabel_tm800a550l_goodix_node = {
545 .properties = whitelabel_tm800a550l_goodix_props,
548 static const struct x86_i2c_client_info whitelabel_tm800a550l_i2c_clients[] __initconst = {
550 /* goodix touchscreen */
552 .type = "GDIX1001:00",
554 .dev_name = "goodix_ts",
555 .swnode = &whitelabel_tm800a550l_goodix_node,
557 .adapter_path = "\\_SB_.I2C2",
559 .type = X86_ACPI_IRQ_TYPE_APIC,
561 .trigger = ACPI_EDGE_SENSITIVE,
562 .polarity = ACPI_ACTIVE_HIGH,
565 /* kxcj91008 accel */
569 .dev_name = "kxcj91008",
570 .swnode = &whitelabel_tm800a550l_accel_node,
572 .adapter_path = "\\_SB_.I2C3",
576 static struct gpiod_lookup_table whitelabel_tm800a550l_goodix_gpios = {
577 .dev_id = "i2c-goodix_ts",
579 GPIO_LOOKUP("INT33FC:01", 26, "reset", GPIO_ACTIVE_HIGH),
580 GPIO_LOOKUP("INT33FC:02", 3, "irq", GPIO_ACTIVE_HIGH),
585 static struct gpiod_lookup_table * const whitelabel_tm800a550l_gpios[] = {
586 &whitelabel_tm800a550l_goodix_gpios,
590 const struct x86_dev_info whitelabel_tm800a550l_info __initconst = {
591 .i2c_client_info = whitelabel_tm800a550l_i2c_clients,
592 .i2c_client_count = ARRAY_SIZE(whitelabel_tm800a550l_i2c_clients),
593 .gpiod_lookup_tables = whitelabel_tm800a550l_gpios,
597 * If the EFI bootloader is not Xiaomi's own signed Android loader, then the
598 * Xiaomi Mi Pad 2 X86 tablet sets OSID in the DSDT to 1 (Windows), causing
599 * a bunch of devices to be hidden.
601 * This takes care of instantiating the hidden devices manually.
603 static const struct x86_i2c_client_info xiaomi_mipad2_i2c_clients[] __initconst = {
605 /* BQ27520 fuel-gauge */
609 .dev_name = "bq27520",
610 .swnode = &fg_bq25890_supply_node,
612 .adapter_path = "\\_SB_.PCI0.I2C1",
614 /* KTD2026 RGB notification LED controller */
618 .dev_name = "ktd2026",
620 .adapter_path = "\\_SB_.PCI0.I2C3",
624 const struct x86_dev_info xiaomi_mipad2_info __initconst = {
625 .i2c_client_info = xiaomi_mipad2_i2c_clients,
626 .i2c_client_count = ARRAY_SIZE(xiaomi_mipad2_i2c_clients),