blob: df176d7c2b87c00356a11b383a61185e7f3e47ae [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
Harald Geyer264b88c2017-02-23 17:06:52 +0000122#define REGULATOR_EVENT_ENABLE 0x1000
Heiko Stübner71795692014-08-28 12:36:04 -0700123
Axel Haslam1b5b4222016-11-03 12:11:42 +0100124/*
125 * Regulator errors that can be queried using regulator_get_error_flags
126 *
127 * UNDER_VOLTAGE Regulator output is under voltage.
128 * OVER_CURRENT Regulator output current is too high.
129 * REGULATION_OUT Regulator output is out of regulation.
130 * FAIL Regulator output has failed.
131 * OVER_TEMP Regulator over temp.
132 *
133 * NOTE: These errors can be OR'ed together.
134 */
135
136#define REGULATOR_ERROR_UNDER_VOLTAGE BIT(1)
137#define REGULATOR_ERROR_OVER_CURRENT BIT(2)
138#define REGULATOR_ERROR_REGULATION_OUT BIT(3)
139#define REGULATOR_ERROR_FAIL BIT(4)
140#define REGULATOR_ERROR_OVER_TEMP BIT(5)
141
142
Heiko Stübner71795692014-08-28 12:36:04 -0700143/**
144 * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event
145 *
146 * @old_uV: Current voltage before change.
147 * @min_uV: Min voltage we'll change to.
148 * @max_uV: Max voltage we'll change to.
149 */
150struct pre_voltage_change_data {
151 unsigned long old_uV;
152 unsigned long min_uV;
153 unsigned long max_uV;
154};
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100155
156struct regulator;
157
158/**
159 * struct regulator_bulk_data - Data used for bulk regulator operations.
160 *
Mark Brown69279fb2008-12-31 12:52:41 +0000161 * @supply: The name of the supply. Initialised by the user before
162 * using the bulk regulator APIs.
163 * @consumer: The regulator consumer for the supply. This will be managed
164 * by the bulk API.
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100165 *
166 * The regulator APIs provide a series of regulator_bulk_() API calls as
167 * a convenience to consumers which require multiple supplies. This
168 * structure is used to manage data for these calls.
169 */
170struct regulator_bulk_data {
171 const char *supply;
172 struct regulator *consumer;
Mark Brownf21e0e82011-05-24 08:12:40 +0800173
Randy Dunlapbff747c2011-09-08 10:16:47 -0700174 /* private: Internal use */
Mark Brownf21e0e82011-05-24 08:12:40 +0800175 int ret;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100176};
177
178#if defined(CONFIG_REGULATOR)
179
180/* regulator get and put */
181struct regulator *__must_check regulator_get(struct device *dev,
182 const char *id);
Stephen Boyd070b9072012-01-16 19:39:58 -0800183struct regulator *__must_check devm_regulator_get(struct device *dev,
184 const char *id);
Mark Brown5ffbd132009-07-21 16:00:23 +0100185struct regulator *__must_check regulator_get_exclusive(struct device *dev,
186 const char *id);
Matthias Kaehlcke9efdd272013-08-25 17:54:13 +0200187struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev,
188 const char *id);
Mark Brownde1dd9f2013-07-29 21:42:42 +0100189struct regulator *__must_check regulator_get_optional(struct device *dev,
190 const char *id);
191struct regulator *__must_check devm_regulator_get_optional(struct device *dev,
192 const char *id);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100193void regulator_put(struct regulator *regulator);
Axel Lin2950c4b2012-01-29 17:52:37 +0800194void devm_regulator_put(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100195
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100196int regulator_register_supply_alias(struct device *dev, const char *id,
197 struct device *alias_dev,
198 const char *alias_id);
199void regulator_unregister_supply_alias(struct device *dev, const char *id);
200
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100201int regulator_bulk_register_supply_alias(struct device *dev,
202 const char *const *id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100203 struct device *alias_dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100204 const char *const *alias_id,
205 int num_id);
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100206void regulator_bulk_unregister_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100207 const char * const *id, int num_id);
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100208
209int devm_regulator_register_supply_alias(struct device *dev, const char *id,
210 struct device *alias_dev,
211 const char *alias_id);
212void devm_regulator_unregister_supply_alias(struct device *dev,
213 const char *id);
214
215int devm_regulator_bulk_register_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100216 const char *const *id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100217 struct device *alias_dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100218 const char *const *alias_id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100219 int num_id);
220void devm_regulator_bulk_unregister_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100221 const char *const *id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100222 int num_id);
223
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100224/* regulator output control and status */
Mark Brownc8801a82012-03-19 16:35:48 +0000225int __must_check regulator_enable(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100226int regulator_disable(struct regulator *regulator);
227int regulator_force_disable(struct regulator *regulator);
228int regulator_is_enabled(struct regulator *regulator);
Mark Brownda07ecd2011-09-11 09:53:50 +0100229int regulator_disable_deferred(struct regulator *regulator, int ms);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100230
Mark Brownc8801a82012-03-19 16:35:48 +0000231int __must_check regulator_bulk_get(struct device *dev, int num_consumers,
232 struct regulator_bulk_data *consumers);
233int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers,
234 struct regulator_bulk_data *consumers);
235int __must_check regulator_bulk_enable(int num_consumers,
236 struct regulator_bulk_data *consumers);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100237int regulator_bulk_disable(int num_consumers,
238 struct regulator_bulk_data *consumers);
Donggeun Kime1de2f42012-01-03 16:22:03 +0900239int regulator_bulk_force_disable(int num_consumers,
240 struct regulator_bulk_data *consumers);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100241void regulator_bulk_free(int num_consumers,
242 struct regulator_bulk_data *consumers);
243
David Brownell4367cfd2009-02-26 11:48:36 -0800244int regulator_count_voltages(struct regulator *regulator);
245int regulator_list_voltage(struct regulator *regulator, unsigned selector);
Mark Browna7a1ad92009-07-21 16:00:24 +0100246int regulator_is_supported_voltage(struct regulator *regulator,
247 int min_uV, int max_uV);
Paul Walmsley2a668a82013-06-07 08:06:56 +0000248unsigned int regulator_get_linear_step(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100249int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
Linus Walleij88cd222b2011-03-17 13:24:52 +0100250int regulator_set_voltage_time(struct regulator *regulator,
251 int old_uV, int new_uV);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100252int regulator_get_voltage(struct regulator *regulator);
Mark Brown606a2562010-12-16 15:49:36 +0000253int regulator_sync_voltage(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100254int regulator_set_current_limit(struct regulator *regulator,
255 int min_uA, int max_uA);
256int regulator_get_current_limit(struct regulator *regulator);
257
258int regulator_set_mode(struct regulator *regulator, unsigned int mode);
259unsigned int regulator_get_mode(struct regulator *regulator);
Axel Haslam1b5b4222016-11-03 12:11:42 +0100260int regulator_get_error_flags(struct regulator *regulator,
261 unsigned int *flags);
Bjorn Anderssone39ce482015-02-11 19:35:27 -0800262int regulator_set_load(struct regulator *regulator, int load_uA);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100263
Mark Brownf59c8f92012-08-31 10:36:37 -0700264int regulator_allow_bypass(struct regulator *regulator, bool allow);
265
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300266struct regmap *regulator_get_regmap(struct regulator *regulator);
267int regulator_get_hardware_vsel_register(struct regulator *regulator,
268 unsigned *vsel_reg,
269 unsigned *vsel_mask);
270int regulator_list_hardware_vsel(struct regulator *regulator,
271 unsigned selector);
272
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100273/* regulator notifier block */
274int regulator_register_notifier(struct regulator *regulator,
275 struct notifier_block *nb);
Charles Keepax046db762015-03-05 15:39:20 +0000276int devm_regulator_register_notifier(struct regulator *regulator,
277 struct notifier_block *nb);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100278int regulator_unregister_notifier(struct regulator *regulator,
279 struct notifier_block *nb);
Charles Keepax046db762015-03-05 15:39:20 +0000280void devm_regulator_unregister_notifier(struct regulator *regulator,
281 struct notifier_block *nb);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100282
283/* driver data - core doesn't touch */
284void *regulator_get_drvdata(struct regulator *regulator);
285void regulator_set_drvdata(struct regulator *regulator, void *data);
286
287#else
288
289/*
290 * Make sure client drivers will still build on systems with no software
291 * controllable voltage or current regulators.
292 */
293static inline struct regulator *__must_check regulator_get(struct device *dev,
294 const char *id)
295{
296 /* Nothing except the stubbed out regulator API should be
297 * looking at the value except to check if it is an error
Jean Delvarebe1a50d2010-04-03 17:37:45 +0200298 * value. Drivers are free to handle NULL specifically by
299 * skipping all regulator API calls, but they don't have to.
300 * Drivers which don't, should make sure they properly handle
301 * corner cases of the API, such as regulator_get_voltage()
302 * returning 0.
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100303 */
Jean Delvarebe1a50d2010-04-03 17:37:45 +0200304 return NULL;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100305}
Stephen Boyd070b9072012-01-16 19:39:58 -0800306
307static inline struct regulator *__must_check
308devm_regulator_get(struct device *dev, const char *id)
309{
310 return NULL;
311}
312
Mark Brownde1dd9f2013-07-29 21:42:42 +0100313static inline struct regulator *__must_check
Mark Brown4bdfb272013-07-29 21:00:53 +0100314regulator_get_exclusive(struct device *dev, const char *id)
315{
Mark Brown70b946f2014-10-24 21:56:58 +0100316 return ERR_PTR(-ENODEV);
Mark Brown4bdfb272013-07-29 21:00:53 +0100317}
318
Mark Brownde1dd9f2013-07-29 21:42:42 +0100319static inline struct regulator *__must_check
320regulator_get_optional(struct device *dev, const char *id)
321{
Tim Krygerdf7926f2014-04-17 11:55:24 -0700322 return ERR_PTR(-ENODEV);
Mark Brownde1dd9f2013-07-29 21:42:42 +0100323}
324
Mark Brown4bdfb272013-07-29 21:00:53 +0100325
326static inline struct regulator *__must_check
Mark Brownde1dd9f2013-07-29 21:42:42 +0100327devm_regulator_get_optional(struct device *dev, const char *id)
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100328{
Tim Krygerdf7926f2014-04-17 11:55:24 -0700329 return ERR_PTR(-ENODEV);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100330}
331
332static inline void regulator_put(struct regulator *regulator)
333{
334}
335
Axel Lin2950c4b2012-01-29 17:52:37 +0800336static inline void devm_regulator_put(struct regulator *regulator)
337{
338}
339
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100340static inline int regulator_register_supply_alias(struct device *dev,
341 const char *id,
342 struct device *alias_dev,
343 const char *alias_id)
344{
345 return 0;
346}
347
348static inline void regulator_unregister_supply_alias(struct device *dev,
349 const char *id)
350{
351}
352
353static inline int regulator_bulk_register_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100354 const char *const *id,
355 struct device *alias_dev,
356 const char * const *alias_id,
357 int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100358{
359 return 0;
360}
361
362static inline void regulator_bulk_unregister_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100363 const char * const *id,
364 int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100365{
366}
367
368static inline int devm_regulator_register_supply_alias(struct device *dev,
369 const char *id,
370 struct device *alias_dev,
371 const char *alias_id)
372{
373 return 0;
374}
375
376static inline void devm_regulator_unregister_supply_alias(struct device *dev,
377 const char *id)
378{
379}
380
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100381static inline int devm_regulator_bulk_register_supply_alias(struct device *dev,
382 const char *const *id,
383 struct device *alias_dev,
384 const char *const *alias_id,
385 int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100386{
387 return 0;
388}
389
390static inline void devm_regulator_bulk_unregister_supply_alias(
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100391 struct device *dev, const char *const *id, int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100392{
393}
394
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100395static inline int regulator_enable(struct regulator *regulator)
396{
397 return 0;
398}
399
400static inline int regulator_disable(struct regulator *regulator)
401{
402 return 0;
403}
404
MyungJoo Ham935a5212012-01-02 18:49:32 +0900405static inline int regulator_force_disable(struct regulator *regulator)
406{
407 return 0;
408}
409
Mark Brownda07ecd2011-09-11 09:53:50 +0100410static inline int regulator_disable_deferred(struct regulator *regulator,
411 int ms)
412{
413 return 0;
414}
415
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100416static inline int regulator_is_enabled(struct regulator *regulator)
417{
418 return 1;
419}
420
421static inline int regulator_bulk_get(struct device *dev,
422 int num_consumers,
423 struct regulator_bulk_data *consumers)
424{
425 return 0;
426}
427
Axel Line24abd62012-01-27 12:55:28 +0800428static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers,
429 struct regulator_bulk_data *consumers)
430{
431 return 0;
432}
433
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100434static inline int regulator_bulk_enable(int num_consumers,
435 struct regulator_bulk_data *consumers)
436{
437 return 0;
438}
439
440static inline int regulator_bulk_disable(int num_consumers,
441 struct regulator_bulk_data *consumers)
442{
443 return 0;
444}
445
Donggeun Kime1de2f42012-01-03 16:22:03 +0900446static inline int regulator_bulk_force_disable(int num_consumers,
447 struct regulator_bulk_data *consumers)
448{
449 return 0;
450}
451
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100452static inline void regulator_bulk_free(int num_consumers,
453 struct regulator_bulk_data *consumers)
454{
455}
456
457static inline int regulator_set_voltage(struct regulator *regulator,
458 int min_uV, int max_uV)
459{
460 return 0;
461}
462
Viresh Kumard660e922014-05-27 17:37:29 +0530463static inline int regulator_set_voltage_time(struct regulator *regulator,
464 int old_uV, int new_uV)
465{
466 return 0;
467}
468
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100469static inline int regulator_get_voltage(struct regulator *regulator)
470{
Mark Brown08aed2f2012-06-11 20:14:24 +0800471 return -EINVAL;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100472}
473
Philip Rakity4fe23792012-06-30 16:05:36 -0700474static inline int regulator_is_supported_voltage(struct regulator *regulator,
475 int min_uV, int max_uV)
476{
477 return 0;
478}
479
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100480static inline int regulator_set_current_limit(struct regulator *regulator,
481 int min_uA, int max_uA)
482{
483 return 0;
484}
485
486static inline int regulator_get_current_limit(struct regulator *regulator)
487{
488 return 0;
489}
490
491static inline int regulator_set_mode(struct regulator *regulator,
492 unsigned int mode)
493{
494 return 0;
495}
496
497static inline unsigned int regulator_get_mode(struct regulator *regulator)
498{
499 return REGULATOR_MODE_NORMAL;
500}
501
David Lechner30103b52016-12-04 16:52:31 -0600502static inline int regulator_get_error_flags(struct regulator *regulator,
503 unsigned int *flags)
Axel Haslam1b5b4222016-11-03 12:11:42 +0100504{
505 return -EINVAL;
506}
507
Bjorn Anderssone39ce482015-02-11 19:35:27 -0800508static inline int regulator_set_load(struct regulator *regulator, int load_uA)
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100509{
510 return REGULATOR_MODE_NORMAL;
511}
512
Mark Brownf59c8f92012-08-31 10:36:37 -0700513static inline int regulator_allow_bypass(struct regulator *regulator,
514 bool allow)
515{
516 return 0;
517}
518
Mark Brown3bc03122014-07-25 19:07:11 +0100519static inline struct regmap *regulator_get_regmap(struct regulator *regulator)
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300520{
521 return ERR_PTR(-EOPNOTSUPP);
522}
523
Mark Brown3bc03122014-07-25 19:07:11 +0100524static inline int regulator_get_hardware_vsel_register(struct regulator *regulator,
525 unsigned *vsel_reg,
526 unsigned *vsel_mask)
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300527{
528 return -EOPNOTSUPP;
529}
530
Mark Brown3bc03122014-07-25 19:07:11 +0100531static inline int regulator_list_hardware_vsel(struct regulator *regulator,
532 unsigned selector)
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300533{
534 return -EOPNOTSUPP;
535}
536
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100537static inline int regulator_register_notifier(struct regulator *regulator,
538 struct notifier_block *nb)
539{
540 return 0;
541}
542
Charles Keepax046db762015-03-05 15:39:20 +0000543static inline int devm_regulator_register_notifier(struct regulator *regulator,
544 struct notifier_block *nb)
545{
546 return 0;
547}
548
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100549static inline int regulator_unregister_notifier(struct regulator *regulator,
550 struct notifier_block *nb)
551{
552 return 0;
553}
554
Charles Keepax046db762015-03-05 15:39:20 +0000555static inline int devm_regulator_unregister_notifier(struct regulator *regulator,
556 struct notifier_block *nb)
557{
558 return 0;
559}
560
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100561static inline void *regulator_get_drvdata(struct regulator *regulator)
562{
563 return NULL;
564}
565
566static inline void regulator_set_drvdata(struct regulator *regulator,
567 void *data)
568{
569}
570
Philip Rakity1a8f85d2012-11-20 18:07:41 +0100571static inline int regulator_count_voltages(struct regulator *regulator)
572{
573 return 0;
574}
Suzuki K. Poulose5127e312015-07-10 16:26:38 +0100575
576static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector)
577{
578 return -EINVAL;
579}
580
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100581#endif
582
Viresh Kumar30f93ca2015-08-17 08:16:51 +0530583static inline int regulator_set_voltage_triplet(struct regulator *regulator,
584 int min_uV, int target_uV,
585 int max_uV)
586{
587 if (regulator_set_voltage(regulator, target_uV, max_uV) == 0)
588 return 0;
589
590 return regulator_set_voltage(regulator, min_uV, max_uV);
591}
592
Shawn Guo3f196572012-08-05 23:05:20 +0800593static inline int regulator_set_voltage_tol(struct regulator *regulator,
594 int new_uV, int tol_uV)
595{
Mark Browndc9ceed2013-07-04 17:27:14 +0100596 if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0)
597 return 0;
598 else
599 return regulator_set_voltage(regulator,
600 new_uV - tol_uV, new_uV + tol_uV);
Shawn Guo3f196572012-08-05 23:05:20 +0800601}
602
Mark Brownfe1e43f2012-11-14 16:47:10 +0900603static inline int regulator_is_supported_voltage_tol(struct regulator *regulator,
604 int target_uV, int tol_uV)
605{
606 return regulator_is_supported_voltage(regulator,
607 target_uV - tol_uV,
608 target_uV + tol_uV);
609}
610
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100611#endif