pwrseq.rst 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. .. SPDX-License-Identifier: GPL-2.0-only
  2. .. Copyright 2024 Linaro Ltd.
  3. ====================
  4. Power Sequencing API
  5. ====================
  6. :Author: Bartosz Golaszewski
  7. Introduction
  8. ============
  9. This framework is designed to abstract complex power-up sequences that are
  10. shared between multiple logical devices in the linux kernel.
  11. The intention is to allow consumers to obtain a power sequencing handle
  12. exposed by the power sequence provider and delegate the actual requesting and
  13. control of the underlying resources as well as to allow the provider to
  14. mitigate any potential conflicts between multiple users behind the scenes.
  15. Glossary
  16. --------
  17. The power sequencing API uses a number of terms specific to the subsystem:
  18. Unit
  19. A unit is a discreet chunk of a power sequence. For instance one unit may
  20. enable a set of regulators, another may enable a specific GPIO. Units can
  21. define dependencies in the form of other units that must be enabled before
  22. it itself can be.
  23. Target
  24. A target is a set of units (composed of the "final" unit and its
  25. dependencies) that a consumer selects by its name when requesting a handle
  26. to the power sequencer. Via the dependency system, multiple targets may
  27. share the same parts of a power sequence but ignore parts that are
  28. irrelevant.
  29. Descriptor
  30. A handle passed by the pwrseq core to every consumer that serves as the
  31. entry point to the provider layer. It ensures coherence between different
  32. users and keeps reference counting consistent.
  33. Consumer interface
  34. ==================
  35. The consumer API is aimed to be as simple as possible. The driver interested in
  36. getting a descriptor from the power sequencer should call pwrseq_get() and
  37. specify the name of the target it wants to reach in the sequence after calling
  38. pwrseq_power_up(). The descriptor can be released by calling pwrseq_put() and
  39. the consumer can request the powering down of its target with
  40. pwrseq_power_off(). Note that there is no guarantee that pwrseq_power_off()
  41. will have any effect as there may be multiple users of the underlying resources
  42. who may keep them active.
  43. Provider interface
  44. ==================
  45. The provider API is admittedly not nearly as straightforward as the one for
  46. consumers but it makes up for it in flexibility.
  47. Each provider can logically split the power-up sequence into descrete chunks
  48. (units) and define their dependencies. They can then expose named targets that
  49. consumers may use as the final point in the sequence that they wish to reach.
  50. To that end the providers fill out a set of configuration structures and
  51. register with the pwrseq subsystem by calling pwrseq_device_register().
  52. Dynamic consumer matching
  53. -------------------------
  54. The main difference between pwrseq and other linux kernel providers is the
  55. mechanism for dynamic matching of consumers and providers. Every power sequence
  56. provider driver must implement the `match()` callback and pass it to the pwrseq
  57. core when registering with the subsystems.
  58. When a client requests a sequencer handle, the core will call this callback for
  59. every registered provider and let it flexibly figure out whether the proposed
  60. client device is indeed its consumer. For example: if the provider binds to the
  61. device-tree node representing a power management unit of a chipset and the
  62. consumer driver controls one of its modules, the provider driver may parse the
  63. relevant regulator supply properties in device tree and see if they lead from
  64. the PMU to the consumer.
  65. API reference
  66. =============
  67. .. kernel-doc:: include/linux/pwrseq/provider.h
  68. :internal:
  69. .. kernel-doc:: drivers/power/sequencing/core.c
  70. :export: