Lines Matching +full:nosleep +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2011-2016 Synaptics Incorporated
64 /* The device is in bootloader mode */
70 * Sleep mode controls power management on the device and affects all
81 * This bit disables whatever sleep mode may be selected by the sleep_mode
87 * When this bit is set, the touch controller employs a noise-filtering
106 * struct f01_device_control - controls basic sensor functions
110 * when the touch sensor is in doze mode, in units of 10ms.
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()
271 f01->properties.manufacturer_id); in rmi_driver_manufacturer_id_show()
281 struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); in rmi_driver_dom_show()
283 return scnprintf(buf, PAGE_SIZE, "%s\n", f01->properties.dom); in rmi_driver_dom_show()
293 struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); in rmi_driver_product_id_show()
295 return scnprintf(buf, PAGE_SIZE, "%s\n", f01->properties.product_id); in rmi_driver_product_id_show()
305 struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); in rmi_driver_firmware_id_show()
307 return scnprintf(buf, PAGE_SIZE, "%d\n", f01->properties.firmware_id); in rmi_driver_firmware_id_show()
317 struct f01_data *f01 = dev_get_drvdata(&data->f01_container->dev); in rmi_driver_package_id_show()
319 u32 package_id = f01->properties.package_id; in rmi_driver_package_id_show()
348 (u32 *)&pdata->power_management.nosleep, in rmi_f01_of_probe()
349 "syna,nosleep-mode", 1); in rmi_f01_of_probe()
354 "syna,wakeup-threshold", 1); in rmi_f01_of_probe()
358 pdata->power_management.wakeup_threshold = val; in rmi_f01_of_probe()
361 "syna,doze-holdoff-ms", 1); in rmi_f01_of_probe()
365 pdata->power_management.doze_holdoff = val * 100; in rmi_f01_of_probe()
368 "syna,doze-interval-ms", 1); in rmi_f01_of_probe()
372 pdata->power_management.doze_interval = val / 10; in rmi_f01_of_probe()
380 return -ENODEV; in rmi_f01_of_probe()
386 struct rmi_device *rmi_dev = fn->rmi_dev; in rmi_f01_probe()
387 struct rmi_driver_data *driver_data = dev_get_drvdata(&rmi_dev->dev); in rmi_f01_probe()
391 u16 ctrl_base_addr = fn->fd.control_base_addr; in rmi_f01_probe()
395 if (fn->dev.of_node) { in rmi_f01_probe()
396 error = rmi_f01_of_probe(&fn->dev, pdata); in rmi_f01_probe()
401 f01 = devm_kzalloc(&fn->dev, sizeof(struct f01_data), GFP_KERNEL); in rmi_f01_probe()
403 return -ENOMEM; in rmi_f01_probe()
405 f01->num_of_irq_regs = driver_data->num_of_irq_regs; in rmi_f01_probe()
412 error = rmi_read(rmi_dev, fn->fd.control_base_addr, in rmi_f01_probe()
413 &f01->device_control.ctrl0); in rmi_f01_probe()
415 dev_err(&fn->dev, "Failed to read F01 control: %d\n", error); in rmi_f01_probe()
419 switch (pdata->power_management.nosleep) { in rmi_f01_probe()
423 f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_NOSLEEP_BIT; in rmi_f01_probe()
426 f01->device_control.ctrl0 |= RMI_F01_CTRL0_NOSLEEP_BIT; in rmi_f01_probe()
431 * Sleep mode might be set as a hangover from a system crash or in rmi_f01_probe()
435 if ((f01->device_control.ctrl0 & RMI_F01_CTRL0_SLEEP_MODE_MASK) != in rmi_f01_probe()
437 dev_warn(&fn->dev, in rmi_f01_probe()
438 "WARNING: Non-zero sleep mode found. Clearing...\n"); in rmi_f01_probe()
439 f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_SLEEP_MODE_MASK; in rmi_f01_probe()
442 f01->device_control.ctrl0 |= RMI_F01_CTRL0_CONFIGURED_BIT; in rmi_f01_probe()
444 error = rmi_write(rmi_dev, fn->fd.control_base_addr, in rmi_f01_probe()
445 f01->device_control.ctrl0); in rmi_f01_probe()
447 dev_err(&fn->dev, "Failed to write F01 control: %d\n", error); in rmi_f01_probe()
452 error = rmi_read(rmi_dev, fn->fd.data_base_addr + 1, &temp); in rmi_f01_probe()
454 dev_err(&fn->dev, "Failed to read Interrupt Status.\n"); in rmi_f01_probe()
458 error = rmi_f01_read_properties(rmi_dev, fn->fd.query_base_addr, in rmi_f01_probe()
459 &f01->properties); in rmi_f01_probe()
461 dev_err(&fn->dev, "Failed to read F01 properties.\n"); in rmi_f01_probe()
465 dev_info(&fn->dev, "found RMI device, manufacturer: %s, product: %s, fw id: %d\n", in rmi_f01_probe()
466 f01->properties.manufacturer_id == 1 ? "Synaptics" : "unknown", in rmi_f01_probe()
467 f01->properties.product_id, f01->properties.firmware_id); in rmi_f01_probe()
471 ctrl_base_addr += f01->num_of_irq_regs; in rmi_f01_probe()
474 if (f01->properties.has_adjustable_doze) { in rmi_f01_probe()
475 f01->doze_interval_addr = ctrl_base_addr; in rmi_f01_probe()
478 if (pdata->power_management.doze_interval) { in rmi_f01_probe()
479 f01->device_control.doze_interval = in rmi_f01_probe()
480 pdata->power_management.doze_interval; in rmi_f01_probe()
481 error = rmi_write(rmi_dev, f01->doze_interval_addr, in rmi_f01_probe()
482 f01->device_control.doze_interval); in rmi_f01_probe()
484 dev_err(&fn->dev, in rmi_f01_probe()
490 error = rmi_read(rmi_dev, f01->doze_interval_addr, in rmi_f01_probe()
491 &f01->device_control.doze_interval); in rmi_f01_probe()
493 dev_err(&fn->dev, in rmi_f01_probe()
500 f01->wakeup_threshold_addr = ctrl_base_addr; in rmi_f01_probe()
503 if (pdata->power_management.wakeup_threshold) { in rmi_f01_probe()
504 f01->device_control.wakeup_threshold = in rmi_f01_probe()
505 pdata->power_management.wakeup_threshold; in rmi_f01_probe()
506 error = rmi_write(rmi_dev, f01->wakeup_threshold_addr, in rmi_f01_probe()
507 f01->device_control.wakeup_threshold); in rmi_f01_probe()
509 dev_err(&fn->dev, in rmi_f01_probe()
515 error = rmi_read(rmi_dev, f01->wakeup_threshold_addr, in rmi_f01_probe()
516 &f01->device_control.wakeup_threshold); in rmi_f01_probe()
518 dev_err(&fn->dev, in rmi_f01_probe()
526 if (f01->properties.has_lts) in rmi_f01_probe()
529 if (f01->properties.has_adjustable_doze_holdoff) { in rmi_f01_probe()
530 f01->doze_holdoff_addr = ctrl_base_addr; in rmi_f01_probe()
533 if (pdata->power_management.doze_holdoff) { in rmi_f01_probe()
534 f01->device_control.doze_holdoff = in rmi_f01_probe()
535 pdata->power_management.doze_holdoff; in rmi_f01_probe()
536 error = rmi_write(rmi_dev, f01->doze_holdoff_addr, in rmi_f01_probe()
537 f01->device_control.doze_holdoff); in rmi_f01_probe()
539 dev_err(&fn->dev, in rmi_f01_probe()
545 error = rmi_read(rmi_dev, f01->doze_holdoff_addr, in rmi_f01_probe()
546 &f01->device_control.doze_holdoff); in rmi_f01_probe()
548 dev_err(&fn->dev, in rmi_f01_probe()
556 error = rmi_read(rmi_dev, fn->fd.data_base_addr, &device_status); in rmi_f01_probe()
558 dev_err(&fn->dev, in rmi_f01_probe()
564 dev_err(&fn->dev, in rmi_f01_probe()
567 return -EINVAL; in rmi_f01_probe()
570 dev_set_drvdata(&fn->dev, f01); in rmi_f01_probe()
572 error = sysfs_create_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group); in rmi_f01_probe()
574 dev_warn(&fn->dev, "Failed to create sysfs group: %d\n", error); in rmi_f01_probe()
582 sysfs_remove_group(&fn->rmi_dev->dev.kobj, &rmi_f01_attr_group); in rmi_f01_remove()
587 struct f01_data *f01 = dev_get_drvdata(&fn->dev); in rmi_f01_config()
590 error = rmi_write(fn->rmi_dev, fn->fd.control_base_addr, in rmi_f01_config()
591 f01->device_control.ctrl0); in rmi_f01_config()
593 dev_err(&fn->dev, in rmi_f01_config()
598 if (f01->properties.has_adjustable_doze) { in rmi_f01_config()
599 error = rmi_write(fn->rmi_dev, f01->doze_interval_addr, in rmi_f01_config()
600 f01->device_control.doze_interval); in rmi_f01_config()
602 dev_err(&fn->dev, in rmi_f01_config()
607 error = rmi_write_block(fn->rmi_dev, in rmi_f01_config()
608 f01->wakeup_threshold_addr, in rmi_f01_config()
609 &f01->device_control.wakeup_threshold, in rmi_f01_config()
612 dev_err(&fn->dev, in rmi_f01_config()
619 if (f01->properties.has_adjustable_doze_holdoff) { in rmi_f01_config()
620 error = rmi_write(fn->rmi_dev, f01->doze_holdoff_addr, in rmi_f01_config()
621 f01->device_control.doze_holdoff); in rmi_f01_config()
623 dev_err(&fn->dev, in rmi_f01_config()
634 struct f01_data *f01 = dev_get_drvdata(&fn->dev); in rmi_f01_suspend()
637 f01->old_nosleep = in rmi_f01_suspend()
638 f01->device_control.ctrl0 & RMI_F01_CTRL0_NOSLEEP_BIT; in rmi_f01_suspend()
639 f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_NOSLEEP_BIT; in rmi_f01_suspend()
641 f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_SLEEP_MODE_MASK; in rmi_f01_suspend()
642 if (device_may_wakeup(fn->rmi_dev->xport->dev)) in rmi_f01_suspend()
643 f01->device_control.ctrl0 |= RMI_SLEEP_MODE_RESERVED1; in rmi_f01_suspend()
645 f01->device_control.ctrl0 |= RMI_SLEEP_MODE_SENSOR_SLEEP; in rmi_f01_suspend()
647 error = rmi_write(fn->rmi_dev, fn->fd.control_base_addr, in rmi_f01_suspend()
648 f01->device_control.ctrl0); in rmi_f01_suspend()
650 dev_err(&fn->dev, "Failed to write sleep mode: %d.\n", error); in rmi_f01_suspend()
651 if (f01->old_nosleep) in rmi_f01_suspend()
652 f01->device_control.ctrl0 |= RMI_F01_CTRL0_NOSLEEP_BIT; in rmi_f01_suspend()
653 f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_SLEEP_MODE_MASK; in rmi_f01_suspend()
654 f01->device_control.ctrl0 |= RMI_SLEEP_MODE_NORMAL; in rmi_f01_suspend()
663 struct f01_data *f01 = dev_get_drvdata(&fn->dev); in rmi_f01_resume()
666 if (f01->old_nosleep) in rmi_f01_resume()
667 f01->device_control.ctrl0 |= RMI_F01_CTRL0_NOSLEEP_BIT; in rmi_f01_resume()
669 f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_SLEEP_MODE_MASK; in rmi_f01_resume()
670 f01->device_control.ctrl0 |= RMI_SLEEP_MODE_NORMAL; in rmi_f01_resume()
672 error = rmi_write(fn->rmi_dev, fn->fd.control_base_addr, in rmi_f01_resume()
673 f01->device_control.ctrl0); in rmi_f01_resume()
675 dev_err(&fn->dev, in rmi_f01_resume()
686 struct rmi_device *rmi_dev = fn->rmi_dev; in rmi_f01_attention()
690 error = rmi_read(rmi_dev, fn->fd.data_base_addr, &device_status); in rmi_f01_attention()
692 dev_err(&fn->dev, in rmi_f01_attention()
698 dev_warn(&fn->dev, in rmi_f01_attention()
699 "Device in bootloader mode, please update firmware\n"); in rmi_f01_attention()
702 dev_warn(&fn->dev, "Device reset detected.\n"); in rmi_f01_attention()
703 error = rmi_dev->driver->reset_handler(rmi_dev); in rmi_f01_attention()
705 dev_err(&fn->dev, "Device reset failed: %d\n", error); in rmi_f01_attention()