blob: aaf3cee7043976d1c1b784e60dce9a6b5268a3cd [file] [log] [blame]
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +01001/*
2 * consumer.h -- SoC Regulator consumer support.
3 *
4 * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
5 *
Liam Girdwood1dd68f02009-02-02 21:43:31 +00006 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +01007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * Regulator Consumer Interface.
13 *
14 * A Power Management Regulator framework for SoC based devices.
15 * Features:-
16 * o Voltage and current level control.
17 * o Operating mode control.
18 * o Regulator status.
19 * o sysfs entries for showing client devices and status
20 *
21 * EXPERIMENTAL FEATURES:
22 * Dynamic Regulator operating Mode Switching (DRMS) - allows regulators
23 * to use most efficient operating mode depending upon voltage and load and
24 * is transparent to client drivers.
25 *
26 * e.g. Devices x,y,z share regulator r. Device x and y draw 20mA each during
27 * IO and 1mA at idle. Device z draws 100mA when under load and 5mA when
28 * idling. Regulator r has > 90% efficiency in NORMAL mode at loads > 100mA
29 * but this drops rapidly to 60% when below 100mA. Regulator r has > 90%
30 * efficiency in IDLE mode at loads < 10mA. Thus regulator r will operate
31 * in normal mode for loads > 10mA and in IDLE mode for load <= 10mA.
32 *
33 */
34
35#ifndef __LINUX_REGULATOR_CONSUMER_H_
36#define __LINUX_REGULATOR_CONSUMER_H_
37
Guenter Roeck174e9642014-10-09 12:43:27 -070038#include <linux/err.h>
39
Paul Gortmaker313162d2012-01-30 11:46:54 -050040struct device;
41struct notifier_block;
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +030042struct regmap;
Liam Girdwoodb56daf12009-11-11 14:16:10 +000043
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +010044/*
45 * Regulator operating modes.
46 *
47 * Regulators can run in a variety of different operating modes depending on
48 * output load. This allows further system power savings by selecting the
49 * best (and most efficient) regulator mode for a desired load.
50 *
51 * Most drivers will only care about NORMAL. The modes below are generic and
52 * will probably not match the naming convention of your regulator data sheet
53 * but should match the use cases in the datasheet.
54 *
55 * In order of power efficiency (least efficient at top).
56 *
57 * Mode Description
58 * FAST Regulator can handle fast changes in it's load.
59 * e.g. useful in CPU voltage & frequency scaling where
60 * load can quickly increase with CPU frequency increases.
61 *
62 * NORMAL Normal regulator power supply mode. Most drivers will
63 * use this mode.
64 *
65 * IDLE Regulator runs in a more efficient mode for light
66 * loads. Can be used for devices that have a low power
67 * requirement during periods of inactivity. This mode
68 * may be more noisy than NORMAL and may not be able
69 * to handle fast load switching.
70 *
71 * STANDBY Regulator runs in the most efficient mode for very
72 * light loads. Can be used by devices when they are
73 * in a sleep/standby state. This mode is likely to be
74 * the most noisy and may not be able to handle fast load
75 * switching.
76 *
77 * NOTE: Most regulators will only support a subset of these modes. Some
78 * will only just support NORMAL.
79 *
80 * These modes can be OR'ed together to make up a mask of valid register modes.
81 */
82
Douglas Anderson02f37032018-04-18 08:54:18 -070083#define REGULATOR_MODE_INVALID 0x0
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +010084#define REGULATOR_MODE_FAST 0x1
85#define REGULATOR_MODE_NORMAL 0x2
86#define REGULATOR_MODE_IDLE 0x4
87#define REGULATOR_MODE_STANDBY 0x8
88
89/*
90 * Regulator notifier events.
91 *
92 * UNDER_VOLTAGE Regulator output is under voltage.
93 * OVER_CURRENT Regulator output current is too high.
94 * REGULATION_OUT Regulator output is out of regulation.
95 * FAIL Regulator output has failed.
96 * OVER_TEMP Regulator over temp.
Mark Brown84b68262009-12-01 21:12:27 +000097 * FORCE_DISABLE Regulator forcibly shut down by software.
Jonathan Cameronb136fb42009-01-19 18:20:58 +000098 * VOLTAGE_CHANGE Regulator voltage changed.
Heiko Stübner71795692014-08-28 12:36:04 -070099 * Data passed is old voltage cast to (void *).
Mark Brown84b68262009-12-01 21:12:27 +0000100 * DISABLE Regulator was disabled.
Heiko Stübner71795692014-08-28 12:36:04 -0700101 * PRE_VOLTAGE_CHANGE Regulator is about to have voltage changed.
102 * Data passed is "struct pre_voltage_change_data"
103 * ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason.
104 * Data passed is old voltage cast to (void *).
Richard Fitzgeralda1c8a552014-11-24 14:10:52 +0000105 * PRE_DISABLE Regulator is about to be disabled
106 * ABORT_DISABLE Regulator disable failed for some reason
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100107 *
108 * NOTE: These events can be OR'ed together when passed into handler.
109 */
110
111#define REGULATOR_EVENT_UNDER_VOLTAGE 0x01
112#define REGULATOR_EVENT_OVER_CURRENT 0x02
113#define REGULATOR_EVENT_REGULATION_OUT 0x04
114#define REGULATOR_EVENT_FAIL 0x08
115#define REGULATOR_EVENT_OVER_TEMP 0x10
116#define REGULATOR_EVENT_FORCE_DISABLE 0x20
Jonathan Cameronb136fb42009-01-19 18:20:58 +0000117#define REGULATOR_EVENT_VOLTAGE_CHANGE 0x40
Geert Uytterhoeven5c9e7192015-02-23 17:10:03 +0100118#define REGULATOR_EVENT_DISABLE 0x80
Heiko Stübner71795692014-08-28 12:36:04 -0700119#define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100
120#define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200
Richard Fitzgeralda1c8a552014-11-24 14:10:52 +0000121#define REGULATOR_EVENT_PRE_DISABLE 0x400
122#define REGULATOR_EVENT_ABORT_DISABLE 0x800
Harald Geyer264b88c2017-02-23 17:06:52 +0000123#define REGULATOR_EVENT_ENABLE 0x1000
Heiko Stübner71795692014-08-28 12:36:04 -0700124
Axel Haslam1b5b4222016-11-03 12:11:42 +0100125/*
126 * Regulator errors that can be queried using regulator_get_error_flags
127 *
128 * UNDER_VOLTAGE Regulator output is under voltage.
129 * OVER_CURRENT Regulator output current is too high.
130 * REGULATION_OUT Regulator output is out of regulation.
131 * FAIL Regulator output has failed.
132 * OVER_TEMP Regulator over temp.
133 *
134 * NOTE: These errors can be OR'ed together.
135 */
136
137#define REGULATOR_ERROR_UNDER_VOLTAGE BIT(1)
138#define REGULATOR_ERROR_OVER_CURRENT BIT(2)
139#define REGULATOR_ERROR_REGULATION_OUT BIT(3)
140#define REGULATOR_ERROR_FAIL BIT(4)
141#define REGULATOR_ERROR_OVER_TEMP BIT(5)
142
143
Heiko Stübner71795692014-08-28 12:36:04 -0700144/**
145 * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event
146 *
147 * @old_uV: Current voltage before change.
148 * @min_uV: Min voltage we'll change to.
149 * @max_uV: Max voltage we'll change to.
150 */
151struct pre_voltage_change_data {
152 unsigned long old_uV;
153 unsigned long min_uV;
154 unsigned long max_uV;
155};
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100156
157struct regulator;
158
159/**
160 * struct regulator_bulk_data - Data used for bulk regulator operations.
161 *
Mark Brown69279fb2008-12-31 12:52:41 +0000162 * @supply: The name of the supply. Initialised by the user before
163 * using the bulk regulator APIs.
164 * @consumer: The regulator consumer for the supply. This will be managed
165 * by the bulk API.
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100166 *
167 * The regulator APIs provide a series of regulator_bulk_() API calls as
168 * a convenience to consumers which require multiple supplies. This
169 * structure is used to manage data for these calls.
170 */
171struct regulator_bulk_data {
172 const char *supply;
173 struct regulator *consumer;
Mark Brownf21e0e82011-05-24 08:12:40 +0800174
Randy Dunlapbff747c2011-09-08 10:16:47 -0700175 /* private: Internal use */
Mark Brownf21e0e82011-05-24 08:12:40 +0800176 int ret;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100177};
178
179#if defined(CONFIG_REGULATOR)
180
181/* regulator get and put */
182struct regulator *__must_check regulator_get(struct device *dev,
183 const char *id);
Stephen Boyd070b9072012-01-16 19:39:58 -0800184struct regulator *__must_check devm_regulator_get(struct device *dev,
185 const char *id);
Mark Brown5ffbd132009-07-21 16:00:23 +0100186struct regulator *__must_check regulator_get_exclusive(struct device *dev,
187 const char *id);
Matthias Kaehlcke9efdd272013-08-25 17:54:13 +0200188struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev,
189 const char *id);
Mark Brownde1dd9f2013-07-29 21:42:42 +0100190struct regulator *__must_check regulator_get_optional(struct device *dev,
191 const char *id);
192struct regulator *__must_check devm_regulator_get_optional(struct device *dev,
193 const char *id);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100194void regulator_put(struct regulator *regulator);
Axel Lin2950c4b2012-01-29 17:52:37 +0800195void devm_regulator_put(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100196
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100197int regulator_register_supply_alias(struct device *dev, const char *id,
198 struct device *alias_dev,
199 const char *alias_id);
200void regulator_unregister_supply_alias(struct device *dev, const char *id);
201
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100202int regulator_bulk_register_supply_alias(struct device *dev,
203 const char *const *id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100204 struct device *alias_dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100205 const char *const *alias_id,
206 int num_id);
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100207void regulator_bulk_unregister_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100208 const char * const *id, int num_id);
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100209
210int devm_regulator_register_supply_alias(struct device *dev, const char *id,
211 struct device *alias_dev,
212 const char *alias_id);
213void devm_regulator_unregister_supply_alias(struct device *dev,
214 const char *id);
215
216int devm_regulator_bulk_register_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100217 const char *const *id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100218 struct device *alias_dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100219 const char *const *alias_id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100220 int num_id);
221void devm_regulator_bulk_unregister_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100222 const char *const *id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100223 int num_id);
224
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100225/* regulator output control and status */
Mark Brownc8801a82012-03-19 16:35:48 +0000226int __must_check regulator_enable(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100227int regulator_disable(struct regulator *regulator);
228int regulator_force_disable(struct regulator *regulator);
229int regulator_is_enabled(struct regulator *regulator);
Mark Brownda07ecd2011-09-11 09:53:50 +0100230int regulator_disable_deferred(struct regulator *regulator, int ms);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100231
Mark Brownc8801a82012-03-19 16:35:48 +0000232int __must_check regulator_bulk_get(struct device *dev, int num_consumers,
233 struct regulator_bulk_data *consumers);
234int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers,
235 struct regulator_bulk_data *consumers);
236int __must_check regulator_bulk_enable(int num_consumers,
237 struct regulator_bulk_data *consumers);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100238int regulator_bulk_disable(int num_consumers,
239 struct regulator_bulk_data *consumers);
Donggeun Kime1de2f42012-01-03 16:22:03 +0900240int regulator_bulk_force_disable(int num_consumers,
241 struct regulator_bulk_data *consumers);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100242void regulator_bulk_free(int num_consumers,
243 struct regulator_bulk_data *consumers);
244
David Brownell4367cfd2009-02-26 11:48:36 -0800245int regulator_count_voltages(struct regulator *regulator);
246int regulator_list_voltage(struct regulator *regulator, unsigned selector);
Mark Browna7a1ad902009-07-21 16:00:24 +0100247int regulator_is_supported_voltage(struct regulator *regulator,
248 int min_uV, int max_uV);
Paul Walmsley2a668a82013-06-07 08:06:56 +0000249unsigned int regulator_get_linear_step(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100250int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
Linus Walleij88cd222b2011-03-17 13:24:52 +0100251int regulator_set_voltage_time(struct regulator *regulator,
252 int old_uV, int new_uV);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100253int regulator_get_voltage(struct regulator *regulator);
Mark Brown606a2562010-12-16 15:49:36 +0000254int regulator_sync_voltage(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100255int regulator_set_current_limit(struct regulator *regulator,
256 int min_uA, int max_uA);
257int regulator_get_current_limit(struct regulator *regulator);
258
259int regulator_set_mode(struct regulator *regulator, unsigned int mode);
260unsigned int regulator_get_mode(struct regulator *regulator);
Axel Haslam1b5b4222016-11-03 12:11:42 +0100261int regulator_get_error_flags(struct regulator *regulator,
262 unsigned int *flags);
Bjorn Anderssone39ce482015-02-11 19:35:27 -0800263int regulator_set_load(struct regulator *regulator, int load_uA);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100264
Mark Brownf59c8f92012-08-31 10:36:37 -0700265int regulator_allow_bypass(struct regulator *regulator, bool allow);
266
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300267struct regmap *regulator_get_regmap(struct regulator *regulator);
268int regulator_get_hardware_vsel_register(struct regulator *regulator,
269 unsigned *vsel_reg,
270 unsigned *vsel_mask);
271int regulator_list_hardware_vsel(struct regulator *regulator,
272 unsigned selector);
273
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100274/* regulator notifier block */
275int regulator_register_notifier(struct regulator *regulator,
276 struct notifier_block *nb);
Charles Keepax046db762015-03-05 15:39:20 +0000277int devm_regulator_register_notifier(struct regulator *regulator,
278 struct notifier_block *nb);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100279int regulator_unregister_notifier(struct regulator *regulator,
280 struct notifier_block *nb);
Charles Keepax046db762015-03-05 15:39:20 +0000281void devm_regulator_unregister_notifier(struct regulator *regulator,
282 struct notifier_block *nb);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100283
284/* driver data - core doesn't touch */
285void *regulator_get_drvdata(struct regulator *regulator);
286void regulator_set_drvdata(struct regulator *regulator, void *data);
287
288#else
289
290/*
291 * Make sure client drivers will still build on systems with no software
292 * controllable voltage or current regulators.
293 */
294static inline struct regulator *__must_check regulator_get(struct device *dev,
295 const char *id)
296{
297 /* Nothing except the stubbed out regulator API should be
298 * looking at the value except to check if it is an error
Jean Delvarebe1a50d2010-04-03 17:37:45 +0200299 * value. Drivers are free to handle NULL specifically by
300 * skipping all regulator API calls, but they don't have to.
301 * Drivers which don't, should make sure they properly handle
302 * corner cases of the API, such as regulator_get_voltage()
303 * returning 0.
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100304 */
Jean Delvarebe1a50d2010-04-03 17:37:45 +0200305 return NULL;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100306}
Stephen Boyd070b9072012-01-16 19:39:58 -0800307
308static inline struct regulator *__must_check
309devm_regulator_get(struct device *dev, const char *id)
310{
311 return NULL;
312}
313
Mark Brownde1dd9f2013-07-29 21:42:42 +0100314static inline struct regulator *__must_check
Mark Brown4bdfb272013-07-29 21:00:53 +0100315regulator_get_exclusive(struct device *dev, const char *id)
316{
Mark Brown70b946f2014-10-24 21:56:58 +0100317 return ERR_PTR(-ENODEV);
Mark Brown4bdfb272013-07-29 21:00:53 +0100318}
319
Mark Brownde1dd9f2013-07-29 21:42:42 +0100320static inline struct regulator *__must_check
321regulator_get_optional(struct device *dev, const char *id)
322{
Tim Krygerdf7926f2014-04-17 11:55:24 -0700323 return ERR_PTR(-ENODEV);
Mark Brownde1dd9f2013-07-29 21:42:42 +0100324}
325
Mark Brown4bdfb272013-07-29 21:00:53 +0100326
327static inline struct regulator *__must_check
Mark Brownde1dd9f2013-07-29 21:42:42 +0100328devm_regulator_get_optional(struct device *dev, const char *id)
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100329{
Tim Krygerdf7926f2014-04-17 11:55:24 -0700330 return ERR_PTR(-ENODEV);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100331}
332
333static inline void regulator_put(struct regulator *regulator)
334{
335}
336
Axel Lin2950c4b2012-01-29 17:52:37 +0800337static inline void devm_regulator_put(struct regulator *regulator)
338{
339}
340
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100341static inline int regulator_register_supply_alias(struct device *dev,
342 const char *id,
343 struct device *alias_dev,
344 const char *alias_id)
345{
346 return 0;
347}
348
349static inline void regulator_unregister_supply_alias(struct device *dev,
350 const char *id)
351{
352}
353
354static inline int regulator_bulk_register_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100355 const char *const *id,
356 struct device *alias_dev,
357 const char * const *alias_id,
358 int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100359{
360 return 0;
361}
362
363static inline void regulator_bulk_unregister_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100364 const char * const *id,
365 int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100366{
367}
368
369static inline int devm_regulator_register_supply_alias(struct device *dev,
370 const char *id,
371 struct device *alias_dev,
372 const char *alias_id)
373{
374 return 0;
375}
376
377static inline void devm_regulator_unregister_supply_alias(struct device *dev,
378 const char *id)
379{
380}
381
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100382static inline int devm_regulator_bulk_register_supply_alias(struct device *dev,
383 const char *const *id,
384 struct device *alias_dev,
385 const char *const *alias_id,
386 int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100387{
388 return 0;
389}
390
391static inline void devm_regulator_bulk_unregister_supply_alias(
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100392 struct device *dev, const char *const *id, int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100393{
394}
395
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100396static inline int regulator_enable(struct regulator *regulator)
397{
398 return 0;
399}
400
401static inline int regulator_disable(struct regulator *regulator)
402{
403 return 0;
404}
405
MyungJoo Ham935a52102012-01-02 18:49:32 +0900406static inline int regulator_force_disable(struct regulator *regulator)
407{
408 return 0;
409}
410
Mark Brownda07ecd2011-09-11 09:53:50 +0100411static inline int regulator_disable_deferred(struct regulator *regulator,
412 int ms)
413{
414 return 0;
415}
416
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100417static inline int regulator_is_enabled(struct regulator *regulator)
418{
419 return 1;
420}
421
422static inline int regulator_bulk_get(struct device *dev,
423 int num_consumers,
424 struct regulator_bulk_data *consumers)
425{
426 return 0;
427}
428
Axel Line24abd62012-01-27 12:55:28 +0800429static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers,
430 struct regulator_bulk_data *consumers)
431{
432 return 0;
433}
434
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100435static inline int regulator_bulk_enable(int num_consumers,
436 struct regulator_bulk_data *consumers)
437{
438 return 0;
439}
440
441static inline int regulator_bulk_disable(int num_consumers,
442 struct regulator_bulk_data *consumers)
443{
444 return 0;
445}
446
Donggeun Kime1de2f42012-01-03 16:22:03 +0900447static inline int regulator_bulk_force_disable(int num_consumers,
448 struct regulator_bulk_data *consumers)
449{
450 return 0;
451}
452
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100453static inline void regulator_bulk_free(int num_consumers,
454 struct regulator_bulk_data *consumers)
455{
456}
457
458static inline int regulator_set_voltage(struct regulator *regulator,
459 int min_uV, int max_uV)
460{
461 return 0;
462}
463
Viresh Kumard660e922014-05-27 17:37:29 +0530464static inline int regulator_set_voltage_time(struct regulator *regulator,
465 int old_uV, int new_uV)
466{
467 return 0;
468}
469
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100470static inline int regulator_get_voltage(struct regulator *regulator)
471{
Mark Brown08aed2f2012-06-11 20:14:24 +0800472 return -EINVAL;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100473}
474
Philip Rakity4fe23792012-06-30 16:05:36 -0700475static inline int regulator_is_supported_voltage(struct regulator *regulator,
476 int min_uV, int max_uV)
477{
478 return 0;
479}
480
Arnd Bergmann72872752019-03-04 20:38:29 +0100481static inline unsigned int regulator_get_linear_step(struct regulator *regulator)
482{
483 return 0;
484}
485
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100486static inline int regulator_set_current_limit(struct regulator *regulator,
487 int min_uA, int max_uA)
488{
489 return 0;
490}
491
492static inline int regulator_get_current_limit(struct regulator *regulator)
493{
494 return 0;
495}
496
497static inline int regulator_set_mode(struct regulator *regulator,
498 unsigned int mode)
499{
500 return 0;
501}
502
503static inline unsigned int regulator_get_mode(struct regulator *regulator)
504{
505 return REGULATOR_MODE_NORMAL;
506}
507
David Lechner30103b52016-12-04 16:52:31 -0600508static inline int regulator_get_error_flags(struct regulator *regulator,
509 unsigned int *flags)
Axel Haslam1b5b4222016-11-03 12:11:42 +0100510{
511 return -EINVAL;
512}
513
Bjorn Anderssone39ce482015-02-11 19:35:27 -0800514static inline int regulator_set_load(struct regulator *regulator, int load_uA)
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100515{
Mark Brownf1abf672018-11-16 19:19:30 -0800516 return 0;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100517}
518
Mark Brownf59c8f92012-08-31 10:36:37 -0700519static inline int regulator_allow_bypass(struct regulator *regulator,
520 bool allow)
521{
522 return 0;
523}
524
Mark Brown3bc03122014-07-25 19:07:11 +0100525static inline struct regmap *regulator_get_regmap(struct regulator *regulator)
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300526{
527 return ERR_PTR(-EOPNOTSUPP);
528}
529
Mark Brown3bc03122014-07-25 19:07:11 +0100530static inline int regulator_get_hardware_vsel_register(struct regulator *regulator,
531 unsigned *vsel_reg,
532 unsigned *vsel_mask)
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300533{
534 return -EOPNOTSUPP;
535}
536
Mark Brown3bc03122014-07-25 19:07:11 +0100537static inline int regulator_list_hardware_vsel(struct regulator *regulator,
538 unsigned selector)
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300539{
540 return -EOPNOTSUPP;
541}
542
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100543static inline int regulator_register_notifier(struct regulator *regulator,
544 struct notifier_block *nb)
545{
546 return 0;
547}
548
Charles Keepax046db762015-03-05 15:39:20 +0000549static inline int devm_regulator_register_notifier(struct regulator *regulator,
550 struct notifier_block *nb)
551{
552 return 0;
553}
554
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100555static inline int regulator_unregister_notifier(struct regulator *regulator,
556 struct notifier_block *nb)
557{
558 return 0;
559}
560
Charles Keepax046db762015-03-05 15:39:20 +0000561static inline int devm_regulator_unregister_notifier(struct regulator *regulator,
562 struct notifier_block *nb)
563{
564 return 0;
565}
566
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100567static inline void *regulator_get_drvdata(struct regulator *regulator)
568{
569 return NULL;
570}
571
572static inline void regulator_set_drvdata(struct regulator *regulator,
573 void *data)
574{
575}
576
Philip Rakity1a8f85d2012-11-20 18:07:41 +0100577static inline int regulator_count_voltages(struct regulator *regulator)
578{
579 return 0;
580}
Suzuki K. Poulose5127e312015-07-10 16:26:38 +0100581
582static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector)
583{
584 return -EINVAL;
585}
586
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100587#endif
588
Viresh Kumar30f93ca2015-08-17 08:16:51 +0530589static inline int regulator_set_voltage_triplet(struct regulator *regulator,
590 int min_uV, int target_uV,
591 int max_uV)
592{
593 if (regulator_set_voltage(regulator, target_uV, max_uV) == 0)
594 return 0;
595
596 return regulator_set_voltage(regulator, min_uV, max_uV);
597}
598
Shawn Guo3f196572012-08-05 23:05:20 +0800599static inline int regulator_set_voltage_tol(struct regulator *regulator,
600 int new_uV, int tol_uV)
601{
Mark Browndc9ceed2013-07-04 17:27:14 +0100602 if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0)
603 return 0;
604 else
605 return regulator_set_voltage(regulator,
606 new_uV - tol_uV, new_uV + tol_uV);
Shawn Guo3f196572012-08-05 23:05:20 +0800607}
608
Mark Brownfe1e43f2012-11-14 16:47:10 +0900609static inline int regulator_is_supported_voltage_tol(struct regulator *regulator,
610 int target_uV, int tol_uV)
611{
612 return regulator_is_supported_voltage(regulator,
613 target_uV - tol_uV,
614 target_uV + tol_uV);
615}
616
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100617#endif