|
| 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 <[email protected]> |
| 9 | + */ |
| 10 | + |
| 11 | +#include <linux/gpio_keys.h> |
| 12 | +#include <linux/gpio/consumer.h> |
| 13 | +#include <linux/gpio/machine.h> |
| 14 | +#include <linux/input.h> |
| 15 | +#include <linux/platform_device.h> |
| 16 | + |
| 17 | +#include "shared-psy-info.h" |
| 18 | +#include "x86-android-tablets.h" |
| 19 | + |
| 20 | +/* Asus ME176C and TF103C tablets shared data */ |
| 21 | +static struct gpiod_lookup_table int3496_gpo2_pin22_gpios = { |
| 22 | + .dev_id = "intel-int3496", |
| 23 | + .table = { |
| 24 | + GPIO_LOOKUP("INT33FC:02", 22, "id", GPIO_ACTIVE_HIGH), |
| 25 | + { } |
| 26 | + }, |
| 27 | +}; |
| 28 | + |
| 29 | +static struct gpio_keys_button asus_me176c_tf103c_lid = { |
| 30 | + .code = SW_LID, |
| 31 | + /* .gpio gets filled in by asus_me176c_tf103c_init() */ |
| 32 | + .active_low = true, |
| 33 | + .desc = "lid_sw", |
| 34 | + .type = EV_SW, |
| 35 | + .wakeup = true, |
| 36 | + .debounce_interval = 50, |
| 37 | +}; |
| 38 | + |
| 39 | +static const struct gpio_keys_platform_data asus_me176c_tf103c_lid_pdata __initconst = { |
| 40 | + .buttons = &asus_me176c_tf103c_lid, |
| 41 | + .nbuttons = 1, |
| 42 | + .name = "lid_sw", |
| 43 | +}; |
| 44 | + |
| 45 | +static const struct platform_device_info asus_me176c_tf103c_pdevs[] __initconst = { |
| 46 | + { |
| 47 | + .name = "gpio-keys", |
| 48 | + .id = PLATFORM_DEVID_AUTO, |
| 49 | + .data = &asus_me176c_tf103c_lid_pdata, |
| 50 | + .size_data = sizeof(asus_me176c_tf103c_lid_pdata), |
| 51 | + }, |
| 52 | + { |
| 53 | + /* For micro USB ID pin handling */ |
| 54 | + .name = "intel-int3496", |
| 55 | + .id = PLATFORM_DEVID_NONE, |
| 56 | + }, |
| 57 | +}; |
| 58 | + |
| 59 | +static int __init asus_me176c_tf103c_init(void) |
| 60 | +{ |
| 61 | + struct gpio_desc *gpiod; |
| 62 | + int ret; |
| 63 | + |
| 64 | + ret = x86_android_tablet_get_gpiod("INT33FC:02", 12, &gpiod); |
| 65 | + if (ret < 0) |
| 66 | + return ret; |
| 67 | + asus_me176c_tf103c_lid.gpio = desc_to_gpio(gpiod); |
| 68 | + |
| 69 | + return 0; |
| 70 | +} |
| 71 | + |
| 72 | + |
| 73 | +/* Asus ME176C tablets have an Android factory img with everything hardcoded */ |
| 74 | +static const char * const asus_me176c_accel_mount_matrix[] = { |
| 75 | + "-1", "0", "0", |
| 76 | + "0", "1", "0", |
| 77 | + "0", "0", "1" |
| 78 | +}; |
| 79 | + |
| 80 | +static const struct property_entry asus_me176c_accel_props[] = { |
| 81 | + PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", asus_me176c_accel_mount_matrix), |
| 82 | + { } |
| 83 | +}; |
| 84 | + |
| 85 | +static const struct software_node asus_me176c_accel_node = { |
| 86 | + .properties = asus_me176c_accel_props, |
| 87 | +}; |
| 88 | + |
| 89 | +static const struct property_entry asus_me176c_bq24190_props[] = { |
| 90 | + PROPERTY_ENTRY_STRING_ARRAY_LEN("supplied-from", tusb1211_chg_det_psy, 1), |
| 91 | + PROPERTY_ENTRY_REF("monitored-battery", &generic_lipo_hv_4v35_battery_node), |
| 92 | + PROPERTY_ENTRY_U32("ti,system-minimum-microvolt", 3600000), |
| 93 | + PROPERTY_ENTRY_BOOL("omit-battery-class"), |
| 94 | + PROPERTY_ENTRY_BOOL("disable-reset"), |
| 95 | + { } |
| 96 | +}; |
| 97 | + |
| 98 | +static const struct software_node asus_me176c_bq24190_node = { |
| 99 | + .properties = asus_me176c_bq24190_props, |
| 100 | +}; |
| 101 | + |
| 102 | +static const struct property_entry asus_me176c_ug3105_props[] = { |
| 103 | + PROPERTY_ENTRY_STRING_ARRAY_LEN("supplied-from", bq24190_psy, 1), |
| 104 | + PROPERTY_ENTRY_REF("monitored-battery", &generic_lipo_hv_4v35_battery_node), |
| 105 | + PROPERTY_ENTRY_U32("upisemi,rsns-microohm", 10000), |
| 106 | + { } |
| 107 | +}; |
| 108 | + |
| 109 | +static const struct software_node asus_me176c_ug3105_node = { |
| 110 | + .properties = asus_me176c_ug3105_props, |
| 111 | +}; |
| 112 | + |
| 113 | +static const struct x86_i2c_client_info asus_me176c_i2c_clients[] __initconst = { |
| 114 | + { |
| 115 | + /* bq24297 battery charger */ |
| 116 | + .board_info = { |
| 117 | + .type = "bq24190", |
| 118 | + .addr = 0x6b, |
| 119 | + .dev_name = "bq24297", |
| 120 | + .swnode = &asus_me176c_bq24190_node, |
| 121 | + .platform_data = &bq24190_pdata, |
| 122 | + }, |
| 123 | + .adapter_path = "\\_SB_.I2C1", |
| 124 | + .irq_data = { |
| 125 | + .type = X86_ACPI_IRQ_TYPE_PMIC, |
| 126 | + .chip = "\\_SB_.I2C7.PMIC", |
| 127 | + .domain = DOMAIN_BUS_WAKEUP, |
| 128 | + .index = 0, |
| 129 | + }, |
| 130 | + }, { |
| 131 | + /* ug3105 battery monitor */ |
| 132 | + .board_info = { |
| 133 | + .type = "ug3105", |
| 134 | + .addr = 0x70, |
| 135 | + .dev_name = "ug3105", |
| 136 | + .swnode = &asus_me176c_ug3105_node, |
| 137 | + }, |
| 138 | + .adapter_path = "\\_SB_.I2C1", |
| 139 | + }, { |
| 140 | + /* ak09911 compass */ |
| 141 | + .board_info = { |
| 142 | + .type = "ak09911", |
| 143 | + .addr = 0x0c, |
| 144 | + .dev_name = "ak09911", |
| 145 | + }, |
| 146 | + .adapter_path = "\\_SB_.I2C5", |
| 147 | + }, { |
| 148 | + /* kxtj21009 accel */ |
| 149 | + .board_info = { |
| 150 | + .type = "kxtj21009", |
| 151 | + .addr = 0x0f, |
| 152 | + .dev_name = "kxtj21009", |
| 153 | + .swnode = &asus_me176c_accel_node, |
| 154 | + }, |
| 155 | + .adapter_path = "\\_SB_.I2C5", |
| 156 | + .irq_data = { |
| 157 | + .type = X86_ACPI_IRQ_TYPE_APIC, |
| 158 | + .index = 0x44, |
| 159 | + .trigger = ACPI_EDGE_SENSITIVE, |
| 160 | + .polarity = ACPI_ACTIVE_LOW, |
| 161 | + }, |
| 162 | + }, { |
| 163 | + /* goodix touchscreen */ |
| 164 | + .board_info = { |
| 165 | + .type = "GDIX1001:00", |
| 166 | + .addr = 0x14, |
| 167 | + .dev_name = "goodix_ts", |
| 168 | + }, |
| 169 | + .adapter_path = "\\_SB_.I2C6", |
| 170 | + .irq_data = { |
| 171 | + .type = X86_ACPI_IRQ_TYPE_APIC, |
| 172 | + .index = 0x45, |
| 173 | + .trigger = ACPI_EDGE_SENSITIVE, |
| 174 | + .polarity = ACPI_ACTIVE_LOW, |
| 175 | + }, |
| 176 | + }, |
| 177 | +}; |
| 178 | + |
| 179 | +static const struct x86_serdev_info asus_me176c_serdevs[] __initconst = { |
| 180 | + { |
| 181 | + .ctrl_hid = "80860F0A", |
| 182 | + .ctrl_uid = "2", |
| 183 | + .ctrl_devname = "serial0", |
| 184 | + .serdev_hid = "BCM2E3A", |
| 185 | + }, |
| 186 | +}; |
| 187 | + |
| 188 | +static struct gpiod_lookup_table asus_me176c_goodix_gpios = { |
| 189 | + .dev_id = "i2c-goodix_ts", |
| 190 | + .table = { |
| 191 | + GPIO_LOOKUP("INT33FC:00", 60, "reset", GPIO_ACTIVE_HIGH), |
| 192 | + GPIO_LOOKUP("INT33FC:02", 28, "irq", GPIO_ACTIVE_HIGH), |
| 193 | + { } |
| 194 | + }, |
| 195 | +}; |
| 196 | + |
| 197 | +static struct gpiod_lookup_table * const asus_me176c_gpios[] = { |
| 198 | + &int3496_gpo2_pin22_gpios, |
| 199 | + &asus_me176c_goodix_gpios, |
| 200 | + NULL |
| 201 | +}; |
| 202 | + |
| 203 | +const struct x86_dev_info asus_me176c_info __initconst = { |
| 204 | + .i2c_client_info = asus_me176c_i2c_clients, |
| 205 | + .i2c_client_count = ARRAY_SIZE(asus_me176c_i2c_clients), |
| 206 | + .pdev_info = asus_me176c_tf103c_pdevs, |
| 207 | + .pdev_count = ARRAY_SIZE(asus_me176c_tf103c_pdevs), |
| 208 | + .serdev_info = asus_me176c_serdevs, |
| 209 | + .serdev_count = ARRAY_SIZE(asus_me176c_serdevs), |
| 210 | + .gpiod_lookup_tables = asus_me176c_gpios, |
| 211 | + .bat_swnode = &generic_lipo_hv_4v35_battery_node, |
| 212 | + .modules = bq24190_modules, |
| 213 | + .invalid_aei_gpiochip = "INT33FC:02", |
| 214 | + .init = asus_me176c_tf103c_init, |
| 215 | +}; |
| 216 | + |
| 217 | +/* Asus TF103C tablets have an Android factory img with everything hardcoded */ |
| 218 | +static const char * const asus_tf103c_accel_mount_matrix[] = { |
| 219 | + "0", "-1", "0", |
| 220 | + "-1", "0", "0", |
| 221 | + "0", "0", "1" |
| 222 | +}; |
| 223 | + |
| 224 | +static const struct property_entry asus_tf103c_accel_props[] = { |
| 225 | + PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", asus_tf103c_accel_mount_matrix), |
| 226 | + { } |
| 227 | +}; |
| 228 | + |
| 229 | +static const struct software_node asus_tf103c_accel_node = { |
| 230 | + .properties = asus_tf103c_accel_props, |
| 231 | +}; |
| 232 | + |
| 233 | +static const struct property_entry asus_tf103c_touchscreen_props[] = { |
| 234 | + PROPERTY_ENTRY_STRING("compatible", "atmel,atmel_mxt_ts"), |
| 235 | + { } |
| 236 | +}; |
| 237 | + |
| 238 | +static const struct software_node asus_tf103c_touchscreen_node = { |
| 239 | + .properties = asus_tf103c_touchscreen_props, |
| 240 | +}; |
| 241 | + |
| 242 | +static const struct property_entry asus_tf103c_battery_props[] = { |
| 243 | + PROPERTY_ENTRY_STRING("compatible", "simple-battery"), |
| 244 | + PROPERTY_ENTRY_STRING("device-chemistry", "lithium-ion-polymer"), |
| 245 | + PROPERTY_ENTRY_U32("precharge-current-microamp", 256000), |
| 246 | + PROPERTY_ENTRY_U32("charge-term-current-microamp", 128000), |
| 247 | + PROPERTY_ENTRY_U32("constant-charge-current-max-microamp", 2048000), |
| 248 | + PROPERTY_ENTRY_U32("constant-charge-voltage-max-microvolt", 4208000), |
| 249 | + PROPERTY_ENTRY_U32("factory-internal-resistance-micro-ohms", 150000), |
| 250 | + { } |
| 251 | +}; |
| 252 | + |
| 253 | +static const struct software_node asus_tf103c_battery_node = { |
| 254 | + .properties = asus_tf103c_battery_props, |
| 255 | +}; |
| 256 | + |
| 257 | +static const struct property_entry asus_tf103c_bq24190_props[] = { |
| 258 | + PROPERTY_ENTRY_STRING_ARRAY_LEN("supplied-from", tusb1211_chg_det_psy, 1), |
| 259 | + PROPERTY_ENTRY_REF("monitored-battery", &asus_tf103c_battery_node), |
| 260 | + PROPERTY_ENTRY_U32("ti,system-minimum-microvolt", 3600000), |
| 261 | + PROPERTY_ENTRY_BOOL("omit-battery-class"), |
| 262 | + PROPERTY_ENTRY_BOOL("disable-reset"), |
| 263 | + { } |
| 264 | +}; |
| 265 | + |
| 266 | +static const struct software_node asus_tf103c_bq24190_node = { |
| 267 | + .properties = asus_tf103c_bq24190_props, |
| 268 | +}; |
| 269 | + |
| 270 | +static const struct property_entry asus_tf103c_ug3105_props[] = { |
| 271 | + PROPERTY_ENTRY_STRING_ARRAY_LEN("supplied-from", bq24190_psy, 1), |
| 272 | + PROPERTY_ENTRY_REF("monitored-battery", &asus_tf103c_battery_node), |
| 273 | + PROPERTY_ENTRY_U32("upisemi,rsns-microohm", 5000), |
| 274 | + { } |
| 275 | +}; |
| 276 | + |
| 277 | +static const struct software_node asus_tf103c_ug3105_node = { |
| 278 | + .properties = asus_tf103c_ug3105_props, |
| 279 | +}; |
| 280 | + |
| 281 | +static const struct x86_i2c_client_info asus_tf103c_i2c_clients[] __initconst = { |
| 282 | + { |
| 283 | + /* bq24297 battery charger */ |
| 284 | + .board_info = { |
| 285 | + .type = "bq24190", |
| 286 | + .addr = 0x6b, |
| 287 | + .dev_name = "bq24297", |
| 288 | + .swnode = &asus_tf103c_bq24190_node, |
| 289 | + .platform_data = &bq24190_pdata, |
| 290 | + }, |
| 291 | + .adapter_path = "\\_SB_.I2C1", |
| 292 | + .irq_data = { |
| 293 | + .type = X86_ACPI_IRQ_TYPE_PMIC, |
| 294 | + .chip = "\\_SB_.I2C7.PMIC", |
| 295 | + .domain = DOMAIN_BUS_WAKEUP, |
| 296 | + .index = 0, |
| 297 | + }, |
| 298 | + }, { |
| 299 | + /* ug3105 battery monitor */ |
| 300 | + .board_info = { |
| 301 | + .type = "ug3105", |
| 302 | + .addr = 0x70, |
| 303 | + .dev_name = "ug3105", |
| 304 | + .swnode = &asus_tf103c_ug3105_node, |
| 305 | + }, |
| 306 | + .adapter_path = "\\_SB_.I2C1", |
| 307 | + }, { |
| 308 | + /* ak09911 compass */ |
| 309 | + .board_info = { |
| 310 | + .type = "ak09911", |
| 311 | + .addr = 0x0c, |
| 312 | + .dev_name = "ak09911", |
| 313 | + }, |
| 314 | + .adapter_path = "\\_SB_.I2C5", |
| 315 | + }, { |
| 316 | + /* kxtj21009 accel */ |
| 317 | + .board_info = { |
| 318 | + .type = "kxtj21009", |
| 319 | + .addr = 0x0f, |
| 320 | + .dev_name = "kxtj21009", |
| 321 | + .swnode = &asus_tf103c_accel_node, |
| 322 | + }, |
| 323 | + .adapter_path = "\\_SB_.I2C5", |
| 324 | + }, { |
| 325 | + /* atmel touchscreen */ |
| 326 | + .board_info = { |
| 327 | + .type = "atmel_mxt_ts", |
| 328 | + .addr = 0x4a, |
| 329 | + .dev_name = "atmel_mxt_ts", |
| 330 | + .swnode = &asus_tf103c_touchscreen_node, |
| 331 | + }, |
| 332 | + .adapter_path = "\\_SB_.I2C6", |
| 333 | + .irq_data = { |
| 334 | + .type = X86_ACPI_IRQ_TYPE_GPIOINT, |
| 335 | + .chip = "INT33FC:02", |
| 336 | + .index = 28, |
| 337 | + .trigger = ACPI_EDGE_SENSITIVE, |
| 338 | + .polarity = ACPI_ACTIVE_LOW, |
| 339 | + }, |
| 340 | + }, |
| 341 | +}; |
| 342 | + |
| 343 | +static struct gpiod_lookup_table * const asus_tf103c_gpios[] = { |
| 344 | + &int3496_gpo2_pin22_gpios, |
| 345 | + NULL |
| 346 | +}; |
| 347 | + |
| 348 | +const struct x86_dev_info asus_tf103c_info __initconst = { |
| 349 | + .i2c_client_info = asus_tf103c_i2c_clients, |
| 350 | + .i2c_client_count = ARRAY_SIZE(asus_tf103c_i2c_clients), |
| 351 | + .pdev_info = asus_me176c_tf103c_pdevs, |
| 352 | + .pdev_count = ARRAY_SIZE(asus_me176c_tf103c_pdevs), |
| 353 | + .gpiod_lookup_tables = asus_tf103c_gpios, |
| 354 | + .bat_swnode = &asus_tf103c_battery_node, |
| 355 | + .modules = bq24190_modules, |
| 356 | + .invalid_aei_gpiochip = "INT33FC:02", |
| 357 | + .init = asus_me176c_tf103c_init, |
| 358 | +}; |
0 commit comments