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