diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2016-03-02 05:54:46 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2016-03-02 09:13:05 -0500 |
commit | 670666b9e0aff40c65d8061a2f53e79eee238685 (patch) | |
tree | 04660dbf7aa36d14372c31d58a6647af77c94415 | |
parent | bd667d40a999e35c270e424b6d550410cb2c6d06 (diff) |
regulator: core: Add support for active-discharge configuration
Add support to enable/disable active discharge of regulator via
machine constraints. This configuration is done when setting
machine constraint during regulator register and if regulator
driver implemented the callback ops.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | drivers/regulator/core.c | 11 | ||||
-rw-r--r-- | drivers/regulator/of_regulator.c | 6 | ||||
-rw-r--r-- | include/linux/regulator/driver.h | 3 | ||||
-rw-r--r-- | include/linux/regulator/machine.h | 12 |
4 files changed, 32 insertions, 0 deletions
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/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..59dbaf78a25c 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 *); |
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 */ |