Lines Matching +full:doze +full:- +full:interval +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2011-2016 Synaptics Incorporated
87 * When this bit is set, the touch controller employs a noise-filtering
106 * struct f01_device_control - controls basic sensor functions
109 * @doze_interval: controls the interval between checks for finger presence
110 * when the touch sensor is in doze mode, in units of 10ms.
114 * finger lifts before entering the doze state, in units of 100ms.
155 dev_err(&rmi_dev->dev, in rmi_f01_read_properties()
164 props->manufacturer_id = queries[0]; in rmi_f01_read_properties()
166 props->has_lts = queries[1] & RMI_F01_QRY1_HAS_LTS; in rmi_f01_read_properties()
167 props->has_adjustable_doze = in rmi_f01_read_properties()
169 props->has_adjustable_doze_holdoff = in rmi_f01_read_properties()
174 snprintf(props->dom, sizeof(props->dom), "20%02d/%02d/%02d", in rmi_f01_read_properties()
179 memcpy(props->product_id, &queries[11], in rmi_f01_read_properties()
181 props->product_id[RMI_PRODUCT_ID_LENGTH] = '\0'; in rmi_f01_read_properties()
183 props->productinfo = in rmi_f01_read_properties()
193 dev_err(&rmi_dev->dev, in rmi_f01_read_properties()
205 dev_err(&rmi_dev->dev, in rmi_f01_read_properties()
214 dev_err(&rmi_dev->dev, in rmi_f01_read_properties()
228 dev_err(&rmi_dev->dev, in rmi_f01_read_properties()
234 props->package_id = get_unaligned_le64(queries); in rmi_f01_read_properties()
242 dev_err(&rmi_dev->dev, in rmi_f01_read_properties()
248 props->firmware_id = queries[1] << 8 | queries[0]; in rmi_f01_read_properties()
249 props->firmware_id += queries[2] * 65536; in rmi_f01_read_properties()
258 struct f01_data *f01 = dev_get_drvdata(&fn->dev); in rmi_f01_get_product_ID()
260 return f01->properties.product_id; in rmi_f01_get_product_ID()
268 struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); in rmi_driver_manufacturer_id_show()
270 return sysfs_emit(buf, "%d\n", f01->properties.manufacturer_id); in rmi_driver_manufacturer_id_show()
280 struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); in rmi_driver_dom_show()
282 return sysfs_emit(buf, "%s\n", f01->properties.dom); in rmi_driver_dom_show()
292 struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); in rmi_driver_product_id_show()
294 return sysfs_emit(buf, "%s\n", f01->properties.product_id); in rmi_driver_product_id_show()
304 struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); in rmi_driver_firmware_id_show()
306 return sysfs_emit(buf, "%d\n", f01->properties.firmware_id); in rmi_driver_firmware_id_show()
316 struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); in rmi_driver_package_id_show()
318 u32 package_id = f01->properties.package_id; in rmi_driver_package_id_show()
347 (u32 *)&pdata->power_management.nosleep, in rmi_f01_of_probe()
348 "syna,nosleep-mode", 1); in rmi_f01_of_probe()
353 "syna,wakeup-threshold", 1); in rmi_f01_of_probe()
357 pdata->power_management.wakeup_threshold = val; in rmi_f01_of_probe()
360 "syna,doze-holdoff-ms", 1); in rmi_f01_of_probe()
364 pdata->power_management.doze_holdoff = val * 100; in rmi_f01_of_probe()
367 "syna,doze-interval-ms", 1); in rmi_f01_of_probe()
371 pdata->power_management.doze_interval = val / 10; in rmi_f01_of_probe()
379 return -ENODEV; in rmi_f01_of_probe()
385 struct rmi_device *rmi_dev = fn->rmi_dev; in rmi_f01_probe()
386 struct rmi_driver_data *driver_data = dev_get_drvdata(&rmi_dev->dev); in rmi_f01_probe()
390 u16 ctrl_base_addr = fn->fd.control_base_addr; in rmi_f01_probe()
394 if (fn->dev.of_node) { in rmi_f01_probe()
395 error = rmi_f01_of_probe(&fn->dev, pdata); in rmi_f01_probe()
400 f01 = devm_kzalloc(&fn->dev, sizeof(struct f01_data), GFP_KERNEL); in rmi_f01_probe()
402 return -ENOMEM; in rmi_f01_probe()
404 f01->num_of_irq_regs = driver_data->num_of_irq_regs; in rmi_f01_probe()
411 error = rmi_read(rmi_dev, fn->fd.control_base_addr, in rmi_f01_probe()
412 &f01->device_control.ctrl0); in rmi_f01_probe()
414 dev_err(&fn->dev, "Failed to read F01 control: %d\n", error); in rmi_f01_probe()
418 switch (pdata->power_management.nosleep) { in rmi_f01_probe()
422 f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_NOSLEEP_BIT; in rmi_f01_probe()
425 f01->device_control.ctrl0 |= RMI_F01_CTRL0_NOSLEEP_BIT; in rmi_f01_probe()
434 if ((f01->device_control.ctrl0 & RMI_F01_CTRL0_SLEEP_MODE_MASK) != in rmi_f01_probe()
436 dev_warn(&fn->dev, in rmi_f01_probe()
437 "WARNING: Non-zero sleep mode found. Clearing...\n"); in rmi_f01_probe()
438 f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_SLEEP_MODE_MASK; in rmi_f01_probe()
441 f01->device_control.ctrl0 |= RMI_F01_CTRL0_CONFIGURED_BIT; in rmi_f01_probe()
443 error = rmi_write(rmi_dev, fn->fd.control_base_addr, in rmi_f01_probe()
444 f01->device_control.ctrl0); in rmi_f01_probe()
446 dev_err(&fn->dev, "Failed to write F01 control: %d\n", error); in rmi_f01_probe()
451 error = rmi_read(rmi_dev, fn->fd.data_base_addr + 1, &temp); in rmi_f01_probe()
453 dev_err(&fn->dev, "Failed to read Interrupt Status.\n"); in rmi_f01_probe()
457 error = rmi_f01_read_properties(rmi_dev, fn->fd.query_base_addr, in rmi_f01_probe()
458 &f01->properties); in rmi_f01_probe()
460 dev_err(&fn->dev, "Failed to read F01 properties.\n"); in rmi_f01_probe()
464 dev_info(&fn->dev, "found RMI device, manufacturer: %s, product: %s, fw id: %d\n", in rmi_f01_probe()
465 f01->properties.manufacturer_id == 1 ? "Synaptics" : "unknown", in rmi_f01_probe()
466 f01->properties.product_id, f01->properties.firmware_id); in rmi_f01_probe()
470 ctrl_base_addr += f01->num_of_irq_regs; in rmi_f01_probe()
473 if (f01->properties.has_adjustable_doze) { in rmi_f01_probe()
474 f01->doze_interval_addr = ctrl_base_addr; in rmi_f01_probe()
477 if (pdata->power_management.doze_interval) { in rmi_f01_probe()
478 f01->device_control.doze_interval = in rmi_f01_probe()
479 pdata->power_management.doze_interval; in rmi_f01_probe()
480 error = rmi_write(rmi_dev, f01->doze_interval_addr, in rmi_f01_probe()
481 f01->device_control.doze_interval); in rmi_f01_probe()
483 dev_err(&fn->dev, in rmi_f01_probe()
484 "Failed to configure F01 doze interval register: %d\n", in rmi_f01_probe()
489 error = rmi_read(rmi_dev, f01->doze_interval_addr, in rmi_f01_probe()
490 &f01->device_control.doze_interval); in rmi_f01_probe()
492 dev_err(&fn->dev, in rmi_f01_probe()
493 "Failed to read F01 doze interval register: %d\n", in rmi_f01_probe()
499 f01->wakeup_threshold_addr = ctrl_base_addr; in rmi_f01_probe()
502 if (pdata->power_management.wakeup_threshold) { in rmi_f01_probe()
503 f01->device_control.wakeup_threshold = in rmi_f01_probe()
504 pdata->power_management.wakeup_threshold; in rmi_f01_probe()
505 error = rmi_write(rmi_dev, f01->wakeup_threshold_addr, in rmi_f01_probe()
506 f01->device_control.wakeup_threshold); in rmi_f01_probe()
508 dev_err(&fn->dev, in rmi_f01_probe()
514 error = rmi_read(rmi_dev, f01->wakeup_threshold_addr, in rmi_f01_probe()
515 &f01->device_control.wakeup_threshold); in rmi_f01_probe()
517 dev_err(&fn->dev, in rmi_f01_probe()
525 if (f01->properties.has_lts) in rmi_f01_probe()
528 if (f01->properties.has_adjustable_doze_holdoff) { in rmi_f01_probe()
529 f01->doze_holdoff_addr = ctrl_base_addr; in rmi_f01_probe()
532 if (pdata->power_management.doze_holdoff) { in rmi_f01_probe()
533 f01->device_control.doze_holdoff = in rmi_f01_probe()
534 pdata->power_management.doze_holdoff; in rmi_f01_probe()
535 error = rmi_write(rmi_dev, f01->doze_holdoff_addr, in rmi_f01_probe()
536 f01->device_control.doze_holdoff); in rmi_f01_probe()
538 dev_err(&fn->dev, in rmi_f01_probe()
539 "Failed to configure F01 doze holdoff register: %d\n", in rmi_f01_probe()
544 error = rmi_read(rmi_dev, f01->doze_holdoff_addr, in rmi_f01_probe()
545 &f01->device_control.doze_holdoff); in rmi_f01_probe()
547 dev_err(&fn->dev, in rmi_f01_probe()
548 "Failed to read F01 doze holdoff register: %d\n", in rmi_f01_probe()
555 error = rmi_read(rmi_dev, fn->fd.data_base_addr, &device_status); in rmi_f01_probe()
557 dev_err(&fn->dev, in rmi_f01_probe()
563 dev_err(&fn->dev, in rmi_f01_probe()
566 return -EINVAL; in rmi_f01_probe()
569 dev_set_drvdata(&fn->dev, f01); in rmi_f01_probe()
571 error = sysfs_create_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group); in rmi_f01_probe()
573 dev_warn(&fn->dev, "Failed to create sysfs group: %d\n", error); in rmi_f01_probe()
581 sysfs_remove_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group); in rmi_f01_remove()
586 struct f01_data *f01 = dev_get_drvdata(&fn->dev); in rmi_f01_config()
589 error = rmi_write(fn->rmi_dev, fn->fd.control_base_addr, in rmi_f01_config()
590 f01->device_control.ctrl0); in rmi_f01_config()
592 dev_err(&fn->dev, in rmi_f01_config()
597 if (f01->properties.has_adjustable_doze) { in rmi_f01_config()
598 error = rmi_write(fn->rmi_dev, f01->doze_interval_addr, in rmi_f01_config()
599 f01->device_control.doze_interval); in rmi_f01_config()
601 dev_err(&fn->dev, in rmi_f01_config()
602 "Failed to write doze interval: %d\n", error); in rmi_f01_config()
606 error = rmi_write_block(fn->rmi_dev, in rmi_f01_config()
607 f01->wakeup_threshold_addr, in rmi_f01_config()
608 &f01->device_control.wakeup_threshold, in rmi_f01_config()
611 dev_err(&fn->dev, in rmi_f01_config()
618 if (f01->properties.has_adjustable_doze_holdoff) { in rmi_f01_config()
619 error = rmi_write(fn->rmi_dev, f01->doze_holdoff_addr, in rmi_f01_config()
620 f01->device_control.doze_holdoff); in rmi_f01_config()
622 dev_err(&fn->dev, in rmi_f01_config()
623 "Failed to write doze holdoff: %d\n", error); in rmi_f01_config()
633 struct f01_data *f01 = dev_get_drvdata(&fn->dev); in rmi_f01_suspend()
636 f01->old_nosleep = in rmi_f01_suspend()
637 f01->device_control.ctrl0 & RMI_F01_CTRL0_NOSLEEP_BIT; in rmi_f01_suspend()
638 f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_NOSLEEP_BIT; in rmi_f01_suspend()
640 f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_SLEEP_MODE_MASK; in rmi_f01_suspend()
641 if (device_may_wakeup(fn->rmi_dev->xport->dev)) in rmi_f01_suspend()
642 f01->device_control.ctrl0 |= RMI_SLEEP_MODE_RESERVED1; in rmi_f01_suspend()
644 f01->device_control.ctrl0 |= RMI_SLEEP_MODE_SENSOR_SLEEP; in rmi_f01_suspend()
646 error = rmi_write(fn->rmi_dev, fn->fd.control_base_addr, in rmi_f01_suspend()
647 f01->device_control.ctrl0); in rmi_f01_suspend()
649 dev_err(&fn->dev, "Failed to write sleep mode: %d.\n", error); in rmi_f01_suspend()
650 if (f01->old_nosleep) in rmi_f01_suspend()
651 f01->device_control.ctrl0 |= RMI_F01_CTRL0_NOSLEEP_BIT; in rmi_f01_suspend()
652 f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_SLEEP_MODE_MASK; in rmi_f01_suspend()
653 f01->device_control.ctrl0 |= RMI_SLEEP_MODE_NORMAL; in rmi_f01_suspend()
662 struct f01_data *f01 = dev_get_drvdata(&fn->dev); in rmi_f01_resume()
665 if (f01->old_nosleep) in rmi_f01_resume()
666 f01->device_control.ctrl0 |= RMI_F01_CTRL0_NOSLEEP_BIT; in rmi_f01_resume()
668 f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_SLEEP_MODE_MASK; in rmi_f01_resume()
669 f01->device_control.ctrl0 |= RMI_SLEEP_MODE_NORMAL; in rmi_f01_resume()
671 error = rmi_write(fn->rmi_dev, fn->fd.control_base_addr, in rmi_f01_resume()
672 f01->device_control.ctrl0); in rmi_f01_resume()
674 dev_err(&fn->dev, in rmi_f01_resume()
685 struct rmi_device *rmi_dev = fn->rmi_dev; in rmi_f01_attention()
689 error = rmi_read(rmi_dev, fn->fd.data_base_addr, &device_status); in rmi_f01_attention()
691 dev_err(&fn->dev, in rmi_f01_attention()
697 dev_warn(&fn->dev, in rmi_f01_attention()
701 dev_warn(&fn->dev, "Device reset detected.\n"); in rmi_f01_attention()
702 error = rmi_dev->driver->reset_handler(rmi_dev); in rmi_f01_attention()
704 dev_err(&fn->dev, "Device reset failed: %d\n", error); in rmi_f01_attention()