Commit 19a9ffb3 authored by Viresh Kumar's avatar Viresh Kumar Committed by Daniel Lezcano

clockevents/drivers/sh_mtu2: Migrate to new 'set-state' interface

Migrate sh_mtu2 driver to the new 'set-state' interface provided by
clockevents core, the earlier 'set-mode' interface is marked obsolete
now.

This also enables us to implement callbacks for new states of clockevent
devices, for example: ONESHOT_STOPPED.

Cc: Magnus Damm <damm+renesas@opensource.se>
Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
parent 051b782e
...@@ -276,36 +276,25 @@ static struct sh_mtu2_channel *ced_to_sh_mtu2(struct clock_event_device *ced) ...@@ -276,36 +276,25 @@ static struct sh_mtu2_channel *ced_to_sh_mtu2(struct clock_event_device *ced)
return container_of(ced, struct sh_mtu2_channel, ced); return container_of(ced, struct sh_mtu2_channel, ced);
} }
static void sh_mtu2_clock_event_mode(enum clock_event_mode mode, static int sh_mtu2_clock_event_shutdown(struct clock_event_device *ced)
struct clock_event_device *ced)
{ {
struct sh_mtu2_channel *ch = ced_to_sh_mtu2(ced); struct sh_mtu2_channel *ch = ced_to_sh_mtu2(ced);
int disabled = 0;
/* deal with old setting first */ sh_mtu2_disable(ch);
switch (ced->mode) { return 0;
case CLOCK_EVT_MODE_PERIODIC: }
static int sh_mtu2_clock_event_set_periodic(struct clock_event_device *ced)
{
struct sh_mtu2_channel *ch = ced_to_sh_mtu2(ced);
if (clockevent_state_periodic(ced))
sh_mtu2_disable(ch); sh_mtu2_disable(ch);
disabled = 1;
break;
default:
break;
}
switch (mode) { dev_info(&ch->mtu->pdev->dev, "ch%u: used for periodic clock events\n",
case CLOCK_EVT_MODE_PERIODIC: ch->index);
dev_info(&ch->mtu->pdev->dev, sh_mtu2_enable(ch);
"ch%u: used for periodic clock events\n", ch->index); return 0;
sh_mtu2_enable(ch);
break;
case CLOCK_EVT_MODE_UNUSED:
if (!disabled)
sh_mtu2_disable(ch);
break;
case CLOCK_EVT_MODE_SHUTDOWN:
default:
break;
}
} }
static void sh_mtu2_clock_event_suspend(struct clock_event_device *ced) static void sh_mtu2_clock_event_suspend(struct clock_event_device *ced)
...@@ -327,7 +316,8 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch, ...@@ -327,7 +316,8 @@ static void sh_mtu2_register_clockevent(struct sh_mtu2_channel *ch,
ced->features = CLOCK_EVT_FEAT_PERIODIC; ced->features = CLOCK_EVT_FEAT_PERIODIC;
ced->rating = 200; ced->rating = 200;
ced->cpumask = cpu_possible_mask; ced->cpumask = cpu_possible_mask;
ced->set_mode = sh_mtu2_clock_event_mode; ced->set_state_shutdown = sh_mtu2_clock_event_shutdown;
ced->set_state_periodic = sh_mtu2_clock_event_set_periodic;
ced->suspend = sh_mtu2_clock_event_suspend; ced->suspend = sh_mtu2_clock_event_suspend;
ced->resume = sh_mtu2_clock_event_resume; ced->resume = sh_mtu2_clock_event_resume;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment