aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pwm/pwm-rcar.c
diff options
context:
space:
mode:
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>2019-01-09 03:19:07 -0500
committerThierry Reding <thierry.reding@gmail.com>2019-03-04 06:14:07 -0500
commit8cc2b970397c59b25ffb22e0e4a86753fa162619 (patch)
tree014f3a9cf185a8c8eaaaf08b8f0a3b53e3145a6f /drivers/pwm/pwm-rcar.c
parent87f50ce981b8ac33734e3b5847f7f0bbfcad856b (diff)
pwm: rcar: Remove legacy APIs
This patch removes legacy APIs. Since rcar_pwm_{en,dis}able() functions are reused on "atomic" API, this patch changes the arguments of these functions. No change in behavior. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm/pwm-rcar.c')
-rw-r--r--drivers/pwm/pwm-rcar.c44
1 files changed, 4 insertions, 40 deletions
diff --git a/drivers/pwm/pwm-rcar.c b/drivers/pwm/pwm-rcar.c
index 652a937ef8b0..1e13fbb41fd1 100644
--- a/drivers/pwm/pwm-rcar.c
+++ b/drivers/pwm/pwm-rcar.c
@@ -139,39 +139,8 @@ static void rcar_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
139 pm_runtime_put(chip->dev); 139 pm_runtime_put(chip->dev);
140} 140}
141 141
142static int rcar_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, 142static int rcar_pwm_enable(struct rcar_pwm_chip *rp)
143 int duty_ns, int period_ns)
144{ 143{
145 struct rcar_pwm_chip *rp = to_rcar_pwm_chip(chip);
146 int div, ret;
147
148 div = rcar_pwm_get_clock_division(rp, period_ns);
149 if (div < 0)
150 return div;
151
152 /*
153 * Let the core driver set pwm->period if disabled and duty_ns == 0.
154 * But, this driver should prevent to set the new duty_ns if current
155 * duty_cycle is not set
156 */
157 if (!pwm_is_enabled(pwm) && !duty_ns && !pwm->state.duty_cycle)
158 return 0;
159
160 rcar_pwm_update(rp, RCAR_PWMCR_SYNC, RCAR_PWMCR_SYNC, RCAR_PWMCR);
161
162 ret = rcar_pwm_set_counter(rp, div, duty_ns, period_ns);
163 if (!ret)
164 rcar_pwm_set_clock_control(rp, div);
165
166 /* The SYNC should be set to 0 even if rcar_pwm_set_counter failed */
167 rcar_pwm_update(rp, RCAR_PWMCR_SYNC, 0, RCAR_PWMCR);
168
169 return ret;
170}
171
172static int rcar_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
173{
174 struct rcar_pwm_chip *rp = to_rcar_pwm_chip(chip);
175 u32 value; 144 u32 value;
176 145
177 /* Don't enable the PWM device if CYC0 or PH0 is 0 */ 146 /* Don't enable the PWM device if CYC0 or PH0 is 0 */
@@ -185,10 +154,8 @@ static int rcar_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
185 return 0; 154 return 0;
186} 155}
187 156
188static void rcar_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm) 157static void rcar_pwm_disable(struct rcar_pwm_chip *rp)
189{ 158{
190 struct rcar_pwm_chip *rp = to_rcar_pwm_chip(chip);
191
192 rcar_pwm_update(rp, RCAR_PWMCR_EN0, 0, RCAR_PWMCR); 159 rcar_pwm_update(rp, RCAR_PWMCR_EN0, 0, RCAR_PWMCR);
193} 160}
194 161
@@ -205,7 +172,7 @@ static int rcar_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
205 return -ENOTSUPP; 172 return -ENOTSUPP;
206 173
207 if (!state->enabled) { 174 if (!state->enabled) {
208 rcar_pwm_disable(chip, pwm); 175 rcar_pwm_disable(rp);
209 return 0; 176 return 0;
210 } 177 }
211 178
@@ -223,7 +190,7 @@ static int rcar_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
223 rcar_pwm_update(rp, RCAR_PWMCR_SYNC, 0, RCAR_PWMCR); 190 rcar_pwm_update(rp, RCAR_PWMCR_SYNC, 0, RCAR_PWMCR);
224 191
225 if (!ret && state->enabled) 192 if (!ret && state->enabled)
226 ret = rcar_pwm_enable(chip, pwm); 193 ret = rcar_pwm_enable(rp);
227 194
228 return ret; 195 return ret;
229} 196}
@@ -231,9 +198,6 @@ static int rcar_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
231static const struct pwm_ops rcar_pwm_ops = { 198static const struct pwm_ops rcar_pwm_ops = {
232 .request = rcar_pwm_request, 199 .request = rcar_pwm_request,
233 .free = rcar_pwm_free, 200 .free = rcar_pwm_free,
234 .config = rcar_pwm_config,
235 .enable = rcar_pwm_enable,
236 .disable = rcar_pwm_disable,
237 .apply = rcar_pwm_apply, 201 .apply = rcar_pwm_apply,
238 .owner = THIS_MODULE, 202 .owner = THIS_MODULE,
239}; 203};