1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * consumer.h -- SoC Regulator consumer support.
4  *
5  * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
6  *
7  * Author: Liam Girdwood <lrg@slimlogic.co.uk>
8  *
9  * Regulator Consumer Interface.
10  *
11  * A Power Management Regulator framework for SoC based devices.
12  * Features:-
13  *   o Voltage and current level control.
14  *   o Operating mode control.
15  *   o Regulator status.
16  *   o sysfs entries for showing client devices and status
17  *
18  * EXPERIMENTAL FEATURES:
19  *   Dynamic Regulator operating Mode Switching (DRMS) - allows regulators
20  *   to use most efficient operating mode depending upon voltage and load and
21  *   is transparent to client drivers.
22  *
23  *   e.g. Devices x,y,z share regulator r. Device x and y draw 20mA each during
24  *   IO and 1mA at idle. Device z draws 100mA when under load and 5mA when
25  *   idling. Regulator r has > 90% efficiency in NORMAL mode at loads > 100mA
26  *   but this drops rapidly to 60% when below 100mA. Regulator r has > 90%
27  *   efficiency in IDLE mode at loads < 10mA. Thus regulator r will operate
28  *   in normal mode for loads > 10mA and in IDLE mode for load <= 10mA.
29  */
30 
31 #ifndef __LINUX_REGULATOR_CONSUMER_H_
32 #define __LINUX_REGULATOR_CONSUMER_H_
33 
34 #include <linux/err.h>
35 #include <linux/suspend.h>
36 
37 struct device;
38 struct notifier_block;
39 struct regmap;
40 struct regulator_dev;
41 
42 /*
43  * Regulator operating modes.
44  *
45  * Regulators can run in a variety of different operating modes depending on
46  * output load. This allows further system power savings by selecting the
47  * best (and most efficient) regulator mode for a desired load.
48  *
49  * Most drivers will only care about NORMAL. The modes below are generic and
50  * will probably not match the naming convention of your regulator data sheet
51  * but should match the use cases in the datasheet.
52  *
53  * In order of power efficiency (least efficient at top).
54  *
55  *  Mode       Description
56  *  FAST       Regulator can handle fast changes in it's load.
57  *             e.g. useful in CPU voltage & frequency scaling where
58  *             load can quickly increase with CPU frequency increases.
59  *
60  *  NORMAL     Normal regulator power supply mode. Most drivers will
61  *             use this mode.
62  *
63  *  IDLE       Regulator runs in a more efficient mode for light
64  *             loads. Can be used for devices that have a low power
65  *             requirement during periods of inactivity. This mode
66  *             may be more noisy than NORMAL and may not be able
67  *             to handle fast load switching.
68  *
69  *  STANDBY    Regulator runs in the most efficient mode for very
70  *             light loads. Can be used by devices when they are
71  *             in a sleep/standby state. This mode is likely to be
72  *             the most noisy and may not be able to handle fast load
73  *             switching.
74  *
75  * NOTE: Most regulators will only support a subset of these modes. Some
76  * will only just support NORMAL.
77  *
78  * These modes can be OR'ed together to make up a mask of valid register modes.
79  */
80 
81 #define REGULATOR_MODE_INVALID			0x0
82 #define REGULATOR_MODE_FAST			0x1
83 #define REGULATOR_MODE_NORMAL			0x2
84 #define REGULATOR_MODE_IDLE			0x4
85 #define REGULATOR_MODE_STANDBY			0x8
86 
87 /*
88  * Regulator notifier events.
89  *
90  * UNDER_VOLTAGE  Regulator output is under voltage.
91  * OVER_CURRENT   Regulator output current is too high.
92  * REGULATION_OUT Regulator output is out of regulation.
93  * FAIL           Regulator output has failed.
94  * OVER_TEMP      Regulator over temp.
95  * FORCE_DISABLE  Regulator forcibly shut down by software.
96  * VOLTAGE_CHANGE Regulator voltage changed.
97  *                Data passed is old voltage cast to (void *).
98  * DISABLE        Regulator was disabled.
99  * PRE_VOLTAGE_CHANGE   Regulator is about to have voltage changed.
100  *                      Data passed is "struct pre_voltage_change_data"
101  * ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason.
102  *                      Data passed is old voltage cast to (void *).
103  * PRE_DISABLE    Regulator is about to be disabled
104  * ABORT_DISABLE  Regulator disable failed for some reason
105  *
106  * NOTE: These events can be OR'ed together when passed into handler.
107  */
108 
109 #define REGULATOR_EVENT_UNDER_VOLTAGE		0x01
110 #define REGULATOR_EVENT_OVER_CURRENT		0x02
111 #define REGULATOR_EVENT_REGULATION_OUT		0x04
112 #define REGULATOR_EVENT_FAIL			0x08
113 #define REGULATOR_EVENT_OVER_TEMP		0x10
114 #define REGULATOR_EVENT_FORCE_DISABLE		0x20
115 #define REGULATOR_EVENT_VOLTAGE_CHANGE		0x40
116 #define REGULATOR_EVENT_DISABLE			0x80
117 #define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE	0x100
118 #define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE	0x200
119 #define REGULATOR_EVENT_PRE_DISABLE		0x400
120 #define REGULATOR_EVENT_ABORT_DISABLE		0x800
121 #define REGULATOR_EVENT_ENABLE			0x1000
122 /*
123  * Following notifications should be emitted only if detected condition
124  * is such that the HW is likely to still be working but consumers should
125  * take a recovery action to prevent problems esacalating into errors.
126  */
127 #define REGULATOR_EVENT_UNDER_VOLTAGE_WARN	0x2000
128 #define REGULATOR_EVENT_OVER_CURRENT_WARN	0x4000
129 #define REGULATOR_EVENT_OVER_VOLTAGE_WARN	0x8000
130 #define REGULATOR_EVENT_OVER_TEMP_WARN		0x10000
131 #define REGULATOR_EVENT_WARN_MASK		0x1E000
132 
133 /*
134  * Regulator errors that can be queried using regulator_get_error_flags
135  *
136  * UNDER_VOLTAGE  Regulator output is under voltage.
137  * OVER_CURRENT   Regulator output current is too high.
138  * REGULATION_OUT Regulator output is out of regulation.
139  * FAIL           Regulator output has failed.
140  * OVER_TEMP      Regulator over temp.
141  *
142  * NOTE: These errors can be OR'ed together.
143  */
144 
145 #define REGULATOR_ERROR_UNDER_VOLTAGE		BIT(1)
146 #define REGULATOR_ERROR_OVER_CURRENT		BIT(2)
147 #define REGULATOR_ERROR_REGULATION_OUT		BIT(3)
148 #define REGULATOR_ERROR_FAIL			BIT(4)
149 #define REGULATOR_ERROR_OVER_TEMP		BIT(5)
150 
151 #define REGULATOR_ERROR_UNDER_VOLTAGE_WARN	BIT(6)
152 #define REGULATOR_ERROR_OVER_CURRENT_WARN	BIT(7)
153 #define REGULATOR_ERROR_OVER_VOLTAGE_WARN	BIT(8)
154 #define REGULATOR_ERROR_OVER_TEMP_WARN		BIT(9)
155 
156 /**
157  * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event
158  *
159  * @old_uV: Current voltage before change.
160  * @min_uV: Min voltage we'll change to.
161  * @max_uV: Max voltage we'll change to.
162  */
163 struct pre_voltage_change_data {
164 	unsigned long old_uV;
165 	unsigned long min_uV;
166 	unsigned long max_uV;
167 };
168 
169 struct regulator;
170 
171 /**
172  * struct regulator_bulk_data - Data used for bulk regulator operations.
173  *
174  * @supply:       The name of the supply.  Initialised by the user before
175  *                using the bulk regulator APIs.
176  * @init_load_uA: After getting the regulator, regulator_set_load() will be
177  *                called with this load.  Initialised by the user before
178  *                using the bulk regulator APIs.
179  * @consumer:     The regulator consumer for the supply.  This will be managed
180  *                by the bulk API.
181  *
182  * The regulator APIs provide a series of regulator_bulk_() API calls as
183  * a convenience to consumers which require multiple supplies.  This
184  * structure is used to manage data for these calls.
185  */
186 struct regulator_bulk_data {
187 	const char *supply;
188 	int init_load_uA;
189 	struct regulator *consumer;
190 
191 	/* private: Internal use */
192 	int ret;
193 };
194 
195 #if defined(CONFIG_REGULATOR)
196 
197 /* regulator get and put */
198 struct regulator *__must_check regulator_get(struct device *dev,
199 					     const char *id);
200 struct regulator *__must_check devm_regulator_get(struct device *dev,
201 					     const char *id);
202 struct regulator *__must_check regulator_get_exclusive(struct device *dev,
203 						       const char *id);
204 struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev,
205 							const char *id);
206 struct regulator *__must_check regulator_get_optional(struct device *dev,
207 						      const char *id);
208 struct regulator *__must_check devm_regulator_get_optional(struct device *dev,
209 							   const char *id);
210 int devm_regulator_get_enable(struct device *dev, const char *id);
211 int devm_regulator_get_enable_optional(struct device *dev, const char *id);
212 void regulator_put(struct regulator *regulator);
213 void devm_regulator_put(struct regulator *regulator);
214 
215 int regulator_register_supply_alias(struct device *dev, const char *id,
216 				    struct device *alias_dev,
217 				    const char *alias_id);
218 void regulator_unregister_supply_alias(struct device *dev, const char *id);
219 
220 int regulator_bulk_register_supply_alias(struct device *dev,
221 					 const char *const *id,
222 					 struct device *alias_dev,
223 					 const char *const *alias_id,
224 					 int num_id);
225 void regulator_bulk_unregister_supply_alias(struct device *dev,
226 					    const char * const *id, int num_id);
227 
228 int devm_regulator_register_supply_alias(struct device *dev, const char *id,
229 					 struct device *alias_dev,
230 					 const char *alias_id);
231 
232 int devm_regulator_bulk_register_supply_alias(struct device *dev,
233 					      const char *const *id,
234 					      struct device *alias_dev,
235 					      const char *const *alias_id,
236 					      int num_id);
237 
238 /* regulator output control and status */
239 int __must_check regulator_enable(struct regulator *regulator);
240 int regulator_disable(struct regulator *regulator);
241 int regulator_force_disable(struct regulator *regulator);
242 int regulator_is_enabled(struct regulator *regulator);
243 int regulator_disable_deferred(struct regulator *regulator, int ms);
244 
245 int __must_check regulator_bulk_get(struct device *dev, int num_consumers,
246 				    struct regulator_bulk_data *consumers);
247 int __must_check of_regulator_bulk_get_all(struct device *dev, struct device_node *np,
248 					   struct regulator_bulk_data **consumers);
249 int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers,
250 					 struct regulator_bulk_data *consumers);
251 void devm_regulator_bulk_put(struct regulator_bulk_data *consumers);
252 int __must_check devm_regulator_bulk_get_exclusive(struct device *dev, int num_consumers,
253 						   struct regulator_bulk_data *consumers);
254 int __must_check devm_regulator_bulk_get_const(
255 	struct device *dev, int num_consumers,
256 	const struct regulator_bulk_data *in_consumers,
257 	struct regulator_bulk_data **out_consumers);
258 int __must_check regulator_bulk_enable(int num_consumers,
259 				       struct regulator_bulk_data *consumers);
260 int devm_regulator_bulk_get_enable(struct device *dev, int num_consumers,
261 				   const char * const *id);
262 int regulator_bulk_disable(int num_consumers,
263 			   struct regulator_bulk_data *consumers);
264 int regulator_bulk_force_disable(int num_consumers,
265 			   struct regulator_bulk_data *consumers);
266 void regulator_bulk_free(int num_consumers,
267 			 struct regulator_bulk_data *consumers);
268 
269 int regulator_count_voltages(struct regulator *regulator);
270 int regulator_list_voltage(struct regulator *regulator, unsigned selector);
271 int regulator_is_supported_voltage(struct regulator *regulator,
272 				   int min_uV, int max_uV);
273 unsigned int regulator_get_linear_step(struct regulator *regulator);
274 int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
275 int regulator_set_voltage_time(struct regulator *regulator,
276 			       int old_uV, int new_uV);
277 int regulator_get_voltage(struct regulator *regulator);
278 int regulator_sync_voltage(struct regulator *regulator);
279 int regulator_set_current_limit(struct regulator *regulator,
280 			       int min_uA, int max_uA);
281 int regulator_get_current_limit(struct regulator *regulator);
282 
283 int regulator_set_mode(struct regulator *regulator, unsigned int mode);
284 unsigned int regulator_get_mode(struct regulator *regulator);
285 int regulator_get_error_flags(struct regulator *regulator,
286 				unsigned int *flags);
287 int regulator_set_load(struct regulator *regulator, int load_uA);
288 
289 int regulator_allow_bypass(struct regulator *regulator, bool allow);
290 
291 struct regmap *regulator_get_regmap(struct regulator *regulator);
292 int regulator_get_hardware_vsel_register(struct regulator *regulator,
293 					 unsigned *vsel_reg,
294 					 unsigned *vsel_mask);
295 int regulator_list_hardware_vsel(struct regulator *regulator,
296 				 unsigned selector);
297 
298 /* regulator notifier block */
299 int regulator_register_notifier(struct regulator *regulator,
300 			      struct notifier_block *nb);
301 int devm_regulator_register_notifier(struct regulator *regulator,
302 				     struct notifier_block *nb);
303 int regulator_unregister_notifier(struct regulator *regulator,
304 				struct notifier_block *nb);
305 void devm_regulator_unregister_notifier(struct regulator *regulator,
306 					struct notifier_block *nb);
307 
308 /* regulator suspend */
309 int regulator_suspend_enable(struct regulator_dev *rdev,
310 			     suspend_state_t state);
311 int regulator_suspend_disable(struct regulator_dev *rdev,
312 			      suspend_state_t state);
313 int regulator_set_suspend_voltage(struct regulator *regulator, int min_uV,
314 				  int max_uV, suspend_state_t state);
315 
316 /* driver data - core doesn't touch */
317 void *regulator_get_drvdata(struct regulator *regulator);
318 void regulator_set_drvdata(struct regulator *regulator, void *data);
319 
320 /* misc helpers */
321 
322 void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
323 				     const char *const *supply_names,
324 				     unsigned int num_supplies);
325 
326 bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2);
327 
328 #else
329 
330 /*
331  * Make sure client drivers will still build on systems with no software
332  * controllable voltage or current regulators.
333  */
regulator_get(struct device * dev,const char * id)334 static inline struct regulator *__must_check regulator_get(struct device *dev,
335 	const char *id)
336 {
337 	/* Nothing except the stubbed out regulator API should be
338 	 * looking at the value except to check if it is an error
339 	 * value. Drivers are free to handle NULL specifically by
340 	 * skipping all regulator API calls, but they don't have to.
341 	 * Drivers which don't, should make sure they properly handle
342 	 * corner cases of the API, such as regulator_get_voltage()
343 	 * returning 0.
344 	 */
345 	return NULL;
346 }
347 
348 static inline struct regulator *__must_check
devm_regulator_get(struct device * dev,const char * id)349 devm_regulator_get(struct device *dev, const char *id)
350 {
351 	return NULL;
352 }
353 
354 static inline struct regulator *__must_check
regulator_get_exclusive(struct device * dev,const char * id)355 regulator_get_exclusive(struct device *dev, const char *id)
356 {
357 	return ERR_PTR(-ENODEV);
358 }
359 
360 static inline struct regulator *__must_check
devm_regulator_get_exclusive(struct device * dev,const char * id)361 devm_regulator_get_exclusive(struct device *dev, const char *id)
362 {
363 	return ERR_PTR(-ENODEV);
364 }
365 
devm_regulator_get_enable(struct device * dev,const char * id)366 static inline int devm_regulator_get_enable(struct device *dev, const char *id)
367 {
368 	return 0;
369 }
370 
devm_regulator_get_enable_optional(struct device * dev,const char * id)371 static inline int devm_regulator_get_enable_optional(struct device *dev,
372 						     const char *id)
373 {
374 	return 0;
375 }
376 
377 static inline struct regulator *__must_check
regulator_get_optional(struct device * dev,const char * id)378 regulator_get_optional(struct device *dev, const char *id)
379 {
380 	return ERR_PTR(-ENODEV);
381 }
382 
383 
384 static inline struct regulator *__must_check
devm_regulator_get_optional(struct device * dev,const char * id)385 devm_regulator_get_optional(struct device *dev, const char *id)
386 {
387 	return ERR_PTR(-ENODEV);
388 }
389 
regulator_put(struct regulator * regulator)390 static inline void regulator_put(struct regulator *regulator)
391 {
392 }
393 
devm_regulator_put(struct regulator * regulator)394 static inline void devm_regulator_put(struct regulator *regulator)
395 {
396 }
397 
devm_regulator_bulk_put(struct regulator_bulk_data * consumers)398 static inline void devm_regulator_bulk_put(struct regulator_bulk_data *consumers)
399 {
400 }
401 
regulator_register_supply_alias(struct device * dev,const char * id,struct device * alias_dev,const char * alias_id)402 static inline int regulator_register_supply_alias(struct device *dev,
403 						  const char *id,
404 						  struct device *alias_dev,
405 						  const char *alias_id)
406 {
407 	return 0;
408 }
409 
regulator_unregister_supply_alias(struct device * dev,const char * id)410 static inline void regulator_unregister_supply_alias(struct device *dev,
411 						    const char *id)
412 {
413 }
414 
regulator_bulk_register_supply_alias(struct device * dev,const char * const * id,struct device * alias_dev,const char * const * alias_id,int num_id)415 static inline int regulator_bulk_register_supply_alias(struct device *dev,
416 						const char *const *id,
417 						struct device *alias_dev,
418 						const char * const *alias_id,
419 						int num_id)
420 {
421 	return 0;
422 }
423 
regulator_bulk_unregister_supply_alias(struct device * dev,const char * const * id,int num_id)424 static inline void regulator_bulk_unregister_supply_alias(struct device *dev,
425 						const char * const *id,
426 						int num_id)
427 {
428 }
429 
devm_regulator_register_supply_alias(struct device * dev,const char * id,struct device * alias_dev,const char * alias_id)430 static inline int devm_regulator_register_supply_alias(struct device *dev,
431 						       const char *id,
432 						       struct device *alias_dev,
433 						       const char *alias_id)
434 {
435 	return 0;
436 }
437 
devm_regulator_bulk_register_supply_alias(struct device * dev,const char * const * id,struct device * alias_dev,const char * const * alias_id,int num_id)438 static inline int devm_regulator_bulk_register_supply_alias(struct device *dev,
439 						const char *const *id,
440 						struct device *alias_dev,
441 						const char *const *alias_id,
442 						int num_id)
443 {
444 	return 0;
445 }
446 
regulator_enable(struct regulator * regulator)447 static inline int regulator_enable(struct regulator *regulator)
448 {
449 	return 0;
450 }
451 
regulator_disable(struct regulator * regulator)452 static inline int regulator_disable(struct regulator *regulator)
453 {
454 	return 0;
455 }
456 
regulator_force_disable(struct regulator * regulator)457 static inline int regulator_force_disable(struct regulator *regulator)
458 {
459 	return 0;
460 }
461 
regulator_disable_deferred(struct regulator * regulator,int ms)462 static inline int regulator_disable_deferred(struct regulator *regulator,
463 					     int ms)
464 {
465 	return 0;
466 }
467 
regulator_is_enabled(struct regulator * regulator)468 static inline int regulator_is_enabled(struct regulator *regulator)
469 {
470 	return 1;
471 }
472 
regulator_bulk_get(struct device * dev,int num_consumers,struct regulator_bulk_data * consumers)473 static inline int regulator_bulk_get(struct device *dev,
474 				     int num_consumers,
475 				     struct regulator_bulk_data *consumers)
476 {
477 	return 0;
478 }
479 
devm_regulator_bulk_get(struct device * dev,int num_consumers,struct regulator_bulk_data * consumers)480 static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers,
481 					  struct regulator_bulk_data *consumers)
482 {
483 	return 0;
484 }
485 
of_regulator_bulk_get_all(struct device * dev,struct device_node * np,struct regulator_bulk_data ** consumers)486 static inline int of_regulator_bulk_get_all(struct device *dev, struct device_node *np,
487 					    struct regulator_bulk_data **consumers)
488 {
489 	return 0;
490 }
491 
devm_regulator_bulk_get_const(struct device * dev,int num_consumers,const struct regulator_bulk_data * in_consumers,struct regulator_bulk_data ** out_consumers)492 static inline int devm_regulator_bulk_get_const(
493 	struct device *dev, int num_consumers,
494 	const struct regulator_bulk_data *in_consumers,
495 	struct regulator_bulk_data **out_consumers)
496 {
497 	return 0;
498 }
499 
regulator_bulk_enable(int num_consumers,struct regulator_bulk_data * consumers)500 static inline int regulator_bulk_enable(int num_consumers,
501 					struct regulator_bulk_data *consumers)
502 {
503 	return 0;
504 }
505 
devm_regulator_bulk_get_enable(struct device * dev,int num_consumers,const char * const * id)506 static inline int devm_regulator_bulk_get_enable(struct device *dev,
507 						 int num_consumers,
508 						 const char * const *id)
509 {
510 	return 0;
511 }
512 
regulator_bulk_disable(int num_consumers,struct regulator_bulk_data * consumers)513 static inline int regulator_bulk_disable(int num_consumers,
514 					 struct regulator_bulk_data *consumers)
515 {
516 	return 0;
517 }
518 
regulator_bulk_force_disable(int num_consumers,struct regulator_bulk_data * consumers)519 static inline int regulator_bulk_force_disable(int num_consumers,
520 					struct regulator_bulk_data *consumers)
521 {
522 	return 0;
523 }
524 
regulator_bulk_free(int num_consumers,struct regulator_bulk_data * consumers)525 static inline void regulator_bulk_free(int num_consumers,
526 				       struct regulator_bulk_data *consumers)
527 {
528 }
529 
regulator_set_voltage(struct regulator * regulator,int min_uV,int max_uV)530 static inline int regulator_set_voltage(struct regulator *regulator,
531 					int min_uV, int max_uV)
532 {
533 	return 0;
534 }
535 
regulator_set_voltage_time(struct regulator * regulator,int old_uV,int new_uV)536 static inline int regulator_set_voltage_time(struct regulator *regulator,
537 					     int old_uV, int new_uV)
538 {
539 	return 0;
540 }
541 
regulator_get_voltage(struct regulator * regulator)542 static inline int regulator_get_voltage(struct regulator *regulator)
543 {
544 	return -EINVAL;
545 }
546 
regulator_sync_voltage(struct regulator * regulator)547 static inline int regulator_sync_voltage(struct regulator *regulator)
548 {
549 	return -EINVAL;
550 }
551 
regulator_is_supported_voltage(struct regulator * regulator,int min_uV,int max_uV)552 static inline int regulator_is_supported_voltage(struct regulator *regulator,
553 				   int min_uV, int max_uV)
554 {
555 	return 0;
556 }
557 
regulator_get_linear_step(struct regulator * regulator)558 static inline unsigned int regulator_get_linear_step(struct regulator *regulator)
559 {
560 	return 0;
561 }
562 
regulator_set_current_limit(struct regulator * regulator,int min_uA,int max_uA)563 static inline int regulator_set_current_limit(struct regulator *regulator,
564 					     int min_uA, int max_uA)
565 {
566 	return 0;
567 }
568 
regulator_get_current_limit(struct regulator * regulator)569 static inline int regulator_get_current_limit(struct regulator *regulator)
570 {
571 	return 0;
572 }
573 
regulator_set_mode(struct regulator * regulator,unsigned int mode)574 static inline int regulator_set_mode(struct regulator *regulator,
575 	unsigned int mode)
576 {
577 	return 0;
578 }
579 
regulator_get_mode(struct regulator * regulator)580 static inline unsigned int regulator_get_mode(struct regulator *regulator)
581 {
582 	return REGULATOR_MODE_NORMAL;
583 }
584 
regulator_get_error_flags(struct regulator * regulator,unsigned int * flags)585 static inline int regulator_get_error_flags(struct regulator *regulator,
586 					    unsigned int *flags)
587 {
588 	return -EINVAL;
589 }
590 
regulator_set_load(struct regulator * regulator,int load_uA)591 static inline int regulator_set_load(struct regulator *regulator, int load_uA)
592 {
593 	return 0;
594 }
595 
regulator_allow_bypass(struct regulator * regulator,bool allow)596 static inline int regulator_allow_bypass(struct regulator *regulator,
597 					 bool allow)
598 {
599 	return 0;
600 }
601 
regulator_get_regmap(struct regulator * regulator)602 static inline struct regmap *regulator_get_regmap(struct regulator *regulator)
603 {
604 	return ERR_PTR(-EOPNOTSUPP);
605 }
606 
regulator_get_hardware_vsel_register(struct regulator * regulator,unsigned * vsel_reg,unsigned * vsel_mask)607 static inline int regulator_get_hardware_vsel_register(struct regulator *regulator,
608 						       unsigned *vsel_reg,
609 						       unsigned *vsel_mask)
610 {
611 	return -EOPNOTSUPP;
612 }
613 
regulator_list_hardware_vsel(struct regulator * regulator,unsigned selector)614 static inline int regulator_list_hardware_vsel(struct regulator *regulator,
615 					       unsigned selector)
616 {
617 	return -EOPNOTSUPP;
618 }
619 
regulator_register_notifier(struct regulator * regulator,struct notifier_block * nb)620 static inline int regulator_register_notifier(struct regulator *regulator,
621 			      struct notifier_block *nb)
622 {
623 	return 0;
624 }
625 
devm_regulator_register_notifier(struct regulator * regulator,struct notifier_block * nb)626 static inline int devm_regulator_register_notifier(struct regulator *regulator,
627 						   struct notifier_block *nb)
628 {
629 	return 0;
630 }
631 
regulator_unregister_notifier(struct regulator * regulator,struct notifier_block * nb)632 static inline int regulator_unregister_notifier(struct regulator *regulator,
633 				struct notifier_block *nb)
634 {
635 	return 0;
636 }
637 
devm_regulator_unregister_notifier(struct regulator * regulator,struct notifier_block * nb)638 static inline int devm_regulator_unregister_notifier(struct regulator *regulator,
639 						     struct notifier_block *nb)
640 {
641 	return 0;
642 }
643 
regulator_suspend_enable(struct regulator_dev * rdev,suspend_state_t state)644 static inline int regulator_suspend_enable(struct regulator_dev *rdev,
645 					   suspend_state_t state)
646 {
647 	return -EINVAL;
648 }
649 
regulator_suspend_disable(struct regulator_dev * rdev,suspend_state_t state)650 static inline int regulator_suspend_disable(struct regulator_dev *rdev,
651 					    suspend_state_t state)
652 {
653 	return -EINVAL;
654 }
655 
regulator_set_suspend_voltage(struct regulator * regulator,int min_uV,int max_uV,suspend_state_t state)656 static inline int regulator_set_suspend_voltage(struct regulator *regulator,
657 						int min_uV, int max_uV,
658 						suspend_state_t state)
659 {
660 	return -EINVAL;
661 }
662 
regulator_get_drvdata(struct regulator * regulator)663 static inline void *regulator_get_drvdata(struct regulator *regulator)
664 {
665 	return NULL;
666 }
667 
regulator_set_drvdata(struct regulator * regulator,void * data)668 static inline void regulator_set_drvdata(struct regulator *regulator,
669 	void *data)
670 {
671 }
672 
regulator_count_voltages(struct regulator * regulator)673 static inline int regulator_count_voltages(struct regulator *regulator)
674 {
675 	return 0;
676 }
677 
regulator_list_voltage(struct regulator * regulator,unsigned selector)678 static inline int regulator_list_voltage(struct regulator *regulator, unsigned selector)
679 {
680 	return -EINVAL;
681 }
682 
683 static inline void
regulator_bulk_set_supply_names(struct regulator_bulk_data * consumers,const char * const * supply_names,unsigned int num_supplies)684 regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
685 				const char *const *supply_names,
686 				unsigned int num_supplies)
687 {
688 }
689 
690 static inline bool
regulator_is_equal(struct regulator * reg1,struct regulator * reg2)691 regulator_is_equal(struct regulator *reg1, struct regulator *reg2)
692 {
693 	return false;
694 }
695 #endif
696 
regulator_set_voltage_triplet(struct regulator * regulator,int min_uV,int target_uV,int max_uV)697 static inline int regulator_set_voltage_triplet(struct regulator *regulator,
698 						int min_uV, int target_uV,
699 						int max_uV)
700 {
701 	if (regulator_set_voltage(regulator, target_uV, max_uV) == 0)
702 		return 0;
703 
704 	return regulator_set_voltage(regulator, min_uV, max_uV);
705 }
706 
regulator_set_voltage_tol(struct regulator * regulator,int new_uV,int tol_uV)707 static inline int regulator_set_voltage_tol(struct regulator *regulator,
708 					    int new_uV, int tol_uV)
709 {
710 	if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0)
711 		return 0;
712 	else
713 		return regulator_set_voltage(regulator,
714 					     new_uV - tol_uV, new_uV + tol_uV);
715 }
716 
regulator_is_supported_voltage_tol(struct regulator * regulator,int target_uV,int tol_uV)717 static inline int regulator_is_supported_voltage_tol(struct regulator *regulator,
718 						     int target_uV, int tol_uV)
719 {
720 	return regulator_is_supported_voltage(regulator,
721 					      target_uV - tol_uV,
722 					      target_uV + tol_uV);
723 }
724 
725 #endif
726