summaryrefslogtreecommitdiff
path: root/drivers/input/touchscreen/gt1x
diff options
context:
space:
mode:
authorJeffy Chen <jeffy.chen@rock-chips.com>2018-07-02 18:28:06 +0800
committerTao Huang <huangtao@rock-chips.com>2018-07-03 11:38:14 +0800
commitbcc29ab6d3a4c9e0df61ee45bb8d375891de4b00 (patch)
tree7771229711bed30916c64d79c3cfb75a7fc30bd4 /drivers/input/touchscreen/gt1x
parentdde2185b030e0e023c0e11df128ca96f57757618 (diff)
input: touchscreen: gt1x: Make power ctrl optional
Some boards don't need to control power supply. Let's make it optional. Change-Id: Ifd72a7c3704cdc0df4f2d2096278a6b58f925e8d Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
Diffstat (limited to 'drivers/input/touchscreen/gt1x')
-rw-r--r--drivers/input/touchscreen/gt1x/gt1x.c4
-rw-r--r--drivers/input/touchscreen/gt1x/gt1x_generic.c58
2 files changed, 33 insertions, 29 deletions
diff --git a/drivers/input/touchscreen/gt1x/gt1x.c b/drivers/input/touchscreen/gt1x/gt1x.c
index 337a4c2ac343..c14581113b92 100644
--- a/drivers/input/touchscreen/gt1x/gt1x.c
+++ b/drivers/input/touchscreen/gt1x/gt1x.c
@@ -316,6 +316,10 @@ static int gt1x_parse_dt(struct device *dev)
if (PTR_ERR(vdd_ana) == -ENODEV) {
GTP_ERROR("vdd_ana not specified, fallback to power-supply");
vdd_ana = devm_regulator_get_optional(dev, "power");
+ if (PTR_ERR(vdd_ana) == -ENODEV) {
+ GTP_ERROR("power not specified, ignore power ctrl");
+ vdd_ana = NULL;
+ }
}
if (IS_ERR(vdd_ana)) {
GTP_ERROR("regulator get of vdd_ana/power-supply failed");
diff --git a/drivers/input/touchscreen/gt1x/gt1x_generic.c b/drivers/input/touchscreen/gt1x/gt1x_generic.c
index c7a036b64569..893815090ad8 100644
--- a/drivers/input/touchscreen/gt1x/gt1x_generic.c
+++ b/drivers/input/touchscreen/gt1x/gt1x_generic.c
@@ -439,7 +439,6 @@ s32 _do_i2c_write(struct i2c_msg *msg, u16 addr, u8 *buffer, s32 len)
return 0;
}
-#if !GTP_POWER_CTRL_SLEEP
#if !GTP_ESD_PROTECT
static s32 gt1x_i2c_test(void)
{
@@ -463,7 +462,6 @@ static s32 gt1x_i2c_test(void)
return ERROR_RETRY;
}
#endif
-#endif
/**
* gt1x_i2c_read_dbl_check - read twice and double check
@@ -911,29 +909,30 @@ s32 gt1x_get_chip_type(void)
*/
static s32 gt1x_enter_sleep(void)
{
+ s32 retry = 0;
+
#if GTP_POWER_CTRL_SLEEP
- gt1x_power_switch(SWITCH_OFF);
- return 0;
-#else
- {
- s32 retry = 0;
- if (gt1x_wakeup_level == 1) { /* high level wakeup */
- GTP_GPIO_OUTPUT(GTP_INT_PORT, 0);
- }
- usleep_range(5000, 6000);
+ if (!gt1x_power_switch(SWITCH_OFF)) {
+ GTP_INFO("Enter sleep mode by poweroff");
+ return 0;
+ }
+#endif
- while (retry++ < 3) {
- if (!gt1x_send_cmd(GTP_CMD_SLEEP, 0)) {
- GTP_INFO("Enter sleep mode!");
- return 0;
- }
- usleep_range(10000, 11000);
- }
+ if (gt1x_wakeup_level == 1) { /* high level wakeup */
+ GTP_GPIO_OUTPUT(GTP_INT_PORT, 0);
+ }
+ usleep_range(5000, 6000);
- GTP_ERROR("Enter sleep mode failed.");
- return -1;
+ while (retry++ < 3) {
+ if (!gt1x_send_cmd(GTP_CMD_SLEEP, 0)) {
+ GTP_INFO("Enter sleep mode!");
+ return 0;
+ }
+ usleep_range(10000, 11000);
}
-#endif
+
+ GTP_ERROR("Enter sleep mode failed.");
+ return -1;
}
/**
@@ -943,20 +942,22 @@ static s32 gt1x_enter_sleep(void)
*/
static s32 gt1x_wakeup_sleep(void)
{
-#if !GTP_POWER_CTRL_SLEEP
u8 retry = 0;
s32 ret = -1;
int flag = 0;
-#endif
+
GTP_DEBUG("Wake up begin.");
gt1x_irq_disable();
#if GTP_POWER_CTRL_SLEEP /* power manager unit control the procedure */
- gt1x_power_switch(SWITCH_ON);
- gt1x_power_reset();
- GTP_INFO("Wakeup by poweron");
- return 0;
-#else /* gesture wakeup & int port wakeup */
+ if (!gt1x_power_switch(SWITCH_ON)) {
+ gt1x_power_reset();
+ GTP_INFO("Wakeup by poweron");
+ return 0;
+ }
+#endif
+
+ /* gesture wakeup & int port wakeup */
while (retry++ < 2) {
#if GTP_GESTURE_WAKEUP
if (gesture_enabled) {
@@ -1003,7 +1004,6 @@ static s32 gt1x_wakeup_sleep(void)
GTP_INFO("Wake up end.");
return 0;
}
-#endif /* END GTP_POWER_CTRL_SLEEP */
}
/**