Skip to content

Commit bcf5b3d

Browse files
SanderV4ndtor
authored andcommitted
Input: pixcir_i2c - add support for wake and enable gpios
On some devices the wake and enable pins of the pixcir touchscreen controller are connected to gpios and these must be controlled by the driver for the device to operate properly. Signed-off-by: Sander Vermin <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Acked-by: Rob Herring <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent e0361b7 commit bcf5b3d

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ Required properties:
99
- touchscreen-size-y: vertical resolution of touchscreen (in pixels)
1010

1111
Optional properties:
12-
- reset-gpio: GPIO connected to the RESET line of the chip
12+
- reset-gpios: GPIO connected to the RESET line of the chip
13+
- enable-gpios: GPIO connected to the ENABLE line of the chip
14+
- wake-gpios: GPIO connected to the WAKE line of the chip
1315

1416
Example:
1517

drivers/input/touchscreen/pixcir_i2c_ts.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ struct pixcir_i2c_ts_data {
3838
struct input_dev *input;
3939
struct gpio_desc *gpio_attb;
4040
struct gpio_desc *gpio_reset;
41+
struct gpio_desc *gpio_enable;
42+
struct gpio_desc *gpio_wake;
4143
const struct pixcir_i2c_chip_data *chip;
4244
int max_fingers; /* Max fingers supported in this instance */
4345
bool running;
@@ -208,6 +210,11 @@ static int pixcir_set_power_mode(struct pixcir_i2c_ts_data *ts,
208210
struct device *dev = &ts->client->dev;
209211
int ret;
210212

213+
if (mode == PIXCIR_POWER_ACTIVE || mode == PIXCIR_POWER_IDLE) {
214+
if (ts->gpio_wake)
215+
gpiod_set_value_cansleep(ts->gpio_wake, 1);
216+
}
217+
211218
ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_POWER_MODE);
212219
if (ret < 0) {
213220
dev_err(dev, "%s: can't read reg 0x%x : %d\n",
@@ -228,6 +235,11 @@ static int pixcir_set_power_mode(struct pixcir_i2c_ts_data *ts,
228235
return ret;
229236
}
230237

238+
if (mode == PIXCIR_POWER_HALT) {
239+
if (ts->gpio_wake)
240+
gpiod_set_value_cansleep(ts->gpio_wake, 0);
241+
}
242+
231243
return 0;
232244
}
233245

@@ -302,6 +314,11 @@ static int pixcir_start(struct pixcir_i2c_ts_data *ts)
302314
struct device *dev = &ts->client->dev;
303315
int error;
304316

317+
if (ts->gpio_enable) {
318+
gpiod_set_value_cansleep(ts->gpio_enable, 1);
319+
msleep(100);
320+
}
321+
305322
/* LEVEL_TOUCH interrupt with active low polarity */
306323
error = pixcir_set_int_mode(ts, PIXCIR_INT_LEVEL_TOUCH, 0);
307324
if (error) {
@@ -343,6 +360,9 @@ static int pixcir_stop(struct pixcir_i2c_ts_data *ts)
343360
/* Wait till running ISR is complete */
344361
synchronize_irq(ts->client->irq);
345362

363+
if (ts->gpio_enable)
364+
gpiod_set_value_cansleep(ts->gpio_enable, 0);
365+
346366
return 0;
347367
}
348368

@@ -534,6 +554,27 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
534554
return error;
535555
}
536556

557+
tsdata->gpio_wake = devm_gpiod_get_optional(dev, "wake",
558+
GPIOD_OUT_HIGH);
559+
if (IS_ERR(tsdata->gpio_wake)) {
560+
error = PTR_ERR(tsdata->gpio_wake);
561+
if (error != -EPROBE_DEFER)
562+
dev_err(dev, "Failed to get wake gpio: %d\n", error);
563+
return error;
564+
}
565+
566+
tsdata->gpio_enable = devm_gpiod_get_optional(dev, "enable",
567+
GPIOD_OUT_HIGH);
568+
if (IS_ERR(tsdata->gpio_enable)) {
569+
error = PTR_ERR(tsdata->gpio_enable);
570+
if (error != -EPROBE_DEFER)
571+
dev_err(dev, "Failed to get enable gpio: %d\n", error);
572+
return error;
573+
}
574+
575+
if (tsdata->gpio_enable)
576+
msleep(100);
577+
537578
error = devm_request_threaded_irq(dev, client->irq, NULL, pixcir_ts_isr,
538579
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
539580
client->name, tsdata);

0 commit comments

Comments
 (0)