Lines Matching refs:touchkey
3 * TM2 touchkey device driver
26 #define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey"
89 struct tm2_touchkey_data *touchkey =
96 data = touchkey->variant->cmd_led_off;
99 data = touchkey->variant->cmd_led_on;
102 if (!touchkey->variant->fixed_regulator)
103 regulator_set_voltage(touchkey->vdd, volt, volt);
105 return touchkey->variant->no_reg ?
106 i2c_smbus_write_byte(touchkey->client, data) :
107 i2c_smbus_write_byte_data(touchkey->client,
108 touchkey->variant->base_reg, data);
111 static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey)
115 error = regulator_bulk_enable(ARRAY_SIZE(touchkey->regulators),
116 touchkey->regulators);
128 struct tm2_touchkey_data *touchkey = data;
130 regulator_bulk_disable(ARRAY_SIZE(touchkey->regulators),
131 touchkey->regulators);
136 struct tm2_touchkey_data *touchkey = devid;
141 if (touchkey->variant->no_reg)
142 data = i2c_smbus_read_byte(touchkey->client);
144 data = i2c_smbus_read_byte_data(touchkey->client,
145 touchkey->variant->keycode_reg);
147 dev_err(&touchkey->client->dev,
153 if (index < 0 || index >= touchkey->num_keycodes) {
154 dev_warn(&touchkey->client->dev,
160 for (i = 0; i < touchkey->num_keycodes; i++)
161 input_report_key(touchkey->input_dev,
162 touchkey->keycodes[i], 0);
164 input_report_key(touchkey->input_dev,
165 touchkey->keycodes[index], 1);
168 input_sync(touchkey->input_dev);
171 if (touchkey->variant->fixed_regulator &&
174 if (touchkey->led_dev.brightness == LED_OFF)
175 tm2_touchkey_led_brightness_set(&touchkey->led_dev,
186 struct tm2_touchkey_data *touchkey;
196 touchkey = devm_kzalloc(&client->dev, sizeof(*touchkey), GFP_KERNEL);
197 if (!touchkey)
200 touchkey->client = client;
201 i2c_set_clientdata(client, touchkey);
203 touchkey->variant = of_device_get_match_data(&client->dev);
205 touchkey->regulators[0].supply = "vcc";
206 touchkey->regulators[1].supply = "vdd";
208 ARRAY_SIZE(touchkey->regulators),
209 touchkey->regulators);
216 touchkey->vdd = touchkey->regulators[1].consumer;
218 touchkey->num_keycodes = of_property_read_variable_u32_array(np,
219 "linux,keycodes", touchkey->keycodes, 0,
220 ARRAY_SIZE(touchkey->keycodes));
221 if (touchkey->num_keycodes <= 0) {
223 touchkey->keycodes[0] = KEY_PHONE;
224 touchkey->keycodes[1] = KEY_BACK;
225 touchkey->num_keycodes = 2;
228 error = tm2_touchkey_power_enable(touchkey);
235 tm2_touchkey_power_disable, touchkey);
243 touchkey->input_dev = devm_input_allocate_device(&client->dev);
244 if (!touchkey->input_dev) {
249 touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME;
250 touchkey->input_dev->id.bustype = BUS_I2C;
252 for (i = 0; i < touchkey->num_keycodes; i++)
253 input_set_capability(touchkey->input_dev, EV_KEY,
254 touchkey->keycodes[i]);
256 error = input_register_device(touchkey->input_dev);
266 TM2_TOUCHKEY_DEV_NAME, touchkey);
274 touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME;
275 touchkey->led_dev.brightness = LED_ON;
276 touchkey->led_dev.max_brightness = LED_ON;
277 touchkey->led_dev.brightness_set_blocking =
280 error = devm_led_classdev_register(&client->dev, &touchkey->led_dev);
283 "failed to register touchkey led: %d\n", error);
287 if (touchkey->variant->fixed_regulator)
288 tm2_touchkey_led_brightness_set(&touchkey->led_dev, LED_ON);
296 struct tm2_touchkey_data *touchkey = i2c_get_clientdata(client);
299 tm2_touchkey_power_disable(touchkey);
307 struct tm2_touchkey_data *touchkey = i2c_get_clientdata(client);
312 ret = tm2_touchkey_power_enable(touchkey);
330 .compatible = "cypress,tm2-touchkey",
333 .compatible = "cypress,midas-touchkey",
336 .compatible = "cypress,aries-touchkey",
339 .compatible = "coreriver,tc360-touchkey",
359 MODULE_DESCRIPTION("Samsung touchkey driver");