blob: 692108222271a4eee6c6af37a768c9ca53e850e0 [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
83#define REGULATOR_MODE_FAST 0x1
84#define REGULATOR_MODE_NORMAL 0x2
85#define REGULATOR_MODE_IDLE 0x4
86#define REGULATOR_MODE_STANDBY 0x8
87
88/*
89 * Regulator notifier events.
90 *
91 * UNDER_VOLTAGE Regulator output is under voltage.
92 * OVER_CURRENT Regulator output current is too high.
93 * REGULATION_OUT Regulator output is out of regulation.
94 * FAIL Regulator output has failed.
95 * OVER_TEMP Regulator over temp.
Mark Brown84b68262009-12-01 21:12:27 +000096 * FORCE_DISABLE Regulator forcibly shut down by software.
Jonathan Cameronb136fb42009-01-19 18:20:58 +000097 * VOLTAGE_CHANGE Regulator voltage changed.
Heiko Stübner71795692014-08-28 12:36:04 -070098 * Data passed is old voltage cast to (void *).
Mark Brown84b68262009-12-01 21:12:27 +000099 * DISABLE Regulator was disabled.
Heiko Stübner71795692014-08-28 12:36:04 -0700100 * PRE_VOLTAGE_CHANGE Regulator is about to have voltage changed.
101 * Data passed is "struct pre_voltage_change_data"
102 * ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason.
103 * Data passed is old voltage cast to (void *).
Richard Fitzgeralda1c8a552014-11-24 14:10:52 +0000104 * PRE_DISABLE Regulator is about to be disabled
105 * ABORT_DISABLE Regulator disable failed for some reason
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100106 *
107 * NOTE: These events can be OR'ed together when passed into handler.
108 */
109
110#define REGULATOR_EVENT_UNDER_VOLTAGE 0x01
111#define REGULATOR_EVENT_OVER_CURRENT 0x02
112#define REGULATOR_EVENT_REGULATION_OUT 0x04
113#define REGULATOR_EVENT_FAIL 0x08
114#define REGULATOR_EVENT_OVER_TEMP 0x10
115#define REGULATOR_EVENT_FORCE_DISABLE 0x20
Jonathan Cameronb136fb42009-01-19 18:20:58 +0000116#define REGULATOR_EVENT_VOLTAGE_CHANGE 0x40
Geert Uytterhoeven5c9e7192015-02-23 17:10:03 +0100117#define REGULATOR_EVENT_DISABLE 0x80
Heiko Stübner71795692014-08-28 12:36:04 -0700118#define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100
119#define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200
Richard Fitzgeralda1c8a552014-11-24 14:10:52 +0000120#define REGULATOR_EVENT_PRE_DISABLE 0x400
121#define REGULATOR_EVENT_ABORT_DISABLE 0x800
Heiko Stübner71795692014-08-28 12:36:04 -0700122
123/**
124 * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event
125 *
126 * @old_uV: Current voltage before change.
127 * @min_uV: Min voltage we'll change to.
128 * @max_uV: Max voltage we'll change to.
129 */
130struct pre_voltage_change_data {
131 unsigned long old_uV;
132 unsigned long min_uV;
133 unsigned long max_uV;
134};
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100135
136struct regulator;
137
138/**
139 * struct regulator_bulk_data - Data used for bulk regulator operations.
140 *
Mark Brown69279fb2008-12-31 12:52:41 +0000141 * @supply: The name of the supply. Initialised by the user before
142 * using the bulk regulator APIs.
143 * @consumer: The regulator consumer for the supply. This will be managed
144 * by the bulk API.
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100145 *
146 * The regulator APIs provide a series of regulator_bulk_() API calls as
147 * a convenience to consumers which require multiple supplies. This
148 * structure is used to manage data for these calls.
149 */
150struct regulator_bulk_data {
151 const char *supply;
152 struct regulator *consumer;
Mark Brownf21e0e82011-05-24 08:12:40 +0800153
Randy Dunlapbff747c2011-09-08 10:16:47 -0700154 /* private: Internal use */
Mark Brownf21e0e82011-05-24 08:12:40 +0800155 int ret;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100156};
157
158#if defined(CONFIG_REGULATOR)
159
160/* regulator get and put */
161struct regulator *__must_check regulator_get(struct device *dev,
162 const char *id);
Stephen Boyd070b9072012-01-16 19:39:58 -0800163struct regulator *__must_check devm_regulator_get(struct device *dev,
164 const char *id);
Mark Brown5ffbd132009-07-21 16:00:23 +0100165struct regulator *__must_check regulator_get_exclusive(struct device *dev,
166 const char *id);
Matthias Kaehlcke9efdd272013-08-25 17:54:13 +0200167struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev,
168 const char *id);
Mark Brownde1dd9f2013-07-29 21:42:42 +0100169struct regulator *__must_check regulator_get_optional(struct device *dev,
170 const char *id);
171struct regulator *__must_check devm_regulator_get_optional(struct device *dev,
172 const char *id);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100173void regulator_put(struct regulator *regulator);
Axel Lin2950c4b2012-01-29 17:52:37 +0800174void devm_regulator_put(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100175
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100176int regulator_register_supply_alias(struct device *dev, const char *id,
177 struct device *alias_dev,
178 const char *alias_id);
179void regulator_unregister_supply_alias(struct device *dev, const char *id);
180
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100181int regulator_bulk_register_supply_alias(struct device *dev,
182 const char *const *id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100183 struct device *alias_dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100184 const char *const *alias_id,
185 int num_id);
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100186void regulator_bulk_unregister_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100187 const char * const *id, int num_id);
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100188
189int devm_regulator_register_supply_alias(struct device *dev, const char *id,
190 struct device *alias_dev,
191 const char *alias_id);
192void devm_regulator_unregister_supply_alias(struct device *dev,
193 const char *id);
194
195int devm_regulator_bulk_register_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100196 const char *const *id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100197 struct device *alias_dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100198 const char *const *alias_id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100199 int num_id);
200void devm_regulator_bulk_unregister_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100201 const char *const *id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100202 int num_id);
203
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100204/* regulator output control and status */
Mark Brownc8801a82012-03-19 16:35:48 +0000205int __must_check regulator_enable(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100206int regulator_disable(struct regulator *regulator);
207int regulator_force_disable(struct regulator *regulator);
208int regulator_is_enabled(struct regulator *regulator);
Mark Brownda07ecd2011-09-11 09:53:50 +0100209int regulator_disable_deferred(struct regulator *regulator, int ms);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100210
Mark Brownc8801a82012-03-19 16:35:48 +0000211int __must_check regulator_bulk_get(struct device *dev, int num_consumers,
212 struct regulator_bulk_data *consumers);
213int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers,
214 struct regulator_bulk_data *consumers);
215int __must_check regulator_bulk_enable(int num_consumers,
216 struct regulator_bulk_data *consumers);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100217int regulator_bulk_disable(int num_consumers,
218 struct regulator_bulk_data *consumers);
Donggeun Kime1de2f42012-01-03 16:22:03 +0900219int regulator_bulk_force_disable(int num_consumers,
220 struct regulator_bulk_data *consumers);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100221void regulator_bulk_free(int num_consumers,
222 struct regulator_bulk_data *consumers);
223
David Brownell4367cfd2009-02-26 11:48:36 -0800224int regulator_count_voltages(struct regulator *regulator);
225int regulator_list_voltage(struct regulator *regulator, unsigned selector);
Mark Browna7a1ad92009-07-21 16:00:24 +0100226int regulator_is_supported_voltage(struct regulator *regulator,
227 int min_uV, int max_uV);
Paul Walmsley2a668a82013-06-07 08:06:56 +0000228unsigned int regulator_get_linear_step(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100229int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
Linus Walleij88cd222b2011-03-17 13:24:52 +0100230int regulator_set_voltage_time(struct regulator *regulator,
231 int old_uV, int new_uV);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100232int regulator_get_voltage(struct regulator *regulator);
Mark Brown606a2562010-12-16 15:49:36 +0000233int regulator_sync_voltage(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100234int regulator_set_current_limit(struct regulator *regulator,
235 int min_uA, int max_uA);
236int regulator_get_current_limit(struct regulator *regulator);
237
238int regulator_set_mode(struct regulator *regulator, unsigned int mode);
239unsigned int regulator_get_mode(struct regulator *regulator);
Bjorn Anderssone39ce482015-02-11 19:35:27 -0800240int regulator_set_load(struct regulator *regulator, int load_uA);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100241
Mark Brownf59c8f92012-08-31 10:36:37 -0700242int regulator_allow_bypass(struct regulator *regulator, bool allow);
243
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300244struct regmap *regulator_get_regmap(struct regulator *regulator);
245int regulator_get_hardware_vsel_register(struct regulator *regulator,
246 unsigned *vsel_reg,
247 unsigned *vsel_mask);
248int regulator_list_hardware_vsel(struct regulator *regulator,
249 unsigned selector);
250
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100251/* regulator notifier block */
252int regulator_register_notifier(struct regulator *regulator,
253 struct notifier_block *nb);
Charles Keepax046db762015-03-05 15:39:20 +0000254int devm_regulator_register_notifier(struct regulator *regulator,
255 struct notifier_block *nb);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100256int regulator_unregister_notifier(struct regulator *regulator,
257 struct notifier_block *nb);
Charles Keepax046db762015-03-05 15:39:20 +0000258void devm_regulator_unregister_notifier(struct regulator *regulator,
259 struct notifier_block *nb);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100260
261/* driver data - core doesn't touch */
262void *regulator_get_drvdata(struct regulator *regulator);
263void regulator_set_drvdata(struct regulator *regulator, void *data);
264
265#else
266
267/*
268 * Make sure client drivers will still build on systems with no software
269 * controllable voltage or current regulators.
270 */
271static inline struct regulator *__must_check regulator_get(struct device *dev,
272 const char *id)
273{
274 /* Nothing except the stubbed out regulator API should be
275 * looking at the value except to check if it is an error
Jean Delvarebe1a50d2010-04-03 17:37:45 +0200276 * value. Drivers are free to handle NULL specifically by
277 * skipping all regulator API calls, but they don't have to.
278 * Drivers which don't, should make sure they properly handle
279 * corner cases of the API, such as regulator_get_voltage()
280 * returning 0.
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100281 */
Jean Delvarebe1a50d2010-04-03 17:37:45 +0200282 return NULL;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100283}
Stephen Boyd070b9072012-01-16 19:39:58 -0800284
285static inline struct regulator *__must_check
286devm_regulator_get(struct device *dev, const char *id)
287{
288 return NULL;
289}
290
Mark Brownde1dd9f2013-07-29 21:42:42 +0100291static inline struct regulator *__must_check
Mark Brown4bdfb272013-07-29 21:00:53 +0100292regulator_get_exclusive(struct device *dev, const char *id)
293{
Mark Brown70b946f2014-10-24 21:56:58 +0100294 return ERR_PTR(-ENODEV);
Mark Brown4bdfb272013-07-29 21:00:53 +0100295}
296
Mark Brownde1dd9f2013-07-29 21:42:42 +0100297static inline struct regulator *__must_check
298regulator_get_optional(struct device *dev, const char *id)
299{
Tim Krygerdf7926f2014-04-17 11:55:24 -0700300 return ERR_PTR(-ENODEV);
Mark Brownde1dd9f2013-07-29 21:42:42 +0100301}
302
Mark Brown4bdfb272013-07-29 21:00:53 +0100303
304static inline struct regulator *__must_check
Mark Brownde1dd9f2013-07-29 21:42:42 +0100305devm_regulator_get_optional(struct device *dev, const char *id)
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100306{
Tim Krygerdf7926f2014-04-17 11:55:24 -0700307 return ERR_PTR(-ENODEV);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100308}
309
310static inline void regulator_put(struct regulator *regulator)
311{
312}
313
Axel Lin2950c4b2012-01-29 17:52:37 +0800314static inline void devm_regulator_put(struct regulator *regulator)
315{
316}
317
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100318static inline int regulator_register_supply_alias(struct device *dev,
319 const char *id,
320 struct device *alias_dev,
321 const char *alias_id)
322{
323 return 0;
324}
325
326static inline void regulator_unregister_supply_alias(struct device *dev,
327 const char *id)
328{
329}
330
331static inline int regulator_bulk_register_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100332 const char *const *id,
333 struct device *alias_dev,
334 const char * const *alias_id,
335 int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100336{
337 return 0;
338}
339
340static inline void regulator_bulk_unregister_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100341 const char * const *id,
342 int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100343{
344}
345
346static inline int devm_regulator_register_supply_alias(struct device *dev,
347 const char *id,
348 struct device *alias_dev,
349 const char *alias_id)
350{
351 return 0;
352}
353
354static inline void devm_regulator_unregister_supply_alias(struct device *dev,
355 const char *id)
356{
357}
358
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100359static inline int devm_regulator_bulk_register_supply_alias(struct device *dev,
360 const char *const *id,
361 struct device *alias_dev,
362 const char *const *alias_id,
363 int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100364{
365 return 0;
366}
367
368static inline void devm_regulator_bulk_unregister_supply_alias(
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100369 struct device *dev, const char *const *id, int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100370{
371}
372
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100373static inline int regulator_enable(struct regulator *regulator)
374{
375 return 0;
376}
377
378static inline int regulator_disable(struct regulator *regulator)
379{
380 return 0;
381}
382
MyungJoo Ham935a5212012-01-02 18:49:32 +0900383static inline int regulator_force_disable(struct regulator *regulator)
384{
385 return 0;
386}
387
Mark Brownda07ecd2011-09-11 09:53:50 +0100388static inline int regulator_disable_deferred(struct regulator *regulator,
389 int ms)
390{
391 return 0;
392}
393
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100394static inline int regulator_is_enabled(struct regulator *regulator)
395{
396 return 1;
397}
398
399static inline int regulator_bulk_get(struct device *dev,
400 int num_consumers,
401 struct regulator_bulk_data *consumers)
402{
403 return 0;
404}
405
Axel Line24abd62012-01-27 12:55:28 +0800406static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers,
407 struct regulator_bulk_data *consumers)
408{
409 return 0;
410}
411
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100412static inline int regulator_bulk_enable(int num_consumers,
413 struct regulator_bulk_data *consumers)
414{
415 return 0;
416}
417
418static inline int regulator_bulk_disable(int num_consumers,
419 struct regulator_bulk_data *consumers)
420{
421 return 0;
422}
423
Donggeun Kime1de2f42012-01-03 16:22:03 +0900424static inline int regulator_bulk_force_disable(int num_consumers,
425 struct regulator_bulk_data *consumers)
426{
427 return 0;
428}
429
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100430static inline void regulator_bulk_free(int num_consumers,
431 struct regulator_bulk_data *consumers)
432{
433}
434
435static inline int regulator_set_voltage(struct regulator *regulator,
436 int min_uV, int max_uV)
437{
438 return 0;
439}
440
Viresh Kumard660e922014-05-27 17:37:29 +0530441static inline int regulator_set_voltage_time(struct regulator *regulator,
442 int old_uV, int new_uV)
443{
444 return 0;
445}
446
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100447static inline int regulator_get_voltage(struct regulator *regulator)
448{
Mark Brown08aed2f2012-06-11 20:14:24 +0800449 return -EINVAL;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100450}
451
Philip Rakity4fe23792012-06-30 16:05:36 -0700452static inline int regulator_is_supported_voltage(struct regulator *regulator,
453 int min_uV, int max_uV)
454{
455 return 0;
456}
457
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100458static inline int regulator_set_current_limit(struct regulator *regulator,
459 int min_uA, int max_uA)
460{
461 return 0;
462}
463
464static inline int regulator_get_current_limit(struct regulator *regulator)
465{
466 return 0;
467}
468
469static inline int regulator_set_mode(struct regulator *regulator,
470 unsigned int mode)
471{
472 return 0;
473}
474
475static inline unsigned int regulator_get_mode(struct regulator *regulator)
476{
477 return REGULATOR_MODE_NORMAL;
478}
479
Bjorn Anderssone39ce482015-02-11 19:35:27 -0800480static inline int regulator_set_load(struct regulator *regulator, int load_uA)
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100481{
482 return REGULATOR_MODE_NORMAL;
483}
484
Mark Brownf59c8f92012-08-31 10:36:37 -0700485static inline int regulator_allow_bypass(struct regulator *regulator,
486 bool allow)
487{
488 return 0;
489}
490
Mark Brown3bc03122014-07-25 19:07:11 +0100491static inline struct regmap *regulator_get_regmap(struct regulator *regulator)
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300492{
493 return ERR_PTR(-EOPNOTSUPP);
494}
495
Mark Brown3bc03122014-07-25 19:07:11 +0100496static inline int regulator_get_hardware_vsel_register(struct regulator *regulator,
497 unsigned *vsel_reg,
498 unsigned *vsel_mask)
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300499{
500 return -EOPNOTSUPP;
501}
502
Mark Brown3bc03122014-07-25 19:07:11 +0100503static inline int regulator_list_hardware_vsel(struct regulator *regulator,
504 unsigned selector)
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300505{
506 return -EOPNOTSUPP;
507}
508
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100509static inline int regulator_register_notifier(struct regulator *regulator,
510 struct notifier_block *nb)
511{
512 return 0;
513}
514
Charles Keepax046db762015-03-05 15:39:20 +0000515static inline int devm_regulator_register_notifier(struct regulator *regulator,
516 struct notifier_block *nb)
517{
518 return 0;
519}
520
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100521static inline int regulator_unregister_notifier(struct regulator *regulator,
522 struct notifier_block *nb)
523{
524 return 0;
525}
526
Charles Keepax046db762015-03-05 15:39:20 +0000527static inline int devm_regulator_unregister_notifier(struct regulator *regulator,
528 struct notifier_block *nb)
529{
530 return 0;
531}
532
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100533static inline void *regulator_get_drvdata(struct regulator *regulator)
534{
535 return NULL;
536}
537
538static inline void regulator_set_drvdata(struct regulator *regulator,
539 void *data)
540{
541}
542
Philip Rakity1a8f85d2012-11-20 18:07:41 +0100543static inline int regulator_count_voltages(struct regulator *regulator)
544{
545 return 0;
546}
Suzuki K. Poulose5127e312015-07-10 16:26:38 +0100547
548static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector)
549{
550 return -EINVAL;
551}
552
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100553#endif
554
Viresh Kumar30f93ca2015-08-17 08:16:51 +0530555static inline int regulator_set_voltage_triplet(struct regulator *regulator,
556 int min_uV, int target_uV,
557 int max_uV)
558{
559 if (regulator_set_voltage(regulator, target_uV, max_uV) == 0)
560 return 0;
561
562 return regulator_set_voltage(regulator, min_uV, max_uV);
563}
564
Shawn Guo3f196572012-08-05 23:05:20 +0800565static inline int regulator_set_voltage_tol(struct regulator *regulator,
566 int new_uV, int tol_uV)
567{
Mark Browndc9ceed2013-07-04 17:27:14 +0100568 if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0)
569 return 0;
570 else
571 return regulator_set_voltage(regulator,
572 new_uV - tol_uV, new_uV + tol_uV);
Shawn Guo3f196572012-08-05 23:05:20 +0800573}
574
Mark Brownfe1e43f2012-11-14 16:47:10 +0900575static inline int regulator_is_supported_voltage_tol(struct regulator *regulator,
576 int target_uV, int tol_uV)
577{
578 return regulator_is_supported_voltage(regulator,
579 target_uV - tol_uV,
580 target_uV + tol_uV);
581}
582
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100583#endif