@@ -58,9 +58,9 @@ static inline struct twl_pwm_chip *to_twl(struct pwm_chip *chip)
58
58
}
59
59
60
60
static int twl_pwm_config (struct pwm_chip * chip , struct pwm_device * pwm ,
61
- int duty_ns , int period_ns )
61
+ u64 duty_ns , u64 period_ns )
62
62
{
63
- int duty_cycle = DIV_ROUND_UP (duty_ns * TWL_PWM_MAX , period_ns ) + 1 ;
63
+ int duty_cycle = DIV64_U64_ROUND_UP (duty_ns * TWL_PWM_MAX , period_ns ) + 1 ;
64
64
u8 pwm_config [2 ] = { 1 , 0 };
65
65
int base , ret ;
66
66
@@ -279,19 +279,65 @@ static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
279
279
mutex_unlock (& twl -> mutex );
280
280
}
281
281
282
+ static int twl4030_pwm_apply (struct pwm_chip * chip , struct pwm_device * pwm ,
283
+ const struct pwm_state * state )
284
+ {
285
+ int err ;
286
+
287
+ if (state -> polarity != PWM_POLARITY_NORMAL )
288
+ return - EINVAL ;
289
+
290
+ if (!state -> enabled ) {
291
+ if (pwm -> state .enabled )
292
+ twl4030_pwm_disable (chip , pwm );
293
+
294
+ return 0 ;
295
+ }
296
+
297
+ err = twl_pwm_config (pwm -> chip , pwm , state -> duty_cycle , state -> period );
298
+ if (err )
299
+ return err ;
300
+
301
+ if (!pwm -> state .enabled )
302
+ err = twl4030_pwm_enable (chip , pwm );
303
+
304
+ return err ;
305
+ }
306
+
307
+ static int twl6030_pwm_apply (struct pwm_chip * chip , struct pwm_device * pwm ,
308
+ const struct pwm_state * state )
309
+ {
310
+ int err ;
311
+
312
+ if (state -> polarity != PWM_POLARITY_NORMAL )
313
+ return - EINVAL ;
314
+
315
+ if (!state -> enabled ) {
316
+ if (pwm -> state .enabled )
317
+ twl6030_pwm_disable (chip , pwm );
318
+
319
+ return 0 ;
320
+ }
321
+
322
+ err = twl_pwm_config (pwm -> chip , pwm , state -> duty_cycle , state -> period );
323
+ if (err )
324
+ return err ;
325
+
326
+ if (!pwm -> state .enabled )
327
+ err = twl6030_pwm_enable (chip , pwm );
328
+
329
+ return err ;
330
+ }
331
+
282
332
static const struct pwm_ops twl4030_pwm_ops = {
283
- .config = twl_pwm_config ,
284
- .enable = twl4030_pwm_enable ,
285
- .disable = twl4030_pwm_disable ,
333
+ .apply = twl4030_pwm_apply ,
286
334
.request = twl4030_pwm_request ,
287
335
.free = twl4030_pwm_free ,
288
336
.owner = THIS_MODULE ,
289
337
};
290
338
291
339
static const struct pwm_ops twl6030_pwm_ops = {
292
- .config = twl_pwm_config ,
293
- .enable = twl6030_pwm_enable ,
294
- .disable = twl6030_pwm_disable ,
340
+ .apply = twl6030_pwm_apply ,
295
341
.owner = THIS_MODULE ,
296
342
};
297
343
0 commit comments