Loading Documentation/devicetree/bindings/regulator/regulator.txt +5 −0 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,11 @@ Optional properties: any consumer request. any consumer request. - regulator-pull-down: Enable pull down resistor when the regulator is disabled. - regulator-pull-down: Enable pull down resistor when the regulator is disabled. - regulator-over-current-protection: Enable over current protection. - regulator-over-current-protection: Enable over current protection. - regulator-active-discharge: tristate, enable/disable active discharge of regulators. The values are: 0: Disable active discharge. 1: Enable active discharge. Absence of this property will leave configuration to default. Deprecated properties: Deprecated properties: - regulator-compatible: If a regulator chip contains multiple - regulator-compatible: If a regulator chip contains multiple Loading drivers/regulator/core.c +11 −0 Original line number Original line Diff line number Diff line Loading @@ -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: Loading drivers/regulator/helpers.c +23 −0 Original line number Original line Diff line number Diff line Loading @@ -465,3 +465,26 @@ int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable) return 0; return 0; } } EXPORT_SYMBOL_GPL(regulator_get_bypass_regmap); EXPORT_SYMBOL_GPL(regulator_get_bypass_regmap); /** * regulator_set_active_discharge_regmap - Default set_active_discharge() * using regmap * * @rdev: device to operate on. * @enable: state to set, 0 to disable and 1 to enable. */ int regulator_set_active_discharge_regmap(struct regulator_dev *rdev, bool enable) { unsigned int val; if (enable) val = rdev->desc->active_discharge_on; else val = rdev->desc->active_discharge_off; return regmap_update_bits(rdev->regmap, rdev->desc->active_discharge_reg, rdev->desc->active_discharge_mask, val); } EXPORT_SYMBOL_GPL(regulator_set_active_discharge_regmap); drivers/regulator/of_regulator.c +6 −0 Original line number Original line Diff line number Diff line Loading @@ -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) { Loading include/linux/regulator/driver.h +17 −0 Original line number Original line Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 *); Loading Loading @@ -266,6 +269,14 @@ enum regulator_type { * @bypass_mask: Mask for control when using regmap set_bypass * @bypass_mask: Mask for control when using regmap set_bypass * @bypass_val_on: Enabling value for control when using regmap set_bypass * @bypass_val_on: Enabling value for control when using regmap set_bypass * @bypass_val_off: Disabling value for control when using regmap set_bypass * @bypass_val_off: Disabling value for control when using regmap set_bypass * @active_discharge_off: Enabling value for control when using regmap * set_active_discharge * @active_discharge_on: Disabling value for control when using regmap * set_active_discharge * @active_discharge_mask: Mask for control when using regmap * set_active_discharge * @active_discharge_reg: Register for control when using regmap * set_active_discharge * * * @enable_time: Time taken for initial enable of regulator (in uS). * @enable_time: Time taken for initial enable of regulator (in uS). * @off_on_delay: guard time (in uS), before re-enabling a regulator * @off_on_delay: guard time (in uS), before re-enabling a regulator Loading Loading @@ -315,6 +326,10 @@ struct regulator_desc { unsigned int bypass_mask; unsigned int bypass_mask; unsigned int bypass_val_on; unsigned int bypass_val_on; unsigned int bypass_val_off; unsigned int bypass_val_off; unsigned int active_discharge_on; unsigned int active_discharge_off; unsigned int active_discharge_mask; unsigned int active_discharge_reg; unsigned int enable_time; unsigned int enable_time; Loading Loading @@ -447,6 +462,8 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev, int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable); int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable); int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable); int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable); int regulator_set_active_discharge_regmap(struct regulator_dev *rdev, bool enable); void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); #endif #endif Loading
Documentation/devicetree/bindings/regulator/regulator.txt +5 −0 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,11 @@ Optional properties: any consumer request. any consumer request. - regulator-pull-down: Enable pull down resistor when the regulator is disabled. - regulator-pull-down: Enable pull down resistor when the regulator is disabled. - regulator-over-current-protection: Enable over current protection. - regulator-over-current-protection: Enable over current protection. - regulator-active-discharge: tristate, enable/disable active discharge of regulators. The values are: 0: Disable active discharge. 1: Enable active discharge. Absence of this property will leave configuration to default. Deprecated properties: Deprecated properties: - regulator-compatible: If a regulator chip contains multiple - regulator-compatible: If a regulator chip contains multiple Loading
drivers/regulator/core.c +11 −0 Original line number Original line Diff line number Diff line Loading @@ -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: Loading
drivers/regulator/helpers.c +23 −0 Original line number Original line Diff line number Diff line Loading @@ -465,3 +465,26 @@ int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable) return 0; return 0; } } EXPORT_SYMBOL_GPL(regulator_get_bypass_regmap); EXPORT_SYMBOL_GPL(regulator_get_bypass_regmap); /** * regulator_set_active_discharge_regmap - Default set_active_discharge() * using regmap * * @rdev: device to operate on. * @enable: state to set, 0 to disable and 1 to enable. */ int regulator_set_active_discharge_regmap(struct regulator_dev *rdev, bool enable) { unsigned int val; if (enable) val = rdev->desc->active_discharge_on; else val = rdev->desc->active_discharge_off; return regmap_update_bits(rdev->regmap, rdev->desc->active_discharge_reg, rdev->desc->active_discharge_mask, val); } EXPORT_SYMBOL_GPL(regulator_set_active_discharge_regmap);
drivers/regulator/of_regulator.c +6 −0 Original line number Original line Diff line number Diff line Loading @@ -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) { Loading
include/linux/regulator/driver.h +17 −0 Original line number Original line Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 *); Loading Loading @@ -266,6 +269,14 @@ enum regulator_type { * @bypass_mask: Mask for control when using regmap set_bypass * @bypass_mask: Mask for control when using regmap set_bypass * @bypass_val_on: Enabling value for control when using regmap set_bypass * @bypass_val_on: Enabling value for control when using regmap set_bypass * @bypass_val_off: Disabling value for control when using regmap set_bypass * @bypass_val_off: Disabling value for control when using regmap set_bypass * @active_discharge_off: Enabling value for control when using regmap * set_active_discharge * @active_discharge_on: Disabling value for control when using regmap * set_active_discharge * @active_discharge_mask: Mask for control when using regmap * set_active_discharge * @active_discharge_reg: Register for control when using regmap * set_active_discharge * * * @enable_time: Time taken for initial enable of regulator (in uS). * @enable_time: Time taken for initial enable of regulator (in uS). * @off_on_delay: guard time (in uS), before re-enabling a regulator * @off_on_delay: guard time (in uS), before re-enabling a regulator Loading Loading @@ -315,6 +326,10 @@ struct regulator_desc { unsigned int bypass_mask; unsigned int bypass_mask; unsigned int bypass_val_on; unsigned int bypass_val_on; unsigned int bypass_val_off; unsigned int bypass_val_off; unsigned int active_discharge_on; unsigned int active_discharge_off; unsigned int active_discharge_mask; unsigned int active_discharge_reg; unsigned int enable_time; unsigned int enable_time; Loading Loading @@ -447,6 +462,8 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev, int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable); int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable); int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable); int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable); int regulator_set_active_discharge_regmap(struct regulator_dev *rdev, bool enable); void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); #endif #endif