Lines Matching full:touchkey
3 * TM2 touchkey device driver
26 #define TM2_TOUCHKEY_DEV_NAME "tm2-touchkey"
89 struct tm2_touchkey_data *touchkey = in tm2_touchkey_led_brightness_set() local
96 data = touchkey->variant->cmd_led_off; in tm2_touchkey_led_brightness_set()
99 data = touchkey->variant->cmd_led_on; in tm2_touchkey_led_brightness_set()
102 if (!touchkey->variant->fixed_regulator) in tm2_touchkey_led_brightness_set()
103 regulator_set_voltage(touchkey->vdd, volt, volt); in tm2_touchkey_led_brightness_set()
105 return touchkey->variant->no_reg ? in tm2_touchkey_led_brightness_set()
106 i2c_smbus_write_byte(touchkey->client, data) : in tm2_touchkey_led_brightness_set()
107 i2c_smbus_write_byte_data(touchkey->client, in tm2_touchkey_led_brightness_set()
108 touchkey->variant->base_reg, data); in tm2_touchkey_led_brightness_set()
111 static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey) in tm2_touchkey_power_enable() argument
115 error = regulator_bulk_enable(ARRAY_SIZE(touchkey->regulators), in tm2_touchkey_power_enable()
116 touchkey->regulators); in tm2_touchkey_power_enable()
128 struct tm2_touchkey_data *touchkey = data; in tm2_touchkey_power_disable() local
130 regulator_bulk_disable(ARRAY_SIZE(touchkey->regulators), in tm2_touchkey_power_disable()
131 touchkey->regulators); in tm2_touchkey_power_disable()
136 struct tm2_touchkey_data *touchkey = devid; in tm2_touchkey_irq_handler() local
141 if (touchkey->variant->no_reg) in tm2_touchkey_irq_handler()
142 data = i2c_smbus_read_byte(touchkey->client); in tm2_touchkey_irq_handler()
144 data = i2c_smbus_read_byte_data(touchkey->client, in tm2_touchkey_irq_handler()
145 touchkey->variant->keycode_reg); in tm2_touchkey_irq_handler()
147 dev_err(&touchkey->client->dev, in tm2_touchkey_irq_handler()
153 if (index < 0 || index >= touchkey->num_keycodes) { in tm2_touchkey_irq_handler()
154 dev_warn(&touchkey->client->dev, in tm2_touchkey_irq_handler()
159 input_event(touchkey->input_dev, EV_MSC, MSC_SCAN, index); in tm2_touchkey_irq_handler()
162 for (i = 0; i < touchkey->num_keycodes; i++) in tm2_touchkey_irq_handler()
163 input_report_key(touchkey->input_dev, in tm2_touchkey_irq_handler()
164 touchkey->keycodes[i], 0); in tm2_touchkey_irq_handler()
166 input_report_key(touchkey->input_dev, in tm2_touchkey_irq_handler()
167 touchkey->keycodes[index], 1); in tm2_touchkey_irq_handler()
170 input_sync(touchkey->input_dev); in tm2_touchkey_irq_handler()
173 if (touchkey->variant->fixed_regulator && in tm2_touchkey_irq_handler()
176 if (touchkey->led_dev.brightness == LED_OFF) in tm2_touchkey_irq_handler()
177 tm2_touchkey_led_brightness_set(&touchkey->led_dev, in tm2_touchkey_irq_handler()
188 struct tm2_touchkey_data *touchkey; in tm2_touchkey_probe() local
198 touchkey = devm_kzalloc(&client->dev, sizeof(*touchkey), GFP_KERNEL); in tm2_touchkey_probe()
199 if (!touchkey) in tm2_touchkey_probe()
202 touchkey->client = client; in tm2_touchkey_probe()
203 i2c_set_clientdata(client, touchkey); in tm2_touchkey_probe()
205 touchkey->variant = of_device_get_match_data(&client->dev); in tm2_touchkey_probe()
207 touchkey->regulators[0].supply = "vcc"; in tm2_touchkey_probe()
208 touchkey->regulators[1].supply = "vdd"; in tm2_touchkey_probe()
209 touchkey->regulators[2].supply = "vddio"; in tm2_touchkey_probe()
211 ARRAY_SIZE(touchkey->regulators), in tm2_touchkey_probe()
212 touchkey->regulators); in tm2_touchkey_probe()
219 touchkey->vdd = touchkey->regulators[1].consumer; in tm2_touchkey_probe()
221 touchkey->num_keycodes = of_property_read_variable_u32_array(np, in tm2_touchkey_probe()
222 "linux,keycodes", touchkey->keycodes, 0, in tm2_touchkey_probe()
223 ARRAY_SIZE(touchkey->keycodes)); in tm2_touchkey_probe()
224 if (touchkey->num_keycodes <= 0) { in tm2_touchkey_probe()
226 touchkey->keycodes[0] = KEY_PHONE; in tm2_touchkey_probe()
227 touchkey->keycodes[1] = KEY_BACK; in tm2_touchkey_probe()
228 touchkey->num_keycodes = 2; in tm2_touchkey_probe()
231 error = tm2_touchkey_power_enable(touchkey); in tm2_touchkey_probe()
238 tm2_touchkey_power_disable, touchkey); in tm2_touchkey_probe()
246 touchkey->input_dev = devm_input_allocate_device(&client->dev); in tm2_touchkey_probe()
247 if (!touchkey->input_dev) { in tm2_touchkey_probe()
252 touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME; in tm2_touchkey_probe()
253 touchkey->input_dev->id.bustype = BUS_I2C; in tm2_touchkey_probe()
255 touchkey->input_dev->keycode = touchkey->keycodes; in tm2_touchkey_probe()
256 touchkey->input_dev->keycodemax = touchkey->num_keycodes; in tm2_touchkey_probe()
257 touchkey->input_dev->keycodesize = sizeof(touchkey->keycodes[0]); in tm2_touchkey_probe()
259 input_set_capability(touchkey->input_dev, EV_MSC, MSC_SCAN); in tm2_touchkey_probe()
260 for (i = 0; i < touchkey->num_keycodes; i++) in tm2_touchkey_probe()
261 input_set_capability(touchkey->input_dev, EV_KEY, in tm2_touchkey_probe()
262 touchkey->keycodes[i]); in tm2_touchkey_probe()
264 error = input_register_device(touchkey->input_dev); in tm2_touchkey_probe()
274 TM2_TOUCHKEY_DEV_NAME, touchkey); in tm2_touchkey_probe()
282 touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME; in tm2_touchkey_probe()
283 touchkey->led_dev.brightness = LED_ON; in tm2_touchkey_probe()
284 touchkey->led_dev.max_brightness = LED_ON; in tm2_touchkey_probe()
285 touchkey->led_dev.brightness_set_blocking = in tm2_touchkey_probe()
288 error = devm_led_classdev_register(&client->dev, &touchkey->led_dev); in tm2_touchkey_probe()
291 "failed to register touchkey led: %d\n", error); in tm2_touchkey_probe()
295 if (touchkey->variant->fixed_regulator) in tm2_touchkey_probe()
296 tm2_touchkey_led_brightness_set(&touchkey->led_dev, LED_ON); in tm2_touchkey_probe()
304 struct tm2_touchkey_data *touchkey = i2c_get_clientdata(client); in tm2_touchkey_suspend() local
307 tm2_touchkey_power_disable(touchkey); in tm2_touchkey_suspend()
315 struct tm2_touchkey_data *touchkey = i2c_get_clientdata(client); in tm2_touchkey_resume() local
320 ret = tm2_touchkey_power_enable(touchkey); in tm2_touchkey_resume()
338 .compatible = "cypress,tm2-touchkey",
341 .compatible = "cypress,midas-touchkey",
344 .compatible = "cypress,aries-touchkey",
347 .compatible = "coreriver,tc360-touchkey",
367 MODULE_DESCRIPTION("Samsung touchkey driver");