Skip to content

Commit

Permalink
input: touchscreen: gt1x: ignore pin of reset and support power invert
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Jianhua <linjh@rock-chips.com>
Change-Id: I3f0da33eef197d78bfb72c620bfe2c25dd87d02a
  • Loading branch information
Lin Jianhua authored and rkhuangtao committed Nov 17, 2022
1 parent 54f657f commit 334791b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 14 deletions.
53 changes: 41 additions & 12 deletions drivers/input/touchscreen/gt1x/gt1x.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static const struct dev_pm_ops gt1x_ts_pm_ops;
bool gt1x_gt5688;
int gt1x_rst_gpio;
int gt1x_int_gpio;
static bool power_invert;
#endif

static int gt1x_register_powermanger(void);
Expand Down Expand Up @@ -277,6 +278,11 @@ static void gt1x_ts_work_func(struct work_struct *work)
#else
ret = gt1x_touch_event_handler(point_data, input_dev, NULL);
#endif
if (ret < 0) {
#if !GTP_ESD_PROTECT
gt1x_power_reset();
#endif
}

exit_work_func:
if (!gt1x_rawdiff_mode && (ret >= 0 || ret == ERROR_VALUE)) {
Expand Down Expand Up @@ -323,9 +329,14 @@ static int gt1x_parse_dt(struct device *dev)
gt1x_int_gpio = of_get_named_gpio(np, "goodix,irq-gpio", 0);
gt1x_rst_gpio = of_get_named_gpio(np, "goodix,rst-gpio", 0);

if (!gpio_is_valid(gt1x_int_gpio) || !gpio_is_valid(gt1x_rst_gpio)) {
GTP_ERROR("Invalid GPIO, irq-gpio:%d, rst-gpio:%d",
gt1x_int_gpio, gt1x_rst_gpio);
if (!gpio_is_valid(gt1x_rst_gpio)) {
GTP_INFO("Invalid GPIO, rst-gpio:%d",
gt1x_rst_gpio);
}

if (!gpio_is_valid(gt1x_int_gpio)) {
GTP_ERROR("Invalid GPIO, irq-gpio:%d",
gt1x_int_gpio);
return -EINVAL;
}

Expand All @@ -336,6 +347,9 @@ static int gt1x_parse_dt(struct device *dev)
if (PTR_ERR(vdd_ana) == -ENODEV) {
GTP_ERROR("power not specified, ignore power ctrl");
vdd_ana = NULL;
} else {
power_invert = of_property_read_bool(np, "power-invert");
GTP_INFO("Power Invert,%s ", power_invert ? "yes" : "no");
}
}
if (IS_ERR(vdd_ana)) {
Expand Down Expand Up @@ -364,18 +378,30 @@ static int gt1x_parse_dt(struct device *dev)
*/
int gt1x_power_switch(int on)
{
int ret;
int ret = 0;
struct i2c_client *client = gt1x_i2c_client;

if (!client || !vdd_ana)
return -1;

if (on) {
GTP_DEBUG("GTP power on.");
ret = regulator_enable(vdd_ana);
if (power_invert) {
if (regulator_is_enabled(vdd_ana) > 0)
ret = regulator_disable(vdd_ana);
} else {
if (!regulator_is_enabled(vdd_ana))
ret = regulator_enable(vdd_ana);
}
} else {
GTP_DEBUG("GTP power off.");
ret = regulator_disable(vdd_ana);
if (power_invert) {
if (!regulator_is_enabled(vdd_ana))
ret = regulator_enable(vdd_ana);
} else {
if (regulator_is_enabled(vdd_ana) > 0)
ret = regulator_disable(vdd_ana);
}
}
return ret;
}
Expand Down Expand Up @@ -411,14 +437,17 @@ static s32 gt1x_request_io_port(void)
GTP_GPIO_AS_INT(GTP_INT_PORT);
gt1x_i2c_client->irq = GTP_INT_IRQ;

ret = gpio_request(GTP_RST_PORT, "GTP_RST_PORT");
if (ret < 0) {
GTP_ERROR("Failed to request GPIO:%d, ERRNO:%d", (s32) GTP_RST_PORT, ret);
gpio_free(GTP_INT_PORT);
return ret;
if (gpio_is_valid(gt1x_rst_gpio)) {
ret = gpio_request(GTP_RST_PORT, "GTP_RST_PORT");
if (ret < 0) {
GTP_ERROR("Failed to request GPIO:%d, ERRNO:%d", (s32) GTP_RST_PORT, ret);
gpio_free(GTP_INT_PORT);
return ret;
}

GTP_GPIO_AS_INPUT(GTP_RST_PORT);
}

GTP_GPIO_AS_INPUT(GTP_RST_PORT);
return 0;
}

Expand Down
6 changes: 4 additions & 2 deletions drivers/input/touchscreen/gt1x/gt1x_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,12 @@ s32 gt1x_init_panel(void)

void gt1x_select_addr(void)
{
GTP_GPIO_OUTPUT(GTP_RST_PORT, 0);
if (gpio_is_valid(gt1x_rst_gpio))
GTP_GPIO_OUTPUT(GTP_RST_PORT, 0);
GTP_GPIO_OUTPUT(GTP_INT_PORT, gt1x_i2c_client->addr == 0x14);
usleep_range(2000, 3000);
GTP_GPIO_OUTPUT(GTP_RST_PORT, 1);
if (gpio_is_valid(gt1x_rst_gpio))
GTP_GPIO_OUTPUT(GTP_RST_PORT, 1);
usleep_range(2000, 3000);
}

Expand Down

0 comments on commit 334791b

Please sign in to comment.