@@ -26,71 +26,49 @@ struct i2c_hid_of_goodix {
26
26
struct i2chid_ops ops ;
27
27
28
28
struct regulator * vdd ;
29
- struct notifier_block nb ;
29
+ struct regulator * vddio ;
30
30
struct gpio_desc * reset_gpio ;
31
31
const struct goodix_i2c_hid_timing_data * timings ;
32
32
};
33
33
34
- static void goodix_i2c_hid_deassert_reset (struct i2c_hid_of_goodix * ihid_goodix ,
35
- bool regulator_just_turned_on )
34
+ static int goodix_i2c_hid_power_up (struct i2chid_ops * ops )
36
35
{
37
- if (regulator_just_turned_on && ihid_goodix -> timings -> post_power_delay_ms )
36
+ struct i2c_hid_of_goodix * ihid_goodix =
37
+ container_of (ops , struct i2c_hid_of_goodix , ops );
38
+ int ret ;
39
+
40
+ ret = regulator_enable (ihid_goodix -> vdd );
41
+ if (ret )
42
+ return ret ;
43
+
44
+ ret = regulator_enable (ihid_goodix -> vddio );
45
+ if (ret )
46
+ return ret ;
47
+
48
+ if (ihid_goodix -> timings -> post_power_delay_ms )
38
49
msleep (ihid_goodix -> timings -> post_power_delay_ms );
39
50
40
51
gpiod_set_value_cansleep (ihid_goodix -> reset_gpio , 0 );
41
52
if (ihid_goodix -> timings -> post_gpio_reset_delay_ms )
42
53
msleep (ihid_goodix -> timings -> post_gpio_reset_delay_ms );
43
- }
44
-
45
- static int goodix_i2c_hid_power_up (struct i2chid_ops * ops )
46
- {
47
- struct i2c_hid_of_goodix * ihid_goodix =
48
- container_of (ops , struct i2c_hid_of_goodix , ops );
49
54
50
- return regulator_enable ( ihid_goodix -> vdd ) ;
55
+ return 0 ;
51
56
}
52
57
53
58
static void goodix_i2c_hid_power_down (struct i2chid_ops * ops )
54
59
{
55
60
struct i2c_hid_of_goodix * ihid_goodix =
56
61
container_of (ops , struct i2c_hid_of_goodix , ops );
57
62
63
+ gpiod_set_value_cansleep (ihid_goodix -> reset_gpio , 1 );
64
+ regulator_disable (ihid_goodix -> vddio );
58
65
regulator_disable (ihid_goodix -> vdd );
59
66
}
60
67
61
- static int ihid_goodix_vdd_notify (struct notifier_block * nb ,
62
- unsigned long event ,
63
- void * ignored )
64
- {
65
- struct i2c_hid_of_goodix * ihid_goodix =
66
- container_of (nb , struct i2c_hid_of_goodix , nb );
67
- int ret = NOTIFY_OK ;
68
-
69
- switch (event ) {
70
- case REGULATOR_EVENT_PRE_DISABLE :
71
- gpiod_set_value_cansleep (ihid_goodix -> reset_gpio , 1 );
72
- break ;
73
-
74
- case REGULATOR_EVENT_ENABLE :
75
- goodix_i2c_hid_deassert_reset (ihid_goodix , true);
76
- break ;
77
-
78
- case REGULATOR_EVENT_ABORT_DISABLE :
79
- goodix_i2c_hid_deassert_reset (ihid_goodix , false);
80
- break ;
81
-
82
- default :
83
- ret = NOTIFY_DONE ;
84
- break ;
85
- }
86
-
87
- return ret ;
88
- }
89
-
90
68
static int i2c_hid_of_goodix_probe (struct i2c_client * client )
91
69
{
92
70
struct i2c_hid_of_goodix * ihid_goodix ;
93
- int ret ;
71
+
94
72
ihid_goodix = devm_kzalloc (& client -> dev , sizeof (* ihid_goodix ),
95
73
GFP_KERNEL );
96
74
if (!ihid_goodix )
@@ -109,41 +87,11 @@ static int i2c_hid_of_goodix_probe(struct i2c_client *client)
109
87
if (IS_ERR (ihid_goodix -> vdd ))
110
88
return PTR_ERR (ihid_goodix -> vdd );
111
89
112
- ihid_goodix -> timings = device_get_match_data (& client -> dev );
90
+ ihid_goodix -> vddio = devm_regulator_get (& client -> dev , "mainboard-vddio" );
91
+ if (IS_ERR (ihid_goodix -> vddio ))
92
+ return PTR_ERR (ihid_goodix -> vddio );
113
93
114
- /*
115
- * We need to control the "reset" line in lockstep with the regulator
116
- * actually turning on an off instead of just when we make the request.
117
- * This matters if the regulator is shared with another consumer.
118
- * - If the regulator is off then we must assert reset. The reset
119
- * line is active low and on some boards it could cause a current
120
- * leak if left high.
121
- * - If the regulator is on then we don't want reset asserted for very
122
- * long. Holding the controller in reset apparently draws extra
123
- * power.
124
- */
125
- ihid_goodix -> nb .notifier_call = ihid_goodix_vdd_notify ;
126
- ret = devm_regulator_register_notifier (ihid_goodix -> vdd , & ihid_goodix -> nb );
127
- if (ret )
128
- return dev_err_probe (& client -> dev , ret ,
129
- "regulator notifier request failed\n" );
130
-
131
- /*
132
- * If someone else is holding the regulator on (or the regulator is
133
- * an always-on one) we might never be told to deassert reset. Do it
134
- * now... and temporarily bump the regulator reference count just to
135
- * make sure it is impossible for this to race with our own notifier!
136
- * We also assume that someone else might have _just barely_ turned
137
- * the regulator on so we'll do the full "post_power_delay" just in
138
- * case.
139
- */
140
- if (ihid_goodix -> reset_gpio && regulator_is_enabled (ihid_goodix -> vdd )) {
141
- ret = regulator_enable (ihid_goodix -> vdd );
142
- if (ret )
143
- return ret ;
144
- goodix_i2c_hid_deassert_reset (ihid_goodix , true);
145
- regulator_disable (ihid_goodix -> vdd );
146
- }
94
+ ihid_goodix -> timings = device_get_match_data (& client -> dev );
147
95
148
96
return i2c_hid_core_probe (client , & ihid_goodix -> ops , 0x0001 , 0 );
149
97
}
0 commit comments