blob: d347c805f923f8539b6430fa30119527edb7f244 [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
Paul Gortmaker313162d2012-01-30 11:46:54 -050038struct device;
39struct notifier_block;
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +030040struct regmap;
Liam Girdwoodb56daf12009-11-11 14:16:10 +000041
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +010042/*
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_FAST 0x1
82#define REGULATOR_MODE_NORMAL 0x2
83#define REGULATOR_MODE_IDLE 0x4
84#define REGULATOR_MODE_STANDBY 0x8
85
86/*
87 * Regulator notifier events.
88 *
89 * UNDER_VOLTAGE Regulator output is under voltage.
90 * OVER_CURRENT Regulator output current is too high.
91 * REGULATION_OUT Regulator output is out of regulation.
92 * FAIL Regulator output has failed.
93 * OVER_TEMP Regulator over temp.
Mark Brown84b68262009-12-01 21:12:27 +000094 * FORCE_DISABLE Regulator forcibly shut down by software.
Jonathan Cameronb136fb42009-01-19 18:20:58 +000095 * VOLTAGE_CHANGE Regulator voltage changed.
Heiko Stübner71795692014-08-28 12:36:04 -070096 * Data passed is old voltage cast to (void *).
Mark Brown84b68262009-12-01 21:12:27 +000097 * DISABLE Regulator was disabled.
Heiko Stübner71795692014-08-28 12:36:04 -070098 * PRE_VOLTAGE_CHANGE Regulator is about to have voltage changed.
99 * Data passed is "struct pre_voltage_change_data"
100 * ABORT_VOLTAGE_CHANGE Regulator voltage change failed for some reason.
101 * Data passed is old voltage cast to (void *).
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100102 *
103 * NOTE: These events can be OR'ed together when passed into handler.
104 */
105
106#define REGULATOR_EVENT_UNDER_VOLTAGE 0x01
107#define REGULATOR_EVENT_OVER_CURRENT 0x02
108#define REGULATOR_EVENT_REGULATION_OUT 0x04
109#define REGULATOR_EVENT_FAIL 0x08
110#define REGULATOR_EVENT_OVER_TEMP 0x10
111#define REGULATOR_EVENT_FORCE_DISABLE 0x20
Jonathan Cameronb136fb42009-01-19 18:20:58 +0000112#define REGULATOR_EVENT_VOLTAGE_CHANGE 0x40
Mark Brown84b68262009-12-01 21:12:27 +0000113#define REGULATOR_EVENT_DISABLE 0x80
Heiko Stübner71795692014-08-28 12:36:04 -0700114#define REGULATOR_EVENT_PRE_VOLTAGE_CHANGE 0x100
115#define REGULATOR_EVENT_ABORT_VOLTAGE_CHANGE 0x200
116
117/**
118 * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event
119 *
120 * @old_uV: Current voltage before change.
121 * @min_uV: Min voltage we'll change to.
122 * @max_uV: Max voltage we'll change to.
123 */
124struct pre_voltage_change_data {
125 unsigned long old_uV;
126 unsigned long min_uV;
127 unsigned long max_uV;
128};
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100129
130struct regulator;
131
132/**
133 * struct regulator_bulk_data - Data used for bulk regulator operations.
134 *
Mark Brown69279fb2008-12-31 12:52:41 +0000135 * @supply: The name of the supply. Initialised by the user before
136 * using the bulk regulator APIs.
137 * @consumer: The regulator consumer for the supply. This will be managed
138 * by the bulk API.
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100139 *
140 * The regulator APIs provide a series of regulator_bulk_() API calls as
141 * a convenience to consumers which require multiple supplies. This
142 * structure is used to manage data for these calls.
143 */
144struct regulator_bulk_data {
145 const char *supply;
146 struct regulator *consumer;
Mark Brownf21e0e82011-05-24 08:12:40 +0800147
Randy Dunlapbff747c2011-09-08 10:16:47 -0700148 /* private: Internal use */
Mark Brownf21e0e82011-05-24 08:12:40 +0800149 int ret;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100150};
151
152#if defined(CONFIG_REGULATOR)
153
154/* regulator get and put */
155struct regulator *__must_check regulator_get(struct device *dev,
156 const char *id);
Stephen Boyd070b9072012-01-16 19:39:58 -0800157struct regulator *__must_check devm_regulator_get(struct device *dev,
158 const char *id);
Mark Brown5ffbd132009-07-21 16:00:23 +0100159struct regulator *__must_check regulator_get_exclusive(struct device *dev,
160 const char *id);
Matthias Kaehlcke9efdd272013-08-25 17:54:13 +0200161struct regulator *__must_check devm_regulator_get_exclusive(struct device *dev,
162 const char *id);
Mark Brownde1dd9f2013-07-29 21:42:42 +0100163struct regulator *__must_check regulator_get_optional(struct device *dev,
164 const char *id);
165struct regulator *__must_check devm_regulator_get_optional(struct device *dev,
166 const char *id);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100167void regulator_put(struct regulator *regulator);
Axel Lin2950c4b2012-01-29 17:52:37 +0800168void devm_regulator_put(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100169
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100170int regulator_register_supply_alias(struct device *dev, const char *id,
171 struct device *alias_dev,
172 const char *alias_id);
173void regulator_unregister_supply_alias(struct device *dev, const char *id);
174
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100175int regulator_bulk_register_supply_alias(struct device *dev,
176 const char *const *id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100177 struct device *alias_dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100178 const char *const *alias_id,
179 int num_id);
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100180void regulator_bulk_unregister_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100181 const char * const *id, int num_id);
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100182
183int devm_regulator_register_supply_alias(struct device *dev, const char *id,
184 struct device *alias_dev,
185 const char *alias_id);
186void devm_regulator_unregister_supply_alias(struct device *dev,
187 const char *id);
188
189int devm_regulator_bulk_register_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100190 const char *const *id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100191 struct device *alias_dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100192 const char *const *alias_id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100193 int num_id);
194void devm_regulator_bulk_unregister_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100195 const char *const *id,
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100196 int num_id);
197
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100198/* regulator output control and status */
Mark Brownc8801a82012-03-19 16:35:48 +0000199int __must_check regulator_enable(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100200int regulator_disable(struct regulator *regulator);
201int regulator_force_disable(struct regulator *regulator);
202int regulator_is_enabled(struct regulator *regulator);
Mark Brownda07ecd2011-09-11 09:53:50 +0100203int regulator_disable_deferred(struct regulator *regulator, int ms);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100204
Mark Brownc8801a82012-03-19 16:35:48 +0000205int __must_check regulator_bulk_get(struct device *dev, int num_consumers,
206 struct regulator_bulk_data *consumers);
207int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers,
208 struct regulator_bulk_data *consumers);
209int __must_check regulator_bulk_enable(int num_consumers,
210 struct regulator_bulk_data *consumers);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100211int regulator_bulk_disable(int num_consumers,
212 struct regulator_bulk_data *consumers);
Donggeun Kime1de2f42012-01-03 16:22:03 +0900213int regulator_bulk_force_disable(int num_consumers,
214 struct regulator_bulk_data *consumers);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100215void regulator_bulk_free(int num_consumers,
216 struct regulator_bulk_data *consumers);
217
Marek Szyprowskid1e7de32012-12-04 15:01:01 +0100218int regulator_can_change_voltage(struct regulator *regulator);
David Brownell4367cfd2009-02-26 11:48:36 -0800219int regulator_count_voltages(struct regulator *regulator);
220int regulator_list_voltage(struct regulator *regulator, unsigned selector);
Mark Browna7a1ad92009-07-21 16:00:24 +0100221int regulator_is_supported_voltage(struct regulator *regulator,
222 int min_uV, int max_uV);
Paul Walmsley2a668a82013-06-07 08:06:56 +0000223unsigned int regulator_get_linear_step(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100224int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV);
Linus Walleij88cd222b2011-03-17 13:24:52 +0100225int regulator_set_voltage_time(struct regulator *regulator,
226 int old_uV, int new_uV);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100227int regulator_get_voltage(struct regulator *regulator);
Mark Brown606a2562010-12-16 15:49:36 +0000228int regulator_sync_voltage(struct regulator *regulator);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100229int regulator_set_current_limit(struct regulator *regulator,
230 int min_uA, int max_uA);
231int regulator_get_current_limit(struct regulator *regulator);
232
233int regulator_set_mode(struct regulator *regulator, unsigned int mode);
234unsigned int regulator_get_mode(struct regulator *regulator);
235int regulator_set_optimum_mode(struct regulator *regulator, int load_uA);
236
Mark Brownf59c8f92012-08-31 10:36:37 -0700237int regulator_allow_bypass(struct regulator *regulator, bool allow);
238
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300239struct regmap *regulator_get_regmap(struct regulator *regulator);
240int regulator_get_hardware_vsel_register(struct regulator *regulator,
241 unsigned *vsel_reg,
242 unsigned *vsel_mask);
243int regulator_list_hardware_vsel(struct regulator *regulator,
244 unsigned selector);
245
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100246/* regulator notifier block */
247int regulator_register_notifier(struct regulator *regulator,
248 struct notifier_block *nb);
249int regulator_unregister_notifier(struct regulator *regulator,
250 struct notifier_block *nb);
251
252/* driver data - core doesn't touch */
253void *regulator_get_drvdata(struct regulator *regulator);
254void regulator_set_drvdata(struct regulator *regulator, void *data);
255
256#else
257
258/*
259 * Make sure client drivers will still build on systems with no software
260 * controllable voltage or current regulators.
261 */
262static inline struct regulator *__must_check regulator_get(struct device *dev,
263 const char *id)
264{
265 /* Nothing except the stubbed out regulator API should be
266 * looking at the value except to check if it is an error
Jean Delvarebe1a50d2010-04-03 17:37:45 +0200267 * value. Drivers are free to handle NULL specifically by
268 * skipping all regulator API calls, but they don't have to.
269 * Drivers which don't, should make sure they properly handle
270 * corner cases of the API, such as regulator_get_voltage()
271 * returning 0.
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100272 */
Jean Delvarebe1a50d2010-04-03 17:37:45 +0200273 return NULL;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100274}
Stephen Boyd070b9072012-01-16 19:39:58 -0800275
276static inline struct regulator *__must_check
277devm_regulator_get(struct device *dev, const char *id)
278{
279 return NULL;
280}
281
Mark Brownde1dd9f2013-07-29 21:42:42 +0100282static inline struct regulator *__must_check
Mark Brown4bdfb272013-07-29 21:00:53 +0100283regulator_get_exclusive(struct device *dev, const char *id)
284{
285 return NULL;
286}
287
Mark Brownde1dd9f2013-07-29 21:42:42 +0100288static inline struct regulator *__must_check
289regulator_get_optional(struct device *dev, const char *id)
290{
Tim Krygerdf7926f2014-04-17 11:55:24 -0700291 return ERR_PTR(-ENODEV);
Mark Brownde1dd9f2013-07-29 21:42:42 +0100292}
293
Mark Brown4bdfb272013-07-29 21:00:53 +0100294
295static inline struct regulator *__must_check
Mark Brownde1dd9f2013-07-29 21:42:42 +0100296devm_regulator_get_optional(struct device *dev, const char *id)
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100297{
Tim Krygerdf7926f2014-04-17 11:55:24 -0700298 return ERR_PTR(-ENODEV);
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100299}
300
301static inline void regulator_put(struct regulator *regulator)
302{
303}
304
Axel Lin2950c4b2012-01-29 17:52:37 +0800305static inline void devm_regulator_put(struct regulator *regulator)
306{
307}
308
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100309static inline int regulator_register_supply_alias(struct device *dev,
310 const char *id,
311 struct device *alias_dev,
312 const char *alias_id)
313{
314 return 0;
315}
316
317static inline void regulator_unregister_supply_alias(struct device *dev,
318 const char *id)
319{
320}
321
322static inline int regulator_bulk_register_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100323 const char *const *id,
324 struct device *alias_dev,
325 const char * const *alias_id,
326 int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100327{
328 return 0;
329}
330
331static inline void regulator_bulk_unregister_supply_alias(struct device *dev,
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100332 const char * const *id,
333 int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100334{
335}
336
337static inline int devm_regulator_register_supply_alias(struct device *dev,
338 const char *id,
339 struct device *alias_dev,
340 const char *alias_id)
341{
342 return 0;
343}
344
345static inline void devm_regulator_unregister_supply_alias(struct device *dev,
346 const char *id)
347{
348}
349
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100350static inline int devm_regulator_bulk_register_supply_alias(struct device *dev,
351 const char *const *id,
352 struct device *alias_dev,
353 const char *const *alias_id,
354 int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100355{
356 return 0;
357}
358
359static inline void devm_regulator_bulk_unregister_supply_alias(
Lee Jones9f8c0fe2014-05-23 16:44:10 +0100360 struct device *dev, const char *const *id, int num_id)
Charles Keepaxa06ccd92013-10-15 20:14:20 +0100361{
362}
363
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100364static inline int regulator_enable(struct regulator *regulator)
365{
366 return 0;
367}
368
369static inline int regulator_disable(struct regulator *regulator)
370{
371 return 0;
372}
373
MyungJoo Ham935a5212012-01-02 18:49:32 +0900374static inline int regulator_force_disable(struct regulator *regulator)
375{
376 return 0;
377}
378
Mark Brownda07ecd2011-09-11 09:53:50 +0100379static inline int regulator_disable_deferred(struct regulator *regulator,
380 int ms)
381{
382 return 0;
383}
384
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100385static inline int regulator_is_enabled(struct regulator *regulator)
386{
387 return 1;
388}
389
390static inline int regulator_bulk_get(struct device *dev,
391 int num_consumers,
392 struct regulator_bulk_data *consumers)
393{
394 return 0;
395}
396
Axel Line24abd62012-01-27 12:55:28 +0800397static inline int devm_regulator_bulk_get(struct device *dev, int num_consumers,
398 struct regulator_bulk_data *consumers)
399{
400 return 0;
401}
402
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100403static inline int regulator_bulk_enable(int num_consumers,
404 struct regulator_bulk_data *consumers)
405{
406 return 0;
407}
408
409static inline int regulator_bulk_disable(int num_consumers,
410 struct regulator_bulk_data *consumers)
411{
412 return 0;
413}
414
Donggeun Kime1de2f42012-01-03 16:22:03 +0900415static inline int regulator_bulk_force_disable(int num_consumers,
416 struct regulator_bulk_data *consumers)
417{
418 return 0;
419}
420
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100421static inline void regulator_bulk_free(int num_consumers,
422 struct regulator_bulk_data *consumers)
423{
424}
425
Arnd Bergmannb14903e2014-06-04 16:46:00 +0200426static inline int regulator_can_change_voltage(struct regulator *regulator)
427{
428 return 0;
429}
430
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100431static inline int regulator_set_voltage(struct regulator *regulator,
432 int min_uV, int max_uV)
433{
434 return 0;
435}
436
Viresh Kumard660e922014-05-27 17:37:29 +0530437static inline int regulator_set_voltage_time(struct regulator *regulator,
438 int old_uV, int new_uV)
439{
440 return 0;
441}
442
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100443static inline int regulator_get_voltage(struct regulator *regulator)
444{
Mark Brown08aed2f2012-06-11 20:14:24 +0800445 return -EINVAL;
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100446}
447
Philip Rakity4fe23792012-06-30 16:05:36 -0700448static inline int regulator_is_supported_voltage(struct regulator *regulator,
449 int min_uV, int max_uV)
450{
451 return 0;
452}
453
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100454static inline int regulator_set_current_limit(struct regulator *regulator,
455 int min_uA, int max_uA)
456{
457 return 0;
458}
459
460static inline int regulator_get_current_limit(struct regulator *regulator)
461{
462 return 0;
463}
464
465static inline int regulator_set_mode(struct regulator *regulator,
466 unsigned int mode)
467{
468 return 0;
469}
470
471static inline unsigned int regulator_get_mode(struct regulator *regulator)
472{
473 return REGULATOR_MODE_NORMAL;
474}
475
476static inline int regulator_set_optimum_mode(struct regulator *regulator,
477 int load_uA)
478{
479 return REGULATOR_MODE_NORMAL;
480}
481
Mark Brownf59c8f92012-08-31 10:36:37 -0700482static inline int regulator_allow_bypass(struct regulator *regulator,
483 bool allow)
484{
485 return 0;
486}
487
Mark Brown3bc03122014-07-25 19:07:11 +0100488static inline struct regmap *regulator_get_regmap(struct regulator *regulator)
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300489{
490 return ERR_PTR(-EOPNOTSUPP);
491}
492
Mark Brown3bc03122014-07-25 19:07:11 +0100493static inline int regulator_get_hardware_vsel_register(struct regulator *regulator,
494 unsigned *vsel_reg,
495 unsigned *vsel_mask)
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300496{
497 return -EOPNOTSUPP;
498}
499
Mark Brown3bc03122014-07-25 19:07:11 +0100500static inline int regulator_list_hardware_vsel(struct regulator *regulator,
501 unsigned selector)
Tuomas Tynkkynen04eca282014-07-21 18:38:48 +0300502{
503 return -EOPNOTSUPP;
504}
505
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100506static inline int regulator_register_notifier(struct regulator *regulator,
507 struct notifier_block *nb)
508{
509 return 0;
510}
511
512static inline int regulator_unregister_notifier(struct regulator *regulator,
513 struct notifier_block *nb)
514{
515 return 0;
516}
517
518static inline void *regulator_get_drvdata(struct regulator *regulator)
519{
520 return NULL;
521}
522
523static inline void regulator_set_drvdata(struct regulator *regulator,
524 void *data)
525{
526}
527
Philip Rakity1a8f85d2012-11-20 18:07:41 +0100528static inline int regulator_count_voltages(struct regulator *regulator)
529{
530 return 0;
531}
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100532#endif
533
Shawn Guo3f196572012-08-05 23:05:20 +0800534static inline int regulator_set_voltage_tol(struct regulator *regulator,
535 int new_uV, int tol_uV)
536{
Mark Browndc9ceed2013-07-04 17:27:14 +0100537 if (regulator_set_voltage(regulator, new_uV, new_uV + tol_uV) == 0)
538 return 0;
539 else
540 return regulator_set_voltage(regulator,
541 new_uV - tol_uV, new_uV + tol_uV);
Shawn Guo3f196572012-08-05 23:05:20 +0800542}
543
Mark Brownfe1e43f2012-11-14 16:47:10 +0900544static inline int regulator_is_supported_voltage_tol(struct regulator *regulator,
545 int target_uV, int tol_uV)
546{
547 return regulator_is_supported_voltage(regulator,
548 target_uV - tol_uV,
549 target_uV + tol_uV);
550}
551
Liam Girdwoode2ce4eaa2008-04-30 15:10:07 +0100552#endif