diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-28 09:04:11 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-28 09:04:11 -0800 |
commit | 627f4b3ee3899bb70263ee77454a43c73136562f (patch) | |
tree | 0464b4d97b462991e4f3458a9daa3665eaeb6f63 /arch/microblaze/kernel/timer.c | |
parent | e770d73ceb93c235525cb9bbbf1374c9b61a0895 (diff) | |
parent | c0d68cea2db34a510f4d67b90aab1c48bc47461e (diff) | |
download | blackbird-op-linux-627f4b3ee3899bb70263ee77454a43c73136562f.tar.gz blackbird-op-linux-627f4b3ee3899bb70263ee77454a43c73136562f.zip |
Merge tag 'microblaze-3.14-rc1' of git://git.monstr.eu/linux-2.6-microblaze
Pull microblaze patches from Michal Simek:
- add CCF support
- fix BS=0 compilation
- wire up defconfig
- some minor cleanups and fixes
* tag 'microblaze-3.14-rc1' of git://git.monstr.eu/linux-2.6-microblaze:
microblaze: Add missing v8.50.a version
microblaze: Fix missing bracket in printk
microblaze: Fix compilation error for BS=0
microblaze: Disable stack protection from bootloader
microblaze: Define read/write{b,w,l}_relaxed MMIO
microblaze: timer: Do not initialized system timer twice
microblaze: timer: Use generic sched_clock implementation
microblaze: Add NOTES section to linker script
microblaze: Add support for CCF
microblaze: Simplify fcpu helper function
microblaze/uapi: Use Kbuild logic to include <asm-generic/types.h>
microblaze: Remove duplicate declarations of _stext[] and _etext[]
microblaze: Remove _fdt_start casts
microblaze: Wire up defconfig to mmu_defconfig
Diffstat (limited to 'arch/microblaze/kernel/timer.c')
-rw-r--r-- | arch/microblaze/kernel/timer.c | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c index 3e39b1082fdf..fb0c61443f19 100644 --- a/arch/microblaze/kernel/timer.c +++ b/arch/microblaze/kernel/timer.c @@ -12,12 +12,12 @@ #include <linux/interrupt.h> #include <linux/delay.h> #include <linux/sched.h> +#include <linux/sched_clock.h> #include <linux/clk.h> #include <linux/clockchips.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <asm/cpuinfo.h> -#include <linux/cnt32_to_63.h> static void __iomem *timer_baseaddr; @@ -167,10 +167,15 @@ static __init void xilinx_clockevent_init(void) clockevents_register_device(&clockevent_xilinx_timer); } +static u64 xilinx_clock_read(void) +{ + return in_be32(timer_baseaddr + TCR1); +} + static cycle_t xilinx_read(struct clocksource *cs) { /* reading actual value of timer 1 */ - return (cycle_t) (in_be32(timer_baseaddr + TCR1)); + return (cycle_t)xilinx_clock_read(); } static struct timecounter xilinx_tc = { @@ -222,17 +227,17 @@ static int __init xilinx_clocksource_init(void) return 0; } -/* - * We have to protect accesses before timer initialization - * and return 0 for sched_clock function below. - */ -static int timer_initialized; - static void __init xilinx_timer_init(struct device_node *timer) { + struct clk *clk; + static int initialized; u32 irq; u32 timer_num = 1; - int ret; + + if (initialized) + return; + + initialized = 1; timer_baseaddr = of_iomap(timer, 0); if (!timer_baseaddr) { @@ -250,10 +255,20 @@ static void __init xilinx_timer_init(struct device_node *timer) pr_info("%s: irq=%d\n", timer->full_name, irq); - /* If there is clock-frequency property than use it */ - ret = of_property_read_u32(timer, "clock-frequency", &timer_clock_freq); - if (ret < 0) + clk = of_clk_get(timer, 0); + if (IS_ERR(clk)) { + pr_err("ERROR: timer CCF input clock not found\n"); + /* If there is clock-frequency property than use it */ + of_property_read_u32(timer, "clock-frequency", + &timer_clock_freq); + } else { + timer_clock_freq = clk_get_rate(clk); + } + + if (!timer_clock_freq) { + pr_err("ERROR: Using CPU clock frequency\n"); timer_clock_freq = cpuinfo.cpu_clock_freq; + } freq_div_hz = timer_clock_freq / HZ; @@ -263,18 +278,8 @@ static void __init xilinx_timer_init(struct device_node *timer) #endif xilinx_clocksource_init(); xilinx_clockevent_init(); - timer_initialized = 1; -} -unsigned long long notrace sched_clock(void) -{ - if (timer_initialized) { - struct clocksource *cs = &clocksource_microblaze; - - cycle_t cyc = cnt32_to_63(cs->read(NULL)) & LLONG_MAX; - return clocksource_cyc2ns(cyc, cs->mult, cs->shift); - } - return 0; + sched_clock_register(xilinx_clock_read, 32, timer_clock_freq); } CLOCKSOURCE_OF_DECLARE(xilinx_timer, "xlnx,xps-timer-1.00.a", |