diff options
author | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-08-04 17:14:27 +0800 |
---|---|---|
committer | Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | 2012-10-04 18:54:12 +0800 |
commit | ebf6e1d052b6a846d0adab673385df6a427cfe51 (patch) | |
tree | 030bdf96fddb128411dea473ac4dfe88a8e244c5 /arch/arm/mach-nomadik | |
parent | 0228863348ffb3938bb5115950e3737713b1c8f8 (diff) | |
download | barebox-ebf6e1d052b6a846d0adab673385df6a427cfe51.tar.gz barebox-ebf6e1d052b6a846d0adab673385df6a427cfe51.tar.xz |
arm: move nomadik timer to drivers/clocksource
as this timer is shared with multiple arch
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Diffstat (limited to 'arch/arm/mach-nomadik')
-rw-r--r-- | arch/arm/mach-nomadik/8815.c | 5 | ||||
-rw-r--r-- | arch/arm/mach-nomadik/include/mach/mtu.h | 46 | ||||
-rw-r--r-- | arch/arm/mach-nomadik/include/mach/timex.h | 6 | ||||
-rw-r--r-- | arch/arm/mach-nomadik/timer.c | 54 |
4 files changed, 8 insertions, 103 deletions
diff --git a/arch/arm/mach-nomadik/8815.c b/arch/arm/mach-nomadik/8815.c index 81c5ce16d8..c5cac580d2 100644 --- a/arch/arm/mach-nomadik/8815.c +++ b/arch/arm/mach-nomadik/8815.c @@ -29,6 +29,10 @@ static struct clk st8815_clk_48 = { .rate = 48 * 1000 * 1000, }; +static struct clk st8815_clk_2_4 = { + .rate = 2400000, +}; + static struct clk st8815_dummy; void st8815_add_device_sdram(u32 size) @@ -38,6 +42,7 @@ void st8815_add_device_sdram(u32 size) static struct clk_lookup clocks_lookups[] = { CLKDEV_CON_ID("apb_pclk", &st8815_dummy), + CLKDEV_CON_ID("nomadik_mtu", &st8815_clk_2_4), CLKDEV_DEV_ID("uart-pl0110", &st8815_clk_48), CLKDEV_DEV_ID("uart-pl0111", &st8815_clk_48), }; diff --git a/arch/arm/mach-nomadik/include/mach/mtu.h b/arch/arm/mach-nomadik/include/mach/mtu.h deleted file mode 100644 index 9095d86a5a..0000000000 --- a/arch/arm/mach-nomadik/include/mach/mtu.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef __ASM_ARCH_MTU_H -#define __ASM_ARCH_MTU_H - -/* - * The MTU device hosts four different counters, with 4 set of - * registers. These are register names. - */ - -#define MTU_IMSC 0x00 /* Interrupt mask set/clear */ -#define MTU_RIS 0x04 /* Raw interrupt status */ -#define MTU_MIS 0x08 /* Masked interrupt status */ -#define MTU_ICR 0x0C /* Interrupt clear register */ - -/* per-timer registers take 0..3 as argument */ -#define MTU_LR(x) (0x10 + 0x10 * (x) + 0x00) /* Load value */ -#define MTU_VAL(x) (0x10 + 0x10 * (x) + 0x04) /* Current value */ - -#define MTU_CR(x) (0x10 + 0x10 * (x) + 0x08) /* Control reg */ -#define MTU_BGLR(x) (0x10 + 0x10 * (x) + 0x0c) /* At next overflow */ - - -/* bits for the control register */ -#define MTU_CRn_ENA 0x80 -#define MTU_CRn_PERIODIC 0x40 /* if 0 = free-running */ -#define MTU_CRn_PRESCALE_MASK 0x0c -#define MTU_CRn_PRESCALE_1 0x00 -#define MTU_CRn_PRESCALE_16 0x04 -#define MTU_CRn_PRESCALE_256 0x08 -#define MTU_CRn_32BITS 0x02 -#define MTU_CRn_ONESHOT 0x01 /* if 0 = wraps reloading from BGLR*/ - -/* Other registers are usual amba/primecell registers, currently not used */ -#define MTU_ITCR 0xff0 -#define MTU_ITOP 0xff4 - -#define MTU_PERIPH_ID0 0xfe0 -#define MTU_PERIPH_ID1 0xfe4 -#define MTU_PERIPH_ID2 0xfe8 -#define MTU_PERIPH_ID3 0xfeC - -#define MTU_PCELL0 0xff0 -#define MTU_PCELL1 0xff4 -#define MTU_PCELL2 0xff8 -#define MTU_PCELL3 0xffC - -#endif /* __ASM_ARCH_MTU_H */ diff --git a/arch/arm/mach-nomadik/include/mach/timex.h b/arch/arm/mach-nomadik/include/mach/timex.h deleted file mode 100644 index b2b41faa1b..0000000000 --- a/arch/arm/mach-nomadik/include/mach/timex.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __ASM_ARCH_TIMEX_H -#define __ASM_ARCH_TIMEX_H - -#define CLOCK_TICK_RATE 2400000 - -#endif diff --git a/arch/arm/mach-nomadik/timer.c b/arch/arm/mach-nomadik/timer.c index becd36357a..0b8dc866eb 100644 --- a/arch/arm/mach-nomadik/timer.c +++ b/arch/arm/mach-nomadik/timer.c @@ -10,55 +10,16 @@ */ #include <common.h> #include <init.h> -#include <clock.h> #include <io.h> #include <mach/hardware.h> -#include <mach/mtu.h> -#include <mach/timex.h> /* Initial value for SRC control register: all timers use MXTAL/8 source */ #define SRC_CR_INIT_MASK 0x00007fff #define SRC_CR_INIT_VAL 0x2aaa8000 -static u32 nmdk_cycle; /* write-once */ -static __iomem void *mtu_base; - -/* - * clocksource: the MTU device is a decrementing counters, so we negate - * the value being read. - */ -static uint64_t nmdk_read_timer(void) -{ - return nmdk_cycle - readl(mtu_base + MTU_VAL(0)); -} - -static struct clocksource nmdk_clksrc = { - .read = nmdk_read_timer, - .shift = 20, - .mask = CLOCKSOURCE_MASK(32), -}; - -static void nmdk_timer_reset(void) -{ - u32 cr; - - writel(0, mtu_base + MTU_CR(0)); /* off */ - - /* configure load and background-load, and fire it up */ - writel(nmdk_cycle, mtu_base + MTU_LR(0)); - writel(nmdk_cycle, mtu_base + MTU_BGLR(0)); - cr = MTU_CRn_PRESCALE_1 | MTU_CRn_32BITS; - writel(cr, mtu_base + MTU_CR(0)); - writel(cr | MTU_CRn_ENA, mtu_base + MTU_CR(0)); -} - -static int nmdk_timer_init(void) +static int st8815_timer_init(void) { u32 src_cr; - unsigned long rate; - - rate = CLOCK_TICK_RATE; /* 2.4MHz */ - nmdk_cycle = (rate + 1000 / 2) / 1000; /* Configure timer sources in "system reset controller" ctrl reg */ src_cr = readl(NOMADIK_SRC_BASE); @@ -66,16 +27,7 @@ static int nmdk_timer_init(void) src_cr |= SRC_CR_INIT_VAL; writel(src_cr, NOMADIK_SRC_BASE); - /* Save global pointer to mtu, used by functions above */ - mtu_base = (void *)NOMADIK_MTU0_BASE; - - /* Init the timer and register clocksource */ - nmdk_timer_reset(); - - nmdk_clksrc.mult = clocksource_hz2mult(rate, nmdk_clksrc.shift); - - init_clock(&nmdk_clksrc); - + add_generic_device("nomadik_mtu", DEVICE_ID_SINGLE, NULL, NOMADIK_MTU0_BASE, 0x1000, IORESOURCE_MEM, NULL); return 0; } -core_initcall(nmdk_timer_init); +coredevice_initcall(st8815_timer_init); |