aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennert Buytenhek <buytenh@wantstofly.org>2006-09-18 18:19:02 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-09-25 05:25:43 -0400
commit863753a81e4f863015be34900dc2ba3637622f34 (patch)
tree9843fbb5b8f972f488d056c3dd11de483064b27d
parent48388b2a56ae5e0f1c422e84d536f31729469b17 (diff)
[ARM] 3823/1: iop3xx: switch iop32x/iop33x over to shared time code
Switch the iop32x and iop33x code over to the common time implementation, and remove the (nearly identical) iop32x and iop33x time implementations. Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-iop32x/Makefile2
-rw-r--r--arch/arm/mach-iop32x/setup.c15
-rw-r--r--arch/arm/mach-iop32x/time.c108
-rw-r--r--arch/arm/mach-iop33x/Makefile2
-rw-r--r--arch/arm/mach-iop33x/setup.c12
-rw-r--r--arch/arm/mach-iop33x/time.c106
-rw-r--r--include/asm-arm/arch-iop32x/iop321.h21
-rw-r--r--include/asm-arm/arch-iop32x/timex.h2
-rw-r--r--include/asm-arm/arch-iop33x/iop331.h21
-rw-r--r--include/asm-arm/arch-iop33x/timex.h2
10 files changed, 26 insertions, 265 deletions
diff --git a/arch/arm/mach-iop32x/Makefile b/arch/arm/mach-iop32x/Makefile
index 7266224ab6d7..ef561db20c9b 100644
--- a/arch/arm/mach-iop32x/Makefile
+++ b/arch/arm/mach-iop32x/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5obj-y := common.o setup.o irq.o time.o 5obj-y := common.o setup.o irq.o
6obj-m := 6obj-m :=
7obj-n := 7obj-n :=
8obj- := 8obj- :=
diff --git a/arch/arm/mach-iop32x/setup.c b/arch/arm/mach-iop32x/setup.c
index 1a03b0b41baa..68de247a4cca 100644
--- a/arch/arm/mach-iop32x/setup.c
+++ b/arch/arm/mach-iop32x/setup.c
@@ -29,6 +29,7 @@
29#include <asm/hardware.h> 29#include <asm/hardware.h>
30#include <asm/mach-types.h> 30#include <asm/mach-types.h>
31#include <asm/mach/arch.h> 31#include <asm/mach/arch.h>
32#include <asm/mach/time.h>
32#include <asm/hardware/iop3xx.h> 33#include <asm/hardware/iop3xx.h>
33 34
34#define IOP321_UART_XTAL 1843200 35#define IOP321_UART_XTAL 1843200
@@ -67,16 +68,22 @@ void __init iop32x_init(void)
67 68
68#ifdef CONFIG_ARCH_IQ80321 69#ifdef CONFIG_ARCH_IQ80321
69extern void iq80321_map_io(void); 70extern void iq80321_map_io(void);
70extern struct sys_timer iop321_timer;
71extern void iop321_init_time(void);
72#endif 71#endif
73 72
74#ifdef CONFIG_ARCH_IQ31244 73#ifdef CONFIG_ARCH_IQ31244
75extern void iq31244_map_io(void); 74extern void iq31244_map_io(void);
76extern struct sys_timer iop321_timer;
77extern void iop321_init_time(void);
78#endif 75#endif
79 76
77static void __init iop3xx_timer_init(void)
78{
79 iop3xx_init_time(IOP321_TICK_RATE);
80}
81
82struct sys_timer iop321_timer = {
83 .init = iop3xx_timer_init,
84 .offset = iop3xx_gettimeoffset,
85};
86
80#if defined(CONFIG_ARCH_IQ80321) 87#if defined(CONFIG_ARCH_IQ80321)
81MACHINE_START(IQ80321, "Intel IQ80321") 88MACHINE_START(IQ80321, "Intel IQ80321")
82 /* Maintainer: Intel Corporation */ 89 /* Maintainer: Intel Corporation */
diff --git a/arch/arm/mach-iop32x/time.c b/arch/arm/mach-iop32x/time.c
deleted file mode 100644
index 3cabbbca0a02..000000000000
--- a/arch/arm/mach-iop32x/time.c
+++ /dev/null
@@ -1,108 +0,0 @@
1/*
2 * arch/arm/mach-iop32x/time.c
3 *
4 * Timer code for IOP321 based systems
5 *
6 * Author: Deepak Saxena <dsaxena@mvista.com>
7 *
8 * Copyright 2002-2003 MontaVista Software Inc.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#include <linux/kernel.h>
17#include <linux/interrupt.h>
18#include <linux/time.h>
19#include <linux/init.h>
20#include <linux/timex.h>
21
22#include <asm/hardware.h>
23#include <asm/io.h>
24#include <asm/irq.h>
25#include <asm/uaccess.h>
26#include <asm/mach/irq.h>
27#include <asm/mach/time.h>
28
29#define IOP321_TIME_SYNC 0
30
31static inline unsigned long get_elapsed(void)
32{
33 return LATCH - *IOP321_TU_TCR0;
34}
35
36static unsigned long iop321_gettimeoffset(void)
37{
38 unsigned long elapsed, usec;
39 u32 tisr1, tisr2;
40
41 /*
42 * If an interrupt was pending before we read the timer,
43 * we've already wrapped. Factor this into the time.
44 * If an interrupt was pending after we read the timer,
45 * it may have wrapped between checking the interrupt
46 * status and reading the timer. Re-read the timer to
47 * be sure its value is after the wrap.
48 */
49
50 asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr1));
51 elapsed = get_elapsed();
52 asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr2));
53
54 if(tisr1 & 1)
55 elapsed += LATCH;
56 else if (tisr2 & 1)
57 elapsed = LATCH + get_elapsed();
58
59 /*
60 * Now convert them to usec.
61 */
62 usec = (unsigned long)(elapsed / (CLOCK_TICK_RATE/1000000));
63
64 return usec;
65}
66
67static irqreturn_t
68iop321_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
69{
70 u32 tisr;
71
72 write_seqlock(&xtime_lock);
73
74 asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr));
75 tisr |= 1;
76 asm volatile("mcr p6, 0, %0, c6, c1, 0" : : "r" (tisr));
77
78 timer_tick(regs);
79
80 write_sequnlock(&xtime_lock);
81
82 return IRQ_HANDLED;
83}
84
85static struct irqaction iop321_timer_irq = {
86 .name = "IOP321 Timer Tick",
87 .handler = iop321_timer_interrupt,
88 .flags = IRQF_DISABLED | IRQF_TIMER,
89};
90
91static void __init iop321_timer_init(void)
92{
93 u32 timer_ctl;
94
95 setup_irq(IRQ_IOP321_TIMER0, &iop321_timer_irq);
96
97 timer_ctl = IOP321_TMR_EN | IOP321_TMR_PRIVILEGED | IOP321_TMR_RELOAD |
98 IOP321_TMR_RATIO_1_1;
99
100 asm volatile("mcr p6, 0, %0, c4, c1, 0" : : "r" (LATCH));
101
102 asm volatile("mcr p6, 0, %0, c0, c1, 0" : : "r" (timer_ctl));
103}
104
105struct sys_timer iop321_timer = {
106 .init = &iop321_timer_init,
107 .offset = iop321_gettimeoffset,
108};
diff --git a/arch/arm/mach-iop33x/Makefile b/arch/arm/mach-iop33x/Makefile
index 6c74f13b1139..f825cee57d9f 100644
--- a/arch/arm/mach-iop33x/Makefile
+++ b/arch/arm/mach-iop33x/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the linux kernel. 2# Makefile for the linux kernel.
3# 3#
4 4
5obj-y := setup.o irq.o time.o 5obj-y := setup.o irq.o
6obj-m := 6obj-m :=
7obj-n := 7obj-n :=
8obj- := 8obj- :=
diff --git a/arch/arm/mach-iop33x/setup.c b/arch/arm/mach-iop33x/setup.c
index ad737d6582b5..7cf5015436f3 100644
--- a/arch/arm/mach-iop33x/setup.c
+++ b/arch/arm/mach-iop33x/setup.c
@@ -28,6 +28,7 @@
28#include <asm/hardware.h> 28#include <asm/hardware.h>
29#include <asm/mach-types.h> 29#include <asm/mach-types.h>
30#include <asm/mach/arch.h> 30#include <asm/mach/arch.h>
31#include <asm/mach/time.h>
31#include <asm/hardware/iop3xx.h> 32#include <asm/hardware/iop3xx.h>
32 33
33#define IOP331_UART_XTAL 33334000 34#define IOP331_UART_XTAL 33334000
@@ -118,9 +119,18 @@ void __init iop33x_init(void)
118 119
119#ifdef CONFIG_ARCH_IOP33X 120#ifdef CONFIG_ARCH_IOP33X
120extern void iop331_init_irq(void); 121extern void iop331_init_irq(void);
121extern struct sys_timer iop331_timer;
122#endif 122#endif
123 123
124static void __init iop3xx_timer_init(void)
125{
126 iop3xx_init_time(IOP331_TICK_RATE);
127}
128
129struct sys_timer iop331_timer = {
130 .init = iop3xx_timer_init,
131 .offset = iop3xx_gettimeoffset,
132};
133
124#if defined(CONFIG_ARCH_IQ80331) 134#if defined(CONFIG_ARCH_IQ80331)
125MACHINE_START(IQ80331, "Intel IQ80331") 135MACHINE_START(IQ80331, "Intel IQ80331")
126 /* Maintainer: Intel Corp. */ 136 /* Maintainer: Intel Corp. */
diff --git a/arch/arm/mach-iop33x/time.c b/arch/arm/mach-iop33x/time.c
deleted file mode 100644
index d839cd0d926e..000000000000
--- a/arch/arm/mach-iop33x/time.c
+++ /dev/null
@@ -1,106 +0,0 @@
1/*
2 * arch/arm/mach-iop33x/time.c
3 *
4 * Timer code for IOP331 based systems
5 *
6 * Author: Dave Jiang <dave.jiang@intel.com>
7 *
8 * Copyright 2003 Intel Corp.
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
14 */
15
16#include <linux/kernel.h>
17#include <linux/interrupt.h>
18#include <linux/time.h>
19#include <linux/init.h>
20#include <linux/timex.h>
21
22#include <asm/hardware.h>
23#include <asm/io.h>
24#include <asm/irq.h>
25#include <asm/uaccess.h>
26#include <asm/mach/irq.h>
27#include <asm/mach/time.h>
28
29static inline unsigned long get_elapsed(void)
30{
31 return LATCH - *IOP331_TU_TCR0;
32}
33
34static unsigned long iop331_gettimeoffset(void)
35{
36 unsigned long elapsed, usec;
37 u32 tisr1, tisr2;
38
39 /*
40 * If an interrupt was pending before we read the timer,
41 * we've already wrapped. Factor this into the time.
42 * If an interrupt was pending after we read the timer,
43 * it may have wrapped between checking the interrupt
44 * status and reading the timer. Re-read the timer to
45 * be sure its value is after the wrap.
46 */
47
48 asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr1));
49 elapsed = get_elapsed();
50 asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr2));
51
52 if(tisr1 & 1)
53 elapsed += LATCH;
54 else if (tisr2 & 1)
55 elapsed = LATCH + get_elapsed();
56
57 /*
58 * Now convert them to usec.
59 */
60 usec = (unsigned long)(elapsed / (CLOCK_TICK_RATE/1000000));
61
62 return usec;
63}
64
65static irqreturn_t
66iop331_timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
67{
68 u32 tisr;
69
70 write_seqlock(&xtime_lock);
71
72 asm volatile("mrc p6, 0, %0, c6, c1, 0" : "=r" (tisr));
73 tisr |= 1;
74 asm volatile("mcr p6, 0, %0, c6, c1, 0" : : "r" (tisr));
75
76 timer_tick(regs);
77
78 write_sequnlock(&xtime_lock);
79 return IRQ_HANDLED;
80}
81
82static struct irqaction iop331_timer_irq = {
83 .name = "IOP331 Timer Tick",
84 .handler = iop331_timer_interrupt,
85 .flags = IRQF_DISABLED | IRQF_TIMER,
86};
87
88static void __init iop331_timer_init(void)
89{
90 u32 timer_ctl;
91
92 setup_irq(IRQ_IOP331_TIMER0, &iop331_timer_irq);
93
94 timer_ctl = IOP331_TMR_EN | IOP331_TMR_PRIVILEGED | IOP331_TMR_RELOAD |
95 IOP331_TMR_RATIO_1_1;
96
97 asm volatile("mcr p6, 0, %0, c4, c1, 0" : : "r" (LATCH));
98
99 asm volatile("mcr p6, 0, %0, c0, c1, 0" : : "r" (timer_ctl));
100
101}
102
103struct sys_timer iop331_timer = {
104 .init = iop331_timer_init,
105 .offset = iop331_gettimeoffset,
106};
diff --git a/include/asm-arm/arch-iop32x/iop321.h b/include/asm-arm/arch-iop32x/iop321.h
index bd96b8d55a76..34fe07f0a44e 100644
--- a/include/asm-arm/arch-iop32x/iop321.h
+++ b/include/asm-arm/arch-iop32x/iop321.h
@@ -151,10 +151,6 @@
151#define IOP321_FINTSRC (volatile u32 *)IOP321_REG_ADDR(0x000007DC) 151#define IOP321_FINTSRC (volatile u32 *)IOP321_REG_ADDR(0x000007DC)
152 152
153/* Timers */ 153/* Timers */
154
155#define IOP321_TU_TMR0 (volatile u32 *)IOP321_REG_ADDR(0x000007E0)
156#define IOP321_TU_TMR1 (volatile u32 *)IOP321_REG_ADDR(0x000007E4)
157
158#ifdef CONFIG_ARCH_IQ80321 154#ifdef CONFIG_ARCH_IQ80321
159#define IOP321_TICK_RATE 200000000 /* 200 MHz clock */ 155#define IOP321_TICK_RATE 200000000 /* 200 MHz clock */
160#elif defined(CONFIG_ARCH_IQ31244) 156#elif defined(CONFIG_ARCH_IQ31244)
@@ -166,23 +162,6 @@
166#define IOP321_TICK_RATE 200000000 /* 33.333333 Mhz crystal */ 162#define IOP321_TICK_RATE 200000000 /* 33.333333 Mhz crystal */
167#endif 163#endif
168 164
169#define IOP321_TMR_TC 0x01
170#define IOP321_TMR_EN 0x02
171#define IOP321_TMR_RELOAD 0x04
172#define IOP321_TMR_PRIVILEGED 0x09
173
174#define IOP321_TMR_RATIO_1_1 0x00
175#define IOP321_TMR_RATIO_4_1 0x10
176#define IOP321_TMR_RATIO_8_1 0x20
177#define IOP321_TMR_RATIO_16_1 0x30
178
179#define IOP321_TU_TCR0 (volatile u32 *)IOP321_REG_ADDR(0x000007E8)
180#define IOP321_TU_TCR1 (volatile u32 *)IOP321_REG_ADDR(0x000007EC)
181#define IOP321_TU_TRR0 (volatile u32 *)IOP321_REG_ADDR(0x000007F0)
182#define IOP321_TU_TRR1 (volatile u32 *)IOP321_REG_ADDR(0x000007F4)
183#define IOP321_TU_TISR (volatile u32 *)IOP321_REG_ADDR(0x000007F8)
184#define IOP321_TU_WDTCR (volatile u32 *)IOP321_REG_ADDR(0x000007FC)
185
186/* Application accelerator unit 0x00000800 - 0x000008FF */ 165/* Application accelerator unit 0x00000800 - 0x000008FF */
187#define IOP321_AAU_ACR (volatile u32 *)IOP321_REG_ADDR(0x00000800) 166#define IOP321_AAU_ACR (volatile u32 *)IOP321_REG_ADDR(0x00000800)
188#define IOP321_AAU_ASR (volatile u32 *)IOP321_REG_ADDR(0x00000804) 167#define IOP321_AAU_ASR (volatile u32 *)IOP321_REG_ADDR(0x00000804)
diff --git a/include/asm-arm/arch-iop32x/timex.h b/include/asm-arm/arch-iop32x/timex.h
index 08badde2e820..328f37282c3e 100644
--- a/include/asm-arm/arch-iop32x/timex.h
+++ b/include/asm-arm/arch-iop32x/timex.h
@@ -5,4 +5,4 @@
5 */ 5 */
6#include <asm/hardware.h> 6#include <asm/hardware.h>
7 7
8#define CLOCK_TICK_RATE IOP321_TICK_RATE 8#define CLOCK_TICK_RATE (100 * HZ)
diff --git a/include/asm-arm/arch-iop33x/iop331.h b/include/asm-arm/arch-iop33x/iop331.h
index b301ef8f7f32..4ebcd7197c86 100644
--- a/include/asm-arm/arch-iop33x/iop331.h
+++ b/include/asm-arm/arch-iop33x/iop331.h
@@ -137,27 +137,6 @@
137 137
138 138
139/* Timers */ 139/* Timers */
140
141#define IOP331_TU_TMR0 (volatile u32 *)IOP331_REG_ADDR(0x000007D0)
142#define IOP331_TU_TMR1 (volatile u32 *)IOP331_REG_ADDR(0x000007D4)
143
144#define IOP331_TMR_TC 0x01
145#define IOP331_TMR_EN 0x02
146#define IOP331_TMR_RELOAD 0x04
147#define IOP331_TMR_PRIVILEGED 0x09
148
149#define IOP331_TMR_RATIO_1_1 0x00
150#define IOP331_TMR_RATIO_4_1 0x10
151#define IOP331_TMR_RATIO_8_1 0x20
152#define IOP331_TMR_RATIO_16_1 0x30
153
154#define IOP331_TU_TCR0 (volatile u32 *)IOP331_REG_ADDR(0x000007D8)
155#define IOP331_TU_TCR1 (volatile u32 *)IOP331_REG_ADDR(0x000007DC)
156#define IOP331_TU_TRR0 (volatile u32 *)IOP331_REG_ADDR(0x000007E0)
157#define IOP331_TU_TRR1 (volatile u32 *)IOP331_REG_ADDR(0x000007E4)
158#define IOP331_TU_TISR (volatile u32 *)IOP331_REG_ADDR(0x000007E8)
159#define IOP331_TU_WDTCR (volatile u32 *)IOP331_REG_ADDR(0x000007EC)
160
161#if defined(CONFIG_ARCH_IOP33X) 140#if defined(CONFIG_ARCH_IOP33X)
162#define IOP331_TICK_RATE 266000000 /* 266 MHz IB clock */ 141#define IOP331_TICK_RATE 266000000 /* 266 MHz IB clock */
163#endif 142#endif
diff --git a/include/asm-arm/arch-iop33x/timex.h b/include/asm-arm/arch-iop33x/timex.h
index cc8085fa2a1e..8994322a09f4 100644
--- a/include/asm-arm/arch-iop33x/timex.h
+++ b/include/asm-arm/arch-iop33x/timex.h
@@ -5,4 +5,4 @@
5 */ 5 */
6#include <asm/hardware.h> 6#include <asm/hardware.h>
7 7
8#define CLOCK_TICK_RATE IOP331_TICK_RATE 8#define CLOCK_TICK_RATE (100 * HZ)