diff options
Diffstat (limited to 'arch/arm/mach-versatile/core.c')
-rw-r--r-- | arch/arm/mach-versatile/core.c | 147 |
1 files changed, 7 insertions, 140 deletions
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c index eb94a07dc9..b0124b700c 100644 --- a/arch/arm/mach-versatile/core.c +++ b/arch/arm/mach-versatile/core.c @@ -35,144 +35,11 @@ #include <linux/amba/bus.h> #include <io.h> -#include <asm/hardware/arm_timer.h> #include <asm/armlinux.h> -#include <mach/platform.h> -#include <mach/init.h> +#include <mach/versatile/platform.h> -struct clk { - unsigned long rate; -}; - -static struct clk ref_clk_dummy; - -static struct clk ref_clk_24 = { - .rate = 24000000, -}; - -unsigned long clk_get_rate(struct clk *clk) -{ - return clk->rate; -} -EXPORT_SYMBOL(clk_get_rate); - -/* enable and disable do nothing */ -int clk_set_rate(struct clk *clk, unsigned long rate) -{ - return 0; -} -EXPORT_SYMBOL(clk_set_rate); - -int clk_enable(struct clk *clk) -{ - return 0; -} -EXPORT_SYMBOL(clk_enable); - -void clk_disable(struct clk *clk) -{ -} -EXPORT_SYMBOL(clk_disable); - -/* 1Mhz / 256 */ -#define TIMER_FREQ (1000000/256) - -#define TIMER0_BASE (VERSATILE_TIMER0_1_BASE) -#define TIMER1_BASE ((VERSATILE_TIMER0_1_BASE) + 0x20) -#define TIMER2_BASE (VERSATILE_TIMER2_3_BASE) -#define TIMER3_BASE ((VERSATILE_TIMER2_3_BASE) + 0x20) - -static uint64_t vpb_clocksource_read(void) -{ - return ~readl(TIMER0_BASE + TIMER_VALUE); -} - -static struct clocksource vpb_cs = { - .read = vpb_clocksource_read, - .mask = CLOCKSOURCE_MASK(32), - .shift = 10, -}; - -/* From Linux v2.6.35 - * arch/arm/mach-versatile/core.c */ -static void versatile_timer_init (void) -{ - u32 val; - - /* - * set clock frequency: - * VERSATILE_REFCLK is 32KHz - * VERSATILE_TIMCLK is 1MHz - */ - - val = readl(VERSATILE_SCTL_BASE); - val |= (VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel); - writel(val, VERSATILE_SCTL_BASE); - - /* - * Disable all timers, just to be sure. - */ - - writel(0, TIMER0_BASE + TIMER_CTRL); - writel(0, TIMER1_BASE + TIMER_CTRL); - writel(0, TIMER2_BASE + TIMER_CTRL); - writel(0, TIMER3_BASE + TIMER_CTRL); - - writel(TIMER_CTRL_32BIT | TIMER_CTRL_ENABLE | TIMER_CTRL_DIV256, - TIMER0_BASE + TIMER_CTRL); -} - -static int vpb_clocksource_init(void) -{ - versatile_timer_init(); - vpb_cs.mult = clocksource_hz2mult(TIMER_FREQ, vpb_cs.shift); - - return init_clock(&vpb_cs); -} - -core_initcall(vpb_clocksource_init); - -static struct clk_lookup clocks_lookups[] = { - CLKDEV_CON_ID("apb_pclk", &ref_clk_dummy), - CLKDEV_DEV_ID("uart-pl0110", &ref_clk_24), - CLKDEV_DEV_ID("uart-pl0111", &ref_clk_24), - CLKDEV_DEV_ID("uart-pl0112", &ref_clk_24), - CLKDEV_DEV_ID("uart-pl0113", &ref_clk_24), -}; - -static int versatile_clkdev_init(void) -{ - clkdev_add_table(clocks_lookups, ARRAY_SIZE(clocks_lookups)); - - return 0; -} -postcore_initcall(versatile_clkdev_init); - -void versatile_register_uart(unsigned id) -{ - resource_size_t start; - - switch (id) { - case 0: - start = VERSATILE_UART0_BASE; - break; - case 1: - start = VERSATILE_UART1_BASE; - break; - case 2: - start = VERSATILE_UART2_BASE; - break; - case 3: - start = VERSATILE_UART3_BASE; - break; - default: - return; - } - amba_apb_device_add(NULL, "uart-pl011", id, start, 4096, NULL, 0); -} - -static void versatile_reset_soc(struct restart_handler *rst) +static void __noreturn versatile_reset_soc(struct restart_handler *rst) { u32 val; @@ -188,11 +55,11 @@ static void versatile_reset_soc(struct restart_handler *rst) static int versatile_init(void) { - amba_apb_device_add(NULL, "pl061_gpio", 0, 0x101e4000, 4096, NULL, 0); - amba_apb_device_add(NULL, "pl061_gpio", 1, 0x101e5000, 4096, NULL, 0); - amba_apb_device_add(NULL, "pl061_gpio", 2, 0x101e6000, 4096, NULL, 0); - amba_apb_device_add(NULL, "pl061_gpio", 3, 0x101e7000, 4096, NULL, 0); + if (!of_machine_is_compatible("arm,versatile-pb") && + !of_machine_is_compatible("arm,versatile-ab")) + return 0; + restart_handler_register_fn("soc", versatile_reset_soc); return 0; } -coredevice_initcall(versatile_init); +core_initcall(versatile_init); |