Commit 354794da authored by Laxman Dewangan's avatar Laxman Dewangan Committed by Mark Brown

regulator: helper: Add helper to configure active-discharge using regmap

Add helper function to set the state of active-discharge of
regulator using regmap. The HW regulator driver can directly
use this by providing the necessary information in the regulator
descriptor.
Signed-off-by: default avatarLaxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 670666b9
...@@ -465,3 +465,26 @@ int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable) ...@@ -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);
...@@ -269,6 +269,14 @@ enum regulator_type { ...@@ -269,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
...@@ -318,6 +326,10 @@ struct regulator_desc { ...@@ -318,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;
...@@ -450,6 +462,8 @@ int regulator_set_voltage_time_sel(struct regulator_dev *rdev, ...@@ -450,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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment