asus.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Board info for Asus X86 tablets which ship with Android as the factory image
  4. * and which have broken DSDT tables. 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 <hansg@kernel.org>
  9. */
  10. #include <linux/gpio/machine.h>
  11. #include <linux/gpio/property.h>
  12. #include <linux/input-event-codes.h>
  13. #include <linux/platform_device.h>
  14. #include "shared-psy-info.h"
  15. #include "x86-android-tablets.h"
  16. /* Asus ME176C and TF103C tablets shared data */
  17. static const struct property_entry asus_me176c_tf103c_int3496_props[] __initconst = {
  18. PROPERTY_ENTRY_GPIO("id-gpios", &baytrail_gpiochip_nodes[2], 22, GPIO_ACTIVE_HIGH),
  19. { }
  20. };
  21. static const struct platform_device_info asus_me176c_tf103c_pdevs[] __initconst = {
  22. {
  23. /* For micro USB ID pin handling */
  24. .name = "intel-int3496",
  25. .id = PLATFORM_DEVID_NONE,
  26. .properties = asus_me176c_tf103c_int3496_props,
  27. },
  28. };
  29. static const struct software_node asus_me176c_tf103c_gpio_keys_node = {
  30. .name = "lid_sw",
  31. };
  32. static const struct property_entry asus_me176c_tf103c_lid_props[] = {
  33. PROPERTY_ENTRY_U32("linux,input-type", EV_SW),
  34. PROPERTY_ENTRY_U32("linux,code", SW_LID),
  35. PROPERTY_ENTRY_STRING("label", "lid_sw"),
  36. PROPERTY_ENTRY_GPIO("gpios", &baytrail_gpiochip_nodes[2], 12, GPIO_ACTIVE_LOW),
  37. PROPERTY_ENTRY_U32("debounce-interval", 50),
  38. PROPERTY_ENTRY_BOOL("wakeup-source"),
  39. { }
  40. };
  41. static const struct software_node asus_me176c_tf103c_lid_node = {
  42. .parent = &asus_me176c_tf103c_gpio_keys_node,
  43. .properties = asus_me176c_tf103c_lid_props,
  44. };
  45. static const struct software_node *asus_me176c_tf103c_lid_swnodes[] = {
  46. &asus_me176c_tf103c_gpio_keys_node,
  47. &asus_me176c_tf103c_lid_node,
  48. NULL
  49. };
  50. /* Asus ME176C tablets have an Android factory image with everything hardcoded */
  51. static const char * const asus_me176c_accel_mount_matrix[] = {
  52. "-1", "0", "0",
  53. "0", "1", "0",
  54. "0", "0", "1"
  55. };
  56. static const struct property_entry asus_me176c_accel_props[] = {
  57. PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", asus_me176c_accel_mount_matrix),
  58. { }
  59. };
  60. static const struct software_node asus_me176c_accel_node = {
  61. .properties = asus_me176c_accel_props,
  62. };
  63. static const struct property_entry asus_me176c_bq24190_props[] = {
  64. PROPERTY_ENTRY_STRING_ARRAY_LEN("supplied-from", tusb1211_chg_det_psy, 1),
  65. PROPERTY_ENTRY_REF("monitored-battery", &generic_lipo_hv_4v35_battery_node),
  66. PROPERTY_ENTRY_U32("ti,system-minimum-microvolt", 3600000),
  67. PROPERTY_ENTRY_BOOL("omit-battery-class"),
  68. PROPERTY_ENTRY_BOOL("disable-reset"),
  69. { }
  70. };
  71. static const struct software_node asus_me176c_bq24190_node = {
  72. .properties = asus_me176c_bq24190_props,
  73. };
  74. static const struct property_entry asus_me176c_ug3105_props[] = {
  75. PROPERTY_ENTRY_STRING_ARRAY_LEN("supplied-from", bq24190_psy, 1),
  76. PROPERTY_ENTRY_REF("monitored-battery", &generic_lipo_hv_4v35_battery_node),
  77. PROPERTY_ENTRY_U32("upisemi,rsns-microohm", 10000),
  78. { }
  79. };
  80. static const struct software_node asus_me176c_ug3105_node = {
  81. .properties = asus_me176c_ug3105_props,
  82. };
  83. static const struct property_entry asus_me176c_touchscreen_props[] = {
  84. PROPERTY_ENTRY_GPIO("reset-gpios", &baytrail_gpiochip_nodes[0], 60, GPIO_ACTIVE_HIGH),
  85. PROPERTY_ENTRY_GPIO("irq-gpios", &baytrail_gpiochip_nodes[2], 28, GPIO_ACTIVE_HIGH),
  86. { }
  87. };
  88. static const struct software_node asus_me176c_touchscreen_node = {
  89. .properties = asus_me176c_touchscreen_props,
  90. };
  91. static const struct x86_i2c_client_info asus_me176c_i2c_clients[] __initconst = {
  92. {
  93. /* bq24297 battery charger */
  94. .board_info = {
  95. .type = "bq24190",
  96. .addr = 0x6b,
  97. .dev_name = "bq24297",
  98. .swnode = &asus_me176c_bq24190_node,
  99. .platform_data = &bq24190_pdata,
  100. },
  101. .adapter_path = "\\_SB_.I2C1",
  102. .irq_data = {
  103. .type = X86_ACPI_IRQ_TYPE_PMIC,
  104. .chip = "\\_SB_.I2C7.PMIC",
  105. .domain = DOMAIN_BUS_WAKEUP,
  106. .index = 0,
  107. },
  108. }, {
  109. /* ug3105 battery monitor */
  110. .board_info = {
  111. .type = "ug3105",
  112. .addr = 0x70,
  113. .dev_name = "ug3105",
  114. .swnode = &asus_me176c_ug3105_node,
  115. },
  116. .adapter_path = "\\_SB_.I2C1",
  117. }, {
  118. /* ak09911 compass */
  119. .board_info = {
  120. .type = "ak09911",
  121. .addr = 0x0c,
  122. .dev_name = "ak09911",
  123. },
  124. .adapter_path = "\\_SB_.I2C5",
  125. }, {
  126. /* kxtj21009 accelerometer */
  127. .board_info = {
  128. .type = "kxtj21009",
  129. .addr = 0x0f,
  130. .dev_name = "kxtj21009",
  131. .swnode = &asus_me176c_accel_node,
  132. },
  133. .adapter_path = "\\_SB_.I2C5",
  134. .irq_data = {
  135. .type = X86_ACPI_IRQ_TYPE_APIC,
  136. .index = 0x44,
  137. .trigger = ACPI_EDGE_SENSITIVE,
  138. .polarity = ACPI_ACTIVE_LOW,
  139. },
  140. }, {
  141. /* goodix touchscreen */
  142. .board_info = {
  143. .type = "GDIX1001:00",
  144. .addr = 0x14,
  145. .dev_name = "goodix_ts",
  146. .swnode = &asus_me176c_touchscreen_node,
  147. },
  148. .adapter_path = "\\_SB_.I2C6",
  149. .irq_data = {
  150. .type = X86_ACPI_IRQ_TYPE_APIC,
  151. .index = 0x45,
  152. .trigger = ACPI_EDGE_SENSITIVE,
  153. .polarity = ACPI_ACTIVE_LOW,
  154. },
  155. },
  156. };
  157. static const struct x86_serdev_info asus_me176c_serdevs[] __initconst = {
  158. {
  159. .ctrl.acpi.hid = "80860F0A",
  160. .ctrl.acpi.uid = "2",
  161. .ctrl_devname = "serial0",
  162. .serdev_hid = "BCM2E3A",
  163. },
  164. };
  165. const struct x86_dev_info asus_me176c_info __initconst = {
  166. .i2c_client_info = asus_me176c_i2c_clients,
  167. .i2c_client_count = ARRAY_SIZE(asus_me176c_i2c_clients),
  168. .pdev_info = asus_me176c_tf103c_pdevs,
  169. .pdev_count = ARRAY_SIZE(asus_me176c_tf103c_pdevs),
  170. .serdev_info = asus_me176c_serdevs,
  171. .serdev_count = ARRAY_SIZE(asus_me176c_serdevs),
  172. .gpio_button_swnodes = asus_me176c_tf103c_lid_swnodes,
  173. .swnode_group = generic_lipo_hv_4v35_battery_swnodes,
  174. .modules = bq24190_modules,
  175. .gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
  176. };
  177. /* Asus TF103C tablets have an Android factory image with everything hardcoded */
  178. static const char * const asus_tf103c_accel_mount_matrix[] = {
  179. "0", "-1", "0",
  180. "-1", "0", "0",
  181. "0", "0", "1"
  182. };
  183. static const struct property_entry asus_tf103c_accel_props[] = {
  184. PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", asus_tf103c_accel_mount_matrix),
  185. { }
  186. };
  187. static const struct software_node asus_tf103c_accel_node = {
  188. .properties = asus_tf103c_accel_props,
  189. };
  190. static const struct property_entry asus_tf103c_touchscreen_props[] = {
  191. PROPERTY_ENTRY_STRING("compatible", "atmel,atmel_mxt_ts"),
  192. { }
  193. };
  194. static const struct software_node asus_tf103c_touchscreen_node = {
  195. .properties = asus_tf103c_touchscreen_props,
  196. };
  197. static const struct property_entry asus_tf103c_bq24190_props[] = {
  198. PROPERTY_ENTRY_STRING_ARRAY_LEN("supplied-from", tusb1211_chg_det_psy, 1),
  199. PROPERTY_ENTRY_REF("monitored-battery", &generic_lipo_4v2_battery_node),
  200. PROPERTY_ENTRY_U32("ti,system-minimum-microvolt", 3600000),
  201. PROPERTY_ENTRY_BOOL("omit-battery-class"),
  202. PROPERTY_ENTRY_BOOL("disable-reset"),
  203. { }
  204. };
  205. static const struct software_node asus_tf103c_bq24190_node = {
  206. .properties = asus_tf103c_bq24190_props,
  207. };
  208. static const struct property_entry asus_tf103c_ug3105_props[] = {
  209. PROPERTY_ENTRY_STRING_ARRAY_LEN("supplied-from", bq24190_psy, 1),
  210. PROPERTY_ENTRY_REF("monitored-battery", &generic_lipo_4v2_battery_node),
  211. PROPERTY_ENTRY_U32("upisemi,rsns-microohm", 5000),
  212. { }
  213. };
  214. static const struct software_node asus_tf103c_ug3105_node = {
  215. .properties = asus_tf103c_ug3105_props,
  216. };
  217. static const struct x86_i2c_client_info asus_tf103c_i2c_clients[] __initconst = {
  218. {
  219. /* bq24297 battery charger */
  220. .board_info = {
  221. .type = "bq24190",
  222. .addr = 0x6b,
  223. .dev_name = "bq24297",
  224. .swnode = &asus_tf103c_bq24190_node,
  225. .platform_data = &bq24190_pdata,
  226. },
  227. .adapter_path = "\\_SB_.I2C1",
  228. .irq_data = {
  229. .type = X86_ACPI_IRQ_TYPE_PMIC,
  230. .chip = "\\_SB_.I2C7.PMIC",
  231. .domain = DOMAIN_BUS_WAKEUP,
  232. .index = 0,
  233. },
  234. }, {
  235. /* ug3105 battery monitor */
  236. .board_info = {
  237. .type = "ug3105",
  238. .addr = 0x70,
  239. .dev_name = "ug3105",
  240. .swnode = &asus_tf103c_ug3105_node,
  241. },
  242. .adapter_path = "\\_SB_.I2C1",
  243. }, {
  244. /* ak09911 compass */
  245. .board_info = {
  246. .type = "ak09911",
  247. .addr = 0x0c,
  248. .dev_name = "ak09911",
  249. },
  250. .adapter_path = "\\_SB_.I2C5",
  251. }, {
  252. /* kxtj21009 accelerometer */
  253. .board_info = {
  254. .type = "kxtj21009",
  255. .addr = 0x0f,
  256. .dev_name = "kxtj21009",
  257. .swnode = &asus_tf103c_accel_node,
  258. },
  259. .adapter_path = "\\_SB_.I2C5",
  260. }, {
  261. /* atmel touchscreen */
  262. .board_info = {
  263. .type = "atmel_mxt_ts",
  264. .addr = 0x4a,
  265. .dev_name = "atmel_mxt_ts",
  266. .swnode = &asus_tf103c_touchscreen_node,
  267. },
  268. .adapter_path = "\\_SB_.I2C6",
  269. .irq_data = {
  270. .type = X86_ACPI_IRQ_TYPE_GPIOINT,
  271. .chip = "INT33FC:02",
  272. .index = 28,
  273. .trigger = ACPI_EDGE_SENSITIVE,
  274. .polarity = ACPI_ACTIVE_LOW,
  275. .con_id = "atmel_mxt_ts_irq",
  276. },
  277. },
  278. };
  279. const struct x86_dev_info asus_tf103c_info __initconst = {
  280. .i2c_client_info = asus_tf103c_i2c_clients,
  281. .i2c_client_count = ARRAY_SIZE(asus_tf103c_i2c_clients),
  282. .pdev_info = asus_me176c_tf103c_pdevs,
  283. .pdev_count = ARRAY_SIZE(asus_me176c_tf103c_pdevs),
  284. .gpio_button_swnodes = asus_me176c_tf103c_lid_swnodes,
  285. .swnode_group = generic_lipo_4v2_battery_swnodes,
  286. .modules = bq24190_modules,
  287. .gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
  288. };