Lines Matching refs:touchkey
88 struct tm2_touchkey_data *touchkey = in tm2_touchkey_led_brightness_set() local
95 data = touchkey->variant->cmd_led_off; in tm2_touchkey_led_brightness_set()
98 data = touchkey->variant->cmd_led_on; in tm2_touchkey_led_brightness_set()
101 if (!touchkey->variant->fixed_regulator) in tm2_touchkey_led_brightness_set()
102 regulator_set_voltage(touchkey->vdd, volt, volt); in tm2_touchkey_led_brightness_set()
104 return touchkey->variant->no_reg ? in tm2_touchkey_led_brightness_set()
105 i2c_smbus_write_byte(touchkey->client, data) : in tm2_touchkey_led_brightness_set()
106 i2c_smbus_write_byte_data(touchkey->client, in tm2_touchkey_led_brightness_set()
107 touchkey->variant->base_reg, data); in tm2_touchkey_led_brightness_set()
110 static int tm2_touchkey_power_enable(struct tm2_touchkey_data *touchkey) in tm2_touchkey_power_enable() argument
114 error = regulator_bulk_enable(ARRAY_SIZE(touchkey->regulators), in tm2_touchkey_power_enable()
115 touchkey->regulators); in tm2_touchkey_power_enable()
127 struct tm2_touchkey_data *touchkey = data; in tm2_touchkey_power_disable() local
129 regulator_bulk_disable(ARRAY_SIZE(touchkey->regulators), in tm2_touchkey_power_disable()
130 touchkey->regulators); in tm2_touchkey_power_disable()
135 struct tm2_touchkey_data *touchkey = devid; in tm2_touchkey_irq_handler() local
140 if (touchkey->variant->no_reg) in tm2_touchkey_irq_handler()
141 data = i2c_smbus_read_byte(touchkey->client); in tm2_touchkey_irq_handler()
143 data = i2c_smbus_read_byte_data(touchkey->client, in tm2_touchkey_irq_handler()
144 touchkey->variant->keycode_reg); in tm2_touchkey_irq_handler()
146 dev_err(&touchkey->client->dev, in tm2_touchkey_irq_handler()
152 if (index < 0 || index >= touchkey->num_keycodes) { in tm2_touchkey_irq_handler()
153 dev_warn(&touchkey->client->dev, in tm2_touchkey_irq_handler()
158 input_event(touchkey->input_dev, EV_MSC, MSC_SCAN, index); in tm2_touchkey_irq_handler()
161 for (i = 0; i < touchkey->num_keycodes; i++) in tm2_touchkey_irq_handler()
162 input_report_key(touchkey->input_dev, in tm2_touchkey_irq_handler()
163 touchkey->keycodes[i], 0); in tm2_touchkey_irq_handler()
165 input_report_key(touchkey->input_dev, in tm2_touchkey_irq_handler()
166 touchkey->keycodes[index], 1); in tm2_touchkey_irq_handler()
169 input_sync(touchkey->input_dev); in tm2_touchkey_irq_handler()
172 if (touchkey->variant->fixed_regulator && in tm2_touchkey_irq_handler()
175 if (touchkey->led_dev.brightness == LED_OFF) in tm2_touchkey_irq_handler()
176 tm2_touchkey_led_brightness_set(&touchkey->led_dev, in tm2_touchkey_irq_handler()
186 struct tm2_touchkey_data *touchkey; in tm2_touchkey_probe() local
196 touchkey = devm_kzalloc(&client->dev, sizeof(*touchkey), GFP_KERNEL); in tm2_touchkey_probe()
197 if (!touchkey) in tm2_touchkey_probe()
200 touchkey->client = client; in tm2_touchkey_probe()
201 i2c_set_clientdata(client, touchkey); in tm2_touchkey_probe()
203 touchkey->variant = of_device_get_match_data(&client->dev); in tm2_touchkey_probe()
205 touchkey->regulators[0].supply = "vcc"; in tm2_touchkey_probe()
206 touchkey->regulators[1].supply = "vdd"; in tm2_touchkey_probe()
207 touchkey->regulators[2].supply = "vddio"; in tm2_touchkey_probe()
209 ARRAY_SIZE(touchkey->regulators), in tm2_touchkey_probe()
210 touchkey->regulators); in tm2_touchkey_probe()
217 touchkey->vdd = touchkey->regulators[1].consumer; in tm2_touchkey_probe()
219 touchkey->num_keycodes = of_property_read_variable_u32_array(np, in tm2_touchkey_probe()
220 "linux,keycodes", touchkey->keycodes, 0, in tm2_touchkey_probe()
221 ARRAY_SIZE(touchkey->keycodes)); in tm2_touchkey_probe()
222 if (touchkey->num_keycodes <= 0) { in tm2_touchkey_probe()
224 touchkey->keycodes[0] = KEY_PHONE; in tm2_touchkey_probe()
225 touchkey->keycodes[1] = KEY_BACK; in tm2_touchkey_probe()
226 touchkey->num_keycodes = 2; in tm2_touchkey_probe()
229 error = tm2_touchkey_power_enable(touchkey); in tm2_touchkey_probe()
236 tm2_touchkey_power_disable, touchkey); in tm2_touchkey_probe()
244 touchkey->input_dev = devm_input_allocate_device(&client->dev); in tm2_touchkey_probe()
245 if (!touchkey->input_dev) { in tm2_touchkey_probe()
250 touchkey->input_dev->name = TM2_TOUCHKEY_DEV_NAME; in tm2_touchkey_probe()
251 touchkey->input_dev->id.bustype = BUS_I2C; in tm2_touchkey_probe()
253 touchkey->input_dev->keycode = touchkey->keycodes; in tm2_touchkey_probe()
254 touchkey->input_dev->keycodemax = touchkey->num_keycodes; in tm2_touchkey_probe()
255 touchkey->input_dev->keycodesize = sizeof(touchkey->keycodes[0]); in tm2_touchkey_probe()
257 input_set_capability(touchkey->input_dev, EV_MSC, MSC_SCAN); in tm2_touchkey_probe()
258 for (i = 0; i < touchkey->num_keycodes; i++) in tm2_touchkey_probe()
259 input_set_capability(touchkey->input_dev, EV_KEY, in tm2_touchkey_probe()
260 touchkey->keycodes[i]); in tm2_touchkey_probe()
262 error = input_register_device(touchkey->input_dev); in tm2_touchkey_probe()
272 TM2_TOUCHKEY_DEV_NAME, touchkey); in tm2_touchkey_probe()
280 touchkey->led_dev.name = TM2_TOUCHKEY_DEV_NAME; in tm2_touchkey_probe()
281 touchkey->led_dev.brightness = LED_ON; in tm2_touchkey_probe()
282 touchkey->led_dev.max_brightness = LED_ON; in tm2_touchkey_probe()
283 touchkey->led_dev.brightness_set_blocking = in tm2_touchkey_probe()
286 error = devm_led_classdev_register(&client->dev, &touchkey->led_dev); in tm2_touchkey_probe()
293 if (touchkey->variant->fixed_regulator) in tm2_touchkey_probe()
294 tm2_touchkey_led_brightness_set(&touchkey->led_dev, LED_ON); in tm2_touchkey_probe()
302 struct tm2_touchkey_data *touchkey = i2c_get_clientdata(client); in tm2_touchkey_suspend() local
305 tm2_touchkey_power_disable(touchkey); in tm2_touchkey_suspend()
313 struct tm2_touchkey_data *touchkey = i2c_get_clientdata(client); in tm2_touchkey_resume() local
318 ret = tm2_touchkey_power_enable(touchkey); in tm2_touchkey_resume()