diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2021-02-08 20:18:24 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-02-10 10:14:29 +0100 |
commit | 6ee83ce08b24ed66dd24b7bc572a363ff95b4d6c (patch) | |
tree | 1e1f01b2ec20b8ff249eacac02926cc94b74aed6 /include/regulator.h | |
parent | f38f34a2f41e5981f2995231d94688d31104befc (diff) | |
download | barebox-6ee83ce08b24ed66dd24b7bc572a363ff95b4d6c.tar.gz |
regulator: add regulator_get_voltage() to API
ADC drivers need to query their reference regulator's voltage to
format their raw readings. Provide regulator_get_voltage() so ADC
drivers need not hardcode a reference voltage. Regulator drivers
that don't support this (i.e. nearly everything in-tree) will
have the function return with -EINVAL.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/regulator.h')
-rw-r--r-- | include/regulator.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/regulator.h b/include/regulator.h index 7c2a01b687..524e53042c 100644 --- a/include/regulator.h +++ b/include/regulator.h @@ -51,6 +51,7 @@ struct regulator_bulk_data { * @disable_val: Disabling value for control when using regmap enable/disable ops * @enable_is_inverted: A flag to indicate set enable_mask bits to disable * when using regulator_enable_regmap and friends APIs. + * @fixed_uV: Fixed voltage of rails. */ struct regulator_desc { @@ -73,6 +74,7 @@ struct regulator_desc { const struct regulator_linear_range *linear_ranges; int n_linear_ranges; + int fixed_uV; }; struct regulator_dev { @@ -92,6 +94,9 @@ struct regulator_ops { int (*list_voltage) (struct regulator_dev *, unsigned int); int (*set_voltage_sel) (struct regulator_dev *, unsigned int); int (*map_voltage)(struct regulator_dev *, int min_uV, int max_uV); + + int (*get_voltage) (struct regulator_dev *); + int (*get_voltage_sel) (struct regulator_dev *); }; /* @@ -166,6 +171,17 @@ int regulator_bulk_disable(int num_consumers, void regulator_bulk_free(int num_consumers, struct regulator_bulk_data *consumers); +/** + * regulator_get_voltage - get regulator output voltage + * @regulator: regulator source + * + * This returns the current regulator voltage in uV. + * + * NOTE: If the regulator is disabled it will return the voltage value. This + * function should not be used to determine regulator state. + */ +int regulator_get_voltage(struct regulator *regulator); + /* * Helper functions intended to be used by regulator drivers prior registering * their regulators. @@ -223,6 +239,11 @@ static inline void regulator_bulk_free(int num_consumers, { } +static inline int regulator_get_voltage(struct regulator *regulator) +{ + return -EINVAL; +} + #endif #endif /* __REGULATOR_H */ |