Skip to content

Commit 92fd868

Browse files
lokeshvutladlezcano
authored andcommitted
clocksource/drivers/timer-ti-dm: Add support to get pwm current status
omap_dm_timer_ops provide support to configure the pwm but there is no support to get the current status. For configuring pwm it is advised to check the current hw status instead of relying on pwm framework. So implement a new timer ops to get the current status of pwm. Signed-off-by: Lokesh Vutla <[email protected]> Acked-by: Tony Lindgen <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent aff7665 commit 92fd868

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

drivers/clocksource/timer-ti-dm.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,20 @@ static int omap_dm_timer_set_pwm(struct omap_dm_timer *timer, int def_on,
627627
return 0;
628628
}
629629

630+
static int omap_dm_timer_get_pwm_status(struct omap_dm_timer *timer)
631+
{
632+
u32 l;
633+
634+
if (unlikely(!timer))
635+
return -EINVAL;
636+
637+
omap_dm_timer_enable(timer);
638+
l = omap_dm_timer_read_reg(timer, OMAP_TIMER_CTRL_REG);
639+
omap_dm_timer_disable(timer);
640+
641+
return l;
642+
}
643+
630644
static int omap_dm_timer_set_prescaler(struct omap_dm_timer *timer,
631645
int prescaler)
632646
{
@@ -927,6 +941,7 @@ static const struct omap_dm_timer_ops dmtimer_ops = {
927941
.set_load = omap_dm_timer_set_load,
928942
.set_match = omap_dm_timer_set_match,
929943
.set_pwm = omap_dm_timer_set_pwm,
944+
.get_pwm_status = omap_dm_timer_get_pwm_status,
930945
.set_prescaler = omap_dm_timer_set_prescaler,
931946
.read_counter = omap_dm_timer_read_counter,
932947
.write_counter = omap_dm_timer_write_counter,

include/linux/platform_data/dmtimer-omap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct omap_dm_timer_ops {
3636
unsigned int match);
3737
int (*set_pwm)(struct omap_dm_timer *timer, int def_on,
3838
int toggle, int trigger);
39+
int (*get_pwm_status)(struct omap_dm_timer *timer);
3940
int (*set_prescaler)(struct omap_dm_timer *timer, int prescaler);
4041

4142
unsigned int (*read_counter)(struct omap_dm_timer *timer);

0 commit comments

Comments
 (0)