[ARM] 4013/1: clocksource driver for netx

Add a clocksource driver for netx systems

Signed-off-by: Luotao Fu <lfu@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by Sascha Hauer and committed by Russell King 1a815aed c80204e5

+30 -12
+30 -12
arch/arm/mach-netx/time.c
··· 19 19 20 20 #include <linux/init.h> 21 21 #include <linux/interrupt.h> 22 + #include <linux/irq.h> 23 + #include <linux/clocksource.h> 22 24 23 25 #include <asm/hardware.h> 24 26 #include <asm/io.h> 25 27 #include <asm/mach/time.h> 26 28 #include <asm/arch/netx-regs.h> 27 - 28 - /* 29 - * Returns number of us since last clock interrupt. Note that interrupts 30 - * will have been disabled by do_gettimeoffset() 31 - */ 32 - static unsigned long netx_gettimeoffset(void) 33 - { 34 - return readl(NETX_GPIO_COUNTER_CURRENT(0)) / 100; 35 - } 36 29 37 30 /* 38 31 * IRQ handler for the timer ··· 36 43 write_seqlock(&xtime_lock); 37 44 38 45 timer_tick(); 46 + 39 47 write_sequnlock(&xtime_lock); 40 48 41 49 /* acknowledge interrupt */ ··· 45 51 return IRQ_HANDLED; 46 52 } 47 53 48 - 49 54 static struct irqaction netx_timer_irq = { 50 55 .name = "NetX Timer Tick", 51 56 .flags = IRQF_DISABLED | IRQF_TIMER, 52 57 .handler = netx_timer_interrupt, 58 + }; 59 + 60 + cycle_t netx_get_cycles(void) 61 + { 62 + return readl(NETX_GPIO_COUNTER_CURRENT(1)); 63 + } 64 + 65 + static struct clocksource clocksource_netx = { 66 + .name = "netx_timer", 67 + .rating = 200, 68 + .read = netx_get_cycles, 69 + .mask = CLOCKSOURCE_MASK(32), 70 + .shift = 20, 71 + .is_continuous = 1, 53 72 }; 54 73 55 74 /* ··· 87 80 NETX_GPIO_COUNTER_CTRL(0)); 88 81 89 82 setup_irq(NETX_IRQ_TIMER0, &netx_timer_irq); 83 + 84 + /* Setup timer one for clocksource */ 85 + writel(0, NETX_GPIO_COUNTER_CTRL(1)); 86 + writel(0, NETX_GPIO_COUNTER_CURRENT(1)); 87 + writel(0xFFFFFFFF, NETX_GPIO_COUNTER_MAX(1)); 88 + 89 + writel(NETX_GPIO_COUNTER_CTRL_RUN, 90 + NETX_GPIO_COUNTER_CTRL(1)); 91 + 92 + clocksource_netx.mult = 93 + clocksource_hz2mult(CLOCK_TICK_RATE, clocksource_netx.shift); 94 + clocksource_register(&clocksource_netx); 90 95 } 91 96 92 97 struct sys_timer netx_timer = { 93 - .init = netx_timer_init, 94 - .offset = netx_gettimeoffset, 98 + .init = netx_timer_init, 95 99 };