From b6fde03e089c31680145c7b04f20c7e9f7fc0522 Mon Sep 17 00:00:00 2001 From: Shengfei xu Date: Fri, 19 Feb 2016 17:16:22 +0800 Subject: [PATCH] Input: gt911: get regulator form dts. Make it possible to specify the supply of a regulator, through the tp-supply property in dt. Change-Id: If741bb48280a339fc37e9f53d566fbbb444c31e8 Signed-off-by: Shengfei xu --- arch/arm64/boot/dts/rockchip/rk3368-tb.dtsi | 2 +- drivers/input/touchscreen/gt9xx/gt9xx.c | 42 ++++++++------------- drivers/input/touchscreen/gt9xx/gt9xx.h | 3 +- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/arch/arm64/boot/dts/rockchip/rk3368-tb.dtsi b/arch/arm64/boot/dts/rockchip/rk3368-tb.dtsi index 2a503bfd2a10..cbee1ca0152c 100644 --- a/arch/arm64/boot/dts/rockchip/rk3368-tb.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3368-tb.dtsi @@ -465,7 +465,6 @@ }; vcc_tp: LDO_REG2 { - regulator-always-on; regulator-boot-on; regulator-min-microvolt = <3000000>; regulator-max-microvolt = <3000000>; @@ -606,6 +605,7 @@ max-y = <1900>; tp-size = <911>; status = "disabled"; + tp-supply = <&vcc_tp>; }; }; diff --git a/drivers/input/touchscreen/gt9xx/gt9xx.c b/drivers/input/touchscreen/gt9xx/gt9xx.c index dfbe060ea075..68396b5613db 100755 --- a/drivers/input/touchscreen/gt9xx/gt9xx.c +++ b/drivers/input/touchscreen/gt9xx/gt9xx.c @@ -1911,7 +1911,6 @@ static int goodix_ts_early_suspend(struct tp_device *tp_d) { struct goodix_ts_data *ts; s8 ret = -1; - struct regulator *regulator_tp = NULL; int reg = 0; ts = container_of(tp_d, struct goodix_ts_data, tp); @@ -1944,18 +1943,10 @@ static int goodix_ts_early_suspend(struct tp_device *tp_d) // to avoid waking up while not sleeping // delay 48 + 10ms to ensure reliability msleep(58); - regulator_tp = regulator_get(NULL,"vcc_tp"); - if(IS_ERR(regulator_tp)) - { - printk("!!!!%s:%d:get regulator_tp failed\n",__func__,__LINE__); - return 0; - } - while(regulator_is_enabled(regulator_tp)) - { - reg = regulator_disable(regulator_tp); - msleep(10); - } - regulator_put(regulator_tp); + + reg = regulator_disable(ts->tp_regulator); + if (reg < 0) + GTP_ERROR("failed to disable tp regulator\n"); msleep(20); return 0; } @@ -1972,25 +1963,15 @@ static int goodix_ts_early_resume(struct tp_device *tp_d) { struct goodix_ts_data *ts; s8 ret = -1; - struct regulator *regulator_tp = NULL; int reg = 0; ts = container_of(tp_d, struct goodix_ts_data, tp); GTP_DEBUG_FUNC(); GTP_INFO("System resume."); - regulator_tp = regulator_get(NULL, "vcc_tp"); - if(IS_ERR(regulator_tp)) - { - printk("!!!!%s:%d:get regulator_tp failed\n",__func__,__LINE__); - return 0; - } - while(!(regulator_is_enabled(regulator_tp))) - { - reg = regulator_enable(regulator_tp); - msleep(10); - } - regulator_put(regulator_tp); + reg = regulator_enable(ts->tp_regulator); + if (reg < 0) + GTP_ERROR("failed to enable tp regulator\n"); msleep(10); ret = gtp_wakeup_sleep(ts); @@ -2621,6 +2602,13 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id mGtp_Y_Reverse = TRUE; } + ts->tp_regulator = devm_regulator_get(&client->dev, "tp"); + if (IS_ERR(ts->tp_regulator)) { + dev_err(&client->dev, "failed to get regulator, %ld\n", + PTR_ERR(ts->tp_regulator)); + return PTR_ERR(ts->tp_regulator); + } + ts->irq_pin = of_get_named_gpio_flags(np, "touch-gpio", 0, (enum of_gpio_flags *)(&ts->irq_flags)); ts->rst_pin = of_get_named_gpio_flags(np, "reset-gpio", 0, &rst_flags); ts->pwr_pin = of_get_named_gpio_flags(np, "power-gpio", 0, &pwr_flags); @@ -2752,7 +2740,7 @@ static int goodix_ts_probe(struct i2c_client *client, const struct i2c_device_id #if GTP_CREATE_WR_NODE init_wr_node(client); #endif - + #if GTP_ESD_PROTECT gtp_esd_switch(client, SWITCH_ON); #endif diff --git a/drivers/input/touchscreen/gt9xx/gt9xx.h b/drivers/input/touchscreen/gt9xx/gt9xx.h index 05e707234b67..2e16a2b318d0 100755 --- a/drivers/input/touchscreen/gt9xx/gt9xx.h +++ b/drivers/input/touchscreen/gt9xx/gt9xx.h @@ -141,7 +141,8 @@ struct goodix_ts_data { u8 rqst_processing; u8 is_950; #endif - + struct regulator *tp_regulator; + }; extern u16 show_len; -- 2.34.1