Skip to content

Commit 141e813

Browse files
JeffyCNrkhuangtao
authored andcommitted
input: touchscreen: gt1x: Reuse the original power control flow
The official driver only has vdd_ana regulator, which matches our case: https://github.com/goodix/gt1x_driver_generic/blob/master/gt1x.c So remove the extra regulators, and reuse the original vdd_ana. Change-Id: Ia080344b3871e1c69b77c0f3048f601d57b8610a Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
1 parent 88d0096 commit 141e813

2 files changed

Lines changed: 8 additions & 29 deletions

File tree

drivers/input/touchscreen/gt1x/gt1x.c

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ 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;
3534
#endif
3635

3736
static int gt1x_register_powermanger(void);
@@ -293,8 +292,6 @@ static void gt1x_ts_work_func(struct work_struct *work)
293292
#ifdef GTP_CONFIG_OF
294293

295294
static struct regulator *vdd_ana;
296-
static struct regulator *vcc_i2c;
297-
298295
/**
299296
* gt1x_parse_dt - parse platform infomation form devices tree.
300297
*/
@@ -315,23 +312,16 @@ static int gt1x_parse_dt(struct device *dev)
315312
return -EINVAL;
316313
}
317314

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);
315+
vdd_ana = devm_regulator_get_optional(dev, "vdd_ana");
316+
if (PTR_ERR(vdd_ana) == -ENODEV) {
317+
GTP_ERROR("vdd_ana not specified, fallback to power-supply");
318+
vdd_ana = devm_regulator_get_optional(dev, "power");
322319
}
323-
324-
vdd_ana = devm_regulator_get(dev, "vdd_ana");
325320
if (IS_ERR(vdd_ana)) {
326-
GTP_ERROR("regulator get of vdd_ana failed");
327-
vdd_ana = NULL;
321+
GTP_ERROR("regulator get of vdd_ana/power-supply failed");
322+
return PTR_ERR(vdd_ana);
328323
}
329324

330-
vcc_i2c = devm_regulator_get(dev, "vcc_i2c");
331-
if (IS_ERR(vcc_i2c)) {
332-
GTP_ERROR("regulator get of vcc_i2c failed");
333-
vcc_i2c = NULL;
334-
}
335325
return 0;
336326
}
337327

@@ -345,18 +335,14 @@ int gt1x_power_switch(int on)
345335
int ret;
346336
struct i2c_client *client = gt1x_i2c_client;
347337

348-
if (!client || !vdd_ana || !vcc_i2c)
338+
if (!client || !vdd_ana)
349339
return -1;
350340

351341
if (on) {
352342
GTP_DEBUG("GTP power on.");
353343
ret = regulator_enable(vdd_ana);
354-
udelay(2);
355-
ret = regulator_enable(vcc_i2c);
356344
} else {
357345
GTP_DEBUG("GTP power off.");
358-
ret = regulator_disable(vcc_i2c);
359-
udelay(2);
360346
ret = regulator_disable(vdd_ana);
361347
}
362348
return ret;
@@ -372,9 +358,6 @@ static void gt1x_remove_gpio_and_power(void)
372358
gpio_free(gt1x_rst_gpio);
373359

374360
#ifdef GTP_CONFIG_OF
375-
if (vcc_i2c)
376-
regulator_put(vcc_i2c);
377-
378361
if (vdd_ana)
379362
regulator_put(vdd_ana);
380363
#endif

drivers/input/touchscreen/gt1x/gt1x_generic.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ static s32 gt1x_enter_sleep(void)
944944
gt1x_power_switch(SWITCH_OFF);
945945
return 0;
946946
#else
947+
int ret;
947948
{
948949
int ret;
949950
s32 retry = 0;
@@ -955,7 +956,6 @@ static s32 gt1x_enter_sleep(void)
955956
while (retry++ < 3) {
956957
if (!gt1x_send_cmd(GTP_CMD_SLEEP, 0)) {
957958
GTP_INFO("Enter sleep mode!");
958-
ret = regulator_disable(gt1x_supply);
959959
if (ret < 0)
960960
GTP_ERROR("disable power-supply error %d\n", ret);
961961
return 0;
@@ -981,12 +981,8 @@ static s32 gt1x_wakeup_sleep(void)
981981
s32 ret = -1;
982982
int flag = 0;
983983
#endif
984-
s32 ret = -1;
985984
GTP_DEBUG("Wake up begin.");
986985
gt1x_irq_disable();
987-
ret = regulator_enable(gt1x_supply);
988-
if (ret < 0)
989-
GTP_ERROR("enable power-supply error: %d\n", ret);
990986

991987
#if GTP_POWER_CTRL_SLEEP /* power manager unit control the procedure */
992988
gt1x_power_reset();

0 commit comments

Comments
 (0)