diff options
author | Mark Brown <broonie@kernel.org> | 2016-03-02 09:31:35 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-03-02 09:31:35 -0500 |
commit | 07a06694cb591592842b608dd3ada839503f1134 (patch) | |
tree | 7974b7ddf4dbdfc2ca341fc8218979b88e38de71 | |
parent | 4d92325125e437e46d9198fe7dc0ebdc792ea5e0 (diff) | |
parent | 354794dacc213da7596cefea4dbcd8c094368807 (diff) |
Merge branch 'topic/discharge' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator into regulator-max77620
-rw-r--r-- | Documentation/devicetree/bindings/regulator/regulator.txt | 5 | ||||
-rw-r--r-- | drivers/regulator/core.c | 11 | ||||
-rw-r--r-- | drivers/regulator/helpers.c | 23 | ||||
-rw-r--r-- | drivers/regulator/of_regulator.c | 6 | ||||
-rw-r--r-- | include/linux/regulator/driver.h | 17 | ||||
-rw-r--r-- | include/linux/regulator/machine.h | 12 |
6 files changed, 74 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt index 1d112fc456aa..ecfc593cac15 100644 --- a/Documentation/devicetree/bindings/regulator/regulator.txt +++ b/Documentation/devicetree/bindings/regulator/regulator.txt | |||
@@ -44,6 +44,11 @@ Optional properties: | |||
44 | any consumer request. | 44 | any consumer request. |
45 | - regulator-pull-down: Enable pull down resistor when the regulator is disabled. | 45 | - regulator-pull-down: Enable pull down resistor when the regulator is disabled. |
46 | - regulator-over-current-protection: Enable over current protection. | 46 | - regulator-over-current-protection: Enable over current protection. |
47 | - regulator-active-discharge: tristate, enable/disable active discharge of | ||
48 | regulators. The values are: | ||
49 | 0: Disable active discharge. | ||
50 | 1: Enable active discharge. | ||
51 | Absence of this property will leave configuration to default. | ||
47 | 52 | ||
48 | Deprecated properties: | 53 | Deprecated properties: |
49 | - regulator-compatible: If a regulator chip contains multiple | 54 | - regulator-compatible: If a regulator chip contains multiple |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 744c9889f88d..7ebb7c899158 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1140,6 +1140,17 @@ static int set_machine_constraints(struct regulator_dev *rdev, | |||
1140 | } | 1140 | } |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | if (rdev->constraints->active_discharge && ops->set_active_discharge) { | ||
1144 | bool ad_state = (rdev->constraints->active_discharge == | ||
1145 | REGULATOR_ACTIVE_DISCHARGE_ENABLE) ? true : false; | ||
1146 | |||
1147 | ret = ops->set_active_discharge(rdev, ad_state); | ||
1148 | if (ret < 0) { | ||
1149 | rdev_err(rdev, "failed to set active discharge\n"); | ||
1150 | return ret; | ||
1151 | } | ||
1152 | } | ||
1153 | |||
1143 | print_constraints(rdev); | 1154 | print_constraints(rdev); |
1144 | return 0; | 1155 | return 0; |
1145 | out: | 1156 | out: |
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index 3bbb32680a94..b1e32e7482e9 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c | |||
@@ -465,3 +465,26 @@ int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable) | |||
465 | return 0; | 465 | return 0; |
466 | } | 466 | } |
467 | EXPORT_SYMBOL_GPL(regulator_get_bypass_regmap); | 467 | EXPORT_SYMBOL_GPL(regulator_get_bypass_regmap); |
468 | |||
469 | /** | ||
470 | * regulator_set_active_discharge_regmap - Default set_active_discharge() | ||
471 | * using regmap | ||
472 | * | ||
473 | * @rdev: device to operate on. | ||
474 | * @enable: state to set, 0 to disable and 1 to enable. | ||
475 | */ | ||
476 | int regulator_set_active_discharge_regmap(struct regulator_dev *rdev, | ||
477 | bool enable) | ||
478 | { | ||
479 | unsigned int val; | ||
480 | |||
481 | if (enable) | ||
482 | val = rdev->desc->active_discharge_on; | ||
483 | else | ||
484 | val = rdev->desc->active_discharge_off; | ||
485 | |||
486 | return regmap_update_bits(rdev->regmap, | ||
487 | rdev->desc->active_discharge_reg, | ||
488 | rdev->desc->active_discharge_mask, val); | ||
489 | } | ||
490 | EXPORT_SYMBOL_GPL(regulator_set_active_discharge_regmap); | ||
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 499e437c7e91..fe2e33441dae 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c | |||
@@ -93,6 +93,12 @@ static void of_get_regulation_constraints(struct device_node *np, | |||
93 | 93 | ||
94 | constraints->soft_start = of_property_read_bool(np, | 94 | constraints->soft_start = of_property_read_bool(np, |
95 | "regulator-soft-start"); | 95 | "regulator-soft-start"); |
96 | ret = of_property_read_u32(np, "regulator-active-discharge", &pval); | ||
97 | if (!ret) { | ||
98 | constraints->active_discharge = | ||
99 | (pval) ? REGULATOR_ACTIVE_DISCHARGE_ENABLE : | ||
100 | REGULATOR_ACTIVE_DISCHARGE_DISABLE; | ||
101 | } | ||
96 | 102 | ||
97 | if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) { | 103 | if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) { |
98 | if (desc && desc->of_map_mode) { | 104 | if (desc && desc->of_map_mode) { |
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 16ac9e108806..cd271e89a7e6 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h | |||
@@ -93,6 +93,8 @@ struct regulator_linear_range { | |||
93 | * @get_current_limit: Get the configured limit for a current-limited regulator. | 93 | * @get_current_limit: Get the configured limit for a current-limited regulator. |
94 | * @set_input_current_limit: Configure an input limit. | 94 | * @set_input_current_limit: Configure an input limit. |
95 | * | 95 | * |
96 | * @set_active_discharge: Set active discharge enable/disable of regulators. | ||
97 | * | ||
96 | * @set_mode: Set the configured operating mode for the regulator. | 98 | * @set_mode: Set the configured operating mode for the regulator. |
97 | * @get_mode: Get the configured operating mode for the regulator. | 99 | * @get_mode: Get the configured operating mode for the regulator. |
98 | * @get_status: Return actual (not as-configured) status of regulator, as a | 100 | * @get_status: Return actual (not as-configured) status of regulator, as a |
@@ -149,6 +151,7 @@ struct regulator_ops { | |||
149 | 151 | ||
150 | int (*set_input_current_limit) (struct regulator_dev *, int lim_uA); | 152 | int (*set_input_current_limit) (struct regulator_dev *, int lim_uA); |
151 | int (*set_over_current_protection) (struct regulator_dev *); | 153 | int (*set_over_current_protection) (struct regulator_dev *); |
154 | int (*set_active_discharge) (struct regulator_dev *, bool enable); | ||
152 | 155 | ||
153 | /* enable/disable regulator */ | 156 | /* enable/disable regulator */ |
154 | int (*enable) (struct regulator_dev *); | 157 | int (*enable) (struct regulator_dev *); |
@@ -266,6 +269,14 @@ enum regulator_type { | |||
266 | * @bypass_mask: Mask for control when using regmap set_bypass | 269 | * @bypass_mask: Mask for control when using regmap set_bypass |
267 | * @bypass_val_on: Enabling value for control when using regmap set_bypass | 270 | * @bypass_val_on: Enabling value for control when using regmap set_bypass |
268 | * @bypass_val_off: Disabling value for control when using regmap set_bypass | 271 | * @bypass_val_off: Disabling value for control when using regmap set_bypass |
272 | * @active_discharge_off: Enabling value for control when using regmap | ||
273 | * set_active_discharge | ||
274 | * @active_discharge_on: Disabling value for control when using regmap | ||
275 | * set_active_discharge | ||
276 | * @active_discharge_mask: Mask for control when using regmap | ||
277 | * set_active_discharge | ||
278 | * @active_discharge_reg: Register for control when using regmap | ||
279 | * set_active_discharge | ||
269 | * | 280 | * |
270 | * @enable_time: Time taken for initial enable of regulator (in uS). | 281 | * @enable_time: Time taken for initial enable of regulator (in uS). |
271 | * @off_on_delay: guard time (in uS), before re-enabling a regulator | 282 | * @off_on_delay: guard time (in uS), before re-enabling a regulator |
@@ -315,6 +326,10 @@ struct regulator_desc { | |||
315 | unsigned int bypass_mask; | 326 | unsigned int bypass_mask; |
316 | unsigned int bypass_val_on; | 327 | unsigned int bypass_val_on; |
317 | unsigned int bypass_val_off; | 328 | unsigned int bypass_val_off; |
329 | unsigned int active_discharge_on; | ||
330 | unsigned int active_discharge_off; | ||
331 | unsigned int active_discharge_mask; | ||
332 | unsigned int active_discharge_reg; | ||
318 | 333 | ||
319 | unsigned int enable_time; | 334 | unsigned int enable_time; |
320 | 335 | ||
@@ -447,6 +462,8 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev, | |||
447 | int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable); | 462 | int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable); |
448 | int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable); | 463 | int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable); |
449 | 464 | ||
465 | int regulator_set_active_discharge_regmap(struct regulator_dev *rdev, | ||
466 | bool enable); | ||
450 | void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); | 467 | void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); |
451 | 468 | ||
452 | #endif | 469 | #endif |
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index a1067d0b3991..5d627c83a630 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h | |||
@@ -42,6 +42,13 @@ struct regulator; | |||
42 | #define REGULATOR_CHANGE_DRMS 0x10 | 42 | #define REGULATOR_CHANGE_DRMS 0x10 |
43 | #define REGULATOR_CHANGE_BYPASS 0x20 | 43 | #define REGULATOR_CHANGE_BYPASS 0x20 |
44 | 44 | ||
45 | /* Regulator active discharge flags */ | ||
46 | enum regulator_active_discharge { | ||
47 | REGULATOR_ACTIVE_DISCHARGE_DEFAULT, | ||
48 | REGULATOR_ACTIVE_DISCHARGE_DISABLE, | ||
49 | REGULATOR_ACTIVE_DISCHARGE_ENABLE, | ||
50 | }; | ||
51 | |||
45 | /** | 52 | /** |
46 | * struct regulator_state - regulator state during low power system states | 53 | * struct regulator_state - regulator state during low power system states |
47 | * | 54 | * |
@@ -100,6 +107,9 @@ struct regulator_state { | |||
100 | * @initial_state: Suspend state to set by default. | 107 | * @initial_state: Suspend state to set by default. |
101 | * @initial_mode: Mode to set at startup. | 108 | * @initial_mode: Mode to set at startup. |
102 | * @ramp_delay: Time to settle down after voltage change (unit: uV/us) | 109 | * @ramp_delay: Time to settle down after voltage change (unit: uV/us) |
110 | * @active_discharge: Enable/disable active discharge. The enum | ||
111 | * regulator_active_discharge values are used for | ||
112 | * initialisation. | ||
103 | * @enable_time: Turn-on time of the rails (unit: microseconds) | 113 | * @enable_time: Turn-on time of the rails (unit: microseconds) |
104 | */ | 114 | */ |
105 | struct regulation_constraints { | 115 | struct regulation_constraints { |
@@ -140,6 +150,8 @@ struct regulation_constraints { | |||
140 | unsigned int ramp_delay; | 150 | unsigned int ramp_delay; |
141 | unsigned int enable_time; | 151 | unsigned int enable_time; |
142 | 152 | ||
153 | unsigned int active_discharge; | ||
154 | |||
143 | /* constraint flags */ | 155 | /* constraint flags */ |
144 | unsigned always_on:1; /* regulator never off when system is on */ | 156 | unsigned always_on:1; /* regulator never off when system is on */ |
145 | unsigned boot_on:1; /* bootloader/firmware enabled regulator */ | 157 | unsigned boot_on:1; /* bootloader/firmware enabled regulator */ |