xref: /linux/drivers/platform/x86/x86-android-tablets/lenovo.c (revision 546b928da0427b0d6c663cbb992bd7bfa9ac7971)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Board info for Lenovo 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 
11 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12 
13 #include <linux/efi.h>
14 #include <linux/gpio/machine.h>
15 #include <linux/gpio/property.h>
16 #include <linux/input-event-codes.h>
17 #include <linux/mfd/arizona/pdata.h>
18 #include <linux/mfd/arizona/registers.h>
19 #include <linux/mfd/intel_soc_pmic.h>
20 #include <linux/pinctrl/consumer.h>
21 #include <linux/pinctrl/machine.h>
22 #include <linux/platform_data/lp855x.h>
23 #include <linux/platform_device.h>
24 #include <linux/power/bq24190_charger.h>
25 #include <linux/reboot.h>
26 #include <linux/rmi.h>
27 #include <linux/spi/spi.h>
28 
29 #include "shared-psy-info.h"
30 #include "x86-android-tablets.h"
31 
32 /*
33  * Various Lenovo models use a TI LP8557 LED backlight controller with its PWM
34  * input connected to a PWM output coming from the LCD panel's controller.
35  * The Android kernels have a hack in the i915 driver to write a non-standard
36  * panel specific DSI register to set the duty-cycle of the LCD's PWM output.
37  *
38  * To avoid having to have a similar hack in the mainline kernel program the
39  * LP8557 to directly set the level and use the lp855x_bl driver for control.
40  *
41  * The LP8557 can either be configured to multiply its PWM input and
42  * the I2C register set level (requiring both to be at 100% for 100% output);
43  * or to only take the I2C register set level into account.
44  *
45  * Multiplying the 2 levels is useful because this will turn off the backlight
46  * when the panel goes off and turns off its PWM output.
47  *
48  * But on some models the panel's PWM output defaults to a duty-cycle of
49  * much less then 100%, severely limiting max brightness. In this case
50  * the LP8557 should be configured to only take the I2C register into
51  * account and the i915 driver must turn off the panel and the backlight
52  * separately using e.g. VBT MIPI sequences to turn off the backlight.
53  */
54 static struct lp855x_platform_data lenovo_lp8557_pwm_and_reg_pdata = {
55 	.device_control = 0x86,
56 	.initial_brightness = 128,
57 };
58 
59 static struct lp855x_platform_data lenovo_lp8557_reg_only_pdata = {
60 	.device_control = 0x85,
61 	.initial_brightness = 128,
62 };
63 
64 
65 /* Lenovo Yoga Book X90F / X90L's Android factory image has everything hardcoded */
66 
67 static const struct property_entry lenovo_yb1_x90_goodix_props[] = {
68 	PROPERTY_ENTRY_GPIO("reset-gpios", &cherryview_gpiochip_nodes[1], 53, GPIO_ACTIVE_HIGH),
69 	PROPERTY_ENTRY_GPIO("irq-gpios", &cherryview_gpiochip_nodes[1], 56, GPIO_ACTIVE_HIGH),
70 	{ }
71 };
72 
73 static const struct software_node lenovo_yb1_x90_goodix_node = {
74 	.properties = lenovo_yb1_x90_goodix_props,
75 };
76 
77 static const struct property_entry lenovo_yb1_x90_wacom_props[] = {
78 	PROPERTY_ENTRY_U32("hid-descr-addr", 0x0001),
79 	PROPERTY_ENTRY_U32("post-reset-deassert-delay-ms", 150),
80 	PROPERTY_ENTRY_GPIO("reset-gpios", &cherryview_gpiochip_nodes[0], 82, GPIO_ACTIVE_LOW),
81 	{ }
82 };
83 
84 static const struct software_node lenovo_yb1_x90_wacom_node = {
85 	.properties = lenovo_yb1_x90_wacom_props,
86 };
87 
88 /*
89  * The HiDeep IST940E touchscreen comes up in I2C-HID mode. The native protocol
90  * reports ABS_MT_PRESSURE and ABS_MT_TOUCH_MAJOR which are not reported in HID
91  * mode, so using native mode is preferred.
92  * It could alternatively be used in HID mode by changing the properties to:
93  *	PROPERTY_ENTRY_U32("hid-descr-addr", 0x0020),
94  *	PROPERTY_ENTRY_U32("post-reset-deassert-delay-ms", 120),
95  * and changing board_info.type to "hid-over-i2c".
96  */
97 static const struct property_entry lenovo_yb1_x90_hideep_ts_props[] = {
98 	PROPERTY_ENTRY_U32("touchscreen-size-x", 1200),
99 	PROPERTY_ENTRY_U32("touchscreen-size-y", 1920),
100 	PROPERTY_ENTRY_U32("touchscreen-max-pressure", 16384),
101 	PROPERTY_ENTRY_BOOL("hideep,force-native-protocol"),
102 	PROPERTY_ENTRY_GPIO("reset-gpios", &cherryview_gpiochip_nodes[0], 7, GPIO_ACTIVE_LOW),
103 	{ }
104 };
105 
106 static const struct software_node lenovo_yb1_x90_hideep_ts_node = {
107 	.properties = lenovo_yb1_x90_hideep_ts_props,
108 };
109 
110 static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst = {
111 	{
112 		/* BQ27542 fuel-gauge */
113 		.board_info = {
114 			.type = "bq27542",
115 			.addr = 0x55,
116 			.dev_name = "bq27542",
117 			.swnode = &fg_bq25890_supply_node,
118 		},
119 		.adapter_path = "\\_SB_.PCI0.I2C1",
120 	}, {
121 		/* Goodix Touchscreen in keyboard half */
122 		.board_info = {
123 			.type = "GDIX1001:00",
124 			.addr = 0x14,
125 			.dev_name = "goodix_ts",
126 			.swnode = &lenovo_yb1_x90_goodix_node,
127 		},
128 		.adapter_path = "\\_SB_.PCI0.I2C2",
129 		.irq_data = {
130 			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
131 			.chip = "INT33FF:01",
132 			.index = 56,
133 			.trigger = ACPI_EDGE_SENSITIVE,
134 			.polarity = ACPI_ACTIVE_LOW,
135 			.con_id = "goodix_ts_irq",
136 			.free_gpio = true,
137 		},
138 	}, {
139 		/* Wacom Digitizer in keyboard half */
140 		.board_info = {
141 			.type = "hid-over-i2c",
142 			.addr = 0x09,
143 			.dev_name = "wacom",
144 			.swnode = &lenovo_yb1_x90_wacom_node,
145 		},
146 		.adapter_path = "\\_SB_.PCI0.I2C4",
147 		.irq_data = {
148 			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
149 			.chip = "INT33FF:01",
150 			.index = 49,
151 			.trigger = ACPI_LEVEL_SENSITIVE,
152 			.polarity = ACPI_ACTIVE_LOW,
153 			.con_id = "wacom_irq",
154 		},
155 	}, {
156 		/* LP8557 Backlight controller */
157 		.board_info = {
158 			.type = "lp8557",
159 			.addr = 0x2c,
160 			.dev_name = "lp8557",
161 			.platform_data = &lenovo_lp8557_pwm_and_reg_pdata,
162 		},
163 		.adapter_path = "\\_SB_.PCI0.I2C4",
164 	}, {
165 		/* HiDeep IST940E Touchscreen in display half */
166 		.board_info = {
167 			.type = "hideep_ts",
168 			.addr = 0x6c,
169 			.dev_name = "hideep_ts",
170 			.swnode = &lenovo_yb1_x90_hideep_ts_node,
171 		},
172 		.adapter_path = "\\_SB_.PCI0.I2C6",
173 		.irq_data = {
174 			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
175 			.chip = "INT33FF:03",
176 			.index = 77,
177 			.trigger = ACPI_LEVEL_SENSITIVE,
178 			.polarity = ACPI_ACTIVE_LOW,
179 			.con_id = "hideep_ts_irq",
180 		},
181 	},
182 };
183 
184 static const struct platform_device_info lenovo_yb1_x90_pdevs[] __initconst = {
185 	{
186 		.name = "yogabook-touch-kbd-digitizer-switch",
187 		.id = PLATFORM_DEVID_NONE,
188 	},
189 };
190 
191 /*
192  * DSDT says UART path is "\\_SB.PCIO.URT1" with a letter 'O' instead of
193  * the number '0' add the link manually.
194  */
195 static const struct x86_serdev_info lenovo_yb1_x90_serdevs[] __initconst = {
196 	{
197 		.ctrl.acpi.hid = "8086228A",
198 		.ctrl.acpi.uid = "1",
199 		.ctrl_devname = "serial0",
200 		.serdev_hid = "BCM2E1A",
201 	},
202 };
203 
204 /*
205  * Software node attached to gpio-keys device representing the LID and
206  * serving as a parent to software nodes representing individual keys/buttons
207  * as required by the device tree binding.
208  */
209 static const struct software_node lenovo_lid_gpio_keys_node = {
210 	.name = "lid_sw",
211 };
212 
213 static const struct property_entry lenovo_yb1_x90_lid_props[] = {
214 	PROPERTY_ENTRY_U32("linux,input-type", EV_SW),
215 	PROPERTY_ENTRY_U32("linux,code", SW_LID),
216 	PROPERTY_ENTRY_STRING("label", "lid_sw"),
217 	PROPERTY_ENTRY_GPIO("gpios", &cherryview_gpiochip_nodes[2], 19, GPIO_ACTIVE_LOW),
218 	PROPERTY_ENTRY_U32("debounce-interval", 50),
219 	PROPERTY_ENTRY_BOOL("wakeup-source"),
220 	{ }
221 };
222 
223 static const struct software_node lenovo_yb1_x90_lid_node = {
224 	.parent = &lenovo_lid_gpio_keys_node,
225 	.properties = lenovo_yb1_x90_lid_props,
226 };
227 
228 static const struct software_node *lenovo_yb1_x90_lid_swnodes[] = {
229 	&lenovo_lid_gpio_keys_node,
230 	&lenovo_yb1_x90_lid_node,
231 	NULL
232 };
233 
lenovo_yb1_x90_init(struct device * dev)234 static int __init lenovo_yb1_x90_init(struct device *dev)
235 {
236 	/* Enable the regulators used by the touchscreens */
237 
238 	/* Vprog3B 3.0V used by the goodix touchscreen in the keyboard half */
239 	intel_soc_pmic_exec_mipi_pmic_seq_element(0x6e, 0x9b, 0x02, 0xff);
240 
241 	/* Vprog4D 3.0V used by the HiDeep touchscreen in the display half */
242 	intel_soc_pmic_exec_mipi_pmic_seq_element(0x6e, 0x9f, 0x02, 0xff);
243 
244 	/* Vprog5A 1.8V used by the HiDeep touchscreen in the display half */
245 	intel_soc_pmic_exec_mipi_pmic_seq_element(0x6e, 0xa0, 0x02, 0xff);
246 
247 	/* Vprog5B 1.8V used by the goodix touchscreen in the keyboard half */
248 	intel_soc_pmic_exec_mipi_pmic_seq_element(0x6e, 0xa1, 0x02, 0xff);
249 
250 	return 0;
251 }
252 
253 const struct x86_dev_info lenovo_yogabook_x90_info __initconst = {
254 	.i2c_client_info = lenovo_yb1_x90_i2c_clients,
255 	.i2c_client_count = ARRAY_SIZE(lenovo_yb1_x90_i2c_clients),
256 	.pdev_info = lenovo_yb1_x90_pdevs,
257 	.pdev_count = ARRAY_SIZE(lenovo_yb1_x90_pdevs),
258 	.serdev_info = lenovo_yb1_x90_serdevs,
259 	.serdev_count = ARRAY_SIZE(lenovo_yb1_x90_serdevs),
260 	.gpio_button_swnodes = lenovo_yb1_x90_lid_swnodes,
261 	.gpiochip_type = X86_GPIOCHIP_CHERRYVIEW,
262 	.init = lenovo_yb1_x90_init,
263 };
264 
265 /* Lenovo Yoga Book X91F/L Windows tablet needs manual instantiation of the fuel-gauge client */
266 static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __initconst = {
267 	{
268 		/* BQ27542 fuel-gauge */
269 		.board_info = {
270 			.type = "bq27542",
271 			.addr = 0x55,
272 			.dev_name = "bq27542",
273 			.swnode = &fg_bq25890_supply_node,
274 		},
275 		.adapter_path = "\\_SB_.PCI0.I2C1",
276 	},
277 };
278 
279 const struct x86_dev_info lenovo_yogabook_x91_info __initconst = {
280 	.i2c_client_info = lenovo_yogabook_x91_i2c_clients,
281 	.i2c_client_count = ARRAY_SIZE(lenovo_yogabook_x91_i2c_clients),
282 };
283 
284 /* Lenovo Yoga Tablet 2 1050F/L's Android factory image has everything hardcoded */
285 static const struct property_entry lenovo_yoga_tab2_830_1050_bq24190_props[] = {
286 	PROPERTY_ENTRY_STRING_ARRAY_LEN("supplied-from", tusb1211_chg_det_psy, 1),
287 	PROPERTY_ENTRY_REF("monitored-battery", &generic_lipo_hv_4v35_battery_node),
288 	PROPERTY_ENTRY_BOOL("omit-battery-class"),
289 	PROPERTY_ENTRY_BOOL("disable-reset"),
290 	{ }
291 };
292 
293 static const struct software_node lenovo_yoga_tab2_830_1050_bq24190_node = {
294 	.properties = lenovo_yoga_tab2_830_1050_bq24190_props,
295 };
296 
297 static const struct property_entry lenovo_yoga_tab2_830_1050_lid_props[] = {
298 	PROPERTY_ENTRY_U32("linux,input-type", EV_SW),
299 	PROPERTY_ENTRY_U32("linux,code", SW_LID),
300 	PROPERTY_ENTRY_STRING("label", "lid_sw"),
301 	PROPERTY_ENTRY_GPIO("gpios", &baytrail_gpiochip_nodes[2], 26, GPIO_ACTIVE_LOW),
302 	PROPERTY_ENTRY_U32("debounce-interval", 50),
303 	PROPERTY_ENTRY_BOOL("wakeup-source"),
304 	{ }
305 };
306 
307 static const struct software_node lenovo_yoga_tab2_830_1050_lid_node = {
308 	.parent = &lenovo_lid_gpio_keys_node,
309 	.properties = lenovo_yoga_tab2_830_1050_lid_props,
310 };
311 
312 static const struct software_node *lenovo_yoga_tab2_830_1050_lid_swnodes[] = {
313 	&lenovo_lid_gpio_keys_node,
314 	&lenovo_yoga_tab2_830_1050_lid_node,
315 	NULL
316 };
317 
318 /* This gets filled by lenovo_yoga_tab2_830_1050_init() */
319 static struct rmi_device_platform_data lenovo_yoga_tab2_830_1050_rmi_pdata = { };
320 
321 static struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[] __initdata = {
322 	{
323 		/*
324 		 * This must be the first entry because lenovo_yoga_tab2_830_1050_init()
325 		 * may update its swnode. LSM303DA accelerometer + magnetometer.
326 		 */
327 		.board_info = {
328 			.type = "lsm303d",
329 			.addr = 0x1d,
330 			.dev_name = "lsm303d",
331 		},
332 		.adapter_path = "\\_SB_.I2C5",
333 	}, {
334 		/* AL3320A ambient light sensor */
335 		.board_info = {
336 			.type = "al3320a",
337 			.addr = 0x1c,
338 			.dev_name = "al3320a",
339 		},
340 		.adapter_path = "\\_SB_.I2C5",
341 	}, {
342 		/* bq24292i battery charger */
343 		.board_info = {
344 			.type = "bq24190",
345 			.addr = 0x6b,
346 			.dev_name = "bq24292i",
347 			.swnode = &lenovo_yoga_tab2_830_1050_bq24190_node,
348 			.platform_data = &bq24190_pdata,
349 		},
350 		.adapter_path = "\\_SB_.I2C1",
351 		.irq_data = {
352 			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
353 			.chip = "INT33FC:02",
354 			.index = 2,
355 			.trigger = ACPI_EDGE_SENSITIVE,
356 			.polarity = ACPI_ACTIVE_HIGH,
357 			.con_id = "bq24292i_irq",
358 		},
359 	}, {
360 		/* BQ27541 fuel-gauge */
361 		.board_info = {
362 			.type = "bq27541",
363 			.addr = 0x55,
364 			.dev_name = "bq27541",
365 			.swnode = &fg_bq24190_supply_node,
366 		},
367 		.adapter_path = "\\_SB_.I2C1",
368 	}, {
369 		/* Synaptics RMI touchscreen */
370 		.board_info = {
371 			.type = "rmi4_i2c",
372 			.addr = 0x38,
373 			.dev_name = "rmi4_i2c",
374 			.platform_data = &lenovo_yoga_tab2_830_1050_rmi_pdata,
375 		},
376 		.adapter_path = "\\_SB_.I2C6",
377 		.irq_data = {
378 			.type = X86_ACPI_IRQ_TYPE_APIC,
379 			.index = 0x45,
380 			.trigger = ACPI_EDGE_SENSITIVE,
381 			.polarity = ACPI_ACTIVE_HIGH,
382 		},
383 	}, {
384 		/* LP8557 Backlight controller */
385 		.board_info = {
386 			.type = "lp8557",
387 			.addr = 0x2c,
388 			.dev_name = "lp8557",
389 			.platform_data = &lenovo_lp8557_pwm_and_reg_pdata,
390 		},
391 		.adapter_path = "\\_SB_.I2C3",
392 	},
393 };
394 
395 static const struct property_entry lenovo_yoga_tab2_830_1050_int3496_props[] __initconst = {
396 	PROPERTY_ENTRY_GPIO("mux-gpios", &baytrail_gpiochip_nodes[2], 1, GPIO_ACTIVE_LOW),
397 	PROPERTY_ENTRY_GPIO("id-gpios", &baytrail_gpiochip_nodes[2], 24, GPIO_ACTIVE_HIGH),
398 	{ }
399 };
400 
401 static const struct platform_device_info lenovo_yoga_tab2_830_1050_pdevs[] __initconst = {
402 	{
403 		/* For micro USB ID pin handling */
404 		.name = "intel-int3496",
405 		.id = PLATFORM_DEVID_NONE,
406 		.properties = lenovo_yoga_tab2_830_1050_int3496_props,
407 	},
408 };
409 
410 #define LENOVO_YOGA_TAB2_830_1050_CODEC_NAME "spi-10WM5102:00"
411 
412 static const struct software_node lenovo_yoga_tab2_830_1050_wm5102;
413 
414 static const struct property_entry lenovo_yoga_tab2_830_1050_wm1502_props[] = {
415 	PROPERTY_ENTRY_GPIO("reset-gpios",
416 			    &crystalcove_gpiochip_node, 3, GPIO_ACTIVE_HIGH),
417 	PROPERTY_ENTRY_GPIO("wlf,ldoena-gpios",
418 			    &baytrail_gpiochip_nodes[1], 23, GPIO_ACTIVE_HIGH),
419 	PROPERTY_ENTRY_GPIO("wlf,spkvdd-ena-gpios",
420 			    &lenovo_yoga_tab2_830_1050_wm5102, 2, GPIO_ACTIVE_HIGH),
421 	PROPERTY_ENTRY_GPIO("wlf,micd-pol-gpios",
422 			    &lenovo_yoga_tab2_830_1050_wm5102, 4, GPIO_ACTIVE_LOW),
423 	{ }
424 };
425 
426 static const struct software_node lenovo_yoga_tab2_830_1050_wm5102 = {
427 	.properties = lenovo_yoga_tab2_830_1050_wm1502_props,
428 };
429 
430 static int __init lenovo_yoga_tab2_830_1050_init(struct device *dev);
431 static void lenovo_yoga_tab2_830_1050_exit(void);
432 
433 static const char * const lenovo_yoga_tab2_modules[] __initconst = {
434 	"spi_pxa2xx_platform",	/* For the SPI codec device */
435 	"bq24190_charger",	/* For the Vbus regulator for int3496/lc824206xa */
436 	NULL
437 };
438 
439 const struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initconst = {
440 	.i2c_client_info = lenovo_yoga_tab2_830_1050_i2c_clients,
441 	.i2c_client_count = ARRAY_SIZE(lenovo_yoga_tab2_830_1050_i2c_clients),
442 	.pdev_info = lenovo_yoga_tab2_830_1050_pdevs,
443 	.pdev_count = ARRAY_SIZE(lenovo_yoga_tab2_830_1050_pdevs),
444 	.gpio_button_swnodes = lenovo_yoga_tab2_830_1050_lid_swnodes,
445 	.swnode_group = generic_lipo_hv_4v35_battery_swnodes,
446 	.modules = lenovo_yoga_tab2_modules,
447 	.has_crystalcove = true,
448 	.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
449 	.init = lenovo_yoga_tab2_830_1050_init,
450 	.exit = lenovo_yoga_tab2_830_1050_exit,
451 };
452 
453 /*
454  * The Lenovo Yoga Tablet 2 830 and 1050 (8" vs 10") versions use the same
455  * mainboard, but the 830 uses a portrait LCD panel with a landscape touchscreen,
456  * requiring the touchscreen driver to adjust the touch-coords to match the LCD.
457  * And requiring the accelerometer to have a mount-matrix set to correct for
458  * the 90° rotation of the LCD vs the frame.
459  */
460 static const char * const lenovo_yoga_tab2_830_lms303d_mount_matrix[] = {
461 	"0", "1", "0",
462 	"-1", "0", "0",
463 	"0", "0", "1"
464 };
465 
466 static const struct property_entry lenovo_yoga_tab2_830_lms303d_props[] = {
467 	PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", lenovo_yoga_tab2_830_lms303d_mount_matrix),
468 	{ }
469 };
470 
471 static const struct software_node lenovo_yoga_tab2_830_lms303d_node = {
472 	.properties = lenovo_yoga_tab2_830_lms303d_props,
473 };
474 
lenovo_yoga_tab2_830_1050_init_touchscreen(void)475 static int __init lenovo_yoga_tab2_830_1050_init_touchscreen(void)
476 {
477 	struct gpio_desc *gpiod;
478 	int ret;
479 
480 	/* Use PMIC GPIO 10 bootstrap pin to differentiate 830 vs 1050 */
481 	ret = x86_android_tablet_get_gpiod("gpio_crystalcove", 10, "yoga_bootstrap",
482 					   false, GPIOD_ASIS, &gpiod);
483 	if (ret)
484 		return ret;
485 
486 	ret = gpiod_get_value_cansleep(gpiod);
487 	if (ret) {
488 		pr_info("detected Lenovo Yoga Tablet 2 1050F/L\n");
489 	} else {
490 		pr_info("detected Lenovo Yoga Tablet 2 830F/L\n");
491 		lenovo_yoga_tab2_830_1050_rmi_pdata.sensor_pdata.axis_align.swap_axes = true;
492 		lenovo_yoga_tab2_830_1050_rmi_pdata.sensor_pdata.axis_align.flip_y = true;
493 		lenovo_yoga_tab2_830_1050_i2c_clients[0].board_info.swnode =
494 			&lenovo_yoga_tab2_830_lms303d_node;
495 	}
496 
497 	return 0;
498 }
499 
500 /* SUS (INT33FC:02) pin 6 needs to be configured as pmu_clk for the audio codec */
501 static const struct pinctrl_map lenovo_yoga_tab2_830_1050_codec_pinctrl_map =
502 	PIN_MAP_MUX_GROUP(LENOVO_YOGA_TAB2_830_1050_CODEC_NAME, "codec_32khz_clk",
503 			  "INT33FC:02", "pmu_clk2_grp", "pmu_clk");
504 
505 static struct device *lenovo_yoga_tab2_830_1050_codec_dev;
506 static struct pinctrl *lenovo_yoga_tab2_830_1050_codec_pinctrl;
507 static struct sys_off_handler *lenovo_yoga_tab2_830_1050_sys_off_handler;
508 
lenovo_yoga_tab2_830_1050_init_codec(void)509 static int __init lenovo_yoga_tab2_830_1050_init_codec(void)
510 {
511 	struct device *codec_dev;
512 	struct pinctrl *pinctrl;
513 	int ret;
514 
515 	codec_dev = bus_find_device_by_name(&spi_bus_type, NULL,
516 					    LENOVO_YOGA_TAB2_830_1050_CODEC_NAME);
517 	if (!codec_dev) {
518 		pr_err("error cannot find %s device\n", LENOVO_YOGA_TAB2_830_1050_CODEC_NAME);
519 		return -ENODEV;
520 	}
521 
522 	ret = pinctrl_register_mappings(&lenovo_yoga_tab2_830_1050_codec_pinctrl_map, 1);
523 	if (ret)
524 		goto err_put_device;
525 
526 	pinctrl = pinctrl_get_select(codec_dev, "codec_32khz_clk");
527 	if (IS_ERR(pinctrl)) {
528 		ret = dev_err_probe(codec_dev, PTR_ERR(pinctrl), "selecting codec_32khz_clk\n");
529 		goto err_unregister_mappings;
530 	}
531 
532 	ret = device_add_software_node(codec_dev, &lenovo_yoga_tab2_830_1050_wm5102);
533 	if (ret) {
534 		dev_err_probe(codec_dev, ret, "adding software node\n");
535 		goto err_put_pinctrl;
536 	}
537 
538 	lenovo_yoga_tab2_830_1050_codec_dev = codec_dev;
539 	lenovo_yoga_tab2_830_1050_codec_pinctrl = pinctrl;
540 	return 0;
541 
542 err_put_pinctrl:
543 	pinctrl_put(lenovo_yoga_tab2_830_1050_codec_pinctrl);
544 err_unregister_mappings:
545 	pinctrl_unregister_mappings(&lenovo_yoga_tab2_830_1050_codec_pinctrl_map);
546 err_put_device:
547 	put_device(codec_dev);
548 	return ret;
549 }
550 
551 /*
552  * These tablet's DSDT does not set acpi_gbl_reduced_hardware, so acpi_power_off()
553  * gets used as pm_power_off handler. This causes "poweroff" on these tablets
554  * to hang hard. Requiring pressing the power button for 30 seconds *twice*
555  * followed by a normal 3 second press to recover. Avoid this by doing an EFI
556  * poweroff instead.
557  */
lenovo_yoga_tab2_830_1050_power_off(struct sys_off_data * data)558 static int lenovo_yoga_tab2_830_1050_power_off(struct sys_off_data *data)
559 {
560 	efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
561 
562 	return NOTIFY_DONE;
563 }
564 
lenovo_yoga_tab2_830_1050_init(struct device * dev)565 static int __init lenovo_yoga_tab2_830_1050_init(struct device *dev)
566 {
567 	int ret;
568 
569 	ret = lenovo_yoga_tab2_830_1050_init_touchscreen();
570 	if (ret)
571 		return ret;
572 
573 	ret = lenovo_yoga_tab2_830_1050_init_codec();
574 	if (ret)
575 		return ret;
576 
577 	/* SYS_OFF_PRIO_FIRMWARE + 1 so that it runs before acpi_power_off() */
578 	lenovo_yoga_tab2_830_1050_sys_off_handler =
579 		register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_FIRMWARE + 1,
580 					 lenovo_yoga_tab2_830_1050_power_off, NULL);
581 	if (IS_ERR(lenovo_yoga_tab2_830_1050_sys_off_handler))
582 		return PTR_ERR(lenovo_yoga_tab2_830_1050_sys_off_handler);
583 
584 	return 0;
585 }
586 
lenovo_yoga_tab2_830_1050_exit(void)587 static void lenovo_yoga_tab2_830_1050_exit(void)
588 {
589 	unregister_sys_off_handler(lenovo_yoga_tab2_830_1050_sys_off_handler);
590 
591 	device_remove_software_node(lenovo_yoga_tab2_830_1050_codec_dev);
592 	pinctrl_put(lenovo_yoga_tab2_830_1050_codec_pinctrl);
593 	pinctrl_unregister_mappings(&lenovo_yoga_tab2_830_1050_codec_pinctrl_map);
594 	put_device(lenovo_yoga_tab2_830_1050_codec_dev);
595 }
596 
597 /*
598  * Lenovo Yoga Tablet 2 Pro 1380F/L
599  *
600  * The Lenovo Yoga Tablet 2 Pro 1380F/L mostly has the same design as the 830F/L
601  * and the 1050F/L so this re-uses some of the handling for that from above.
602  */
603 static const char * const lc824206xa_chg_det_psy[] = { "lc824206xa-charger-detect" };
604 
605 static const struct property_entry lenovo_yoga_tab2_1380_bq24190_props[] = {
606 	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", lc824206xa_chg_det_psy),
607 	PROPERTY_ENTRY_REF("monitored-battery", &generic_lipo_hv_4v35_battery_node),
608 	PROPERTY_ENTRY_BOOL("omit-battery-class"),
609 	PROPERTY_ENTRY_BOOL("disable-reset"),
610 	{ }
611 };
612 
613 static const struct software_node lenovo_yoga_tab2_1380_bq24190_node = {
614 	.properties = lenovo_yoga_tab2_1380_bq24190_props,
615 };
616 
617 /* For enabling the bq24190 5V boost based on id-pin */
618 static struct regulator_consumer_supply lc824206xa_consumer = {
619 	.supply = "vbus",
620 	.dev_name = "i2c-lc824206xa",
621 };
622 
623 static const struct regulator_init_data lenovo_yoga_tab2_1380_bq24190_vbus_init_data = {
624 	.constraints = {
625 		.name = "bq24190_vbus",
626 		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
627 	},
628 	.consumer_supplies = &lc824206xa_consumer,
629 	.num_consumer_supplies = 1,
630 };
631 
632 static struct bq24190_platform_data lenovo_yoga_tab2_1380_bq24190_pdata = {
633 	.regulator_init_data = &lenovo_yoga_tab2_1380_bq24190_vbus_init_data,
634 };
635 
636 static const struct property_entry lenovo_yoga_tab2_1380_lc824206xa_props[] = {
637 	PROPERTY_ENTRY_BOOL("onnn,enable-miclr-for-dcp"),
638 	{ }
639 };
640 
641 static const struct software_node lenovo_yoga_tab2_1380_lc824206xa_node = {
642 	.properties = lenovo_yoga_tab2_1380_lc824206xa_props,
643 };
644 
645 static const char * const lenovo_yoga_tab2_1380_lms303d_mount_matrix[] = {
646 	"0", "-1", "0",
647 	"-1", "0", "0",
648 	"0", "0", "1"
649 };
650 
651 static const struct property_entry lenovo_yoga_tab2_1380_lms303d_props[] = {
652 	PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", lenovo_yoga_tab2_1380_lms303d_mount_matrix),
653 	{ }
654 };
655 
656 static const struct software_node lenovo_yoga_tab2_1380_lms303d_node = {
657 	.properties = lenovo_yoga_tab2_1380_lms303d_props,
658 };
659 
660 static const struct x86_i2c_client_info lenovo_yoga_tab2_1380_i2c_clients[] __initconst = {
661 	{
662 		/* BQ27541 fuel-gauge */
663 		.board_info = {
664 			.type = "bq27541",
665 			.addr = 0x55,
666 			.dev_name = "bq27541",
667 			.swnode = &fg_bq24190_supply_node,
668 		},
669 		.adapter_path = "\\_SB_.I2C1",
670 	}, {
671 		/* bq24292i battery charger */
672 		.board_info = {
673 			.type = "bq24190",
674 			.addr = 0x6b,
675 			.dev_name = "bq24292i",
676 			.swnode = &lenovo_yoga_tab2_1380_bq24190_node,
677 			.platform_data = &lenovo_yoga_tab2_1380_bq24190_pdata,
678 		},
679 		.adapter_path = "\\_SB_.I2C1",
680 		.irq_data = {
681 			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
682 			.chip = "INT33FC:02",
683 			.index = 2,
684 			.trigger = ACPI_EDGE_SENSITIVE,
685 			.polarity = ACPI_ACTIVE_HIGH,
686 			.con_id = "bq24292i_irq",
687 		},
688 	}, {
689 		/* LP8557 Backlight controller */
690 		.board_info = {
691 			.type = "lp8557",
692 			.addr = 0x2c,
693 			.dev_name = "lp8557",
694 			.platform_data = &lenovo_lp8557_pwm_and_reg_pdata,
695 		},
696 		.adapter_path = "\\_SB_.I2C3",
697 	}, {
698 		/* LC824206XA Micro USB Switch */
699 		.board_info = {
700 			.type = "lc824206xa",
701 			.addr = 0x48,
702 			.dev_name = "lc824206xa",
703 			.swnode = &lenovo_yoga_tab2_1380_lc824206xa_node,
704 		},
705 		.adapter_path = "\\_SB_.I2C3",
706 		.irq_data = {
707 			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
708 			.chip = "INT33FC:02",
709 			.index = 1,
710 			.trigger = ACPI_LEVEL_SENSITIVE,
711 			.polarity = ACPI_ACTIVE_LOW,
712 			.con_id = "lc824206xa_irq",
713 		},
714 	}, {
715 		/* AL3320A ambient light sensor */
716 		.board_info = {
717 			.type = "al3320a",
718 			.addr = 0x1c,
719 			.dev_name = "al3320a",
720 		},
721 		.adapter_path = "\\_SB_.I2C5",
722 	}, {
723 		/* LSM303DA accelerometer + magnetometer */
724 		.board_info = {
725 			.type = "lsm303d",
726 			.addr = 0x1d,
727 			.dev_name = "lsm303d",
728 			.swnode = &lenovo_yoga_tab2_1380_lms303d_node,
729 		},
730 		.adapter_path = "\\_SB_.I2C5",
731 	}, {
732 		/* Synaptics RMI touchscreen */
733 		.board_info = {
734 			.type = "rmi4_i2c",
735 			.addr = 0x38,
736 			.dev_name = "rmi4_i2c",
737 			.platform_data = &lenovo_yoga_tab2_830_1050_rmi_pdata,
738 		},
739 		.adapter_path = "\\_SB_.I2C6",
740 		.irq_data = {
741 			.type = X86_ACPI_IRQ_TYPE_APIC,
742 			.index = 0x45,
743 			.trigger = ACPI_EDGE_SENSITIVE,
744 			.polarity = ACPI_ACTIVE_HIGH,
745 		},
746 	}
747 };
748 
749 static const struct property_entry lenovo_yoga_tab2_1380_fc_props[] __initconst = {
750 	PROPERTY_ENTRY_GPIO("uart3_txd-gpios", &baytrail_gpiochip_nodes[0], 57, GPIO_ACTIVE_HIGH),
751 	PROPERTY_ENTRY_GPIO("uart3_rxd-gpios", &baytrail_gpiochip_nodes[0], 61, GPIO_ACTIVE_HIGH),
752 	{ }
753 };
754 
755 static const struct platform_device_info lenovo_yoga_tab2_1380_pdevs[] __initconst = {
756 	{
757 		/* For the Tablet 2 Pro 1380's custom fast charging driver */
758 		.name = "lenovo-yoga-tab2-pro-1380-fastcharger",
759 		.id = PLATFORM_DEVID_NONE,
760 		.properties = lenovo_yoga_tab2_1380_fc_props,
761 	},
762 };
763 
lenovo_yoga_tab2_1380_init(struct device * dev)764 static int __init lenovo_yoga_tab2_1380_init(struct device *dev)
765 {
766 	int ret;
767 
768 	/* To verify that the DMI matching works vs the 830 / 1050 models */
769 	pr_info("detected Lenovo Yoga Tablet 2 Pro 1380F/L\n");
770 
771 	ret = lenovo_yoga_tab2_830_1050_init_codec();
772 	if (ret)
773 		return ret;
774 
775 	/* SYS_OFF_PRIO_FIRMWARE + 1 so that it runs before acpi_power_off() */
776 	lenovo_yoga_tab2_830_1050_sys_off_handler =
777 		register_sys_off_handler(SYS_OFF_MODE_POWER_OFF, SYS_OFF_PRIO_FIRMWARE + 1,
778 					 lenovo_yoga_tab2_830_1050_power_off, NULL);
779 	if (IS_ERR(lenovo_yoga_tab2_830_1050_sys_off_handler))
780 		return PTR_ERR(lenovo_yoga_tab2_830_1050_sys_off_handler);
781 
782 	return 0;
783 }
784 
785 const struct x86_dev_info lenovo_yoga_tab2_1380_info __initconst = {
786 	.i2c_client_info = lenovo_yoga_tab2_1380_i2c_clients,
787 	.i2c_client_count = ARRAY_SIZE(lenovo_yoga_tab2_1380_i2c_clients),
788 	.pdev_info = lenovo_yoga_tab2_1380_pdevs,
789 	.pdev_count = ARRAY_SIZE(lenovo_yoga_tab2_1380_pdevs),
790 	.gpio_button_swnodes = lenovo_yoga_tab2_830_1050_lid_swnodes,
791 	.swnode_group = generic_lipo_hv_4v35_battery_swnodes,
792 	.modules = lenovo_yoga_tab2_modules,
793 	.has_crystalcove = true,
794 	.gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
795 	.init = lenovo_yoga_tab2_1380_init,
796 	.exit = lenovo_yoga_tab2_830_1050_exit,
797 };
798 
799 /* Lenovo Yoga Tab 3 Pro YT3-X90F */
800 
801 /*
802  * There are 2 batteries, with 2 bq27500 fuel-gauges and 2 bq25892 chargers,
803  * "bq25890-charger-1" is instantiated from: drivers/i2c/busses/i2c-cht-wc.c.
804  */
805 static const char * const lenovo_yt3_bq25892_0_suppliers[] = { "cht_wcove_pwrsrc" };
806 static const char * const bq25890_1_psy[] = { "bq25890-charger-1" };
807 
808 static const struct property_entry fg_bq25890_1_supply_props[] = {
809 	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq25890_1_psy),
810 	{ }
811 };
812 
813 static const struct software_node fg_bq25890_1_supply_node = {
814 	.properties = fg_bq25890_1_supply_props,
815 };
816 
817 /* bq25892 charger settings for the flat LiPo battery behind the screen */
818 static const struct property_entry lenovo_yt3_bq25892_0_props[] = {
819 	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", lenovo_yt3_bq25892_0_suppliers),
820 	PROPERTY_ENTRY_U32("linux,iinlim-percentage", 40),
821 	PROPERTY_ENTRY_BOOL("linux,skip-reset"),
822 	/* Values taken from Android Factory Image */
823 	PROPERTY_ENTRY_U32("ti,charge-current", 2048000),
824 	PROPERTY_ENTRY_U32("ti,battery-regulation-voltage", 4352000),
825 	PROPERTY_ENTRY_U32("ti,termination-current", 128000),
826 	PROPERTY_ENTRY_U32("ti,precharge-current", 128000),
827 	PROPERTY_ENTRY_U32("ti,minimum-sys-voltage", 3700000),
828 	PROPERTY_ENTRY_U32("ti,boost-voltage", 4998000),
829 	PROPERTY_ENTRY_U32("ti,boost-max-current", 500000),
830 	PROPERTY_ENTRY_BOOL("ti,use-ilim-pin"),
831 	{ }
832 };
833 
834 static const struct software_node lenovo_yt3_bq25892_0_node = {
835 	.properties = lenovo_yt3_bq25892_0_props,
836 };
837 
838 static const struct property_entry lenovo_yt3_hideep_ts_props[] = {
839 	PROPERTY_ENTRY_U32("touchscreen-size-x", 1600),
840 	PROPERTY_ENTRY_U32("touchscreen-size-y", 2560),
841 	PROPERTY_ENTRY_U32("touchscreen-max-pressure", 255),
842 	PROPERTY_ENTRY_GPIO("reset-gpios", &cherryview_gpiochip_nodes[0], 7, GPIO_ACTIVE_LOW),
843 	{ }
844 };
845 
846 static const struct software_node lenovo_yt3_hideep_ts_node = {
847 	.properties = lenovo_yt3_hideep_ts_props,
848 };
849 
850 static const struct x86_i2c_client_info lenovo_yt3_i2c_clients[] __initconst = {
851 	{
852 		/* bq27500 fuel-gauge for the flat LiPo battery behind the screen */
853 		.board_info = {
854 			.type = "bq27500",
855 			.addr = 0x55,
856 			.dev_name = "bq27500_0",
857 			.swnode = &fg_bq25890_supply_node,
858 		},
859 		.adapter_path = "\\_SB_.PCI0.I2C1",
860 	}, {
861 		/* bq25892 charger for the flat LiPo battery behind the screen */
862 		.board_info = {
863 			.type = "bq25892",
864 			.addr = 0x6b,
865 			.dev_name = "bq25892_0",
866 			.swnode = &lenovo_yt3_bq25892_0_node,
867 		},
868 		.adapter_path = "\\_SB_.PCI0.I2C1",
869 		.irq_data = {
870 			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
871 			.chip = "INT33FF:01",
872 			.index = 5,
873 			.trigger = ACPI_EDGE_SENSITIVE,
874 			.polarity = ACPI_ACTIVE_LOW,
875 			.con_id = "bq25892_0_irq",
876 		},
877 	}, {
878 		/* bq27500 fuel-gauge for the round Li-ion cells in the hinge */
879 		.board_info = {
880 			.type = "bq27500",
881 			.addr = 0x55,
882 			.dev_name = "bq27500_1",
883 			.swnode = &fg_bq25890_1_supply_node,
884 		},
885 		.adapter_path = "\\_SB_.PCI0.I2C2",
886 	}, {
887 		/* HiDeep IST520E Touchscreen */
888 		.board_info = {
889 			.type = "hideep_ts",
890 			.addr = 0x6c,
891 			.dev_name = "hideep_ts",
892 			.swnode = &lenovo_yt3_hideep_ts_node,
893 		},
894 		.adapter_path = "\\_SB_.PCI0.I2C6",
895 		.irq_data = {
896 			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
897 			.chip = "INT33FF:03",
898 			.index = 77,
899 			.trigger = ACPI_LEVEL_SENSITIVE,
900 			.polarity = ACPI_ACTIVE_LOW,
901 			.con_id = "hideep_ts_irq",
902 		},
903 	}, {
904 		/* LP8557 Backlight controller */
905 		.board_info = {
906 			.type = "lp8557",
907 			.addr = 0x2c,
908 			.dev_name = "lp8557",
909 			.platform_data = &lenovo_lp8557_reg_only_pdata,
910 		},
911 		.adapter_path = "\\_SB_.PCI0.I2C1",
912 	}
913 };
914 
915 /*
916  * The AOSP 3.5 mm Headset: Accessory Specification gives the following values:
917  * Function A Play/Pause:           0 ohm
918  * Function D Voice assistant:    135 ohm
919  * Function B Volume Up           240 ohm
920  * Function C Volume Down         470 ohm
921  * Minimum Mic DC resistance     1000 ohm
922  * Minimum Ear speaker impedance   16 ohm
923  * Note the first max value below must be less then the min. speaker impedance,
924  * to allow CTIA/OMTP detection to work. The other max values are the closest
925  * value from extcon-arizona.c:arizona_micd_levels halfway 2 button resistances.
926  */
927 static const struct arizona_micd_range arizona_micd_aosp_ranges[] = {
928 	{ .max =  11, .key = KEY_PLAYPAUSE },
929 	{ .max = 186, .key = KEY_VOICECOMMAND },
930 	{ .max = 348, .key = KEY_VOLUMEUP },
931 	{ .max = 752, .key = KEY_VOLUMEDOWN },
932 };
933 
934 /* YT3 WM5102 arizona_micd_config comes from Android kernel sources */
935 static struct arizona_micd_config lenovo_yt3_wm5102_micd_config[] = {
936 	{ 0, 1, 0 },
937 	{ ARIZONA_ACCDET_SRC, 2, 1 },
938 };
939 
940 static struct arizona_pdata lenovo_yt3_wm5102_pdata = {
941 	.irq_flags = IRQF_TRIGGER_LOW,
942 	.micd_detect_debounce = 200,
943 	.micd_ranges = arizona_micd_aosp_ranges,
944 	.num_micd_ranges = ARRAY_SIZE(arizona_micd_aosp_ranges),
945 	.hpdet_channel = ARIZONA_ACCDET_MODE_HPL,
946 
947 	/* Below settings come from Android kernel sources */
948 	.micd_bias_start_time = 1,
949 	.micd_rate = 6,
950 	.micd_configs = lenovo_yt3_wm5102_micd_config,
951 	.num_micd_configs = ARRAY_SIZE(lenovo_yt3_wm5102_micd_config),
952 	.micbias = {
953 		[0] = { /* MICBIAS1 */
954 			.mV = 2800,
955 			.ext_cap = 1,
956 			.discharge = 1,
957 			.soft_start = 0,
958 			.bypass = 0,
959 		},
960 		[1] = { /* MICBIAS2 */
961 			.mV = 2800,
962 			.ext_cap = 1,
963 			.discharge = 1,
964 			.soft_start = 0,
965 			.bypass = 0,
966 		},
967 		[2] = { /* MICBIAS2 */
968 			.mV = 2800,
969 			.ext_cap = 1,
970 			.discharge = 1,
971 			.soft_start = 0,
972 			.bypass = 0,
973 		},
974 	},
975 };
976 
977 static const struct software_node lenovo_yt3_wm5102;
978 
979 static const struct property_entry lenovo_yt3_wm1502_props[] = {
980 	PROPERTY_ENTRY_GPIO("wlf,spkvdd-ena-gpios",
981 			    &cherryview_gpiochip_nodes[0], 75, GPIO_ACTIVE_HIGH),
982 	PROPERTY_ENTRY_GPIO("wlf,ldoena-gpios",
983 			    &cherryview_gpiochip_nodes[0], 81, GPIO_ACTIVE_HIGH),
984 	PROPERTY_ENTRY_GPIO("reset-gpios", &cherryview_gpiochip_nodes[0], 82, GPIO_ACTIVE_HIGH),
985 	PROPERTY_ENTRY_GPIO("wlf,micd-pol-gpios", &lenovo_yt3_wm5102, 2, GPIO_ACTIVE_HIGH),
986 	{ }
987 };
988 
989 static const struct software_node lenovo_yt3_wm5102 = {
990 	.properties = lenovo_yt3_wm1502_props,
991 	.name = "wm5102",
992 };
993 
994 
995 static const struct x86_spi_dev_info lenovo_yt3_spi_devs[] __initconst = {
996 	{
997 		/* WM5102 codec */
998 		.board_info = {
999 			.modalias = "wm5102",
1000 			.platform_data = &lenovo_yt3_wm5102_pdata,
1001 			.swnode = &lenovo_yt3_wm5102,
1002 			.max_speed_hz = 5000000,
1003 		},
1004 		.ctrl_path = "\\_SB_.PCI0.SPI1",
1005 		.irq_data = {
1006 			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
1007 			.chip = "INT33FF:00",
1008 			.index = 91,
1009 			.trigger = ACPI_LEVEL_SENSITIVE,
1010 			.polarity = ACPI_ACTIVE_LOW,
1011 			.con_id = "wm5102_irq",
1012 		},
1013 	}
1014 };
1015 
lenovo_yt3_init(struct device * dev)1016 static int __init lenovo_yt3_init(struct device *dev)
1017 {
1018 	int ret;
1019 
1020 	/*
1021 	 * The "bq25892_0" charger IC has its /CE (Charge-Enable) and OTG pins
1022 	 * connected to GPIOs, rather then having them hardwired to the correct
1023 	 * values as is normally done.
1024 	 *
1025 	 * The bq25890_charger driver controls these through I2C, but this only
1026 	 * works if not overridden by the pins. Set these pins here:
1027 	 * 1. Set /CE to 1 to allow charging.
1028 	 * 2. Set OTG to 0 disable V5 boost output since the 5V boost output of
1029 	 *    the main "bq25892_1" charger is used when necessary.
1030 	 */
1031 
1032 	/* /CE pin */
1033 	ret = x86_android_tablet_get_gpiod("INT33FF:02", 22, "bq25892_0_ce",
1034 					   true, GPIOD_OUT_HIGH, NULL);
1035 	if (ret < 0)
1036 		return ret;
1037 
1038 	/* OTG pin */
1039 	ret = x86_android_tablet_get_gpiod("INT33FF:03", 19, "bq25892_0_otg",
1040 					   false, GPIOD_OUT_LOW, NULL);
1041 	if (ret < 0)
1042 		return ret;
1043 
1044 	/* Enable the regulators used by the touchscreen */
1045 	intel_soc_pmic_exec_mipi_pmic_seq_element(0x6e, 0x9b, 0x02, 0xff);
1046 	intel_soc_pmic_exec_mipi_pmic_seq_element(0x6e, 0xa0, 0x02, 0xff);
1047 
1048 	return 0;
1049 }
1050 
1051 static const char * const lenovo_yt3_modules[] __initconst = {
1052 	"spi_pxa2xx_platform",	/* For the SPI codec device */
1053 	NULL
1054 };
1055 
1056 const struct x86_dev_info lenovo_yt3_info __initconst = {
1057 	.i2c_client_info = lenovo_yt3_i2c_clients,
1058 	.i2c_client_count = ARRAY_SIZE(lenovo_yt3_i2c_clients),
1059 	.spi_dev_info = lenovo_yt3_spi_devs,
1060 	.spi_dev_count = ARRAY_SIZE(lenovo_yt3_spi_devs),
1061 	.modules = lenovo_yt3_modules,
1062 	.gpiochip_type = X86_GPIOCHIP_CHERRYVIEW,
1063 	.init = lenovo_yt3_init,
1064 };
1065