Lines Matching +full:button +full:-
1 // SPDX-License-Identifier: GPL-2.0
229 err = regmap_read(ts->regmap, QT1050_CHIP_ID, &val); in qt1050_identify()
231 dev_err(&ts->client->dev, "Failed to read chip ID: %d\n", err); in qt1050_identify()
236 dev_err(&ts->client->dev, "ID %d not supported\n", val); in qt1050_identify()
241 err = regmap_read(ts->regmap, QT1050_FW_VERSION, &val); in qt1050_identify()
243 dev_err(&ts->client->dev, "could not read the firmware version\n"); in qt1050_identify()
247 dev_info(&ts->client->dev, "AT42QT1050 firmware version %1d.%1d\n", in qt1050_identify()
256 struct input_dev *input = ts->input; in qt1050_irq_threaded()
262 err = regmap_read(ts->regmap, QT1050_DET_STATUS, &val); in qt1050_irq_threaded()
264 dev_err(&ts->client->dev, "Fail to read detection status: %d\n", in qt1050_irq_threaded()
270 err = regmap_read(ts->regmap, QT1050_KEY_STATUS, &val); in qt1050_irq_threaded()
272 dev_err(&ts->client->dev, in qt1050_irq_threaded()
277 changed = ts->last_keys ^ new_keys; in qt1050_irq_threaded()
279 changed &= ts->reg_keys; in qt1050_irq_threaded()
282 input_report_key(input, ts->keys[i].keycode, in qt1050_irq_threaded()
285 ts->last_keys = new_keys; in qt1050_irq_threaded()
302 return regmap_update_bits(map, key_regs->di_aks, 0xfc, in qt1050_set_key()
308 struct regmap *map = ts->regmap; in qt1050_apply_fw_data()
309 struct qt1050_key *button = &ts->keys[0]; in qt1050_apply_fw_data() local
320 for (i = 0; i < QT1050_MAX_KEYS; i++, button++) { in qt1050_apply_fw_data()
322 if (button->keycode == KEY_RESERVED) in qt1050_apply_fw_data()
325 err = qt1050_set_key(map, button->num, 1); in qt1050_apply_fw_data()
329 key_regs = qt1050_get_key_regs(button->num); in qt1050_apply_fw_data()
331 err = regmap_write(map, key_regs->pulse_scale, in qt1050_apply_fw_data()
332 (button->samples << 4) | (button->scale)); in qt1050_apply_fw_data()
335 err = regmap_write(map, key_regs->csd, button->charge_delay); in qt1050_apply_fw_data()
338 err = regmap_write(map, key_regs->nthr, button->thr_cnt); in qt1050_apply_fw_data()
348 struct device *dev = &ts->client->dev; in qt1050_parse_fw()
353 return -ENODEV; in qt1050_parse_fw()
356 struct qt1050_key button; in qt1050_parse_fw() local
360 &button.keycode)) { in qt1050_parse_fw()
361 dev_err(dev, "Button without keycode\n"); in qt1050_parse_fw()
362 return -EINVAL; in qt1050_parse_fw()
364 if (button.keycode >= KEY_MAX) { in qt1050_parse_fw()
366 button.keycode); in qt1050_parse_fw()
367 return -EINVAL; in qt1050_parse_fw()
371 &button.num)) { in qt1050_parse_fw()
372 dev_err(dev, "Button without pad number\n"); in qt1050_parse_fw()
373 return -EINVAL; in qt1050_parse_fw()
375 if (button.num < 0 || button.num > QT1050_MAX_KEYS - 1) in qt1050_parse_fw()
376 return -EINVAL; in qt1050_parse_fw()
378 ts->reg_keys |= BIT(button.num); in qt1050_parse_fw()
382 "microchip,pre-charge-time-ns", in qt1050_parse_fw()
383 &button.charge_delay)) { in qt1050_parse_fw()
384 button.charge_delay = 0; in qt1050_parse_fw()
386 if (button.charge_delay % 2500 == 0) in qt1050_parse_fw()
387 button.charge_delay = in qt1050_parse_fw()
388 button.charge_delay / 2500; in qt1050_parse_fw()
390 button.charge_delay = 0; in qt1050_parse_fw()
393 if (fwnode_property_read_u32(child, "microchip,average-samples", in qt1050_parse_fw()
394 &button.samples)) { in qt1050_parse_fw()
395 button.samples = 0; in qt1050_parse_fw()
397 if (is_power_of_2(button.samples)) in qt1050_parse_fw()
398 button.samples = ilog2(button.samples); in qt1050_parse_fw()
400 button.samples = 0; in qt1050_parse_fw()
403 if (fwnode_property_read_u32(child, "microchip,average-scaling", in qt1050_parse_fw()
404 &button.scale)) { in qt1050_parse_fw()
405 button.scale = 0; in qt1050_parse_fw()
407 if (is_power_of_2(button.scale)) in qt1050_parse_fw()
408 button.scale = ilog2(button.scale); in qt1050_parse_fw()
410 button.scale = 0; in qt1050_parse_fw()
415 &button.thr_cnt)) { in qt1050_parse_fw()
416 button.thr_cnt = 20; in qt1050_parse_fw()
418 if (button.thr_cnt > 255) in qt1050_parse_fw()
419 button.thr_cnt = 20; in qt1050_parse_fw()
422 ts->keys[button.num] = button; in qt1050_parse_fw()
432 struct device *dev = &client->dev; in qt1050_probe()
438 err = i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE); in qt1050_probe()
440 dev_err(&client->dev, "%s adapter not supported\n", in qt1050_probe()
441 dev_driver_string(&client->adapter->dev)); in qt1050_probe()
442 return -ENODEV; in qt1050_probe()
445 if (!client->irq) { in qt1050_probe()
447 return -EINVAL; in qt1050_probe()
452 return -ENOMEM; in qt1050_probe()
456 return -ENOMEM; in qt1050_probe()
462 ts->client = client; in qt1050_probe()
463 ts->input = input; in qt1050_probe()
464 ts->regmap = map; in qt1050_probe()
470 return -ENODEV; in qt1050_probe()
479 input->name = "AT42QT1050 QTouch Sensor"; in qt1050_probe()
480 input->dev.parent = &client->dev; in qt1050_probe()
481 input->id.bustype = BUS_I2C; in qt1050_probe()
484 input->keycode = ts->keycodes; in qt1050_probe()
485 input->keycodesize = sizeof(ts->keycodes[0]); in qt1050_probe()
486 input->keycodemax = QT1050_MAX_KEYS; in qt1050_probe()
488 __set_bit(EV_KEY, input->evbit); in qt1050_probe()
490 ts->keycodes[i] = ts->keys[i].keycode; in qt1050_probe()
491 __set_bit(ts->keycodes[i], input->keybit); in qt1050_probe()
494 /* Trigger re-calibration */ in qt1050_probe()
495 err = regmap_update_bits(ts->regmap, QT1050_RES_CAL, 0x7f, in qt1050_probe()
501 err = regmap_read_poll_timeout(ts->regmap, QT1050_DET_STATUS, status, in qt1050_probe()
509 err = regmap_update_bits(ts->regmap, QT1050_RES_CAL, in qt1050_probe()
524 err = devm_request_threaded_irq(dev, client->irq, NULL, in qt1050_probe()
528 dev_err(&client->dev, "Failed to request irq: %d\n", err); in qt1050_probe()
533 err = regmap_read(ts->regmap, QT1050_DET_STATUS, &status); in qt1050_probe()
540 err = input_register_device(ts->input); in qt1050_probe()
542 dev_err(&client->dev, "Failed to register input device: %d\n", in qt1050_probe()
555 disable_irq(client->irq); in qt1050_suspend()
562 return regmap_write(ts->regmap, QT1050_LPMODE, in qt1050_suspend()
571 enable_irq(client->irq); in qt1050_resume()
574 return regmap_write(ts->regmap, QT1050_LPMODE, 2); in qt1050_resume()