Lines Matching +full:event +full:- +full:prox
1 // SPDX-License-Identifier: GPL-2.0+
25 [IQS62X_SW_HALL_N] = "hall-switch-north",
26 [IQS62X_SW_HALL_S] = "hall-switch-south",
52 ret = device_property_count_u32(&pdev->dev, "linux,keycodes"); in iqs62x_keys_parse_prop()
54 dev_err(&pdev->dev, "Too many keycodes present\n"); in iqs62x_keys_parse_prop()
55 return -EINVAL; in iqs62x_keys_parse_prop()
57 dev_err(&pdev->dev, "Failed to count keycodes: %d\n", ret); in iqs62x_keys_parse_prop()
60 iqs62x_keys->keycodemax = ret; in iqs62x_keys_parse_prop()
62 ret = device_property_read_u32_array(&pdev->dev, "linux,keycodes", in iqs62x_keys_parse_prop()
63 iqs62x_keys->keycode, in iqs62x_keys_parse_prop()
64 iqs62x_keys->keycodemax); in iqs62x_keys_parse_prop()
66 dev_err(&pdev->dev, "Failed to read keycodes: %d\n", ret); in iqs62x_keys_parse_prop()
70 for (i = 0; i < ARRAY_SIZE(iqs62x_keys->switches); i++) { in iqs62x_keys_parse_prop()
71 child = device_get_named_child_node(&pdev->dev, in iqs62x_keys_parse_prop()
78 dev_err(&pdev->dev, "Failed to read switch code: %d\n", in iqs62x_keys_parse_prop()
82 iqs62x_keys->switches[i].code = val; in iqs62x_keys_parse_prop()
83 iqs62x_keys->switches[i].enabled = true; in iqs62x_keys_parse_prop()
85 if (fwnode_property_present(child, "azoteq,use-prox")) in iqs62x_keys_parse_prop()
86 iqs62x_keys->switches[i].flag = (i == IQS62X_SW_HALL_N ? in iqs62x_keys_parse_prop()
90 iqs62x_keys->switches[i].flag = (i == IQS62X_SW_HALL_N ? in iqs62x_keys_parse_prop()
100 struct iqs62x_core *iqs62x = iqs62x_keys->iqs62x; in iqs62x_keys_init()
106 switch (iqs62x->dev_desc->prod_num) { in iqs62x_keys_init()
116 for (i = 0; i < iqs62x_keys->keycodemax; i++) { in iqs62x_keys_init()
117 if (iqs62x_keys->keycode[i] == KEY_RESERVED) in iqs62x_keys_init()
121 event_mask |= iqs62x->dev_desc->prox_mask; in iqs62x_keys_init()
123 event_mask |= (iqs62x->dev_desc->hyst_mask | in iqs62x_keys_init()
124 iqs62x->dev_desc->sar_mask); in iqs62x_keys_init()
127 ret = regmap_read(iqs62x->regmap, iqs62x->dev_desc->hall_flags, in iqs62x_keys_init()
136 for (i = 0; i < ARRAY_SIZE(iqs62x_keys->switches); i++) { in iqs62x_keys_init()
137 if (!(iqs62x_keys->switches[i].enabled)) in iqs62x_keys_init()
140 flag = iqs62x_keys->switches[i].flag; in iqs62x_keys_init()
145 event_mask |= iqs62x->dev_desc->hall_mask; in iqs62x_keys_init()
147 input_report_switch(iqs62x_keys->input, in iqs62x_keys_init()
148 iqs62x_keys->switches[i].code, in iqs62x_keys_init()
153 input_sync(iqs62x_keys->input); in iqs62x_keys_init()
163 if (iqs62x_keys->keycode[IQS62X_EVENT_WHEEL_UP] != KEY_RESERVED) in iqs62x_keys_init()
166 if (iqs62x_keys->keycode[IQS62X_EVENT_WHEEL_DN] != KEY_RESERVED) in iqs62x_keys_init()
169 ret = regmap_read(iqs62x->regmap, iqs62x->dev_desc->interval, in iqs62x_keys_init()
174 iqs62x_keys->interval = val; in iqs62x_keys_init()
181 return regmap_update_bits(iqs62x->regmap, event_reg, event_mask, 0); in iqs62x_keys_init()
197 dev_err(iqs62x_keys->input->dev.parent, in iqs62x_keys_notifier()
198 "Failed to re-initialize device: %d\n", ret); in iqs62x_keys_notifier()
205 for (i = 0; i < iqs62x_keys->keycodemax; i++) { in iqs62x_keys_notifier()
207 event_data->interval == iqs62x_keys->interval) in iqs62x_keys_notifier()
210 input_report_key(iqs62x_keys->input, iqs62x_keys->keycode[i], in iqs62x_keys_notifier()
214 for (i = 0; i < ARRAY_SIZE(iqs62x_keys->switches); i++) in iqs62x_keys_notifier()
215 if (iqs62x_keys->switches[i].enabled) in iqs62x_keys_notifier()
216 input_report_switch(iqs62x_keys->input, in iqs62x_keys_notifier()
217 iqs62x_keys->switches[i].code, in iqs62x_keys_notifier()
219 BIT(iqs62x_keys->switches[i].flag)); in iqs62x_keys_notifier()
221 input_sync(iqs62x_keys->input); in iqs62x_keys_notifier()
223 if (event_data->interval == iqs62x_keys->interval) in iqs62x_keys_notifier()
227 * Each frame contains at most one wheel event (up or down), in which in iqs62x_keys_notifier()
231 input_report_key(iqs62x_keys->input, in iqs62x_keys_notifier()
232 iqs62x_keys->keycode[IQS62X_EVENT_WHEEL_UP], in iqs62x_keys_notifier()
234 input_sync(iqs62x_keys->input); in iqs62x_keys_notifier()
236 input_report_key(iqs62x_keys->input, in iqs62x_keys_notifier()
237 iqs62x_keys->keycode[IQS62X_EVENT_WHEEL_DN], in iqs62x_keys_notifier()
239 input_sync(iqs62x_keys->input); in iqs62x_keys_notifier()
242 iqs62x_keys->interval = event_data->interval; in iqs62x_keys_notifier()
249 struct iqs62x_core *iqs62x = dev_get_drvdata(pdev->dev.parent); in iqs62x_keys_probe()
254 iqs62x_keys = devm_kzalloc(&pdev->dev, sizeof(*iqs62x_keys), in iqs62x_keys_probe()
257 return -ENOMEM; in iqs62x_keys_probe()
265 input = devm_input_allocate_device(&pdev->dev); in iqs62x_keys_probe()
267 return -ENOMEM; in iqs62x_keys_probe()
269 input->keycodemax = iqs62x_keys->keycodemax; in iqs62x_keys_probe()
270 input->keycode = iqs62x_keys->keycode; in iqs62x_keys_probe()
271 input->keycodesize = sizeof(*iqs62x_keys->keycode); in iqs62x_keys_probe()
273 input->name = iqs62x->dev_desc->dev_name; in iqs62x_keys_probe()
274 input->id.bustype = BUS_I2C; in iqs62x_keys_probe()
276 for (i = 0; i < iqs62x_keys->keycodemax; i++) in iqs62x_keys_probe()
277 if (iqs62x_keys->keycode[i] != KEY_RESERVED) in iqs62x_keys_probe()
279 iqs62x_keys->keycode[i]); in iqs62x_keys_probe()
281 for (i = 0; i < ARRAY_SIZE(iqs62x_keys->switches); i++) in iqs62x_keys_probe()
282 if (iqs62x_keys->switches[i].enabled) in iqs62x_keys_probe()
284 iqs62x_keys->switches[i].code); in iqs62x_keys_probe()
286 iqs62x_keys->iqs62x = iqs62x; in iqs62x_keys_probe()
287 iqs62x_keys->input = input; in iqs62x_keys_probe()
291 dev_err(&pdev->dev, "Failed to initialize device: %d\n", ret); in iqs62x_keys_probe()
295 ret = input_register_device(iqs62x_keys->input); in iqs62x_keys_probe()
297 dev_err(&pdev->dev, "Failed to register device: %d\n", ret); in iqs62x_keys_probe()
301 iqs62x_keys->notifier.notifier_call = iqs62x_keys_notifier; in iqs62x_keys_probe()
302 ret = blocking_notifier_chain_register(&iqs62x_keys->iqs62x->nh, in iqs62x_keys_probe()
303 &iqs62x_keys->notifier); in iqs62x_keys_probe()
305 dev_err(&pdev->dev, "Failed to register notifier: %d\n", ret); in iqs62x_keys_probe()
315 ret = blocking_notifier_chain_unregister(&iqs62x_keys->iqs62x->nh, in iqs62x_keys_remove()
316 &iqs62x_keys->notifier); in iqs62x_keys_remove()
318 dev_err(&pdev->dev, "Failed to unregister notifier: %d\n", ret); in iqs62x_keys_remove()
325 .name = "iqs62x-keys",
335 MODULE_ALIAS("platform:iqs62x-keys");