Skip to content

Commit ec0be3c

Browse files
javiercarrascocruzbroonie
authored andcommitted
regulator: consumer.rst: document bulk operations
The current consumer documentation does not include bulk operations, providing an example of how to acquire multiple regulators by calling regulator_get() multiple times. That solution is valid and slightly simpler for a small amount of regulators, but it does not scale well. Document the bulk operations to get, enable and disable regulators. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Link: https://patch.msgid.link/20250819-reg_consumer_doc-v1-1-b631fc0d35a3@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent f7f8046 commit ec0be3c

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

Documentation/power/regulator/consumer.rst

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@ To release the regulator the consumer driver should call ::
2323
regulator_put(regulator);
2424

2525
Consumers can be supplied by more than one regulator e.g. codec consumer with
26-
analog and digital supplies ::
26+
analog and digital supplies by means of bulk operations ::
27+
28+
struct regulator_bulk_data supplies[2];
29+
30+
supplies[0].supply = "Vcc"; /* digital core */
31+
supplies[1].supply = "Avdd"; /* analog */
32+
33+
ret = regulator_bulk_get(dev, ARRAY_SIZE(supplies), supplies);
34+
35+
// convenience helper to call regulator_put() on multiple regulators
36+
regulator_bulk_free(ARRAY_SIZE(supplies), supplies);
2737

28-
digital = regulator_get(dev, "Vcc"); /* digital core */
29-
analog = regulator_get(dev, "Avdd"); /* analog */
3038

3139
The regulator access functions regulator_get() and regulator_put() will
3240
usually be called in your device drivers probe() and remove() respectively.
@@ -51,11 +59,21 @@ A consumer can determine if a regulator is enabled by calling::
5159

5260
This will return > zero when the regulator is enabled.
5361

62+
A set of regulators can be enabled with a single bulk operation ::
63+
64+
int regulator_bulk_enable(int num_consumers,
65+
struct regulator_bulk_data *consumers);
66+
5467

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

5770
int regulator_disable(regulator);
5871

72+
Or a number of them ::
73+
74+
int regulator_bulk_disable(int num_consumers,
75+
struct regulator_bulk_data *consumers);
76+
5977
NOTE:
6078
This may not disable the supply if it's shared with other consumers. The
6179
regulator will only be disabled when the enabled reference count is zero.
@@ -64,11 +82,15 @@ Finally, a regulator can be forcefully disabled in the case of an emergency::
6482

6583
int regulator_force_disable(regulator);
6684

85+
This operation is also supported for multiple regulators ::
86+
87+
int regulator_bulk_force_disable(int num_consumers,
88+
struct regulator_bulk_data *consumers);
89+
6790
NOTE:
6891
this will immediately and forcefully shutdown the regulator output. All
6992
consumers will be powered off.
7093

71-
7294
3. Regulator Voltage Control & Status (dynamic drivers)
7395
=======================================================
7496

0 commit comments

Comments
 (0)