aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2011-09-08 16:23:15 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2011-10-17 04:12:43 -0400
commitbb76079a7859fb33a23bef405517b6b653d9f649 (patch)
tree680e267c4700811d6c34893dd3aa94e796130396 /arch/arm
parent6d8ce7129f6c4c2f8716d6a771d59f263deab898 (diff)
ARM: 7087/2: mach-integrator: get timer frequency from clock
We already have a clock definition for the 24MHz clock in the Integrator, use that instead of some unclear defines from the platform.h header. Also delete the senseless comment that the file shouldn't be edited, I just edited it and the world didn't come to an end, so it's obviously false. If anyone still has the mentioned ".s file" and the s2h awk script generating that header, raise your hand (and give me your files). Acked-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-integrator/core.c4
-rw-r--r--arch/arm/mach-integrator/include/mach/platform.h12
-rw-r--r--arch/arm/mach-integrator/integrator_ap.c37
3 files changed, 27 insertions, 26 deletions
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index 77315b995681..82ebc8d772d3 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -126,6 +126,10 @@ static struct clk_lookup lookups[] = {
126 { /* Bus clock */ 126 { /* Bus clock */
127 .con_id = "apb_pclk", 127 .con_id = "apb_pclk",
128 .clk = &dummy_apb_pclk, 128 .clk = &dummy_apb_pclk,
129 }, {
130 /* Integrator/AP timer frequency */
131 .dev_id = "ap_timer",
132 .clk = &clk24mhz,
129 }, { /* UART0 */ 133 }, { /* UART0 */
130 .dev_id = "mb:16", 134 .dev_id = "mb:16",
131 .clk = &uartclk, 135 .clk = &uartclk,
diff --git a/arch/arm/mach-integrator/include/mach/platform.h b/arch/arm/mach-integrator/include/mach/platform.h
index 5e6ea5cfea6e..ec467baade09 100644
--- a/arch/arm/mach-integrator/include/mach/platform.h
+++ b/arch/arm/mach-integrator/include/mach/platform.h
@@ -13,9 +13,6 @@
13 * along with this program; if not, write to the Free Software 13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 */ 15 */
16/* DO NOT EDIT!! - this file automatically generated
17 * from .s file by awk -f s2h.awk
18 */
19/************************************************************************** 16/**************************************************************************
20 * * Copyright © ARM Limited 1998. All rights reserved. 17 * * Copyright © ARM Limited 1998. All rights reserved.
21 * ***********************************************************************/ 18 * ***********************************************************************/
@@ -399,15 +396,6 @@
399#define INTEGRATOR_TIMER1_BASE (INTEGRATOR_CT_BASE + 0x100) 396#define INTEGRATOR_TIMER1_BASE (INTEGRATOR_CT_BASE + 0x100)
400#define INTEGRATOR_TIMER2_BASE (INTEGRATOR_CT_BASE + 0x200) 397#define INTEGRATOR_TIMER2_BASE (INTEGRATOR_CT_BASE + 0x200)
401 398
402#define TICKS_PER_uSEC 24
403
404/*
405 * These are useconds NOT ticks.
406 *
407 */
408#define mSEC_1 1000
409#define mSEC_10 (mSEC_1 * 10)
410
411#define INTEGRATOR_CSR_BASE 0x10000000 399#define INTEGRATOR_CSR_BASE 0x10000000
412#define INTEGRATOR_CSR_SIZE 0x10000000 400#define INTEGRATOR_CSR_SIZE 0x10000000
413 401
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
index 0a6f397f1222..8dca5a7ab370 100644
--- a/arch/arm/mach-integrator/integrator_ap.c
+++ b/arch/arm/mach-integrator/integrator_ap.c
@@ -32,6 +32,7 @@
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/io.h> 33#include <linux/io.h>
34#include <linux/mtd/physmap.h> 34#include <linux/mtd/physmap.h>
35#include <linux/clk.h>
35 36
36#include <mach/hardware.h> 37#include <mach/hardware.h>
37#include <mach/platform.h> 38#include <mach/platform.h>
@@ -322,13 +323,14 @@ static void __init ap_init(void)
322 323
323static unsigned long timer_reload; 324static unsigned long timer_reload;
324 325
325static void integrator_clocksource_init(u32 khz) 326static void integrator_clocksource_init(unsigned long inrate)
326{ 327{
327 void __iomem *base = (void __iomem *)TIMER2_VA_BASE; 328 void __iomem *base = (void __iomem *)TIMER2_VA_BASE;
328 u32 ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC; 329 u32 ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC;
330 unsigned long rate = inrate;
329 331
330 if (khz >= 1500) { 332 if (rate >= 1500000) {
331 khz /= 16; 333 rate /= 16;
332 ctrl |= TIMER_CTRL_DIV16; 334 ctrl |= TIMER_CTRL_DIV16;
333 } 335 }
334 336
@@ -336,7 +338,7 @@ static void integrator_clocksource_init(u32 khz)
336 writel(ctrl, base + TIMER_CTRL); 338 writel(ctrl, base + TIMER_CTRL);
337 339
338 clocksource_mmio_init(base + TIMER_VALUE, "timer2", 340 clocksource_mmio_init(base + TIMER_VALUE, "timer2",
339 khz * 1000, 200, 16, clocksource_mmio_readl_down); 341 rate, 200, 16, clocksource_mmio_readl_down);
340} 342}
341 343
342static void __iomem * const clkevt_base = (void __iomem *)TIMER1_VA_BASE; 344static void __iomem * const clkevt_base = (void __iomem *)TIMER1_VA_BASE;
@@ -411,24 +413,25 @@ static struct irqaction integrator_timer_irq = {
411 .dev_id = &integrator_clockevent, 413 .dev_id = &integrator_clockevent,
412}; 414};
413 415
414static void integrator_clockevent_init(u32 khz) 416static void integrator_clockevent_init(unsigned long inrate)
415{ 417{
418 unsigned long rate = inrate;
416 unsigned int ctrl = 0; 419 unsigned int ctrl = 0;
417 420
418 /* Calculate and program a divisor */ 421 /* Calculate and program a divisor */
419 if (khz * 1000 > 0x100000 * HZ) { 422 if (rate > 0x100000 * HZ) {
420 khz /= 256; 423 rate /= 256;
421 ctrl |= TIMER_CTRL_DIV256; 424 ctrl |= TIMER_CTRL_DIV256;
422 } else if (khz * 1000 > 0x10000 * HZ) { 425 } else if (rate > 0x10000 * HZ) {
423 khz /= 16; 426 rate /= 16;
424 ctrl |= TIMER_CTRL_DIV16; 427 ctrl |= TIMER_CTRL_DIV16;
425 } 428 }
426 timer_reload = khz * 1000 / HZ; 429 timer_reload = rate / HZ;
427 writel(ctrl, clkevt_base + TIMER_CTRL); 430 writel(ctrl, clkevt_base + TIMER_CTRL);
428 431
429 setup_irq(IRQ_TIMERINT1, &integrator_timer_irq); 432 setup_irq(IRQ_TIMERINT1, &integrator_timer_irq);
430 clockevents_config_and_register(&integrator_clockevent, 433 clockevents_config_and_register(&integrator_clockevent,
431 khz * 1000, 434 rate,
432 1, 435 1,
433 0xffffU); 436 0xffffU);
434} 437}
@@ -438,14 +441,20 @@ static void integrator_clockevent_init(u32 khz)
438 */ 441 */
439static void __init ap_init_timer(void) 442static void __init ap_init_timer(void)
440{ 443{
441 u32 khz = TICKS_PER_uSEC * 1000; 444 struct clk *clk;
445 unsigned long rate;
446
447 clk = clk_get_sys("ap_timer", NULL);
448 BUG_ON(IS_ERR(clk));
449 clk_enable(clk);
450 rate = clk_get_rate(clk);
442 451
443 writel(0, TIMER0_VA_BASE + TIMER_CTRL); 452 writel(0, TIMER0_VA_BASE + TIMER_CTRL);
444 writel(0, TIMER1_VA_BASE + TIMER_CTRL); 453 writel(0, TIMER1_VA_BASE + TIMER_CTRL);
445 writel(0, TIMER2_VA_BASE + TIMER_CTRL); 454 writel(0, TIMER2_VA_BASE + TIMER_CTRL);
446 455
447 integrator_clocksource_init(khz); 456 integrator_clocksource_init(rate);
448 integrator_clockevent_init(khz); 457 integrator_clockevent_init(rate);
449} 458}
450 459
451static struct sys_timer ap_timer = { 460static struct sys_timer ap_timer = {