Skip to content

Commit

Permalink
clocksource/drivers/lpc32xx: Support timer-based ARM delay
Browse files Browse the repository at this point in the history
This commit implements the ARM timer-based delay timer for the
LPC32xx, LPC18xx, LPC43xx family of SoCs.

Also, add a dependency to restrict compiling this driver for
the ARM architecture.

Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Joachim Eastwood <manabian@gmail.com>
Tested-by: Joachim Eastwood <manabian@gmail.com>
  • Loading branch information
Ezequiel Garcia authored and Daniel Lezcano committed Feb 25, 2016
1 parent 32f32d9 commit 1b18fd2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/clocksource/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ config CLKSRC_EFM32
config CLKSRC_LPC32XX
bool "Clocksource for LPC32XX" if COMPILE_TEST
depends on GENERIC_CLOCKEVENTS && HAS_IOMEM
depends on ARM
select CLKSRC_MMIO
select CLKSRC_OF
help
Expand Down
12 changes: 12 additions & 0 deletions drivers/clocksource/time-lpc32xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/clk.h>
#include <linux/clockchips.h>
#include <linux/clocksource.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/kernel.h>
Expand Down Expand Up @@ -54,6 +55,15 @@ static u64 notrace lpc32xx_read_sched_clock(void)
return readl(clocksource_timer_counter);
}

static unsigned long lpc32xx_delay_timer_read(void)
{
return readl(clocksource_timer_counter);
}

static struct delay_timer lpc32xx_delay_timer = {
.read_current_timer = lpc32xx_delay_timer_read,
};

static int lpc32xx_clkevt_next_event(unsigned long delta,
struct clock_event_device *evtdev)
{
Expand Down Expand Up @@ -192,6 +202,8 @@ static int __init lpc32xx_clocksource_init(struct device_node *np)
}

clocksource_timer_counter = base + LPC32XX_TIMER_TC;
lpc32xx_delay_timer.freq = rate;
register_current_timer_delay(&lpc32xx_delay_timer);
sched_clock_register(lpc32xx_read_sched_clock, 32, rate);

return 0;
Expand Down

0 comments on commit 1b18fd2

Please sign in to comment.