diff options
-rw-r--r-- | drivers/regulator/pwm-regulator.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index fc3166dfcbfa..3aca067b9901 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c | |||
@@ -69,12 +69,6 @@ static int pwm_regulator_set_voltage_sel(struct regulator_dev *rdev, | |||
69 | 69 | ||
70 | drvdata->state = selector; | 70 | drvdata->state = selector; |
71 | 71 | ||
72 | ret = pwm_enable(drvdata->pwm); | ||
73 | if (ret) { | ||
74 | dev_err(&rdev->dev, "Failed to enable PWM\n"); | ||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | return 0; | 72 | return 0; |
79 | } | 73 | } |
80 | 74 | ||
@@ -89,6 +83,29 @@ static int pwm_regulator_list_voltage(struct regulator_dev *rdev, | |||
89 | return drvdata->duty_cycle_table[selector].uV; | 83 | return drvdata->duty_cycle_table[selector].uV; |
90 | } | 84 | } |
91 | 85 | ||
86 | static int pwm_regulator_enable(struct regulator_dev *dev) | ||
87 | { | ||
88 | struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); | ||
89 | |||
90 | return pwm_enable(drvdata->pwm); | ||
91 | } | ||
92 | |||
93 | static int pwm_regulator_disable(struct regulator_dev *dev) | ||
94 | { | ||
95 | struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); | ||
96 | |||
97 | pwm_disable(drvdata->pwm); | ||
98 | |||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static int pwm_regulator_is_enabled(struct regulator_dev *dev) | ||
103 | { | ||
104 | struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); | ||
105 | |||
106 | return pwm_is_enabled(drvdata->pwm); | ||
107 | } | ||
108 | |||
92 | /** | 109 | /** |
93 | * Continuous voltage call-backs | 110 | * Continuous voltage call-backs |
94 | */ | 111 | */ |
@@ -144,11 +161,17 @@ static struct regulator_ops pwm_regulator_voltage_table_ops = { | |||
144 | .get_voltage_sel = pwm_regulator_get_voltage_sel, | 161 | .get_voltage_sel = pwm_regulator_get_voltage_sel, |
145 | .list_voltage = pwm_regulator_list_voltage, | 162 | .list_voltage = pwm_regulator_list_voltage, |
146 | .map_voltage = regulator_map_voltage_iterate, | 163 | .map_voltage = regulator_map_voltage_iterate, |
164 | .enable = pwm_regulator_enable, | ||
165 | .disable = pwm_regulator_disable, | ||
166 | .is_enabled = pwm_regulator_is_enabled, | ||
147 | }; | 167 | }; |
148 | 168 | ||
149 | static struct regulator_ops pwm_regulator_voltage_continuous_ops = { | 169 | static struct regulator_ops pwm_regulator_voltage_continuous_ops = { |
150 | .get_voltage = pwm_regulator_get_voltage, | 170 | .get_voltage = pwm_regulator_get_voltage, |
151 | .set_voltage = pwm_regulator_set_voltage, | 171 | .set_voltage = pwm_regulator_set_voltage, |
172 | .enable = pwm_regulator_enable, | ||
173 | .disable = pwm_regulator_disable, | ||
174 | .is_enabled = pwm_regulator_is_enabled, | ||
152 | }; | 175 | }; |
153 | 176 | ||
154 | static struct regulator_desc pwm_regulator_desc = { | 177 | static struct regulator_desc pwm_regulator_desc = { |