Lines Matching refs:touchkey
3 * TM2 touchkey device driver
25 #define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey"
88 struct tm2_touchkey_data *touchkey =
95 data = touchkey->variant->cmd_led_off;
98 data = touchkey->variant->cmd_led_on;
101 if (!touchkey->variant->fixed_regulator)
102 regulator_set_voltage(touchkey->vdd, volt, volt);
104 return touchkey->variant->no_reg ?
105 i2c_smbus_write_byte(touchkey->client, data) :
106 i2c_smbus_write_byte_data(touchkey->client,
107 touchkey->variant->base_reg, data);
110 static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey)
114 error = regulator_bulk_enable(ARRAY_SIZE(touchkey->regulators),
115 touchkey->regulators);
127 struct tm2_touchkey_data *touchkey = data;
129 regulator_bulk_disable(ARRAY_SIZE(touchkey->regulators),
130 touchkey->regulators);
135 struct tm2_touchkey_data *touchkey = devid;
140 if (touchkey->variant->no_reg)
141 data = i2c_smbus_read_byte(touchkey->client);
143 data = i2c_smbus_read_byte_data(touchkey->client,
144 touchkey->variant->keycode_reg);
146 dev_err(&touchkey->client->dev,
152 if (index < 0 || index >= touchkey->num_keycodes) {
153 dev_warn(&touchkey->client->dev,
158 input_event(touchkey->input_dev, EV_MSC, MSC_SCAN, index);
161 for (i = 0; i < touchkey->num_keycodes; i++)
162 input_report_key(touchkey->input_dev,
163 touchkey->keycodes[i], 0);
165 input_report_key(touchkey->input_dev,
166 touchkey->keycodes[index], 1);
169 input_sync(touchkey->input_dev);
172 if (touchkey->variant->fixed_regulator &&
175 if (touchkey->led_dev.brightness == LED_OFF)
176 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";
207 touchkey->regulators[2].supply = "vddio";
209 ARRAY_SIZE(touchkey->regulators),
210 touchkey->regulators);
217 touchkey->vdd = touchkey->regulators[1].consumer;
219 touchkey->num_keycodes = of_property_read_variable_u32_array(np,
220 "linux,keycodes", touchkey->keycodes, 0,
221 ARRAY_SIZE(touchkey->keycodes));
222 if (touchkey->num_keycodes <= 0) {
224 touchkey->keycodes[0] = KEY_PHONE;
225 touchkey->keycodes[1] = KEY_BACK;
226 touchkey->num_keycodes = 2;
229 error = tm2_touchkey_power_enable(touchkey);
236 tm2_touchkey_power_disable, touchkey);
244 touchkey->input_dev = devm_input_allocate_device(&client->dev);
245 if (!touchkey->input_dev) {
250 touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME;
251 touchkey->input_dev->id.bustype = BUS_I2C;
253 touchkey->input_dev->keycode = touchkey->keycodes;
254 touchkey->input_dev->keycodemax = touchkey->num_keycodes;
255 touchkey->input_dev->keycodesize = sizeof(touchkey->keycodes[0]);
257 input_set_capability(touchkey->input_dev, EV_MSC, MSC_SCAN);
258 for (i = 0; i < touchkey->num_keycodes; i++)
259 input_set_capability(touchkey->input_dev, EV_KEY,
260 touchkey->keycodes[i]);
262 error = input_register_device(touchkey->input_dev);
272 TM2_TOUCHKEY_DEV_NAME, touchkey);
280 touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME;
281 touchkey->led_dev.brightness = LED_ON;
282 touchkey->led_dev.max_brightness = LED_ON;
283 touchkey->led_dev.brightness_set_blocking =
286 error = devm_led_classdev_register(&client->dev, &touchkey->led_dev);
289 "failed to register touchkey led: %d\n", error);
293 if (touchkey->variant->fixed_regulator)
294 tm2_touchkey_led_brightness_set(&touchkey->led_dev, LED_ON);
302 struct tm2_touchkey_data *touchkey = i2c_get_clientdata(client);
305 tm2_touchkey_power_disable(touchkey);
313 struct tm2_touchkey_data *touchkey = i2c_get_clientdata(client);
318 ret = tm2_touchkey_power_enable(touchkey);
336 .compatible = "cypress,tm2-touchkey",
339 .compatible = "cypress,midas-touchkey",
342 .compatible = "cypress,aries-touchkey",
345 .compatible = "coreriver,tc360-touchkey",
365 MODULE_DESCRIPTION("Samsung touchkey driver");