18
18
#include "i2c-hid.h"
19
19
20
20
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 ;
22
23
unsigned int post_power_delay_ms ;
23
24
u16 hid_descriptor_address ;
25
+ const char * main_supply_name ;
24
26
};
25
27
26
28
struct i2c_hid_of_elan {
@@ -38,9 +40,11 @@ static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
38
40
container_of (ops , struct i2c_hid_of_elan , ops );
39
41
int ret ;
40
42
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
+ }
44
48
45
49
ret = regulator_enable (ihid_elan -> vccio );
46
50
if (ret ) {
@@ -52,8 +56,8 @@ static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
52
56
msleep (ihid_elan -> chip_data -> post_power_delay_ms );
53
57
54
58
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 );
57
61
58
62
return 0 ;
59
63
}
@@ -64,8 +68,12 @@ static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
64
68
container_of (ops , struct i2c_hid_of_elan , ops );
65
69
66
70
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
+
67
74
regulator_disable (ihid_elan -> vccio );
68
- regulator_disable (ihid_elan -> vcc33 );
75
+ if (ihid_elan -> vcc33 )
76
+ regulator_disable (ihid_elan -> vcc33 );
69
77
}
70
78
71
79
static int i2c_hid_of_elan_probe (struct i2c_client * client )
@@ -89,24 +97,42 @@ static int i2c_hid_of_elan_probe(struct i2c_client *client)
89
97
if (IS_ERR (ihid_elan -> vccio ))
90
98
return PTR_ERR (ihid_elan -> vccio );
91
99
92
- ihid_elan -> vcc33 = devm_regulator_get (& client -> dev , "vcc33" );
93
- if (IS_ERR (ihid_elan -> vcc33 ))
94
- return PTR_ERR (ihid_elan -> vcc33 );
95
-
96
100
ihid_elan -> chip_data = device_get_match_data (& client -> dev );
97
101
102
+ if (ihid_elan -> chip_data -> main_supply_name ) {
103
+ ihid_elan -> vcc33 = devm_regulator_get (& client -> dev ,
104
+ ihid_elan -> chip_data -> main_supply_name );
105
+ if (IS_ERR (ihid_elan -> vcc33 ))
106
+ return PTR_ERR (ihid_elan -> vcc33 );
107
+ }
108
+
98
109
return i2c_hid_core_probe (client , & ihid_elan -> ops ,
99
110
ihid_elan -> chip_data -> hid_descriptor_address , 0 );
100
111
}
101
112
102
113
static const struct elan_i2c_hid_chip_data elan_ekth6915_chip_data = {
103
114
.post_power_delay_ms = 1 ,
104
- .post_gpio_reset_delay_ms = 300 ,
115
+ .post_gpio_reset_on_delay_ms = 300 ,
116
+ .hid_descriptor_address = 0x0001 ,
117
+ .main_supply_name = "vcc33" ,
118
+ };
119
+
120
+ static const struct elan_i2c_hid_chip_data ilitek_ili9882t_chip_data = {
121
+ .post_power_delay_ms = 1 ,
122
+ .post_gpio_reset_on_delay_ms = 200 ,
123
+ .post_gpio_reset_off_delay_ms = 65 ,
105
124
.hid_descriptor_address = 0x0001 ,
125
+ /*
126
+ * this touchscreen is tightly integrated with the panel and assumes
127
+ * that the relevant power rails (other than the IO rail) have already
128
+ * been turned on by the panel driver because we're a panel follower.
129
+ */
130
+ .main_supply_name = NULL ,
106
131
};
107
132
108
133
static const struct of_device_id elan_i2c_hid_of_match [] = {
109
134
{ .compatible = "elan,ekth6915" , .data = & elan_ekth6915_chip_data },
135
+ { .compatible = "ilitek,ili9882t" , .data = & ilitek_ili9882t_chip_data },
110
136
{ }
111
137
};
112
138
MODULE_DEVICE_TABLE (of , elan_i2c_hid_of_match );
0 commit comments