summaryrefslogtreecommitdiffstats
path: root/target/linux/lantiq/patches-3.3/0070-icu-multi-base.patch
blob: d7e098f909cebc50a60f7d05d842d243a9ba4d6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
Index: linux-3.3.8/arch/mips/include/asm/mach-lantiq/xway/lantiq_irq.h
===================================================================
--- linux-3.3.8.orig/arch/mips/include/asm/mach-lantiq/xway/lantiq_irq.h	2012-07-31 08:34:35.000000000 +0200
+++ linux-3.3.8/arch/mips/include/asm/mach-lantiq/xway/lantiq_irq.h	2012-07-31 08:34:46.063369976 +0200
@@ -9,6 +9,8 @@
 #ifndef _LANTIQ_XWAY_IRQ_H__
 #define _LANTIQ_XWAY_IRQ_H__
 
+#define IM_NUM			5
+
 #define INT_NUM_IRQ0		8
 #define INT_NUM_IM0_IRL0	(INT_NUM_IRQ0 + 0)
 #define INT_NUM_IM1_IRL0	(INT_NUM_IRQ0 + 32)
Index: linux-3.3.8/arch/mips/lantiq/irq.c
===================================================================
--- linux-3.3.8.orig/arch/mips/lantiq/irq.c	2012-07-31 08:34:35.000000000 +0200
+++ linux-3.3.8/arch/mips/lantiq/irq.c	2012-07-31 08:51:40.203413329 +0200
@@ -48,8 +48,8 @@
  */
 #define LTQ_ICU_EBU_IRQ		22
 
-#define ltq_icu_w32(x, y)	ltq_w32((x), ltq_icu_membase + (y))
-#define ltq_icu_r32(x)		ltq_r32(ltq_icu_membase + (x))
+#define ltq_icu_w32(x, y, m)	ltq_w32((x), ltq_icu_membase[m] + (y))
+#define ltq_icu_r32(x, m)		ltq_r32(ltq_icu_membase[m] + (x))
 
 #define ltq_eiu_w32(x, y)	ltq_w32((x), ltq_eiu_membase + (y))
 #define ltq_eiu_r32(x)		ltq_r32(ltq_eiu_membase + (x))
@@ -63,11 +63,78 @@
 	LTQ_EIU_IR5,
 };
 
-static struct resource ltq_icu_resource = {
-	.name	= "icu",
-	.start	= LTQ_ICU_BASE_ADDR,
-	.end	= LTQ_ICU_BASE_ADDR + LTQ_ICU_SIZE - 1,
-	.flags	= IORESOURCE_MEM,
+static struct resource ltq_icu_resource[IM_NUM] = {
+{
+	.name   = "icu_im0",
+	.start  = LTQ_ICU_BASE_ADDR,
+	.end    = LTQ_ICU_BASE_ADDR + LTQ_ICU_OFFSET - 1,
+	.flags  = IORESOURCE_MEM,
+},
+#if IM_NUM >= 2
+{
+	.name   = "icu_im1",
+#ifdef LTQ_ICU_BASE_ADDR1
+	.start  = LTQ_ICU_BASE_ADDR1,
+	.end    = LTQ_ICU_BASE_ADDR1 + LTQ_ICU_OFFSET - 1,
+#else
+	.start  = LTQ_ICU_BASE_ADDR + (LTQ_ICU_OFFSET * 1),
+	.end    = LTQ_ICU_BASE_ADDR + (LTQ_ICU_OFFSET * 2) - 1,
+#endif
+	.flags  = IORESOURCE_MEM,
+},
+#endif
+#if IM_NUM >= 3
+{
+	.name   = "icu_im2",
+#ifdef LTQ_ICU_BASE_ADDR2
+	.start  = LTQ_ICU_BASE_ADDR2,
+	.end    = LTQ_ICU_BASE_ADDR2 + LTQ_ICU_OFFSET - 1,
+#else
+	.start  = LTQ_ICU_BASE_ADDR + (LTQ_ICU_OFFSET * 2),
+	.end    = LTQ_ICU_BASE_ADDR + (LTQ_ICU_OFFSET * 3) - 1,
+#endif
+	.flags  = IORESOURCE_MEM,
+},
+#endif
+#if IM_NUM >= 4
+{
+	.name   = "icu_im3",
+#ifdef LTQ_ICU_BASE_ADDR3
+	.start  = LTQ_ICU_BASE_ADDR3,
+	.end    = LTQ_ICU_BASE_ADDR3 + LTQ_ICU_OFFSET - 1,
+#else
+	.start  = LTQ_ICU_BASE_ADDR + (LTQ_ICU_OFFSET * 3),
+	.end    = LTQ_ICU_BASE_ADDR + (LTQ_ICU_OFFSET * 4) - 1,
+#endif
+	.flags  = IORESOURCE_MEM,
+},
+#endif
+#if IM_NUM >= 5
+{      
+	.name   = "icu_im4",
+#ifdef LTQ_ICU_BASE_ADDR4
+	.start  = LTQ_ICU_BASE_ADDR4,
+	.end    = LTQ_ICU_BASE_ADDR4 + LTQ_ICU_OFFSET - 1,
+#else
+	.start  = LTQ_ICU_BASE_ADDR + (LTQ_ICU_OFFSET * 4),
+	.end    = LTQ_ICU_BASE_ADDR + (LTQ_ICU_OFFSET * 5) - 1,
+#endif
+	.flags  = IORESOURCE_MEM,
+},
+#endif
+#if IM_NUM >= 6
+{
+	.name   = "icu_im5",
+#ifdef LTQ_ICU_BASE_ADDR5
+	.start  = LTQ_ICU_BASE_ADDR5,
+	.end    = LTQ_ICU_BASE_ADDR5 + LTQ_ICU_OFFSET - 1,
+#else
+	.start  = LTQ_ICU_BASE_ADDR + (LTQ_ICU_OFFSET * 5),
+	.end    = LTQ_ICU_BASE_ADDR + (LTQ_ICU_OFFSET * 6) - 1,
+#endif
+	.flags  = IORESOURCE_MEM,
+},
+#endif
 };
 
 static struct resource ltq_eiu_resource = {
@@ -77,50 +144,56 @@
 	.flags	= IORESOURCE_MEM,
 };
 
-static void __iomem *ltq_icu_membase;
+static void __iomem *ltq_icu_membase[IM_NUM];
 static void __iomem *ltq_eiu_membase;
 
 void ltq_disable_irq(struct irq_data *d)
 {
-	u32 ier = LTQ_ICU_IM0_IER;
 	int irq_nr = d->irq - INT_NUM_IRQ0;
+	unsigned int im_nr;
 
-	ier += LTQ_ICU_OFFSET * (irq_nr / INT_NUM_IM_OFFSET);
+	im_nr = (irq_nr / INT_NUM_IM_OFFSET);
 	irq_nr %= INT_NUM_IM_OFFSET;
-	ltq_icu_w32(ltq_icu_r32(ier) & ~(1 << irq_nr), ier);
+
+	ltq_icu_w32(ltq_icu_r32(LTQ_ICU_IM0_IER, im_nr) & ~(1 << irq_nr),
+		LTQ_ICU_IM0_IER, im_nr);
 }
 
 void ltq_mask_and_ack_irq(struct irq_data *d)
 {
-	u32 ier = LTQ_ICU_IM0_IER;
-	u32 isr = LTQ_ICU_IM0_ISR;
 	int irq_nr = d->irq - INT_NUM_IRQ0;
+	unsigned int im_nr;
 
-	ier += LTQ_ICU_OFFSET * (irq_nr / INT_NUM_IM_OFFSET);
-	isr += LTQ_ICU_OFFSET * (irq_nr / INT_NUM_IM_OFFSET);
+	irq_nr -= INT_NUM_IRQ0;
+	im_nr = (irq_nr / INT_NUM_IM_OFFSET);
 	irq_nr %= INT_NUM_IM_OFFSET;
-	ltq_icu_w32(ltq_icu_r32(ier) & ~(1 << irq_nr), ier);
-	ltq_icu_w32((1 << irq_nr), isr);
+
+	ltq_icu_w32(ltq_icu_r32(LTQ_ICU_IM0_IER, im_nr) & ~(1 << irq_nr), LTQ_ICU_IM0_IER, im_nr);
+	ltq_icu_w32((1 << irq_nr), LTQ_ICU_IM0_ISR, im_nr);
 }
 
 static void ltq_ack_irq(struct irq_data *d)
 {
-	u32 isr = LTQ_ICU_IM0_ISR;
 	int irq_nr = d->irq - INT_NUM_IRQ0;
+	unsigned int im_nr;
 
-	isr += LTQ_ICU_OFFSET * (irq_nr / INT_NUM_IM_OFFSET);
+	irq_nr -= INT_NUM_IRQ0;
+	im_nr = (irq_nr / INT_NUM_IM_OFFSET);
 	irq_nr %= INT_NUM_IM_OFFSET;
-	ltq_icu_w32((1 << irq_nr), isr);
+
+	ltq_icu_w32((1 << irq_nr), LTQ_ICU_IM0_ISR, im_nr);
 }
 
 void ltq_enable_irq(struct irq_data *d)
 {
-	u32 ier = LTQ_ICU_IM0_IER;
 	int irq_nr = d->irq - INT_NUM_IRQ0;
+	unsigned int im_nr;
 
-	ier += LTQ_ICU_OFFSET  * (irq_nr / INT_NUM_IM_OFFSET);
+	irq_nr -= INT_NUM_IRQ0;
+	im_nr = (irq_nr / INT_NUM_IM_OFFSET);
 	irq_nr %= INT_NUM_IM_OFFSET;
-	ltq_icu_w32(ltq_icu_r32(ier) | (1 << irq_nr), ier);
+
+	ltq_icu_w32(ltq_icu_r32(LTQ_ICU_IM0_IER, im_nr) | (1 << irq_nr), LTQ_ICU_IM0_IER, im_nr);
 }
 
 static unsigned int ltq_startup_eiu_irq(struct irq_data *d)
@@ -187,7 +260,7 @@
 {
 	u32 irq;
 
-	irq = ltq_icu_r32(LTQ_ICU_IM0_IOSR + (module * LTQ_ICU_OFFSET));
+	irq = ltq_icu_r32(LTQ_ICU_IM0_IOSR, module);
 	if (irq == 0)
 		return;
 
@@ -250,8 +323,19 @@
 {
 	int i;
 
-	if (insert_resource(&iomem_resource, &ltq_icu_resource) < 0)
-		panic("Failed to insert icu memory");
+	for (i=0; i < IM_NUM; i++) {
+		if (insert_resource(&iomem_resource, &ltq_icu_resource[i]) < 0)
+			panic("Failed to insert icu memory\n");
+
+		if (request_mem_region(ltq_icu_resource[i].start,
+				resource_size(&ltq_icu_resource[i]), "icu") < 0)
+			panic("Failed to request icu memory\n");
+
+		ltq_icu_membase[i] = ioremap_nocache(ltq_icu_resource[i].start,
+					resource_size(&ltq_icu_resource[i]));
+		if (!ltq_icu_membase[i])
+			panic("Failed to remap icu memory\n");
+	}
 
 	if (request_mem_region(ltq_icu_resource.start,
 			resource_size(&ltq_icu_resource), "icu") < 0)
@@ -277,11 +361,11 @@
 	}
 
 	/* make sure all irqs are turned off by default */
-	for (i = 0; i < 5; i++)
-		ltq_icu_w32(0, LTQ_ICU_IM0_IER + (i * LTQ_ICU_OFFSET));
-
-	/* clear all possibly pending interrupts */
-	ltq_icu_w32(~0, LTQ_ICU_IM0_ISR + (i * LTQ_ICU_OFFSET));
+	for (i = 0; i < IM_NUM; i++)
+		ltq_icu_w32(0, LTQ_ICU_IM0_IER, i);
+		/* clear all possibly pending interrupts */
+		ltq_icu_w32(~0, LTQ_ICU_IM0_ISR, i);
+	}
 
 	mips_cpu_irq_init();