mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
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>
This commit is contained in:
@@ -31,7 +31,6 @@ 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);
|
||||
@@ -293,8 +292,6 @@ exit_eint:
|
||||
#ifdef GTP_CONFIG_OF
|
||||
|
||||
static struct regulator *vdd_ana;
|
||||
static struct regulator *vcc_i2c;
|
||||
|
||||
/**
|
||||
* gt1x_parse_dt - parse platform infomation form devices tree.
|
||||
*/
|
||||
@@ -315,23 +312,16 @@ static int gt1x_parse_dt(struct device *dev)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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_optional(dev, "vdd_ana");
|
||||
if (PTR_ERR(vdd_ana) == -ENODEV) {
|
||||
GTP_ERROR("vdd_ana not specified, fallback to power-supply");
|
||||
vdd_ana = devm_regulator_get_optional(dev, "power");
|
||||
}
|
||||
|
||||
vdd_ana = devm_regulator_get(dev, "vdd_ana");
|
||||
if (IS_ERR(vdd_ana)) {
|
||||
GTP_ERROR("regulator get of vdd_ana failed");
|
||||
vdd_ana = NULL;
|
||||
GTP_ERROR("regulator get of vdd_ana/power-supply failed");
|
||||
return PTR_ERR(vdd_ana);
|
||||
}
|
||||
|
||||
vcc_i2c = devm_regulator_get(dev, "vcc_i2c");
|
||||
if (IS_ERR(vcc_i2c)) {
|
||||
GTP_ERROR("regulator get of vcc_i2c failed");
|
||||
vcc_i2c = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -345,18 +335,14 @@ int gt1x_power_switch(int on)
|
||||
int ret;
|
||||
struct i2c_client *client = gt1x_i2c_client;
|
||||
|
||||
if (!client || !vdd_ana || !vcc_i2c)
|
||||
if (!client || !vdd_ana)
|
||||
return -1;
|
||||
|
||||
if (on) {
|
||||
GTP_DEBUG("GTP power on.");
|
||||
ret = regulator_enable(vdd_ana);
|
||||
udelay(2);
|
||||
ret = regulator_enable(vcc_i2c);
|
||||
} else {
|
||||
GTP_DEBUG("GTP power off.");
|
||||
ret = regulator_disable(vcc_i2c);
|
||||
udelay(2);
|
||||
ret = regulator_disable(vdd_ana);
|
||||
}
|
||||
return ret;
|
||||
@@ -372,9 +358,6 @@ static void gt1x_remove_gpio_and_power(void)
|
||||
gpio_free(gt1x_rst_gpio);
|
||||
|
||||
#ifdef GTP_CONFIG_OF
|
||||
if (vcc_i2c)
|
||||
regulator_put(vcc_i2c);
|
||||
|
||||
if (vdd_ana)
|
||||
regulator_put(vdd_ana);
|
||||
#endif
|
||||
|
||||
@@ -944,6 +944,7 @@ static s32 gt1x_enter_sleep(void)
|
||||
gt1x_power_switch(SWITCH_OFF);
|
||||
return 0;
|
||||
#else
|
||||
int ret;
|
||||
{
|
||||
int ret;
|
||||
s32 retry = 0;
|
||||
@@ -955,7 +956,6 @@ 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;
|
||||
@@ -981,12 +981,8 @@ static s32 gt1x_wakeup_sleep(void)
|
||||
s32 ret = -1;
|
||||
int flag = 0;
|
||||
#endif
|
||||
s32 ret = -1;
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user