diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2014-04-08 12:49:33 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2014-04-29 08:01:32 +0200 |
commit | 485788954c1c4be5f64be143228fc54ec41c00f0 (patch) | |
tree | 7f2f7034af557314ceced91bd6ed7a75af33456f /include | |
parent | 0af79fbb6779921d3f1962773adb7fb57d3c89d4 (diff) | |
download | barebox-485788954c1c4be5f64be143228fc54ec41c00f0.tar.gz barebox-485788954c1c4be5f64be143228fc54ec41c00f0.tar.xz |
Add initial regulator support
Provide minimal regulator support. Only supported operations are enabling
and disabling regulators. Association of devices with their regulators is
limited to devicetree only. If regulator support is disabled the API expands
to static inline stubs so consumers can still use the API.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/regulator.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/include/regulator.h b/include/regulator.h new file mode 100644 index 0000000000..26a5e56046 --- /dev/null +++ b/include/regulator.h @@ -0,0 +1,47 @@ +#ifndef __REGULATOR_H +#define __REGULATOR_H + +/* struct regulator is an opaque object for consumers */ +struct regulator; + +struct regulator_dev { + struct regulator_ops *ops; +}; + +struct regulator_ops { + /* enable/disable regulator */ + int (*enable) (struct regulator_dev *); + int (*disable) (struct regulator_dev *); + int (*is_enabled) (struct regulator_dev *); +}; + +int of_regulator_register(struct regulator_dev *rd, struct device_node *node); + +void regulators_print(void); + +#ifdef CONFIG_REGULATOR + +struct regulator *regulator_get(struct device_d *, const char *); +int regulator_enable(struct regulator *); +int regulator_disable(struct regulator *); + +#else + +static inline struct regulator *regulator_get(struct device_d *dev, const char *id) +{ + return NULL; +} + +static inline int regulator_enable(struct regulator *r) +{ + return 0; +} + +static inline int regulator_disable(struct regulator *r) +{ + return 0; +} + +#endif + +#endif /* __REGULATOR_H */ |