Ver código fonte

Input: goodix - put reset and irq into default state during probe

The Goodix touchscreen controller requires a specific pin sequencing to be
done when the device is out of reset. Don't assume the initial state of the
pins at probe. Explicitly put the touchscreen controller into a reset state
and set the interrupt pin to low.

Also don't allow reset pin to float by configuring it as an input. This
avoids assumptions based on board's hardware.

Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
Franklin S Cooper Jr 9 anos atrás
pai
commit
da6752c3bb
1 arquivos alterados com 6 adições e 18 exclusões
  1. 6 18
      drivers/input/touchscreen/goodix.c

+ 6 - 18
drivers/input/touchscreen/goodix.c

@@ -484,31 +484,17 @@ static int goodix_reset(struct goodix_ts_data *ts)
 {
 {
 	int error;
 	int error;
 
 
-	/* begin select I2C slave addr */
-	error = gpiod_direction_output(ts->gpiod_rst, 0);
-	if (error)
-		return error;
-
 	msleep(20);				/* T2: > 10ms */
 	msleep(20);				/* T2: > 10ms */
 
 
 	/* HIGH: 0x28/0x29, LOW: 0xBA/0xBB */
 	/* HIGH: 0x28/0x29, LOW: 0xBA/0xBB */
-	error = gpiod_direction_output(ts->gpiod_int, ts->client->addr == 0x14);
-	if (error)
-		return error;
+	gpiod_set_value_cansleep(ts->gpiod_int, ts->client->addr == 0x14);
 
 
 	usleep_range(100, 2000);		/* T3: > 100us */
 	usleep_range(100, 2000);		/* T3: > 100us */
 
 
-	error = gpiod_direction_output(ts->gpiod_rst, 1);
-	if (error)
-		return error;
+	gpiod_set_value_cansleep(ts->gpiod_rst, 1);
 
 
 	usleep_range(6000, 10000);		/* T4: > 5ms */
 	usleep_range(6000, 10000);		/* T4: > 5ms */
 
 
-	/* end select I2C slave addr */
-	error = gpiod_direction_input(ts->gpiod_rst);
-	if (error)
-		return error;
-
 	error = goodix_int_sync(ts);
 	error = goodix_int_sync(ts);
 	if (error)
 	if (error)
 		return error;
 		return error;
@@ -532,7 +518,8 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 	dev = &ts->client->dev;
 	dev = &ts->client->dev;
 
 
 	/* Get the interrupt GPIO pin number */
 	/* Get the interrupt GPIO pin number */
-	gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_INT_NAME, GPIOD_IN);
+	gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_INT_NAME,
+					GPIOD_OUT_LOW);
 	if (IS_ERR(gpiod)) {
 	if (IS_ERR(gpiod)) {
 		error = PTR_ERR(gpiod);
 		error = PTR_ERR(gpiod);
 		if (error != -EPROBE_DEFER)
 		if (error != -EPROBE_DEFER)
@@ -544,7 +531,8 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 	ts->gpiod_int = gpiod;
 	ts->gpiod_int = gpiod;
 
 
 	/* Get the reset line GPIO pin number */
 	/* Get the reset line GPIO pin number */
-	gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME, GPIOD_IN);
+	gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME,
+					GPIOD_OUT_LOW);
 	if (IS_ERR(gpiod)) {
 	if (IS_ERR(gpiod)) {
 		error = PTR_ERR(gpiod);
 		error = PTR_ERR(gpiod);
 		if (error != -EPROBE_DEFER)
 		if (error != -EPROBE_DEFER)