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>
This commit is contained in:
parent
bd667d40a9
commit
670666b9e0
@ -1140,6 +1140,17 @@ static int set_machine_constraints(struct regulator_dev *rdev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rdev->constraints->active_discharge && ops->set_active_discharge) {
|
||||||
|
bool ad_state = (rdev->constraints->active_discharge ==
|
||||||
|
REGULATOR_ACTIVE_DISCHARGE_ENABLE) ? true : false;
|
||||||
|
|
||||||
|
ret = ops->set_active_discharge(rdev, ad_state);
|
||||||
|
if (ret < 0) {
|
||||||
|
rdev_err(rdev, "failed to set active discharge\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
print_constraints(rdev);
|
print_constraints(rdev);
|
||||||
return 0;
|
return 0;
|
||||||
out:
|
out:
|
||||||
|
@ -93,6 +93,12 @@ static void of_get_regulation_constraints(struct device_node *np,
|
|||||||
|
|
||||||
constraints->soft_start = of_property_read_bool(np,
|
constraints->soft_start = of_property_read_bool(np,
|
||||||
"regulator-soft-start");
|
"regulator-soft-start");
|
||||||
|
ret = of_property_read_u32(np, "regulator-active-discharge", &pval);
|
||||||
|
if (!ret) {
|
||||||
|
constraints->active_discharge =
|
||||||
|
(pval) ? REGULATOR_ACTIVE_DISCHARGE_ENABLE :
|
||||||
|
REGULATOR_ACTIVE_DISCHARGE_DISABLE;
|
||||||
|
}
|
||||||
|
|
||||||
if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) {
|
if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) {
|
||||||
if (desc && desc->of_map_mode) {
|
if (desc && desc->of_map_mode) {
|
||||||
|
@ -93,6 +93,8 @@ struct regulator_linear_range {
|
|||||||
* @get_current_limit: Get the configured limit for a current-limited regulator.
|
* @get_current_limit: Get the configured limit for a current-limited regulator.
|
||||||
* @set_input_current_limit: Configure an input limit.
|
* @set_input_current_limit: Configure an input limit.
|
||||||
*
|
*
|
||||||
|
* @set_active_discharge: Set active discharge enable/disable of regulators.
|
||||||
|
*
|
||||||
* @set_mode: Set the configured operating mode for the regulator.
|
* @set_mode: Set the configured operating mode for the regulator.
|
||||||
* @get_mode: Get the configured operating mode for the regulator.
|
* @get_mode: Get the configured operating mode for the regulator.
|
||||||
* @get_status: Return actual (not as-configured) status of regulator, as a
|
* @get_status: Return actual (not as-configured) status of regulator, as a
|
||||||
@ -149,6 +151,7 @@ struct regulator_ops {
|
|||||||
|
|
||||||
int (*set_input_current_limit) (struct regulator_dev *, int lim_uA);
|
int (*set_input_current_limit) (struct regulator_dev *, int lim_uA);
|
||||||
int (*set_over_current_protection) (struct regulator_dev *);
|
int (*set_over_current_protection) (struct regulator_dev *);
|
||||||
|
int (*set_active_discharge) (struct regulator_dev *, bool enable);
|
||||||
|
|
||||||
/* enable/disable regulator */
|
/* enable/disable regulator */
|
||||||
int (*enable) (struct regulator_dev *);
|
int (*enable) (struct regulator_dev *);
|
||||||
|
@ -42,6 +42,13 @@ struct regulator;
|
|||||||
#define REGULATOR_CHANGE_DRMS 0x10
|
#define REGULATOR_CHANGE_DRMS 0x10
|
||||||
#define REGULATOR_CHANGE_BYPASS 0x20
|
#define REGULATOR_CHANGE_BYPASS 0x20
|
||||||
|
|
||||||
|
/* Regulator active discharge flags */
|
||||||
|
enum regulator_active_discharge {
|
||||||
|
REGULATOR_ACTIVE_DISCHARGE_DEFAULT,
|
||||||
|
REGULATOR_ACTIVE_DISCHARGE_DISABLE,
|
||||||
|
REGULATOR_ACTIVE_DISCHARGE_ENABLE,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct regulator_state - regulator state during low power system states
|
* struct regulator_state - regulator state during low power system states
|
||||||
*
|
*
|
||||||
@ -100,6 +107,9 @@ struct regulator_state {
|
|||||||
* @initial_state: Suspend state to set by default.
|
* @initial_state: Suspend state to set by default.
|
||||||
* @initial_mode: Mode to set at startup.
|
* @initial_mode: Mode to set at startup.
|
||||||
* @ramp_delay: Time to settle down after voltage change (unit: uV/us)
|
* @ramp_delay: Time to settle down after voltage change (unit: uV/us)
|
||||||
|
* @active_discharge: Enable/disable active discharge. The enum
|
||||||
|
* regulator_active_discharge values are used for
|
||||||
|
* initialisation.
|
||||||
* @enable_time: Turn-on time of the rails (unit: microseconds)
|
* @enable_time: Turn-on time of the rails (unit: microseconds)
|
||||||
*/
|
*/
|
||||||
struct regulation_constraints {
|
struct regulation_constraints {
|
||||||
@ -140,6 +150,8 @@ struct regulation_constraints {
|
|||||||
unsigned int ramp_delay;
|
unsigned int ramp_delay;
|
||||||
unsigned int enable_time;
|
unsigned int enable_time;
|
||||||
|
|
||||||
|
unsigned int active_discharge;
|
||||||
|
|
||||||
/* constraint flags */
|
/* constraint flags */
|
||||||
unsigned always_on:1; /* regulator never off when system is on */
|
unsigned always_on:1; /* regulator never off when system is on */
|
||||||
unsigned boot_on:1; /* bootloader/firmware enabled regulator */
|
unsigned boot_on:1; /* bootloader/firmware enabled regulator */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user