aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/regulator/core.c33
-rw-r--r--include/linux/regulator/consumer.h26
-rw-r--r--include/linux/regulator/driver.h4
3 files changed, 63 insertions, 0 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 67426c0477d3..08260c215895 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3359,6 +3359,39 @@ unsigned int regulator_get_mode(struct regulator *regulator)
3359} 3359}
3360EXPORT_SYMBOL_GPL(regulator_get_mode); 3360EXPORT_SYMBOL_GPL(regulator_get_mode);
3361 3361
3362static int _regulator_get_error_flags(struct regulator_dev *rdev,
3363 unsigned int *flags)
3364{
3365 int ret;
3366
3367 mutex_lock(&rdev->mutex);
3368
3369 /* sanity check */
3370 if (!rdev->desc->ops->get_error_flags) {
3371 ret = -EINVAL;
3372 goto out;
3373 }
3374
3375 ret = rdev->desc->ops->get_error_flags(rdev, flags);
3376out:
3377 mutex_unlock(&rdev->mutex);
3378 return ret;
3379}
3380
3381/**
3382 * regulator_get_error_flags - get regulator error information
3383 * @regulator: regulator source
3384 * @flags: pointer to store error flags
3385 *
3386 * Get the current regulator error information.
3387 */
3388int regulator_get_error_flags(struct regulator *regulator,
3389 unsigned int *flags)
3390{
3391 return _regulator_get_error_flags(regulator->rdev, flags);
3392}
3393EXPORT_SYMBOL_GPL(regulator_get_error_flags);
3394
3362/** 3395/**
3363 * regulator_set_load - set regulator load 3396 * regulator_set_load - set regulator load
3364 * @regulator: regulator source 3397 * @regulator: regulator source
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 692108222271..528eb1f5273e 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -120,6 +120,25 @@ struct regmap;
120#define REGULATOR_EVENT_PRE_DISABLE 0x400 120#define REGULATOR_EVENT_PRE_DISABLE 0x400
121#define REGULATOR_EVENT_ABORT_DISABLE 0x800 121#define REGULATOR_EVENT_ABORT_DISABLE 0x800
122 122
123/*
124 * Regulator errors that can be queried using regulator_get_error_flags
125 *
126 * UNDER_VOLTAGE Regulator output is under voltage.
127 * OVER_CURRENT Regulator output current is too high.
128 * REGULATION_OUT Regulator output is out of regulation.
129 * FAIL Regulator output has failed.
130 * OVER_TEMP Regulator over temp.
131 *
132 * NOTE: These errors can be OR'ed together.
133 */
134
135#define REGULATOR_ERROR_UNDER_VOLTAGE BIT(1)
136#define REGULATOR_ERROR_OVER_CURRENT BIT(2)
137#define REGULATOR_ERROR_REGULATION_OUT BIT(3)
138#define REGULATOR_ERROR_FAIL BIT(4)
139#define REGULATOR_ERROR_OVER_TEMP BIT(5)
140
141
123/** 142/**
124 * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event 143 * struct pre_voltage_change_data - Data sent with PRE_VOLTAGE_CHANGE event
125 * 144 *
@@ -237,6 +256,8 @@ int regulator_get_current_limit(struct regulator *regulator);
237 256
238int regulator_set_mode(struct regulator *regulator, unsigned int mode); 257int regulator_set_mode(struct regulator *regulator, unsigned int mode);
239unsigned int regulator_get_mode(struct regulator *regulator); 258unsigned int regulator_get_mode(struct regulator *regulator);
259int regulator_get_error_flags(struct regulator *regulator,
260 unsigned int *flags);
240int regulator_set_load(struct regulator *regulator, int load_uA); 261int regulator_set_load(struct regulator *regulator, int load_uA);
241 262
242int regulator_allow_bypass(struct regulator *regulator, bool allow); 263int regulator_allow_bypass(struct regulator *regulator, bool allow);
@@ -477,6 +498,11 @@ static inline unsigned int regulator_get_mode(struct regulator *regulator)
477 return REGULATOR_MODE_NORMAL; 498 return REGULATOR_MODE_NORMAL;
478} 499}
479 500
501static inline int regulator_get_error_flags(struct regulator *regulator)
502{
503 return -EINVAL;
504}
505
480static inline int regulator_set_load(struct regulator *regulator, int load_uA) 506static inline int regulator_set_load(struct regulator *regulator, int load_uA)
481{ 507{
482 return REGULATOR_MODE_NORMAL; 508 return REGULATOR_MODE_NORMAL;
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 37b532410528..dac8e7b16bc6 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -100,6 +100,7 @@ struct regulator_linear_range {
100 * 100 *
101 * @set_mode: Set the configured operating mode for the regulator. 101 * @set_mode: Set the configured operating mode for the regulator.
102 * @get_mode: Get the configured operating mode for the regulator. 102 * @get_mode: Get the configured operating mode for the regulator.
103 * @get_error_flags: Get the current error(s) for the regulator.
103 * @get_status: Return actual (not as-configured) status of regulator, as a 104 * @get_status: Return actual (not as-configured) status of regulator, as a
104 * REGULATOR_STATUS value (or negative errno) 105 * REGULATOR_STATUS value (or negative errno)
105 * @get_optimum_mode: Get the most efficient operating mode for the regulator 106 * @get_optimum_mode: Get the most efficient operating mode for the regulator
@@ -169,6 +170,9 @@ struct regulator_ops {
169 int (*set_mode) (struct regulator_dev *, unsigned int mode); 170 int (*set_mode) (struct regulator_dev *, unsigned int mode);
170 unsigned int (*get_mode) (struct regulator_dev *); 171 unsigned int (*get_mode) (struct regulator_dev *);
171 172
173 /* retrieve current error flags on the regulator */
174 int (*get_error_flags)(struct regulator_dev *, unsigned int *flags);
175
172 /* Time taken to enable or set voltage on the regulator */ 176 /* Time taken to enable or set voltage on the regulator */
173 int (*enable_time) (struct regulator_dev *); 177 int (*enable_time) (struct regulator_dev *);
174 int (*set_ramp_delay) (struct regulator_dev *, int ramp_delay); 178 int (*set_ramp_delay) (struct regulator_dev *, int ramp_delay);