ARM/ixp4xx/timer: Migrate to new 'set-state' interface
Migrate ixp4xx 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. NOTE: ixp4xx_set_{oneshot|periodic} don't perform read operation on 'IXP4XX_OSRT1' register anymore. Cc: Imre Kaloz <kaloz@openwrt.org> Acked-by: Krzysztof Hałasa <khalasa@piap.pl> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
This commit is contained in:
parent
3200579faf
commit
cea50eeef1
|
@ -521,43 +521,55 @@ static int ixp4xx_set_next_event(unsigned long evt,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ixp4xx_set_mode(enum clock_event_mode mode,
|
static int ixp4xx_shutdown(struct clock_event_device *evt)
|
||||||
struct clock_event_device *evt)
|
|
||||||
{
|
{
|
||||||
unsigned long opts = *IXP4XX_OSRT1 & IXP4XX_OST_RELOAD_MASK;
|
unsigned long opts = *IXP4XX_OSRT1 & IXP4XX_OST_RELOAD_MASK;
|
||||||
unsigned long osrt = *IXP4XX_OSRT1 & ~IXP4XX_OST_RELOAD_MASK;
|
unsigned long osrt = *IXP4XX_OSRT1 & ~IXP4XX_OST_RELOAD_MASK;
|
||||||
|
|
||||||
switch (mode) {
|
opts &= ~IXP4XX_OST_ENABLE;
|
||||||
case CLOCK_EVT_MODE_PERIODIC:
|
*IXP4XX_OSRT1 = osrt | opts;
|
||||||
osrt = IXP4XX_LATCH & ~IXP4XX_OST_RELOAD_MASK;
|
return 0;
|
||||||
opts = IXP4XX_OST_ENABLE;
|
}
|
||||||
break;
|
|
||||||
case CLOCK_EVT_MODE_ONESHOT:
|
static int ixp4xx_set_oneshot(struct clock_event_device *evt)
|
||||||
/* period set by 'set next_event' */
|
{
|
||||||
osrt = 0;
|
unsigned long opts = IXP4XX_OST_ENABLE | IXP4XX_OST_ONE_SHOT;
|
||||||
opts = IXP4XX_OST_ENABLE | IXP4XX_OST_ONE_SHOT;
|
unsigned long osrt = 0;
|
||||||
break;
|
|
||||||
case CLOCK_EVT_MODE_SHUTDOWN:
|
/* period set by 'set next_event' */
|
||||||
opts &= ~IXP4XX_OST_ENABLE;
|
*IXP4XX_OSRT1 = osrt | opts;
|
||||||
break;
|
return 0;
|
||||||
case CLOCK_EVT_MODE_RESUME:
|
}
|
||||||
opts |= IXP4XX_OST_ENABLE;
|
|
||||||
break;
|
static int ixp4xx_set_periodic(struct clock_event_device *evt)
|
||||||
case CLOCK_EVT_MODE_UNUSED:
|
{
|
||||||
default:
|
unsigned long opts = IXP4XX_OST_ENABLE;
|
||||||
osrt = opts = 0;
|
unsigned long osrt = IXP4XX_LATCH & ~IXP4XX_OST_RELOAD_MASK;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
*IXP4XX_OSRT1 = osrt | opts;
|
*IXP4XX_OSRT1 = osrt | opts;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ixp4xx_resume(struct clock_event_device *evt)
|
||||||
|
{
|
||||||
|
unsigned long opts = *IXP4XX_OSRT1 & IXP4XX_OST_RELOAD_MASK;
|
||||||
|
unsigned long osrt = *IXP4XX_OSRT1 & ~IXP4XX_OST_RELOAD_MASK;
|
||||||
|
|
||||||
|
opts |= IXP4XX_OST_ENABLE;
|
||||||
|
*IXP4XX_OSRT1 = osrt | opts;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct clock_event_device clockevent_ixp4xx = {
|
static struct clock_event_device clockevent_ixp4xx = {
|
||||||
.name = "ixp4xx timer1",
|
.name = "ixp4xx timer1",
|
||||||
.features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
|
.features = CLOCK_EVT_FEAT_PERIODIC |
|
||||||
.rating = 200,
|
CLOCK_EVT_FEAT_ONESHOT,
|
||||||
.set_mode = ixp4xx_set_mode,
|
.rating = 200,
|
||||||
.set_next_event = ixp4xx_set_next_event,
|
.set_state_shutdown = ixp4xx_shutdown,
|
||||||
|
.set_state_periodic = ixp4xx_set_periodic,
|
||||||
|
.set_state_oneshot = ixp4xx_set_oneshot,
|
||||||
|
.tick_resume = ixp4xx_resume,
|
||||||
|
.set_next_event = ixp4xx_set_next_event,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void __init ixp4xx_clockevent_init(void)
|
static void __init ixp4xx_clockevent_init(void)
|
||||||
|
|
Loading…
Reference in New Issue