Documentation/power/regulator/consumer.rst

Source file repositories/reference/linux-study-clean/Documentation/power/regulator/consumer.rst

File Facts

System
Linux kernel
Corpus path
Documentation/power/regulator/consumer.rst
Extension
.rst
Size
9438 bytes
Lines
258
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

===================================
Regulator Consumer Driver Interface
===================================

This text describes the regulator interface for consumer device drivers.
Please see overview.txt for a description of the terms used in this text.


1. Consumer Regulator Access (static & dynamic drivers)
=======================================================

A consumer driver can get access to its supply regulator by calling ::

	regulator = regulator_get(dev, "Vcc");

The consumer passes in its struct device pointer and power supply ID. The core
then finds the correct regulator by consulting a machine specific lookup table.
If the lookup is successful then this call will return a pointer to the struct
regulator that supplies this consumer.

To release the regulator the consumer driver should call ::

	regulator_put(regulator);

Consumers can be supplied by more than one regulator e.g. codec consumer with
analog and digital supplies by means of bulk operations ::

	struct regulator_bulk_data supplies[2];

	supplies[0].supply = "Vcc"; /* digital core */
	supplies[1].supply = "Avdd"; /* analog */

	ret = regulator_bulk_get(dev, ARRAY_SIZE(supplies), supplies);

	// convenience helper to call regulator_put() on multiple regulators
	regulator_bulk_free(ARRAY_SIZE(supplies), supplies);


The regulator access functions regulator_get() and regulator_put() will
usually be called in your device drivers probe() and remove() respectively.


2. Regulator Output Enable & Disable (static & dynamic drivers)
===============================================================


A consumer can enable its power supply by calling::

	int regulator_enable(regulator);

NOTE:
  The supply may already be enabled before regulator_enable() is called.
  This may happen if the consumer shares the regulator or the regulator has been
  previously enabled by bootloader or kernel board initialization code.

A consumer can determine if a regulator is enabled by calling::

	int regulator_is_enabled(regulator);

This will return > zero when the regulator is enabled.

A set of regulators can be enabled with a single bulk operation ::

	int regulator_bulk_enable(int num_consumers,
				  struct regulator_bulk_data *consumers);


A consumer can disable its supply when no longer needed by calling::

	int regulator_disable(regulator);

Annotation

Implementation Notes