diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-05-23 14:28:04 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2011-05-23 14:28:04 -0400 |
commit | 9a55d9752d8abfc62f1ab05ccc790d22a0c8e7c0 (patch) | |
tree | 894bb6a3fb409c6ac5f0374f5a1f656918bc35cd /arch/arm/plat-orion | |
parent | ec19628d72cff8f80220b7cedba089074ac6a599 (diff) | |
parent | dc7ad3b3d5f1cd0a0d16c05dd3ad3898979d261e (diff) |
Merge branch 'devel-stable' into for-linus
Conflicts:
arch/arm/Kconfig
arch/arm/mach-ns9xxx/include/mach/uncompress.h
Diffstat (limited to 'arch/arm/plat-orion')
-rw-r--r-- | arch/arm/plat-orion/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/plat-orion/common.c | 957 | ||||
-rw-r--r-- | arch/arm/plat-orion/gpio.c | 112 | ||||
-rw-r--r-- | arch/arm/plat-orion/include/plat/common.h | 117 | ||||
-rw-r--r-- | arch/arm/plat-orion/include/plat/gpio.h | 1 | ||||
-rw-r--r-- | arch/arm/plat-orion/include/plat/mpp.h | 34 | ||||
-rw-r--r-- | arch/arm/plat-orion/irq.c | 49 | ||||
-rw-r--r-- | arch/arm/plat-orion/mpp.c | 78 |
8 files changed, 1232 insertions, 118 deletions
diff --git a/arch/arm/plat-orion/Makefile b/arch/arm/plat-orion/Makefile index 56021a72e10c..95a5fc53b6db 100644 --- a/arch/arm/plat-orion/Makefile +++ b/arch/arm/plat-orion/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for the linux kernel. | 2 | # Makefile for the linux kernel. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := irq.o pcie.o time.o | 5 | obj-y := irq.o pcie.o time.o common.o mpp.o |
6 | obj-m := | 6 | obj-m := |
7 | obj-n := | 7 | obj-n := |
8 | obj- := | 8 | obj- := |
diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c new file mode 100644 index 000000000000..9e5451b3c8e3 --- /dev/null +++ b/arch/arm/plat-orion/common.c | |||
@@ -0,0 +1,957 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-orion/common.c | ||
3 | * | ||
4 | * Marvell Orion SoC common setup code used by multiple mach-/common.c | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/dma-mapping.h> | ||
15 | #include <linux/serial_8250.h> | ||
16 | #include <linux/mbus.h> | ||
17 | #include <linux/ata_platform.h> | ||
18 | #include <linux/mv643xx_eth.h> | ||
19 | #include <linux/mv643xx_i2c.h> | ||
20 | #include <net/dsa.h> | ||
21 | #include <linux/spi/orion_spi.h> | ||
22 | #include <plat/orion_wdt.h> | ||
23 | #include <plat/mv_xor.h> | ||
24 | #include <plat/ehci-orion.h> | ||
25 | |||
26 | /* Fill in the resources structure and link it into the platform | ||
27 | device structure. There is always a memory region, and nearly | ||
28 | always an interrupt.*/ | ||
29 | static void fill_resources(struct platform_device *device, | ||
30 | struct resource *resources, | ||
31 | resource_size_t mapbase, | ||
32 | resource_size_t size, | ||
33 | unsigned int irq) | ||
34 | { | ||
35 | device->resource = resources; | ||
36 | device->num_resources = 1; | ||
37 | resources[0].flags = IORESOURCE_MEM; | ||
38 | resources[0].start = mapbase; | ||
39 | resources[0].end = mapbase + size; | ||
40 | |||
41 | if (irq != NO_IRQ) { | ||
42 | device->num_resources++; | ||
43 | resources[1].flags = IORESOURCE_IRQ; | ||
44 | resources[1].start = irq; | ||
45 | resources[1].end = irq; | ||
46 | } | ||
47 | } | ||
48 | |||
49 | /***************************************************************************** | ||
50 | * UART | ||
51 | ****************************************************************************/ | ||
52 | static void __init uart_complete( | ||
53 | struct platform_device *orion_uart, | ||
54 | struct plat_serial8250_port *data, | ||
55 | struct resource *resources, | ||
56 | unsigned int membase, | ||
57 | resource_size_t mapbase, | ||
58 | unsigned int irq, | ||
59 | unsigned int uartclk) | ||
60 | { | ||
61 | data->mapbase = mapbase; | ||
62 | data->membase = (void __iomem *)membase; | ||
63 | data->irq = irq; | ||
64 | data->uartclk = uartclk; | ||
65 | orion_uart->dev.platform_data = data; | ||
66 | |||
67 | fill_resources(orion_uart, resources, mapbase, 0xff, irq); | ||
68 | platform_device_register(orion_uart); | ||
69 | } | ||
70 | |||
71 | /***************************************************************************** | ||
72 | * UART0 | ||
73 | ****************************************************************************/ | ||
74 | static struct plat_serial8250_port orion_uart0_data[] = { | ||
75 | { | ||
76 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, | ||
77 | .iotype = UPIO_MEM, | ||
78 | .regshift = 2, | ||
79 | }, { | ||
80 | }, | ||
81 | }; | ||
82 | |||
83 | static struct resource orion_uart0_resources[2]; | ||
84 | |||
85 | static struct platform_device orion_uart0 = { | ||
86 | .name = "serial8250", | ||
87 | .id = PLAT8250_DEV_PLATFORM, | ||
88 | }; | ||
89 | |||
90 | void __init orion_uart0_init(unsigned int membase, | ||
91 | resource_size_t mapbase, | ||
92 | unsigned int irq, | ||
93 | unsigned int uartclk) | ||
94 | { | ||
95 | uart_complete(&orion_uart0, orion_uart0_data, orion_uart0_resources, | ||
96 | membase, mapbase, irq, uartclk); | ||
97 | } | ||
98 | |||
99 | /***************************************************************************** | ||
100 | * UART1 | ||
101 | ****************************************************************************/ | ||
102 | static struct plat_serial8250_port orion_uart1_data[] = { | ||
103 | { | ||
104 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, | ||
105 | .iotype = UPIO_MEM, | ||
106 | .regshift = 2, | ||
107 | }, { | ||
108 | }, | ||
109 | }; | ||
110 | |||
111 | static struct resource orion_uart1_resources[2]; | ||
112 | |||
113 | static struct platform_device orion_uart1 = { | ||
114 | .name = "serial8250", | ||
115 | .id = PLAT8250_DEV_PLATFORM1, | ||
116 | }; | ||
117 | |||
118 | void __init orion_uart1_init(unsigned int membase, | ||
119 | resource_size_t mapbase, | ||
120 | unsigned int irq, | ||
121 | unsigned int uartclk) | ||
122 | { | ||
123 | uart_complete(&orion_uart1, orion_uart1_data, orion_uart1_resources, | ||
124 | membase, mapbase, irq, uartclk); | ||
125 | } | ||
126 | |||
127 | /***************************************************************************** | ||
128 | * UART2 | ||
129 | ****************************************************************************/ | ||
130 | static struct plat_serial8250_port orion_uart2_data[] = { | ||
131 | { | ||
132 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, | ||
133 | .iotype = UPIO_MEM, | ||
134 | .regshift = 2, | ||
135 | }, { | ||
136 | }, | ||
137 | }; | ||
138 | |||
139 | static struct resource orion_uart2_resources[2]; | ||
140 | |||
141 | static struct platform_device orion_uart2 = { | ||
142 | .name = "serial8250", | ||
143 | .id = PLAT8250_DEV_PLATFORM2, | ||
144 | }; | ||
145 | |||
146 | void __init orion_uart2_init(unsigned int membase, | ||
147 | resource_size_t mapbase, | ||
148 | unsigned int irq, | ||
149 | unsigned int uartclk) | ||
150 | { | ||
151 | uart_complete(&orion_uart2, orion_uart2_data, orion_uart2_resources, | ||
152 | membase, mapbase, irq, uartclk); | ||
153 | } | ||
154 | |||
155 | /***************************************************************************** | ||
156 | * UART3 | ||
157 | ****************************************************************************/ | ||
158 | static struct plat_serial8250_port orion_uart3_data[] = { | ||
159 | { | ||
160 | .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF, | ||
161 | .iotype = UPIO_MEM, | ||
162 | .regshift = 2, | ||
163 | }, { | ||
164 | }, | ||
165 | }; | ||
166 | |||
167 | static struct resource orion_uart3_resources[2]; | ||
168 | |||
169 | static struct platform_device orion_uart3 = { | ||
170 | .name = "serial8250", | ||
171 | .id = 3, | ||
172 | }; | ||
173 | |||
174 | void __init orion_uart3_init(unsigned int membase, | ||
175 | resource_size_t mapbase, | ||
176 | unsigned int irq, | ||
177 | unsigned int uartclk) | ||
178 | { | ||
179 | uart_complete(&orion_uart3, orion_uart3_data, orion_uart3_resources, | ||
180 | membase, mapbase, irq, uartclk); | ||
181 | } | ||
182 | |||
183 | /***************************************************************************** | ||
184 | * SoC RTC | ||
185 | ****************************************************************************/ | ||
186 | static struct resource orion_rtc_resource[2]; | ||
187 | |||
188 | void __init orion_rtc_init(unsigned long mapbase, | ||
189 | unsigned long irq) | ||
190 | { | ||
191 | orion_rtc_resource[0].start = mapbase; | ||
192 | orion_rtc_resource[0].end = mapbase + SZ_32 - 1; | ||
193 | orion_rtc_resource[0].flags = IORESOURCE_MEM; | ||
194 | orion_rtc_resource[1].start = irq; | ||
195 | orion_rtc_resource[1].end = irq; | ||
196 | orion_rtc_resource[1].flags = IORESOURCE_IRQ; | ||
197 | |||
198 | platform_device_register_simple("rtc-mv", -1, orion_rtc_resource, 2); | ||
199 | } | ||
200 | |||
201 | /***************************************************************************** | ||
202 | * GE | ||
203 | ****************************************************************************/ | ||
204 | static __init void ge_complete( | ||
205 | struct mv643xx_eth_shared_platform_data *orion_ge_shared_data, | ||
206 | struct mbus_dram_target_info *mbus_dram_info, int tclk, | ||
207 | struct resource *orion_ge_resource, unsigned long irq, | ||
208 | struct platform_device *orion_ge_shared, | ||
209 | struct mv643xx_eth_platform_data *eth_data, | ||
210 | struct platform_device *orion_ge) | ||
211 | { | ||
212 | orion_ge_shared_data->dram = mbus_dram_info; | ||
213 | orion_ge_shared_data->t_clk = tclk; | ||
214 | orion_ge_resource->start = irq; | ||
215 | orion_ge_resource->end = irq; | ||
216 | eth_data->shared = orion_ge_shared; | ||
217 | orion_ge->dev.platform_data = eth_data; | ||
218 | |||
219 | platform_device_register(orion_ge_shared); | ||
220 | platform_device_register(orion_ge); | ||
221 | } | ||
222 | |||
223 | /***************************************************************************** | ||
224 | * GE00 | ||
225 | ****************************************************************************/ | ||
226 | struct mv643xx_eth_shared_platform_data orion_ge00_shared_data; | ||
227 | |||
228 | static struct resource orion_ge00_shared_resources[] = { | ||
229 | { | ||
230 | .name = "ge00 base", | ||
231 | }, { | ||
232 | .name = "ge00 err irq", | ||
233 | }, | ||
234 | }; | ||
235 | |||
236 | static struct platform_device orion_ge00_shared = { | ||
237 | .name = MV643XX_ETH_SHARED_NAME, | ||
238 | .id = 0, | ||
239 | .dev = { | ||
240 | .platform_data = &orion_ge00_shared_data, | ||
241 | }, | ||
242 | }; | ||
243 | |||
244 | static struct resource orion_ge00_resources[] = { | ||
245 | { | ||
246 | .name = "ge00 irq", | ||
247 | .flags = IORESOURCE_IRQ, | ||
248 | }, | ||
249 | }; | ||
250 | |||
251 | static struct platform_device orion_ge00 = { | ||
252 | .name = MV643XX_ETH_NAME, | ||
253 | .id = 0, | ||
254 | .num_resources = 1, | ||
255 | .resource = orion_ge00_resources, | ||
256 | .dev = { | ||
257 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
258 | }, | ||
259 | }; | ||
260 | |||
261 | void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, | ||
262 | struct mbus_dram_target_info *mbus_dram_info, | ||
263 | unsigned long mapbase, | ||
264 | unsigned long irq, | ||
265 | unsigned long irq_err, | ||
266 | int tclk) | ||
267 | { | ||
268 | fill_resources(&orion_ge00_shared, orion_ge00_shared_resources, | ||
269 | mapbase + 0x2000, SZ_16K - 1, irq_err); | ||
270 | ge_complete(&orion_ge00_shared_data, mbus_dram_info, tclk, | ||
271 | orion_ge00_resources, irq, &orion_ge00_shared, | ||
272 | eth_data, &orion_ge00); | ||
273 | } | ||
274 | |||
275 | /***************************************************************************** | ||
276 | * GE01 | ||
277 | ****************************************************************************/ | ||
278 | struct mv643xx_eth_shared_platform_data orion_ge01_shared_data = { | ||
279 | .shared_smi = &orion_ge00_shared, | ||
280 | }; | ||
281 | |||
282 | static struct resource orion_ge01_shared_resources[] = { | ||
283 | { | ||
284 | .name = "ge01 base", | ||
285 | }, { | ||
286 | .name = "ge01 err irq", | ||
287 | }, | ||
288 | }; | ||
289 | |||
290 | static struct platform_device orion_ge01_shared = { | ||
291 | .name = MV643XX_ETH_SHARED_NAME, | ||
292 | .id = 1, | ||
293 | .dev = { | ||
294 | .platform_data = &orion_ge01_shared_data, | ||
295 | }, | ||
296 | }; | ||
297 | |||
298 | static struct resource orion_ge01_resources[] = { | ||
299 | { | ||
300 | .name = "ge01 irq", | ||
301 | .flags = IORESOURCE_IRQ, | ||
302 | }, | ||
303 | }; | ||
304 | |||
305 | static struct platform_device orion_ge01 = { | ||
306 | .name = MV643XX_ETH_NAME, | ||
307 | .id = 1, | ||
308 | .num_resources = 1, | ||
309 | .resource = orion_ge01_resources, | ||
310 | .dev = { | ||
311 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
312 | }, | ||
313 | }; | ||
314 | |||
315 | void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, | ||
316 | struct mbus_dram_target_info *mbus_dram_info, | ||
317 | unsigned long mapbase, | ||
318 | unsigned long irq, | ||
319 | unsigned long irq_err, | ||
320 | int tclk) | ||
321 | { | ||
322 | fill_resources(&orion_ge01_shared, orion_ge01_shared_resources, | ||
323 | mapbase + 0x2000, SZ_16K - 1, irq_err); | ||
324 | ge_complete(&orion_ge01_shared_data, mbus_dram_info, tclk, | ||
325 | orion_ge01_resources, irq, &orion_ge01_shared, | ||
326 | eth_data, &orion_ge01); | ||
327 | } | ||
328 | |||
329 | /***************************************************************************** | ||
330 | * GE10 | ||
331 | ****************************************************************************/ | ||
332 | struct mv643xx_eth_shared_platform_data orion_ge10_shared_data = { | ||
333 | .shared_smi = &orion_ge00_shared, | ||
334 | }; | ||
335 | |||
336 | static struct resource orion_ge10_shared_resources[] = { | ||
337 | { | ||
338 | .name = "ge10 base", | ||
339 | }, { | ||
340 | .name = "ge10 err irq", | ||
341 | }, | ||
342 | }; | ||
343 | |||
344 | static struct platform_device orion_ge10_shared = { | ||
345 | .name = MV643XX_ETH_SHARED_NAME, | ||
346 | .id = 1, | ||
347 | .dev = { | ||
348 | .platform_data = &orion_ge10_shared_data, | ||
349 | }, | ||
350 | }; | ||
351 | |||
352 | static struct resource orion_ge10_resources[] = { | ||
353 | { | ||
354 | .name = "ge10 irq", | ||
355 | .flags = IORESOURCE_IRQ, | ||
356 | }, | ||
357 | }; | ||
358 | |||
359 | static struct platform_device orion_ge10 = { | ||
360 | .name = MV643XX_ETH_NAME, | ||
361 | .id = 1, | ||
362 | .num_resources = 2, | ||
363 | .resource = orion_ge10_resources, | ||
364 | .dev = { | ||
365 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
366 | }, | ||
367 | }; | ||
368 | |||
369 | void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data, | ||
370 | struct mbus_dram_target_info *mbus_dram_info, | ||
371 | unsigned long mapbase, | ||
372 | unsigned long irq, | ||
373 | unsigned long irq_err, | ||
374 | int tclk) | ||
375 | { | ||
376 | fill_resources(&orion_ge10_shared, orion_ge10_shared_resources, | ||
377 | mapbase + 0x2000, SZ_16K - 1, irq_err); | ||
378 | ge_complete(&orion_ge10_shared_data, mbus_dram_info, tclk, | ||
379 | orion_ge10_resources, irq, &orion_ge10_shared, | ||
380 | eth_data, &orion_ge10); | ||
381 | } | ||
382 | |||
383 | /***************************************************************************** | ||
384 | * GE11 | ||
385 | ****************************************************************************/ | ||
386 | struct mv643xx_eth_shared_platform_data orion_ge11_shared_data = { | ||
387 | .shared_smi = &orion_ge00_shared, | ||
388 | }; | ||
389 | |||
390 | static struct resource orion_ge11_shared_resources[] = { | ||
391 | { | ||
392 | .name = "ge11 base", | ||
393 | }, { | ||
394 | .name = "ge11 err irq", | ||
395 | }, | ||
396 | }; | ||
397 | |||
398 | static struct platform_device orion_ge11_shared = { | ||
399 | .name = MV643XX_ETH_SHARED_NAME, | ||
400 | .id = 1, | ||
401 | .dev = { | ||
402 | .platform_data = &orion_ge11_shared_data, | ||
403 | }, | ||
404 | }; | ||
405 | |||
406 | static struct resource orion_ge11_resources[] = { | ||
407 | { | ||
408 | .name = "ge11 irq", | ||
409 | .flags = IORESOURCE_IRQ, | ||
410 | }, | ||
411 | }; | ||
412 | |||
413 | static struct platform_device orion_ge11 = { | ||
414 | .name = MV643XX_ETH_NAME, | ||
415 | .id = 1, | ||
416 | .num_resources = 2, | ||
417 | .resource = orion_ge11_resources, | ||
418 | .dev = { | ||
419 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
420 | }, | ||
421 | }; | ||
422 | |||
423 | void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, | ||
424 | struct mbus_dram_target_info *mbus_dram_info, | ||
425 | unsigned long mapbase, | ||
426 | unsigned long irq, | ||
427 | unsigned long irq_err, | ||
428 | int tclk) | ||
429 | { | ||
430 | fill_resources(&orion_ge11_shared, orion_ge11_shared_resources, | ||
431 | mapbase + 0x2000, SZ_16K - 1, irq_err); | ||
432 | ge_complete(&orion_ge11_shared_data, mbus_dram_info, tclk, | ||
433 | orion_ge11_resources, irq, &orion_ge11_shared, | ||
434 | eth_data, &orion_ge11); | ||
435 | } | ||
436 | |||
437 | /***************************************************************************** | ||
438 | * Ethernet switch | ||
439 | ****************************************************************************/ | ||
440 | static struct resource orion_switch_resources[] = { | ||
441 | { | ||
442 | .start = 0, | ||
443 | .end = 0, | ||
444 | .flags = IORESOURCE_IRQ, | ||
445 | }, | ||
446 | }; | ||
447 | |||
448 | static struct platform_device orion_switch_device = { | ||
449 | .name = "dsa", | ||
450 | .id = 0, | ||
451 | .num_resources = 0, | ||
452 | .resource = orion_switch_resources, | ||
453 | }; | ||
454 | |||
455 | void __init orion_ge00_switch_init(struct dsa_platform_data *d, int irq) | ||
456 | { | ||
457 | int i; | ||
458 | |||
459 | if (irq != NO_IRQ) { | ||
460 | orion_switch_resources[0].start = irq; | ||
461 | orion_switch_resources[0].end = irq; | ||
462 | orion_switch_device.num_resources = 1; | ||
463 | } | ||
464 | |||
465 | d->netdev = &orion_ge00.dev; | ||
466 | for (i = 0; i < d->nr_chips; i++) | ||
467 | d->chip[i].mii_bus = &orion_ge00_shared.dev; | ||
468 | orion_switch_device.dev.platform_data = d; | ||
469 | |||
470 | platform_device_register(&orion_switch_device); | ||
471 | } | ||
472 | |||
473 | /***************************************************************************** | ||
474 | * I2C | ||
475 | ****************************************************************************/ | ||
476 | static struct mv64xxx_i2c_pdata orion_i2c_pdata = { | ||
477 | .freq_n = 3, | ||
478 | .timeout = 1000, /* Default timeout of 1 second */ | ||
479 | }; | ||
480 | |||
481 | static struct resource orion_i2c_resources[2]; | ||
482 | |||
483 | static struct platform_device orion_i2c = { | ||
484 | .name = MV64XXX_I2C_CTLR_NAME, | ||
485 | .id = 0, | ||
486 | .dev = { | ||
487 | .platform_data = &orion_i2c_pdata, | ||
488 | }, | ||
489 | }; | ||
490 | |||
491 | static struct mv64xxx_i2c_pdata orion_i2c_1_pdata = { | ||
492 | .freq_n = 3, | ||
493 | .timeout = 1000, /* Default timeout of 1 second */ | ||
494 | }; | ||
495 | |||
496 | static struct resource orion_i2c_1_resources[2]; | ||
497 | |||
498 | static struct platform_device orion_i2c_1 = { | ||
499 | .name = MV64XXX_I2C_CTLR_NAME, | ||
500 | .id = 1, | ||
501 | .dev = { | ||
502 | .platform_data = &orion_i2c_1_pdata, | ||
503 | }, | ||
504 | }; | ||
505 | |||
506 | void __init orion_i2c_init(unsigned long mapbase, | ||
507 | unsigned long irq, | ||
508 | unsigned long freq_m) | ||
509 | { | ||
510 | orion_i2c_pdata.freq_m = freq_m; | ||
511 | fill_resources(&orion_i2c, orion_i2c_resources, mapbase, | ||
512 | SZ_32 - 1, irq); | ||
513 | platform_device_register(&orion_i2c); | ||
514 | } | ||
515 | |||
516 | void __init orion_i2c_1_init(unsigned long mapbase, | ||
517 | unsigned long irq, | ||
518 | unsigned long freq_m) | ||
519 | { | ||
520 | orion_i2c_1_pdata.freq_m = freq_m; | ||
521 | fill_resources(&orion_i2c_1, orion_i2c_1_resources, mapbase, | ||
522 | SZ_32 - 1, irq); | ||
523 | platform_device_register(&orion_i2c_1); | ||
524 | } | ||
525 | |||
526 | /***************************************************************************** | ||
527 | * SPI | ||
528 | ****************************************************************************/ | ||
529 | static struct orion_spi_info orion_spi_plat_data; | ||
530 | static struct resource orion_spi_resources; | ||
531 | |||
532 | static struct platform_device orion_spi = { | ||
533 | .name = "orion_spi", | ||
534 | .id = 0, | ||
535 | .dev = { | ||
536 | .platform_data = &orion_spi_plat_data, | ||
537 | }, | ||
538 | }; | ||
539 | |||
540 | static struct orion_spi_info orion_spi_1_plat_data; | ||
541 | static struct resource orion_spi_1_resources; | ||
542 | |||
543 | static struct platform_device orion_spi_1 = { | ||
544 | .name = "orion_spi", | ||
545 | .id = 1, | ||
546 | .dev = { | ||
547 | .platform_data = &orion_spi_1_plat_data, | ||
548 | }, | ||
549 | }; | ||
550 | |||
551 | /* Note: The SPI silicon core does have interrupts. However the | ||
552 | * current Linux software driver does not use interrupts. */ | ||
553 | |||
554 | void __init orion_spi_init(unsigned long mapbase, | ||
555 | unsigned long tclk) | ||
556 | { | ||
557 | orion_spi_plat_data.tclk = tclk; | ||
558 | fill_resources(&orion_spi, &orion_spi_resources, | ||
559 | mapbase, SZ_512 - 1, NO_IRQ); | ||
560 | platform_device_register(&orion_spi); | ||
561 | } | ||
562 | |||
563 | void __init orion_spi_1_init(unsigned long mapbase, | ||
564 | unsigned long tclk) | ||
565 | { | ||
566 | orion_spi_1_plat_data.tclk = tclk; | ||
567 | fill_resources(&orion_spi_1, &orion_spi_1_resources, | ||
568 | mapbase, SZ_512 - 1, NO_IRQ); | ||
569 | platform_device_register(&orion_spi_1); | ||
570 | } | ||
571 | |||
572 | /***************************************************************************** | ||
573 | * Watchdog | ||
574 | ****************************************************************************/ | ||
575 | static struct orion_wdt_platform_data orion_wdt_data; | ||
576 | |||
577 | static struct platform_device orion_wdt_device = { | ||
578 | .name = "orion_wdt", | ||
579 | .id = -1, | ||
580 | .dev = { | ||
581 | .platform_data = &orion_wdt_data, | ||
582 | }, | ||
583 | .num_resources = 0, | ||
584 | }; | ||
585 | |||
586 | void __init orion_wdt_init(unsigned long tclk) | ||
587 | { | ||
588 | orion_wdt_data.tclk = tclk; | ||
589 | platform_device_register(&orion_wdt_device); | ||
590 | } | ||
591 | |||
592 | /***************************************************************************** | ||
593 | * XOR | ||
594 | ****************************************************************************/ | ||
595 | static struct mv_xor_platform_shared_data orion_xor_shared_data; | ||
596 | |||
597 | static u64 orion_xor_dmamask = DMA_BIT_MASK(32); | ||
598 | |||
599 | void __init orion_xor_init_channels( | ||
600 | struct mv_xor_platform_data *orion_xor0_data, | ||
601 | struct platform_device *orion_xor0_channel, | ||
602 | struct mv_xor_platform_data *orion_xor1_data, | ||
603 | struct platform_device *orion_xor1_channel) | ||
604 | { | ||
605 | /* | ||
606 | * two engines can't do memset simultaneously, this limitation | ||
607 | * satisfied by removing memset support from one of the engines. | ||
608 | */ | ||
609 | dma_cap_set(DMA_MEMCPY, orion_xor0_data->cap_mask); | ||
610 | dma_cap_set(DMA_XOR, orion_xor0_data->cap_mask); | ||
611 | platform_device_register(orion_xor0_channel); | ||
612 | |||
613 | dma_cap_set(DMA_MEMCPY, orion_xor1_data->cap_mask); | ||
614 | dma_cap_set(DMA_MEMSET, orion_xor1_data->cap_mask); | ||
615 | dma_cap_set(DMA_XOR, orion_xor1_data->cap_mask); | ||
616 | platform_device_register(orion_xor1_channel); | ||
617 | } | ||
618 | |||
619 | /***************************************************************************** | ||
620 | * XOR0 | ||
621 | ****************************************************************************/ | ||
622 | static struct resource orion_xor0_shared_resources[] = { | ||
623 | { | ||
624 | .name = "xor 0 low", | ||
625 | .flags = IORESOURCE_MEM, | ||
626 | }, { | ||
627 | .name = "xor 0 high", | ||
628 | .flags = IORESOURCE_MEM, | ||
629 | }, | ||
630 | }; | ||
631 | |||
632 | static struct platform_device orion_xor0_shared = { | ||
633 | .name = MV_XOR_SHARED_NAME, | ||
634 | .id = 0, | ||
635 | .dev = { | ||
636 | .platform_data = &orion_xor_shared_data, | ||
637 | }, | ||
638 | .num_resources = ARRAY_SIZE(orion_xor0_shared_resources), | ||
639 | .resource = orion_xor0_shared_resources, | ||
640 | }; | ||
641 | |||
642 | static struct resource orion_xor00_resources[] = { | ||
643 | [0] = { | ||
644 | .flags = IORESOURCE_IRQ, | ||
645 | }, | ||
646 | }; | ||
647 | |||
648 | static struct mv_xor_platform_data orion_xor00_data = { | ||
649 | .shared = &orion_xor0_shared, | ||
650 | .hw_id = 0, | ||
651 | .pool_size = PAGE_SIZE, | ||
652 | }; | ||
653 | |||
654 | static struct platform_device orion_xor00_channel = { | ||
655 | .name = MV_XOR_NAME, | ||
656 | .id = 0, | ||
657 | .num_resources = ARRAY_SIZE(orion_xor00_resources), | ||
658 | .resource = orion_xor00_resources, | ||
659 | .dev = { | ||
660 | .dma_mask = &orion_xor_dmamask, | ||
661 | .coherent_dma_mask = DMA_BIT_MASK(64), | ||
662 | .platform_data = &orion_xor00_data, | ||
663 | }, | ||
664 | }; | ||
665 | |||
666 | static struct resource orion_xor01_resources[] = { | ||
667 | [0] = { | ||
668 | .flags = IORESOURCE_IRQ, | ||
669 | }, | ||
670 | }; | ||
671 | |||
672 | static struct mv_xor_platform_data orion_xor01_data = { | ||
673 | .shared = &orion_xor0_shared, | ||
674 | .hw_id = 1, | ||
675 | .pool_size = PAGE_SIZE, | ||
676 | }; | ||
677 | |||
678 | static struct platform_device orion_xor01_channel = { | ||
679 | .name = MV_XOR_NAME, | ||
680 | .id = 1, | ||
681 | .num_resources = ARRAY_SIZE(orion_xor01_resources), | ||
682 | .resource = orion_xor01_resources, | ||
683 | .dev = { | ||
684 | .dma_mask = &orion_xor_dmamask, | ||
685 | .coherent_dma_mask = DMA_BIT_MASK(64), | ||
686 | .platform_data = &orion_xor01_data, | ||
687 | }, | ||
688 | }; | ||
689 | |||
690 | void __init orion_xor0_init(struct mbus_dram_target_info *mbus_dram_info, | ||
691 | unsigned long mapbase_low, | ||
692 | unsigned long mapbase_high, | ||
693 | unsigned long irq_0, | ||
694 | unsigned long irq_1) | ||
695 | { | ||
696 | orion_xor_shared_data.dram = mbus_dram_info; | ||
697 | |||
698 | orion_xor0_shared_resources[0].start = mapbase_low; | ||
699 | orion_xor0_shared_resources[0].end = mapbase_low + 0xff; | ||
700 | orion_xor0_shared_resources[1].start = mapbase_high; | ||
701 | orion_xor0_shared_resources[1].end = mapbase_high + 0xff; | ||
702 | |||
703 | orion_xor00_resources[0].start = irq_0; | ||
704 | orion_xor00_resources[0].end = irq_0; | ||
705 | orion_xor01_resources[0].start = irq_1; | ||
706 | orion_xor01_resources[0].end = irq_1; | ||
707 | |||
708 | platform_device_register(&orion_xor0_shared); | ||
709 | |||
710 | orion_xor_init_channels(&orion_xor00_data, &orion_xor00_channel, | ||
711 | &orion_xor01_data, &orion_xor01_channel); | ||
712 | } | ||
713 | |||
714 | /***************************************************************************** | ||
715 | * XOR1 | ||
716 | ****************************************************************************/ | ||
717 | static struct resource orion_xor1_shared_resources[] = { | ||
718 | { | ||
719 | .name = "xor 1 low", | ||
720 | .flags = IORESOURCE_MEM, | ||
721 | }, { | ||
722 | .name = "xor 1 high", | ||
723 | .flags = IORESOURCE_MEM, | ||
724 | }, | ||
725 | }; | ||
726 | |||
727 | static struct platform_device orion_xor1_shared = { | ||
728 | .name = MV_XOR_SHARED_NAME, | ||
729 | .id = 1, | ||
730 | .dev = { | ||
731 | .platform_data = &orion_xor_shared_data, | ||
732 | }, | ||
733 | .num_resources = ARRAY_SIZE(orion_xor1_shared_resources), | ||
734 | .resource = orion_xor1_shared_resources, | ||
735 | }; | ||
736 | |||
737 | static struct resource orion_xor10_resources[] = { | ||
738 | [0] = { | ||
739 | .flags = IORESOURCE_IRQ, | ||
740 | }, | ||
741 | }; | ||
742 | |||
743 | static struct mv_xor_platform_data orion_xor10_data = { | ||
744 | .shared = &orion_xor1_shared, | ||
745 | .hw_id = 0, | ||
746 | .pool_size = PAGE_SIZE, | ||
747 | }; | ||
748 | |||
749 | static struct platform_device orion_xor10_channel = { | ||
750 | .name = MV_XOR_NAME, | ||
751 | .id = 2, | ||
752 | .num_resources = ARRAY_SIZE(orion_xor10_resources), | ||
753 | .resource = orion_xor10_resources, | ||
754 | .dev = { | ||
755 | .dma_mask = &orion_xor_dmamask, | ||
756 | .coherent_dma_mask = DMA_BIT_MASK(64), | ||
757 | .platform_data = &orion_xor10_data, | ||
758 | }, | ||
759 | }; | ||
760 | |||
761 | static struct resource orion_xor11_resources[] = { | ||
762 | [0] = { | ||
763 | .flags = IORESOURCE_IRQ, | ||
764 | }, | ||
765 | }; | ||
766 | |||
767 | static struct mv_xor_platform_data orion_xor11_data = { | ||
768 | .shared = &orion_xor1_shared, | ||
769 | .hw_id = 1, | ||
770 | .pool_size = PAGE_SIZE, | ||
771 | }; | ||
772 | |||
773 | static struct platform_device orion_xor11_channel = { | ||
774 | .name = MV_XOR_NAME, | ||
775 | .id = 3, | ||
776 | .num_resources = ARRAY_SIZE(orion_xor11_resources), | ||
777 | .resource = orion_xor11_resources, | ||
778 | .dev = { | ||
779 | .dma_mask = &orion_xor_dmamask, | ||
780 | .coherent_dma_mask = DMA_BIT_MASK(64), | ||
781 | .platform_data = &orion_xor11_data, | ||
782 | }, | ||
783 | }; | ||
784 | |||
785 | void __init orion_xor1_init(unsigned long mapbase_low, | ||
786 | unsigned long mapbase_high, | ||
787 | unsigned long irq_0, | ||
788 | unsigned long irq_1) | ||
789 | { | ||
790 | orion_xor1_shared_resources[0].start = mapbase_low; | ||
791 | orion_xor1_shared_resources[0].end = mapbase_low + 0xff; | ||
792 | orion_xor1_shared_resources[1].start = mapbase_high; | ||
793 | orion_xor1_shared_resources[1].end = mapbase_high + 0xff; | ||
794 | |||
795 | orion_xor10_resources[0].start = irq_0; | ||
796 | orion_xor10_resources[0].end = irq_0; | ||
797 | orion_xor11_resources[0].start = irq_1; | ||
798 | orion_xor11_resources[0].end = irq_1; | ||
799 | |||
800 | platform_device_register(&orion_xor1_shared); | ||
801 | |||
802 | orion_xor_init_channels(&orion_xor10_data, &orion_xor10_channel, | ||
803 | &orion_xor11_data, &orion_xor11_channel); | ||
804 | } | ||
805 | |||
806 | /***************************************************************************** | ||
807 | * EHCI | ||
808 | ****************************************************************************/ | ||
809 | static struct orion_ehci_data orion_ehci_data = { | ||
810 | .phy_version = EHCI_PHY_NA, | ||
811 | }; | ||
812 | |||
813 | static u64 ehci_dmamask = DMA_BIT_MASK(32); | ||
814 | |||
815 | |||
816 | /***************************************************************************** | ||
817 | * EHCI0 | ||
818 | ****************************************************************************/ | ||
819 | static struct resource orion_ehci_resources[2]; | ||
820 | |||
821 | static struct platform_device orion_ehci = { | ||
822 | .name = "orion-ehci", | ||
823 | .id = 0, | ||
824 | .dev = { | ||
825 | .dma_mask = &ehci_dmamask, | ||
826 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
827 | .platform_data = &orion_ehci_data, | ||
828 | }, | ||
829 | }; | ||
830 | |||
831 | void __init orion_ehci_init(struct mbus_dram_target_info *mbus_dram_info, | ||
832 | unsigned long mapbase, | ||
833 | unsigned long irq) | ||
834 | { | ||
835 | orion_ehci_data.dram = mbus_dram_info; | ||
836 | fill_resources(&orion_ehci, orion_ehci_resources, mapbase, SZ_4K - 1, | ||
837 | irq); | ||
838 | |||
839 | platform_device_register(&orion_ehci); | ||
840 | } | ||
841 | |||
842 | /***************************************************************************** | ||
843 | * EHCI1 | ||
844 | ****************************************************************************/ | ||
845 | static struct resource orion_ehci_1_resources[2]; | ||
846 | |||
847 | static struct platform_device orion_ehci_1 = { | ||
848 | .name = "orion-ehci", | ||
849 | .id = 1, | ||
850 | .dev = { | ||
851 | .dma_mask = &ehci_dmamask, | ||
852 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
853 | .platform_data = &orion_ehci_data, | ||
854 | }, | ||
855 | }; | ||
856 | |||
857 | void __init orion_ehci_1_init(struct mbus_dram_target_info *mbus_dram_info, | ||
858 | unsigned long mapbase, | ||
859 | unsigned long irq) | ||
860 | { | ||
861 | orion_ehci_data.dram = mbus_dram_info; | ||
862 | fill_resources(&orion_ehci_1, orion_ehci_1_resources, | ||
863 | mapbase, SZ_4K - 1, irq); | ||
864 | |||
865 | platform_device_register(&orion_ehci_1); | ||
866 | } | ||
867 | |||
868 | /***************************************************************************** | ||
869 | * EHCI2 | ||
870 | ****************************************************************************/ | ||
871 | static struct resource orion_ehci_2_resources[2]; | ||
872 | |||
873 | static struct platform_device orion_ehci_2 = { | ||
874 | .name = "orion-ehci", | ||
875 | .id = 2, | ||
876 | .dev = { | ||
877 | .dma_mask = &ehci_dmamask, | ||
878 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
879 | .platform_data = &orion_ehci_data, | ||
880 | }, | ||
881 | }; | ||
882 | |||
883 | void __init orion_ehci_2_init(struct mbus_dram_target_info *mbus_dram_info, | ||
884 | unsigned long mapbase, | ||
885 | unsigned long irq) | ||
886 | { | ||
887 | orion_ehci_data.dram = mbus_dram_info; | ||
888 | fill_resources(&orion_ehci_2, orion_ehci_2_resources, | ||
889 | mapbase, SZ_4K - 1, irq); | ||
890 | |||
891 | platform_device_register(&orion_ehci_2); | ||
892 | } | ||
893 | |||
894 | /***************************************************************************** | ||
895 | * SATA | ||
896 | ****************************************************************************/ | ||
897 | static struct resource orion_sata_resources[2] = { | ||
898 | { | ||
899 | .name = "sata base", | ||
900 | }, { | ||
901 | .name = "sata irq", | ||
902 | }, | ||
903 | }; | ||
904 | |||
905 | static struct platform_device orion_sata = { | ||
906 | .name = "sata_mv", | ||
907 | .id = 0, | ||
908 | .dev = { | ||
909 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
910 | }, | ||
911 | }; | ||
912 | |||
913 | void __init orion_sata_init(struct mv_sata_platform_data *sata_data, | ||
914 | struct mbus_dram_target_info *mbus_dram_info, | ||
915 | unsigned long mapbase, | ||
916 | unsigned long irq) | ||
917 | { | ||
918 | sata_data->dram = mbus_dram_info; | ||
919 | orion_sata.dev.platform_data = sata_data; | ||
920 | fill_resources(&orion_sata, orion_sata_resources, | ||
921 | mapbase, 0x5000 - 1, irq); | ||
922 | |||
923 | platform_device_register(&orion_sata); | ||
924 | } | ||
925 | |||
926 | /***************************************************************************** | ||
927 | * Cryptographic Engines and Security Accelerator (CESA) | ||
928 | ****************************************************************************/ | ||
929 | static struct resource orion_crypto_resources[] = { | ||
930 | { | ||
931 | .name = "regs", | ||
932 | }, { | ||
933 | .name = "crypto interrupt", | ||
934 | }, { | ||
935 | .name = "sram", | ||
936 | .flags = IORESOURCE_MEM, | ||
937 | }, | ||
938 | }; | ||
939 | |||
940 | static struct platform_device orion_crypto = { | ||
941 | .name = "mv_crypto", | ||
942 | .id = -1, | ||
943 | }; | ||
944 | |||
945 | void __init orion_crypto_init(unsigned long mapbase, | ||
946 | unsigned long srambase, | ||
947 | unsigned long sram_size, | ||
948 | unsigned long irq) | ||
949 | { | ||
950 | fill_resources(&orion_crypto, orion_crypto_resources, | ||
951 | mapbase, 0xffff, irq); | ||
952 | orion_crypto.num_resources = 3; | ||
953 | orion_crypto_resources[2].start = srambase; | ||
954 | orion_crypto_resources[2].end = srambase + sram_size - 1; | ||
955 | |||
956 | platform_device_register(&orion_crypto); | ||
957 | } | ||
diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c index a431a138f402..5b4fffab1eb4 100644 --- a/arch/arm/plat-orion/gpio.c +++ b/arch/arm/plat-orion/gpio.c | |||
@@ -321,59 +321,16 @@ EXPORT_SYMBOL(orion_gpio_set_blink); | |||
321 | * polarity LEVEL mask | 321 | * polarity LEVEL mask |
322 | * | 322 | * |
323 | ****************************************************************************/ | 323 | ****************************************************************************/ |
324 | static void gpio_irq_ack(struct irq_data *d) | ||
325 | { | ||
326 | struct orion_gpio_chip *ochip = irq_data_get_irq_chip_data(d); | ||
327 | int type = irqd_get_trigger_type(d); | ||
328 | |||
329 | if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) { | ||
330 | int pin = d->irq - ochip->secondary_irq_base; | ||
331 | |||
332 | writel(~(1 << pin), GPIO_EDGE_CAUSE(ochip)); | ||
333 | } | ||
334 | } | ||
335 | |||
336 | static void gpio_irq_mask(struct irq_data *d) | ||
337 | { | ||
338 | struct orion_gpio_chip *ochip = irq_data_get_irq_chip_data(d); | ||
339 | int type = irqd_get_trigger_type(d); | ||
340 | void __iomem *reg; | ||
341 | int pin; | ||
342 | |||
343 | if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) | ||
344 | reg = GPIO_EDGE_MASK(ochip); | ||
345 | else | ||
346 | reg = GPIO_LEVEL_MASK(ochip); | ||
347 | |||
348 | pin = d->irq - ochip->secondary_irq_base; | ||
349 | |||
350 | writel(readl(reg) & ~(1 << pin), reg); | ||
351 | } | ||
352 | |||
353 | static void gpio_irq_unmask(struct irq_data *d) | ||
354 | { | ||
355 | struct orion_gpio_chip *ochip = irq_data_get_irq_chip_data(d); | ||
356 | int type = irqd_get_trigger_type(d); | ||
357 | void __iomem *reg; | ||
358 | int pin; | ||
359 | |||
360 | if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) | ||
361 | reg = GPIO_EDGE_MASK(ochip); | ||
362 | else | ||
363 | reg = GPIO_LEVEL_MASK(ochip); | ||
364 | |||
365 | pin = d->irq - ochip->secondary_irq_base; | ||
366 | |||
367 | writel(readl(reg) | (1 << pin), reg); | ||
368 | } | ||
369 | 324 | ||
370 | static int gpio_irq_set_type(struct irq_data *d, u32 type) | 325 | static int gpio_irq_set_type(struct irq_data *d, u32 type) |
371 | { | 326 | { |
372 | struct orion_gpio_chip *ochip = irq_data_get_irq_chip_data(d); | 327 | struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d); |
328 | struct irq_chip_type *ct = irq_data_get_chip_type(d); | ||
329 | struct orion_gpio_chip *ochip = gc->private; | ||
373 | int pin; | 330 | int pin; |
374 | u32 u; | 331 | u32 u; |
375 | 332 | ||
376 | pin = d->irq - ochip->secondary_irq_base; | 333 | pin = d->irq - gc->irq_base; |
377 | 334 | ||
378 | u = readl(GPIO_IO_CONF(ochip)) & (1 << pin); | 335 | u = readl(GPIO_IO_CONF(ochip)) & (1 << pin); |
379 | if (!u) { | 336 | if (!u) { |
@@ -382,18 +339,14 @@ static int gpio_irq_set_type(struct irq_data *d, u32 type) | |||
382 | return -EINVAL; | 339 | return -EINVAL; |
383 | } | 340 | } |
384 | 341 | ||
385 | /* | 342 | type &= IRQ_TYPE_SENSE_MASK; |
386 | * Set edge/level type. | 343 | if (type == IRQ_TYPE_NONE) |
387 | */ | ||
388 | if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING)) { | ||
389 | __irq_set_handler_locked(d->irq, handle_edge_irq); | ||
390 | } else if (type & (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW)) { | ||
391 | __irq_set_handler_locked(d->irq, handle_level_irq); | ||
392 | } else { | ||
393 | printk(KERN_ERR "failed to set irq=%d (type=%d)\n", | ||
394 | d->irq, type); | ||
395 | return -EINVAL; | 344 | return -EINVAL; |
396 | } | 345 | |
346 | /* Check if we need to change chip and handler */ | ||
347 | if (!(ct->type & type)) | ||
348 | if (irq_setup_alt_chip(d, type)) | ||
349 | return -EINVAL; | ||
397 | 350 | ||
398 | /* | 351 | /* |
399 | * Configure interrupt polarity. | 352 | * Configure interrupt polarity. |
@@ -425,19 +378,12 @@ static int gpio_irq_set_type(struct irq_data *d, u32 type) | |||
425 | return 0; | 378 | return 0; |
426 | } | 379 | } |
427 | 380 | ||
428 | struct irq_chip orion_gpio_irq_chip = { | ||
429 | .name = "orion_gpio_irq", | ||
430 | .irq_ack = gpio_irq_ack, | ||
431 | .irq_mask = gpio_irq_mask, | ||
432 | .irq_unmask = gpio_irq_unmask, | ||
433 | .irq_set_type = gpio_irq_set_type, | ||
434 | }; | ||
435 | |||
436 | void __init orion_gpio_init(int gpio_base, int ngpio, | 381 | void __init orion_gpio_init(int gpio_base, int ngpio, |
437 | u32 base, int mask_offset, int secondary_irq_base) | 382 | u32 base, int mask_offset, int secondary_irq_base) |
438 | { | 383 | { |
439 | struct orion_gpio_chip *ochip; | 384 | struct orion_gpio_chip *ochip; |
440 | int i; | 385 | struct irq_chip_generic *gc; |
386 | struct irq_chip_type *ct; | ||
441 | 387 | ||
442 | if (orion_gpio_chip_count == ARRAY_SIZE(orion_gpio_chips)) | 388 | if (orion_gpio_chip_count == ARRAY_SIZE(orion_gpio_chips)) |
443 | return; | 389 | return; |
@@ -471,15 +417,29 @@ void __init orion_gpio_init(int gpio_base, int ngpio, | |||
471 | writel(0, GPIO_EDGE_MASK(ochip)); | 417 | writel(0, GPIO_EDGE_MASK(ochip)); |
472 | writel(0, GPIO_LEVEL_MASK(ochip)); | 418 | writel(0, GPIO_LEVEL_MASK(ochip)); |
473 | 419 | ||
474 | for (i = 0; i < ngpio; i++) { | 420 | gc = irq_alloc_generic_chip("orion_gpio_irq", 2, secondary_irq_base, |
475 | unsigned int irq = secondary_irq_base + i; | 421 | ochip->base, handle_level_irq); |
476 | 422 | gc->private = ochip; | |
477 | irq_set_chip_and_handler(irq, &orion_gpio_irq_chip, | 423 | |
478 | handle_level_irq); | 424 | ct = gc->chip_types; |
479 | irq_set_chip_data(irq, ochip); | 425 | ct->regs.mask = ochip->mask_offset + GPIO_LEVEL_MASK_OFF; |
480 | irq_set_status_flags(irq, IRQ_LEVEL); | 426 | ct->type = IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_LEVEL_LOW; |
481 | set_irq_flags(irq, IRQF_VALID); | 427 | ct->chip.irq_mask = irq_gc_mask_clr_bit; |
482 | } | 428 | ct->chip.irq_unmask = irq_gc_mask_set_bit; |
429 | ct->chip.irq_set_type = gpio_irq_set_type; | ||
430 | |||
431 | ct++; | ||
432 | ct->regs.mask = ochip->mask_offset + GPIO_EDGE_MASK_OFF; | ||
433 | ct->regs.ack = GPIO_EDGE_CAUSE_OFF; | ||
434 | ct->type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING; | ||
435 | ct->chip.irq_ack = irq_gc_ack; | ||
436 | ct->chip.irq_mask = irq_gc_mask_clr_bit; | ||
437 | ct->chip.irq_unmask = irq_gc_mask_set_bit; | ||
438 | ct->chip.irq_set_type = gpio_irq_set_type; | ||
439 | ct->handler = handle_edge_irq; | ||
440 | |||
441 | irq_setup_generic_chip(gc, IRQ_MSK(ngpio), IRQ_GC_INIT_MASK_CACHE, | ||
442 | IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE); | ||
483 | } | 443 | } |
484 | 444 | ||
485 | void orion_gpio_irq_handler(int pinoff) | 445 | void orion_gpio_irq_handler(int pinoff) |
diff --git a/arch/arm/plat-orion/include/plat/common.h b/arch/arm/plat-orion/include/plat/common.h new file mode 100644 index 000000000000..a63c357e2ab1 --- /dev/null +++ b/arch/arm/plat-orion/include/plat/common.h | |||
@@ -0,0 +1,117 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-orion/include/plat/common.h | ||
3 | * | ||
4 | * Marvell Orion SoC common setup code used by different mach-/common.c | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #ifndef __PLAT_COMMON_H | ||
12 | #include <linux/mv643xx_eth.h> | ||
13 | |||
14 | struct dsa_platform_data; | ||
15 | |||
16 | void __init orion_uart0_init(unsigned int membase, | ||
17 | resource_size_t mapbase, | ||
18 | unsigned int irq, | ||
19 | unsigned int uartclk); | ||
20 | |||
21 | void __init orion_uart1_init(unsigned int membase, | ||
22 | resource_size_t mapbase, | ||
23 | unsigned int irq, | ||
24 | unsigned int uartclk); | ||
25 | |||
26 | void __init orion_uart2_init(unsigned int membase, | ||
27 | resource_size_t mapbase, | ||
28 | unsigned int irq, | ||
29 | unsigned int uartclk); | ||
30 | |||
31 | void __init orion_uart3_init(unsigned int membase, | ||
32 | resource_size_t mapbase, | ||
33 | unsigned int irq, | ||
34 | unsigned int uartclk); | ||
35 | |||
36 | void __init orion_rtc_init(unsigned long mapbase, | ||
37 | unsigned long irq); | ||
38 | |||
39 | void __init orion_ge00_init(struct mv643xx_eth_platform_data *eth_data, | ||
40 | struct mbus_dram_target_info *mbus_dram_info, | ||
41 | unsigned long mapbase, | ||
42 | unsigned long irq, | ||
43 | unsigned long irq_err, | ||
44 | int tclk); | ||
45 | |||
46 | void __init orion_ge01_init(struct mv643xx_eth_platform_data *eth_data, | ||
47 | struct mbus_dram_target_info *mbus_dram_info, | ||
48 | unsigned long mapbase, | ||
49 | unsigned long irq, | ||
50 | unsigned long irq_err, | ||
51 | int tclk); | ||
52 | |||
53 | void __init orion_ge10_init(struct mv643xx_eth_platform_data *eth_data, | ||
54 | struct mbus_dram_target_info *mbus_dram_info, | ||
55 | unsigned long mapbase, | ||
56 | unsigned long irq, | ||
57 | unsigned long irq_err, | ||
58 | int tclk); | ||
59 | |||
60 | void __init orion_ge11_init(struct mv643xx_eth_platform_data *eth_data, | ||
61 | struct mbus_dram_target_info *mbus_dram_info, | ||
62 | unsigned long mapbase, | ||
63 | unsigned long irq, | ||
64 | unsigned long irq_err, | ||
65 | int tclk); | ||
66 | |||
67 | void __init orion_ge00_switch_init(struct dsa_platform_data *d, | ||
68 | int irq); | ||
69 | void __init orion_i2c_init(unsigned long mapbase, | ||
70 | unsigned long irq, | ||
71 | unsigned long freq_m); | ||
72 | |||
73 | void __init orion_i2c_1_init(unsigned long mapbase, | ||
74 | unsigned long irq, | ||
75 | unsigned long freq_m); | ||
76 | |||
77 | void __init orion_spi_init(unsigned long mapbase, | ||
78 | unsigned long tclk); | ||
79 | |||
80 | void __init orion_spi_1_init(unsigned long mapbase, | ||
81 | unsigned long tclk); | ||
82 | |||
83 | void __init orion_wdt_init(unsigned long tclk); | ||
84 | |||
85 | void __init orion_xor0_init(struct mbus_dram_target_info *mbus_dram_info, | ||
86 | unsigned long mapbase_low, | ||
87 | unsigned long mapbase_high, | ||
88 | unsigned long irq_0, | ||
89 | unsigned long irq_1); | ||
90 | |||
91 | void __init orion_xor1_init(unsigned long mapbase_low, | ||
92 | unsigned long mapbase_high, | ||
93 | unsigned long irq_0, | ||
94 | unsigned long irq_1); | ||
95 | |||
96 | void __init orion_ehci_init(struct mbus_dram_target_info *mbus_dram_info, | ||
97 | unsigned long mapbase, | ||
98 | unsigned long irq); | ||
99 | |||
100 | void __init orion_ehci_1_init(struct mbus_dram_target_info *mbus_dram_info, | ||
101 | unsigned long mapbase, | ||
102 | unsigned long irq); | ||
103 | |||
104 | void __init orion_ehci_2_init(struct mbus_dram_target_info *mbus_dram_info, | ||
105 | unsigned long mapbase, | ||
106 | unsigned long irq); | ||
107 | |||
108 | void __init orion_sata_init(struct mv_sata_platform_data *sata_data, | ||
109 | struct mbus_dram_target_info *mbus_dram_info, | ||
110 | unsigned long mapbase, | ||
111 | unsigned long irq); | ||
112 | |||
113 | void __init orion_crypto_init(unsigned long mapbase, | ||
114 | unsigned long srambase, | ||
115 | unsigned long sram_size, | ||
116 | unsigned long irq); | ||
117 | #endif | ||
diff --git a/arch/arm/plat-orion/include/plat/gpio.h b/arch/arm/plat-orion/include/plat/gpio.h index 5578b9803fc6..3075b9fdde83 100644 --- a/arch/arm/plat-orion/include/plat/gpio.h +++ b/arch/arm/plat-orion/include/plat/gpio.h | |||
@@ -39,7 +39,6 @@ void __init orion_gpio_init(int gpio_base, int ngpio, | |||
39 | /* | 39 | /* |
40 | * GPIO interrupt handling. | 40 | * GPIO interrupt handling. |
41 | */ | 41 | */ |
42 | extern struct irq_chip orion_gpio_irq_chip; | ||
43 | void orion_gpio_irq_handler(int irqoff); | 42 | void orion_gpio_irq_handler(int irqoff); |
44 | 43 | ||
45 | 44 | ||
diff --git a/arch/arm/plat-orion/include/plat/mpp.h b/arch/arm/plat-orion/include/plat/mpp.h new file mode 100644 index 000000000000..723adce99f41 --- /dev/null +++ b/arch/arm/plat-orion/include/plat/mpp.h | |||
@@ -0,0 +1,34 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-orion/include/plat/mpp.h | ||
3 | * | ||
4 | * Marvell Orion SoC MPP handling. | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #ifndef __PLAT_MPP_H | ||
12 | #define __PLAT_MPP_H | ||
13 | |||
14 | #define MPP_NUM(x) ((x) & 0xff) | ||
15 | #define MPP_SEL(x) (((x) >> 8) & 0xf) | ||
16 | |||
17 | /* This is the generic MPP macro, without any variant information. | ||
18 | Each machine architecture is expected to extend this with further | ||
19 | bit fields indicating which MPP configurations are valid for a | ||
20 | specific variant. */ | ||
21 | |||
22 | #define GENERIC_MPP(_num, _sel, _in, _out) ( \ | ||
23 | /* MPP number */ ((_num) & 0xff) | \ | ||
24 | /* MPP select value */ (((_sel) & 0xf) << 8) | \ | ||
25 | /* may be input signal */ ((!!(_in)) << 12) | \ | ||
26 | /* may be output signal */ ((!!(_out)) << 13)) | ||
27 | |||
28 | #define MPP_INPUT_MASK GENERIC_MPP(0, 0x0, 1, 0) | ||
29 | #define MPP_OUTPUT_MASK GENERIC_MPP(0, 0x0, 0, 1) | ||
30 | |||
31 | void __init orion_mpp_conf(unsigned int *mpp_list, unsigned int variant_mask, | ||
32 | unsigned int mpp_max, unsigned int dev_bus); | ||
33 | |||
34 | #endif | ||
diff --git a/arch/arm/plat-orion/irq.c b/arch/arm/plat-orion/irq.c index d8d638e09f8f..2d5b9c1ef389 100644 --- a/arch/arm/plat-orion/irq.c +++ b/arch/arm/plat-orion/irq.c | |||
@@ -14,52 +14,21 @@ | |||
14 | #include <linux/io.h> | 14 | #include <linux/io.h> |
15 | #include <plat/irq.h> | 15 | #include <plat/irq.h> |
16 | 16 | ||
17 | static void orion_irq_mask(struct irq_data *d) | ||
18 | { | ||
19 | void __iomem *maskaddr = irq_data_get_irq_chip_data(d); | ||
20 | u32 mask; | ||
21 | |||
22 | mask = readl(maskaddr); | ||
23 | mask &= ~(1 << (d->irq & 31)); | ||
24 | writel(mask, maskaddr); | ||
25 | } | ||
26 | |||
27 | static void orion_irq_unmask(struct irq_data *d) | ||
28 | { | ||
29 | void __iomem *maskaddr = irq_data_get_irq_chip_data(d); | ||
30 | u32 mask; | ||
31 | |||
32 | mask = readl(maskaddr); | ||
33 | mask |= 1 << (d->irq & 31); | ||
34 | writel(mask, maskaddr); | ||
35 | } | ||
36 | |||
37 | static struct irq_chip orion_irq_chip = { | ||
38 | .name = "orion_irq", | ||
39 | .irq_mask = orion_irq_mask, | ||
40 | .irq_mask_ack = orion_irq_mask, | ||
41 | .irq_unmask = orion_irq_unmask, | ||
42 | }; | ||
43 | |||
44 | void __init orion_irq_init(unsigned int irq_start, void __iomem *maskaddr) | 17 | void __init orion_irq_init(unsigned int irq_start, void __iomem *maskaddr) |
45 | { | 18 | { |
46 | unsigned int i; | 19 | struct irq_chip_generic *gc; |
20 | struct irq_chip_type *ct; | ||
47 | 21 | ||
48 | /* | 22 | /* |
49 | * Mask all interrupts initially. | 23 | * Mask all interrupts initially. |
50 | */ | 24 | */ |
51 | writel(0, maskaddr); | 25 | writel(0, maskaddr); |
52 | 26 | ||
53 | /* | 27 | gc = irq_alloc_generic_chip("orion_irq", 1, irq_start, maskaddr, |
54 | * Register IRQ sources. | 28 | handle_level_irq); |
55 | */ | 29 | ct = gc->chip_types; |
56 | for (i = 0; i < 32; i++) { | 30 | ct->chip.irq_mask = irq_gc_mask_clr_bit; |
57 | unsigned int irq = irq_start + i; | 31 | ct->chip.irq_unmask = irq_gc_mask_set_bit; |
58 | 32 | irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_MASK_CACHE, | |
59 | irq_set_chip_and_handler(irq, &orion_irq_chip, | 33 | IRQ_NOREQUEST, IRQ_LEVEL | IRQ_NOPROBE); |
60 | handle_level_irq); | ||
61 | irq_set_chip_data(irq, maskaddr); | ||
62 | irq_set_status_flags(irq, IRQ_LEVEL); | ||
63 | set_irq_flags(irq, IRQF_VALID); | ||
64 | } | ||
65 | } | 34 | } |
diff --git a/arch/arm/plat-orion/mpp.c b/arch/arm/plat-orion/mpp.c new file mode 100644 index 000000000000..91553432711d --- /dev/null +++ b/arch/arm/plat-orion/mpp.c | |||
@@ -0,0 +1,78 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-orion/mpp.c | ||
3 | * | ||
4 | * MPP functions for Marvell orion SoCs | ||
5 | * | ||
6 | * This file is licensed under the terms of the GNU General Public | ||
7 | * License version 2. This program is licensed "as is" without any | ||
8 | * warranty of any kind, whether express or implied. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/mbus.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/gpio.h> | ||
16 | #include <mach/hardware.h> | ||
17 | #include <plat/mpp.h> | ||
18 | |||
19 | /* Address of the ith MPP control register */ | ||
20 | static __init unsigned long mpp_ctrl_addr(unsigned int i, | ||
21 | unsigned long dev_bus) | ||
22 | { | ||
23 | return dev_bus + (i) * 4; | ||
24 | } | ||
25 | |||
26 | |||
27 | void __init orion_mpp_conf(unsigned int *mpp_list, unsigned int variant_mask, | ||
28 | unsigned int mpp_max, unsigned int dev_bus) | ||
29 | { | ||
30 | unsigned int mpp_nr_regs = (1 + mpp_max/8); | ||
31 | u32 mpp_ctrl[mpp_nr_regs]; | ||
32 | int i; | ||
33 | |||
34 | printk(KERN_DEBUG "initial MPP regs:"); | ||
35 | for (i = 0; i < mpp_nr_regs; i++) { | ||
36 | mpp_ctrl[i] = readl(mpp_ctrl_addr(i, dev_bus)); | ||
37 | printk(" %08x", mpp_ctrl[i]); | ||
38 | } | ||
39 | printk("\n"); | ||
40 | |||
41 | for ( ; *mpp_list; mpp_list++) { | ||
42 | unsigned int num = MPP_NUM(*mpp_list); | ||
43 | unsigned int sel = MPP_SEL(*mpp_list); | ||
44 | int shift, gpio_mode; | ||
45 | |||
46 | if (num > mpp_max) { | ||
47 | printk(KERN_ERR "orion_mpp_conf: invalid MPP " | ||
48 | "number (%u)\n", num); | ||
49 | continue; | ||
50 | } | ||
51 | if (variant_mask & !(*mpp_list & variant_mask)) { | ||
52 | printk(KERN_WARNING | ||
53 | "orion_mpp_conf: requested MPP%u config " | ||
54 | "unavailable on this hardware\n", num); | ||
55 | continue; | ||
56 | } | ||
57 | |||
58 | shift = (num & 7) << 2; | ||
59 | mpp_ctrl[num / 8] &= ~(0xf << shift); | ||
60 | mpp_ctrl[num / 8] |= sel << shift; | ||
61 | |||
62 | gpio_mode = 0; | ||
63 | if (*mpp_list & MPP_INPUT_MASK) | ||
64 | gpio_mode |= GPIO_INPUT_OK; | ||
65 | if (*mpp_list & MPP_OUTPUT_MASK) | ||
66 | gpio_mode |= GPIO_OUTPUT_OK; | ||
67 | if (sel != 0) | ||
68 | gpio_mode = 0; | ||
69 | orion_gpio_set_valid(num, gpio_mode); | ||
70 | } | ||
71 | |||
72 | printk(KERN_DEBUG " final MPP regs:"); | ||
73 | for (i = 0; i < mpp_nr_regs; i++) { | ||
74 | writel(mpp_ctrl[i], mpp_ctrl_addr(i, dev_bus)); | ||
75 | printk(" %08x", mpp_ctrl[i]); | ||
76 | } | ||
77 | printk("\n"); | ||
78 | } | ||