Skip to content

Commit 274ecd4

Browse files
Cong Yanggregkh
authored andcommitted
HID: i2c-hid: elan: Add ili9882t timing
[ Upstream commit f2f43bf ] The ili9882t is a TDDI IC (Touch with Display Driver). The datasheet specifies there should be 60ms between touch SDA sleep and panel RESX. Doug's series[1] allows panels and touchscreens to power on/off together, so we can add the 65 ms delay in i2c_hid_core_suspend before panel_unprepare. Because ili9882t touchscrgeen is a panel follower, and needs to use vccio-supply instead of vcc33-supply, so set it NULL to ili9882t_chip_data, then not use vcc33 regulator. [1]: https://lore.kernel.org/all/[email protected] Reviewed-by: Douglas Anderson <[email protected]> Signed-off-by: Cong Yang <[email protected]> Acked-by: Benjamin Tissoires <[email protected]> Link: https://lore.kernel.org/r/20230802071947.1683318-3-yangcong5@huaqin.corp-partner.google.com Signed-off-by: Benjamin Tissoires <[email protected]> Stable-dep-of: 0eafc58 ("HID: i2c-hid: elan: fix reset suspend current leakage") Signed-off-by: Sasha Levin <[email protected]>
1 parent 0fce1c9 commit 274ecd4

File tree

1 file changed

+38
-12
lines changed

1 file changed

+38
-12
lines changed

drivers/hid/i2c-hid/i2c-hid-of-elan.c

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
#include "i2c-hid.h"
1919

2020
struct elan_i2c_hid_chip_data {
21-
unsigned int post_gpio_reset_delay_ms;
21+
unsigned int post_gpio_reset_on_delay_ms;
22+
unsigned int post_gpio_reset_off_delay_ms;
2223
unsigned int post_power_delay_ms;
2324
u16 hid_descriptor_address;
25+
const char *main_supply_name;
2426
};
2527

2628
struct i2c_hid_of_elan {
@@ -38,9 +40,11 @@ static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
3840
container_of(ops, struct i2c_hid_of_elan, ops);
3941
int ret;
4042

41-
ret = regulator_enable(ihid_elan->vcc33);
42-
if (ret)
43-
return ret;
43+
if (ihid_elan->vcc33) {
44+
ret = regulator_enable(ihid_elan->vcc33);
45+
if (ret)
46+
return ret;
47+
}
4448

4549
ret = regulator_enable(ihid_elan->vccio);
4650
if (ret) {
@@ -52,8 +56,8 @@ static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
5256
msleep(ihid_elan->chip_data->post_power_delay_ms);
5357

5458
gpiod_set_value_cansleep(ihid_elan->reset_gpio, 0);
55-
if (ihid_elan->chip_data->post_gpio_reset_delay_ms)
56-
msleep(ihid_elan->chip_data->post_gpio_reset_delay_ms);
59+
if (ihid_elan->chip_data->post_gpio_reset_on_delay_ms)
60+
msleep(ihid_elan->chip_data->post_gpio_reset_on_delay_ms);
5761

5862
return 0;
5963
}
@@ -64,8 +68,12 @@ static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
6468
container_of(ops, struct i2c_hid_of_elan, ops);
6569

6670
gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
71+
if (ihid_elan->chip_data->post_gpio_reset_off_delay_ms)
72+
msleep(ihid_elan->chip_data->post_gpio_reset_off_delay_ms);
73+
6774
regulator_disable(ihid_elan->vccio);
68-
regulator_disable(ihid_elan->vcc33);
75+
if (ihid_elan->vcc33)
76+
regulator_disable(ihid_elan->vcc33);
6977
}
7078

7179
static int i2c_hid_of_elan_probe(struct i2c_client *client,
@@ -90,24 +98,42 @@ static int i2c_hid_of_elan_probe(struct i2c_client *client,
9098
if (IS_ERR(ihid_elan->vccio))
9199
return PTR_ERR(ihid_elan->vccio);
92100

93-
ihid_elan->vcc33 = devm_regulator_get(&client->dev, "vcc33");
94-
if (IS_ERR(ihid_elan->vcc33))
95-
return PTR_ERR(ihid_elan->vcc33);
96-
97101
ihid_elan->chip_data = device_get_match_data(&client->dev);
98102

103+
if (ihid_elan->chip_data->main_supply_name) {
104+
ihid_elan->vcc33 = devm_regulator_get(&client->dev,
105+
ihid_elan->chip_data->main_supply_name);
106+
if (IS_ERR(ihid_elan->vcc33))
107+
return PTR_ERR(ihid_elan->vcc33);
108+
}
109+
99110
return i2c_hid_core_probe(client, &ihid_elan->ops,
100111
ihid_elan->chip_data->hid_descriptor_address, 0);
101112
}
102113

103114
static const struct elan_i2c_hid_chip_data elan_ekth6915_chip_data = {
104115
.post_power_delay_ms = 1,
105-
.post_gpio_reset_delay_ms = 300,
116+
.post_gpio_reset_on_delay_ms = 300,
117+
.hid_descriptor_address = 0x0001,
118+
.main_supply_name = "vcc33",
119+
};
120+
121+
static const struct elan_i2c_hid_chip_data ilitek_ili9882t_chip_data = {
122+
.post_power_delay_ms = 1,
123+
.post_gpio_reset_on_delay_ms = 200,
124+
.post_gpio_reset_off_delay_ms = 65,
106125
.hid_descriptor_address = 0x0001,
126+
/*
127+
* this touchscreen is tightly integrated with the panel and assumes
128+
* that the relevant power rails (other than the IO rail) have already
129+
* been turned on by the panel driver because we're a panel follower.
130+
*/
131+
.main_supply_name = NULL,
107132
};
108133

109134
static const struct of_device_id elan_i2c_hid_of_match[] = {
110135
{ .compatible = "elan,ekth6915", .data = &elan_ekth6915_chip_data },
136+
{ .compatible = "ilitek,ili9882t", .data = &ilitek_ili9882t_chip_data },
111137
{ }
112138
};
113139
MODULE_DEVICE_TABLE(of, elan_i2c_hid_of_match);

0 commit comments

Comments
 (0)