x86-android-tablets.h 4.0 KB

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