regulator: pwm-regulator: set init voltage before pwm enable
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com> Change-Id: I37c35eb97dd1e205a4966792acb4df2bb2bf69f1
This commit is contained in:
@ -47,6 +47,9 @@ struct pwm_regulator_data {
|
||||
|
||||
/* Enable GPIO */
|
||||
struct gpio_desc *enb_gpio;
|
||||
|
||||
/* Init voltage */
|
||||
int init_uv;
|
||||
};
|
||||
|
||||
struct pwm_voltages {
|
||||
@ -54,7 +57,11 @@ struct pwm_voltages {
|
||||
unsigned int dutycycle;
|
||||
};
|
||||
|
||||
/**
|
||||
static int pwm_regulator_set_voltage(struct regulator_dev *rdev,
|
||||
int req_min_uV, int req_max_uV,
|
||||
unsigned int *selector);
|
||||
|
||||
/*
|
||||
* Voltage table call-backs
|
||||
*/
|
||||
static void pwm_regulator_init_state(struct regulator_dev *rdev)
|
||||
@ -122,6 +129,10 @@ static int pwm_regulator_enable(struct regulator_dev *dev)
|
||||
{
|
||||
struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
|
||||
|
||||
if (drvdata->init_uv && !pwm_get_duty_cycle(drvdata->pwm))
|
||||
pwm_regulator_set_voltage(dev, drvdata->init_uv,
|
||||
drvdata->init_uv, NULL);
|
||||
|
||||
gpiod_set_value_cansleep(drvdata->enb_gpio, 1);
|
||||
|
||||
return pwm_enable(drvdata->pwm);
|
||||
@ -332,6 +343,7 @@ static int pwm_regulator_probe(struct platform_device *pdev)
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
enum gpiod_flags gpio_flags;
|
||||
int ret;
|
||||
u32 init_uv;
|
||||
|
||||
if (!np) {
|
||||
dev_err(&pdev->dev, "Device Tree node missing\n");
|
||||
@ -351,6 +363,9 @@ static int pwm_regulator_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!of_property_read_u32(np, "regulator-init-microvolt", &init_uv))
|
||||
drvdata->init_uv = init_uv;
|
||||
|
||||
init_data = of_get_regulator_init_data(&pdev->dev, np,
|
||||
&drvdata->desc);
|
||||
if (!init_data)
|
||||
|
||||
Reference in New Issue
Block a user