diff options
author | Zhou weixin <zwx@rock-chips.com> | 2018-06-12 09:42:09 +0800 |
---|---|---|
committer | Tao Huang <huangtao@rock-chips.com> | 2018-06-13 09:38:24 +0800 |
commit | 420f585082ca6e6d9ac3deba65350cf93984c6f1 (patch) | |
tree | b0fd59e2fd8a5466493b52aef871c34654f047d7 /drivers/input/touchscreen/gt1x | |
parent | 69830ffc1261c2d6b0287fe1bec2c9aaefeab5f1 (diff) |
input: touchscreen: gt1x: fix i2c error when wakeup
Change-Id: I8575330a8f15573c6f11ddeaab1327382d302977
Signed-off-by: Weixin Zhou <zwx@rock-chips.com>
Diffstat (limited to 'drivers/input/touchscreen/gt1x')
-rw-r--r-- | drivers/input/touchscreen/gt1x/gt1x.c | 25 | ||||
-rw-r--r-- | drivers/input/touchscreen/gt1x/gt1x.h | 1 | ||||
-rw-r--r-- | drivers/input/touchscreen/gt1x/gt1x_generic.c | 7 |
3 files changed, 20 insertions, 13 deletions
diff --git a/drivers/input/touchscreen/gt1x/gt1x.c b/drivers/input/touchscreen/gt1x/gt1x.c index d701bd5b7193..0fb37c2da167 100644 --- a/drivers/input/touchscreen/gt1x/gt1x.c +++ b/drivers/input/touchscreen/gt1x/gt1x.c @@ -31,6 +31,7 @@ static const char *input_dev_phys = "input/ts"; #ifdef GTP_CONFIG_OF int gt1x_rst_gpio; int gt1x_int_gpio; +struct regulator *gt1x_supply; #endif static int gt1x_register_powermanger(void); @@ -300,7 +301,6 @@ static struct regulator *vcc_i2c; static int gt1x_parse_dt(struct device *dev) { struct device_node *np; - int ret; if (!dev) return -ENODEV; @@ -315,27 +315,24 @@ static int gt1x_parse_dt(struct device *dev) return -EINVAL; } - vdd_ana = regulator_get(dev, "vdd_ana"); + gt1x_supply = devm_regulator_get(dev, "power"); + if (IS_ERR(gt1x_supply)) { + GTP_ERROR("regulator get of power-supply failed"); + return PTR_ERR(gt1x_supply); + } + + vdd_ana = devm_regulator_get(dev, "vdd_ana"); if (IS_ERR(vdd_ana)) { GTP_ERROR("regulator get of vdd_ana failed"); - ret = PTR_ERR(vdd_ana); vdd_ana = NULL; - return ret; } - vcc_i2c = regulator_get(dev, "vcc_i2c"); + vcc_i2c = devm_regulator_get(dev, "vcc_i2c"); if (IS_ERR(vcc_i2c)) { GTP_ERROR("regulator get of vcc_i2c failed"); - ret = PTR_ERR(vcc_i2c); vcc_i2c = NULL; - goto ERR_GET_VCC; } return 0; -ERR_GET_VCC: - regulator_put(vdd_ana); - vdd_ana = NULL; - return ret; - return 0; } /** @@ -544,7 +541,9 @@ static int gt1x_ts_probe(struct i2c_client *client, const struct i2c_device_id * #ifdef GTP_CONFIG_OF /* device tree support */ if (client->dev.of_node) { - gt1x_parse_dt(&client->dev); + ret = gt1x_parse_dt(&client->dev); + if (ret) + return ret; } #endif diff --git a/drivers/input/touchscreen/gt1x/gt1x.h b/drivers/input/touchscreen/gt1x/gt1x.h index 343fdc0cf0c5..1e21c3905b20 100644 --- a/drivers/input/touchscreen/gt1x/gt1x.h +++ b/drivers/input/touchscreen/gt1x/gt1x.h @@ -39,6 +39,7 @@ #ifdef GTP_CONFIG_OF extern int gt1x_rst_gpio; extern int gt1x_int_gpio; +extern struct regulator *gt1x_supply; #define GTP_RST_PORT gt1x_rst_gpio #define GTP_INT_PORT gt1x_int_gpio #else diff --git a/drivers/input/touchscreen/gt1x/gt1x_generic.c b/drivers/input/touchscreen/gt1x/gt1x_generic.c index a2d61bcb9b81..2a704ae688d9 100644 --- a/drivers/input/touchscreen/gt1x/gt1x_generic.c +++ b/drivers/input/touchscreen/gt1x/gt1x_generic.c @@ -938,6 +938,7 @@ s32 gt1x_get_chip_type(void) */ static s32 gt1x_enter_sleep(void) { + int ret; #if GTP_POWER_CTRL_SLEEP gt1x_power_switch(SWITCH_OFF); return 0; @@ -952,6 +953,9 @@ static s32 gt1x_enter_sleep(void) while (retry++ < 3) { if (!gt1x_send_cmd(GTP_CMD_SLEEP, 0)) { GTP_INFO("Enter sleep mode!"); + ret = regulator_disable(gt1x_supply); + if (ret < 0) + GTP_ERROR("disable power-supply error %d\n", ret); return 0; } msleep(10); @@ -978,6 +982,9 @@ static s32 gt1x_wakeup_sleep(void) GTP_DEBUG("Wake up begin."); gt1x_irq_disable(); + ret = regulator_enable(gt1x_supply); + if (ret < 0) + GTP_ERROR("enable power-supply error: %d\n", ret); #if GTP_POWER_CTRL_SLEEP /* power manager unit control the procedure */ gt1x_power_reset(); |