Skip to content

Commit 420f585

Browse files
Zhou weixinrkhuangtao
authored andcommitted
input: touchscreen: gt1x: fix i2c error when wakeup
Change-Id: I8575330a8f15573c6f11ddeaab1327382d302977 Signed-off-by: Weixin Zhou <zwx@rock-chips.com>
1 parent 69830ff commit 420f585

3 files changed

Lines changed: 20 additions & 13 deletions

File tree

drivers/input/touchscreen/gt1x/gt1x.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static const char *input_dev_phys = "input/ts";
3131
#ifdef GTP_CONFIG_OF
3232
int gt1x_rst_gpio;
3333
int gt1x_int_gpio;
34+
struct regulator *gt1x_supply;
3435
#endif
3536

3637
static int gt1x_register_powermanger(void);
@@ -300,7 +301,6 @@ static struct regulator *vcc_i2c;
300301
static int gt1x_parse_dt(struct device *dev)
301302
{
302303
struct device_node *np;
303-
int ret;
304304

305305
if (!dev)
306306
return -ENODEV;
@@ -315,27 +315,24 @@ static int gt1x_parse_dt(struct device *dev)
315315
return -EINVAL;
316316
}
317317

318-
vdd_ana = regulator_get(dev, "vdd_ana");
318+
gt1x_supply = devm_regulator_get(dev, "power");
319+
if (IS_ERR(gt1x_supply)) {
320+
GTP_ERROR("regulator get of power-supply failed");
321+
return PTR_ERR(gt1x_supply);
322+
}
323+
324+
vdd_ana = devm_regulator_get(dev, "vdd_ana");
319325
if (IS_ERR(vdd_ana)) {
320326
GTP_ERROR("regulator get of vdd_ana failed");
321-
ret = PTR_ERR(vdd_ana);
322327
vdd_ana = NULL;
323-
return ret;
324328
}
325329

326-
vcc_i2c = regulator_get(dev, "vcc_i2c");
330+
vcc_i2c = devm_regulator_get(dev, "vcc_i2c");
327331
if (IS_ERR(vcc_i2c)) {
328332
GTP_ERROR("regulator get of vcc_i2c failed");
329-
ret = PTR_ERR(vcc_i2c);
330333
vcc_i2c = NULL;
331-
goto ERR_GET_VCC;
332334
}
333335
return 0;
334-
ERR_GET_VCC:
335-
regulator_put(vdd_ana);
336-
vdd_ana = NULL;
337-
return ret;
338-
return 0;
339336
}
340337

341338
/**
@@ -544,7 +541,9 @@ static int gt1x_ts_probe(struct i2c_client *client, const struct i2c_device_id *
544541

545542
#ifdef GTP_CONFIG_OF /* device tree support */
546543
if (client->dev.of_node) {
547-
gt1x_parse_dt(&client->dev);
544+
ret = gt1x_parse_dt(&client->dev);
545+
if (ret)
546+
return ret;
548547
}
549548
#endif
550549

drivers/input/touchscreen/gt1x/gt1x.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#ifdef GTP_CONFIG_OF
4040
extern int gt1x_rst_gpio;
4141
extern int gt1x_int_gpio;
42+
extern struct regulator *gt1x_supply;
4243
#define GTP_RST_PORT gt1x_rst_gpio
4344
#define GTP_INT_PORT gt1x_int_gpio
4445
#else

drivers/input/touchscreen/gt1x/gt1x_generic.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,7 @@ s32 gt1x_get_chip_type(void)
938938
*/
939939
static s32 gt1x_enter_sleep(void)
940940
{
941+
int ret;
941942
#if GTP_POWER_CTRL_SLEEP
942943
gt1x_power_switch(SWITCH_OFF);
943944
return 0;
@@ -952,6 +953,9 @@ static s32 gt1x_enter_sleep(void)
952953
while (retry++ < 3) {
953954
if (!gt1x_send_cmd(GTP_CMD_SLEEP, 0)) {
954955
GTP_INFO("Enter sleep mode!");
956+
ret = regulator_disable(gt1x_supply);
957+
if (ret < 0)
958+
GTP_ERROR("disable power-supply error %d\n", ret);
955959
return 0;
956960
}
957961
msleep(10);
@@ -978,6 +982,9 @@ static s32 gt1x_wakeup_sleep(void)
978982

979983
GTP_DEBUG("Wake up begin.");
980984
gt1x_irq_disable();
985+
ret = regulator_enable(gt1x_supply);
986+
if (ret < 0)
987+
GTP_ERROR("enable power-supply error: %d\n", ret);
981988

982989
#if GTP_POWER_CTRL_SLEEP /* power manager unit control the procedure */
983990
gt1x_power_reset();

0 commit comments

Comments
 (0)