aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-integrator
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-07 08:20:57 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-07 08:20:57 -0400
commit0e51793e162ca432fc5f04178cf82b80a92c2659 (patch)
treecf7ffdb5064e2f7b6647a63e7323d1c4e99b7739 /arch/arm/mach-integrator
parent5cad3598ea0cdb817681f74518d3213583a04f7a (diff)
parentb4874a3d298606c20118d1ead73235439bbc2823 (diff)
Merge branch 'for-linus' of git://git.linaro.org/people/rmk/linux-arm
Pull ARM updates from Russell King: "This is the first chunk of ARM updates for this merge window. Conflicts are expected in two files - asm/timex.h and mach-integrator/integrator_cp.c. Nothing particularly stands out more than anything else. Most of the growth is down to the opcodes stuff from Dave Martin, which is countered by Rob's patches to use more of the asm-generic headers on ARM." (A few more conflicts grew since then, but it all looked fairly trivial) * 'for-linus' of git://git.linaro.org/people/rmk/linux-arm: (44 commits) ARM: 7548/1: include linux/sched.h in syscall.h ARM: 7541/1: Add ARM ERRATA 775420 workaround ARM: ensure vm_struct has its phys_addr member filled in ARM: 7540/1: kexec: Check segment memory addresses ARM: 7539/1: kexec: scan for dtb magic in segments ARM: 7538/1: delay: add registration mechanism for delay timer sources ARM: 7536/1: smp: Formalize an IPI for wakeup ARM: 7525/1: ptrace: use updated syscall number for syscall auditing ARM: 7524/1: support syscall tracing ARM: 7519/1: integrator: convert platform devices to Device Tree ARM: 7518/1: integrator: convert AMBA devices to device tree ARM: 7517/1: integrator: initial device tree support ARM: 7516/1: plat-versatile: add DT support to FPGA IRQ ARM: 7515/1: integrator: check PL010 base address from resource ARM: 7514/1: integrator: call common init function from machine ARM: 7522/1: arch_timers: register a time/cycle counter ARM: 7523/1: arch_timers: enable the use of the virtual timer ARM: 7531/1: mark kernelmode mem{cpy,set} non-experimental ARM: 7520/1: Build dtb files in all target ARM: Fix build warning in arch/arm/mm/alignment.c ...
Diffstat (limited to 'arch/arm/mach-integrator')
-rw-r--r--arch/arm/mach-integrator/common.h3
-rw-r--r--arch/arm/mach-integrator/core.c17
-rw-r--r--arch/arm/mach-integrator/integrator_ap.c276
-rw-r--r--arch/arm/mach-integrator/integrator_cp.c325
4 files changed, 441 insertions, 180 deletions
diff --git a/arch/arm/mach-integrator/common.h b/arch/arm/mach-integrator/common.h
index 899561d8db28..c3ff21b5ea24 100644
--- a/arch/arm/mach-integrator/common.h
+++ b/arch/arm/mach-integrator/common.h
@@ -1,3 +1,6 @@
1#include <linux/amba/serial.h>
2extern struct amba_pl010_data integrator_uart_data;
1void integrator_init_early(void); 3void integrator_init_early(void);
4int integrator_init(bool is_cp);
2void integrator_reserve(void); 5void integrator_reserve(void);
3void integrator_restart(char, const char *); 6void integrator_restart(char, const char *);
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c
index dad3cb74ed31..ea22a17246d7 100644
--- a/arch/arm/mach-integrator/core.c
+++ b/arch/arm/mach-integrator/core.c
@@ -32,7 +32,9 @@
32#include <asm/mach/time.h> 32#include <asm/mach/time.h>
33#include <asm/pgtable.h> 33#include <asm/pgtable.h>
34 34
35static struct amba_pl010_data integrator_uart_data; 35#include "common.h"
36
37#ifdef CONFIG_ATAGS
36 38
37#define INTEGRATOR_RTC_IRQ { IRQ_RTCINT } 39#define INTEGRATOR_RTC_IRQ { IRQ_RTCINT }
38#define INTEGRATOR_UART0_IRQ { IRQ_UARTINT0 } 40#define INTEGRATOR_UART0_IRQ { IRQ_UARTINT0 }
@@ -60,7 +62,7 @@ static struct amba_device *amba_devs[] __initdata = {
60 &kmi1_device, 62 &kmi1_device,
61}; 63};
62 64
63static int __init integrator_init(void) 65int __init integrator_init(bool is_cp)
64{ 66{
65 int i; 67 int i;
66 68
@@ -69,7 +71,7 @@ static int __init integrator_init(void)
69 * hard-code them. The Integator/CP and forward have proper cell IDs. 71 * hard-code them. The Integator/CP and forward have proper cell IDs.
70 * Else we leave them undefined to the bus driver can autoprobe them. 72 * Else we leave them undefined to the bus driver can autoprobe them.
71 */ 73 */
72 if (machine_is_integrator()) { 74 if (!is_cp) {
73 rtc_device.periphid = 0x00041030; 75 rtc_device.periphid = 0x00041030;
74 uart0_device.periphid = 0x00041010; 76 uart0_device.periphid = 0x00041010;
75 uart1_device.periphid = 0x00041010; 77 uart1_device.periphid = 0x00041010;
@@ -85,7 +87,7 @@ static int __init integrator_init(void)
85 return 0; 87 return 0;
86} 88}
87 89
88arch_initcall(integrator_init); 90#endif
89 91
90/* 92/*
91 * On the Integrator platform, the port RTS and DTR are provided by 93 * On the Integrator platform, the port RTS and DTR are provided by
@@ -100,11 +102,14 @@ arch_initcall(integrator_init);
100static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *base, unsigned int mctrl) 102static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *base, unsigned int mctrl)
101{ 103{
102 unsigned int ctrls = 0, ctrlc = 0, rts_mask, dtr_mask; 104 unsigned int ctrls = 0, ctrlc = 0, rts_mask, dtr_mask;
105 u32 phybase = dev->res.start;
103 106
104 if (dev == &uart0_device) { 107 if (phybase == INTEGRATOR_UART0_BASE) {
108 /* UART0 */
105 rts_mask = 1 << 4; 109 rts_mask = 1 << 4;
106 dtr_mask = 1 << 5; 110 dtr_mask = 1 << 5;
107 } else { 111 } else {
112 /* UART1 */
108 rts_mask = 1 << 6; 113 rts_mask = 1 << 6;
109 dtr_mask = 1 << 7; 114 dtr_mask = 1 << 7;
110 } 115 }
@@ -123,7 +128,7 @@ static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *bas
123 __raw_writel(ctrlc, SC_CTRLC); 128 __raw_writel(ctrlc, SC_CTRLC);
124} 129}
125 130
126static struct amba_pl010_data integrator_uart_data = { 131struct amba_pl010_data integrator_uart_data = {
127 .set_mctrl = integrator_uart_set_mctrl, 132 .set_mctrl = integrator_uart_set_mctrl,
128}; 133};
129 134
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c
index 2215d96cd735..d5b5435a09ae 100644
--- a/arch/arm/mach-integrator/integrator_ap.c
+++ b/arch/arm/mach-integrator/integrator_ap.c
@@ -34,6 +34,9 @@
34#include <linux/mtd/physmap.h> 34#include <linux/mtd/physmap.h>
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/platform_data/clk-integrator.h> 36#include <linux/platform_data/clk-integrator.h>
37#include <linux/of_irq.h>
38#include <linux/of_address.h>
39#include <linux/of_platform.h>
37#include <video/vga.h> 40#include <video/vga.h>
38 41
39#include <mach/hardware.h> 42#include <mach/hardware.h>
@@ -158,23 +161,6 @@ static void __init ap_map_io(void)
158 pci_map_io_early(__phys_to_pfn(PHYS_PCI_IO_BASE)); 161 pci_map_io_early(__phys_to_pfn(PHYS_PCI_IO_BASE));
159} 162}
160 163
161#define INTEGRATOR_SC_VALID_INT 0x003fffff
162
163static void __init ap_init_irq(void)
164{
165 /* Disable all interrupts initially. */
166 /* Do the core module ones */
167 writel(-1, VA_CMIC_BASE + IRQ_ENABLE_CLEAR);
168
169 /* do the header card stuff next */
170 writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR);
171 writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR);
172
173 fpga_irq_init(VA_IC_BASE, "SC", IRQ_PIC_START,
174 -1, INTEGRATOR_SC_VALID_INT, NULL);
175 integrator_clk_init(false);
176}
177
178#ifdef CONFIG_PM 164#ifdef CONFIG_PM
179static unsigned long ic_irq_enable; 165static unsigned long ic_irq_enable;
180 166
@@ -267,50 +253,6 @@ static struct physmap_flash_data ap_flash_data = {
267 .set_vpp = ap_flash_set_vpp, 253 .set_vpp = ap_flash_set_vpp,
268}; 254};
269 255
270static struct resource cfi_flash_resource = {
271 .start = INTEGRATOR_FLASH_BASE,
272 .end = INTEGRATOR_FLASH_BASE + INTEGRATOR_FLASH_SIZE - 1,
273 .flags = IORESOURCE_MEM,
274};
275
276static struct platform_device cfi_flash_device = {
277 .name = "physmap-flash",
278 .id = 0,
279 .dev = {
280 .platform_data = &ap_flash_data,
281 },
282 .num_resources = 1,
283 .resource = &cfi_flash_resource,
284};
285
286static void __init ap_init(void)
287{
288 unsigned long sc_dec;
289 int i;
290
291 platform_device_register(&cfi_flash_device);
292
293 sc_dec = readl(VA_SC_BASE + INTEGRATOR_SC_DEC_OFFSET);
294 for (i = 0; i < 4; i++) {
295 struct lm_device *lmdev;
296
297 if ((sc_dec & (16 << i)) == 0)
298 continue;
299
300 lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL);
301 if (!lmdev)
302 continue;
303
304 lmdev->resource.start = 0xc0000000 + 0x10000000 * i;
305 lmdev->resource.end = lmdev->resource.start + 0x0fffffff;
306 lmdev->resource.flags = IORESOURCE_MEM;
307 lmdev->irq = IRQ_AP_EXPINT0 + i;
308 lmdev->id = i;
309
310 lm_device_register(lmdev);
311 }
312}
313
314/* 256/*
315 * Where is the timer (VA)? 257 * Where is the timer (VA)?
316 */ 258 */
@@ -325,9 +267,9 @@ static u32 notrace integrator_read_sched_clock(void)
325 return -readl((void __iomem *) TIMER2_VA_BASE + TIMER_VALUE); 267 return -readl((void __iomem *) TIMER2_VA_BASE + TIMER_VALUE);
326} 268}
327 269
328static void integrator_clocksource_init(unsigned long inrate) 270static void integrator_clocksource_init(unsigned long inrate,
271 void __iomem *base)
329{ 272{
330 void __iomem *base = (void __iomem *)TIMER2_VA_BASE;
331 u32 ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC; 273 u32 ctrl = TIMER_CTRL_ENABLE | TIMER_CTRL_PERIODIC;
332 unsigned long rate = inrate; 274 unsigned long rate = inrate;
333 275
@@ -344,7 +286,7 @@ static void integrator_clocksource_init(unsigned long inrate)
344 setup_sched_clock(integrator_read_sched_clock, 16, rate); 286 setup_sched_clock(integrator_read_sched_clock, 16, rate);
345} 287}
346 288
347static void __iomem * const clkevt_base = (void __iomem *)TIMER1_VA_BASE; 289static void __iomem * clkevt_base;
348 290
349/* 291/*
350 * IRQ handler for the timer 292 * IRQ handler for the timer
@@ -416,11 +358,13 @@ static struct irqaction integrator_timer_irq = {
416 .dev_id = &integrator_clockevent, 358 .dev_id = &integrator_clockevent,
417}; 359};
418 360
419static void integrator_clockevent_init(unsigned long inrate) 361static void integrator_clockevent_init(unsigned long inrate,
362 void __iomem *base, int irq)
420{ 363{
421 unsigned long rate = inrate; 364 unsigned long rate = inrate;
422 unsigned int ctrl = 0; 365 unsigned int ctrl = 0;
423 366
367 clkevt_base = base;
424 /* Calculate and program a divisor */ 368 /* Calculate and program a divisor */
425 if (rate > 0x100000 * HZ) { 369 if (rate > 0x100000 * HZ) {
426 rate /= 256; 370 rate /= 256;
@@ -432,7 +376,7 @@ static void integrator_clockevent_init(unsigned long inrate)
432 timer_reload = rate / HZ; 376 timer_reload = rate / HZ;
433 writel(ctrl, clkevt_base + TIMER_CTRL); 377 writel(ctrl, clkevt_base + TIMER_CTRL);
434 378
435 setup_irq(IRQ_TIMERINT1, &integrator_timer_irq); 379 setup_irq(irq, &integrator_timer_irq);
436 clockevents_config_and_register(&integrator_clockevent, 380 clockevents_config_and_register(&integrator_clockevent,
437 rate, 381 rate,
438 1, 382 1,
@@ -443,9 +387,153 @@ void __init ap_init_early(void)
443{ 387{
444} 388}
445 389
390#ifdef CONFIG_OF
391
392static void __init ap_init_timer_of(void)
393{
394 struct device_node *node;
395 const char *path;
396 void __iomem *base;
397 int err;
398 int irq;
399 struct clk *clk;
400 unsigned long rate;
401
402 clk = clk_get_sys("ap_timer", NULL);
403 BUG_ON(IS_ERR(clk));
404 clk_prepare_enable(clk);
405 rate = clk_get_rate(clk);
406
407 err = of_property_read_string(of_aliases,
408 "arm,timer-primary", &path);
409 if (WARN_ON(err))
410 return;
411 node = of_find_node_by_path(path);
412 base = of_iomap(node, 0);
413 if (WARN_ON(!base))
414 return;
415 writel(0, base + TIMER_CTRL);
416 integrator_clocksource_init(rate, base);
417
418 err = of_property_read_string(of_aliases,
419 "arm,timer-secondary", &path);
420 if (WARN_ON(err))
421 return;
422 node = of_find_node_by_path(path);
423 base = of_iomap(node, 0);
424 if (WARN_ON(!base))
425 return;
426 irq = irq_of_parse_and_map(node, 0);
427 writel(0, base + TIMER_CTRL);
428 integrator_clockevent_init(rate, base, irq);
429}
430
431static struct sys_timer ap_of_timer = {
432 .init = ap_init_timer_of,
433};
434
435static const struct of_device_id fpga_irq_of_match[] __initconst = {
436 { .compatible = "arm,versatile-fpga-irq", .data = fpga_irq_of_init, },
437 { /* Sentinel */ }
438};
439
440static void __init ap_init_irq_of(void)
441{
442 /* disable core module IRQs */
443 writel(0xffffffffU, VA_CMIC_BASE + IRQ_ENABLE_CLEAR);
444 of_irq_init(fpga_irq_of_match);
445 integrator_clk_init(false);
446}
447
448/* For the Device Tree, add in the UART callbacks as AUXDATA */
449static struct of_dev_auxdata ap_auxdata_lookup[] __initdata = {
450 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_RTC_BASE,
451 "rtc", NULL),
452 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE,
453 "uart0", &integrator_uart_data),
454 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE,
455 "uart1", &integrator_uart_data),
456 OF_DEV_AUXDATA("arm,primecell", KMI0_BASE,
457 "kmi0", NULL),
458 OF_DEV_AUXDATA("arm,primecell", KMI1_BASE,
459 "kmi1", NULL),
460 OF_DEV_AUXDATA("cfi-flash", INTEGRATOR_FLASH_BASE,
461 "physmap-flash", &ap_flash_data),
462 { /* sentinel */ },
463};
464
465static void __init ap_init_of(void)
466{
467 unsigned long sc_dec;
468 int i;
469
470 of_platform_populate(NULL, of_default_bus_match_table,
471 ap_auxdata_lookup, NULL);
472
473 sc_dec = readl(VA_SC_BASE + INTEGRATOR_SC_DEC_OFFSET);
474 for (i = 0; i < 4; i++) {
475 struct lm_device *lmdev;
476
477 if ((sc_dec & (16 << i)) == 0)
478 continue;
479
480 lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL);
481 if (!lmdev)
482 continue;
483
484 lmdev->resource.start = 0xc0000000 + 0x10000000 * i;
485 lmdev->resource.end = lmdev->resource.start + 0x0fffffff;
486 lmdev->resource.flags = IORESOURCE_MEM;
487 lmdev->irq = IRQ_AP_EXPINT0 + i;
488 lmdev->id = i;
489
490 lm_device_register(lmdev);
491 }
492}
493
494static const char * ap_dt_board_compat[] = {
495 "arm,integrator-ap",
496 NULL,
497};
498
499DT_MACHINE_START(INTEGRATOR_AP_DT, "ARM Integrator/AP (Device Tree)")
500 .reserve = integrator_reserve,
501 .map_io = ap_map_io,
502 .nr_irqs = NR_IRQS_INTEGRATOR_AP,
503 .init_early = ap_init_early,
504 .init_irq = ap_init_irq_of,
505 .handle_irq = fpga_handle_irq,
506 .timer = &ap_of_timer,
507 .init_machine = ap_init_of,
508 .restart = integrator_restart,
509 .dt_compat = ap_dt_board_compat,
510MACHINE_END
511
512#endif
513
514#ifdef CONFIG_ATAGS
515
446/* 516/*
447 * Set up timer(s). 517 * This is where non-devicetree initialization code is collected and stashed
518 * for eventual deletion.
448 */ 519 */
520
521static struct resource cfi_flash_resource = {
522 .start = INTEGRATOR_FLASH_BASE,
523 .end = INTEGRATOR_FLASH_BASE + INTEGRATOR_FLASH_SIZE - 1,
524 .flags = IORESOURCE_MEM,
525};
526
527static struct platform_device cfi_flash_device = {
528 .name = "physmap-flash",
529 .id = 0,
530 .dev = {
531 .platform_data = &ap_flash_data,
532 },
533 .num_resources = 1,
534 .resource = &cfi_flash_resource,
535};
536
449static void __init ap_init_timer(void) 537static void __init ap_init_timer(void)
450{ 538{
451 struct clk *clk; 539 struct clk *clk;
@@ -460,14 +548,62 @@ static void __init ap_init_timer(void)
460 writel(0, TIMER1_VA_BASE + TIMER_CTRL); 548 writel(0, TIMER1_VA_BASE + TIMER_CTRL);
461 writel(0, TIMER2_VA_BASE + TIMER_CTRL); 549 writel(0, TIMER2_VA_BASE + TIMER_CTRL);
462 550
463 integrator_clocksource_init(rate); 551 integrator_clocksource_init(rate, (void __iomem *)TIMER2_VA_BASE);
464 integrator_clockevent_init(rate); 552 integrator_clockevent_init(rate, (void __iomem *)TIMER1_VA_BASE,
553 IRQ_TIMERINT1);
465} 554}
466 555
467static struct sys_timer ap_timer = { 556static struct sys_timer ap_timer = {
468 .init = ap_init_timer, 557 .init = ap_init_timer,
469}; 558};
470 559
560#define INTEGRATOR_SC_VALID_INT 0x003fffff
561
562static void __init ap_init_irq(void)
563{
564 /* Disable all interrupts initially. */
565 /* Do the core module ones */
566 writel(-1, VA_CMIC_BASE + IRQ_ENABLE_CLEAR);
567
568 /* do the header card stuff next */
569 writel(-1, VA_IC_BASE + IRQ_ENABLE_CLEAR);
570 writel(-1, VA_IC_BASE + FIQ_ENABLE_CLEAR);
571
572 fpga_irq_init(VA_IC_BASE, "SC", IRQ_PIC_START,
573 -1, INTEGRATOR_SC_VALID_INT, NULL);
574 integrator_clk_init(false);
575}
576
577static void __init ap_init(void)
578{
579 unsigned long sc_dec;
580 int i;
581
582 platform_device_register(&cfi_flash_device);
583
584 sc_dec = readl(VA_SC_BASE + INTEGRATOR_SC_DEC_OFFSET);
585 for (i = 0; i < 4; i++) {
586 struct lm_device *lmdev;
587
588 if ((sc_dec & (16 << i)) == 0)
589 continue;
590
591 lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL);
592 if (!lmdev)
593 continue;
594
595 lmdev->resource.start = 0xc0000000 + 0x10000000 * i;
596 lmdev->resource.end = lmdev->resource.start + 0x0fffffff;
597 lmdev->resource.flags = IORESOURCE_MEM;
598 lmdev->irq = IRQ_AP_EXPINT0 + i;
599 lmdev->id = i;
600
601 lm_device_register(lmdev);
602 }
603
604 integrator_init(false);
605}
606
471MACHINE_START(INTEGRATOR, "ARM-Integrator") 607MACHINE_START(INTEGRATOR, "ARM-Integrator")
472 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 608 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
473 .atag_offset = 0x100, 609 .atag_offset = 0x100,
@@ -481,3 +617,5 @@ MACHINE_START(INTEGRATOR, "ARM-Integrator")
481 .init_machine = ap_init, 617 .init_machine = ap_init,
482 .restart = integrator_restart, 618 .restart = integrator_restart,
483MACHINE_END 619MACHINE_END
620
621#endif
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c
index 3df5fc369361..6870a1fbcd78 100644
--- a/arch/arm/mach-integrator/integrator_cp.c
+++ b/arch/arm/mach-integrator/integrator_cp.c
@@ -23,6 +23,9 @@
23#include <linux/gfp.h> 23#include <linux/gfp.h>
24#include <linux/mtd/physmap.h> 24#include <linux/mtd/physmap.h>
25#include <linux/platform_data/clk-integrator.h> 25#include <linux/platform_data/clk-integrator.h>
26#include <linux/of_irq.h>
27#include <linux/of_address.h>
28#include <linux/of_platform.h>
26 29
27#include <mach/hardware.h> 30#include <mach/hardware.h>
28#include <mach/platform.h> 31#include <mach/platform.h>
@@ -49,16 +52,9 @@
49#include "common.h" 52#include "common.h"
50 53
51#define INTCP_PA_FLASH_BASE 0x24000000 54#define INTCP_PA_FLASH_BASE 0x24000000
52#define INTCP_FLASH_SIZE SZ_32M
53 55
54#define INTCP_PA_CLCD_BASE 0xc0000000 56#define INTCP_PA_CLCD_BASE 0xc0000000
55 57
56#define INTCP_VA_CIC_BASE __io_address(INTEGRATOR_HDR_BASE + 0x40)
57#define INTCP_VA_PIC_BASE __io_address(INTEGRATOR_IC_BASE)
58#define INTCP_VA_SIC_BASE __io_address(INTEGRATOR_CP_SIC_BASE)
59
60#define INTCP_ETH_SIZE 0x10
61
62#define INTCP_VA_CTRL_BASE __io_address(INTEGRATOR_CP_CTL_BASE) 58#define INTCP_VA_CTRL_BASE __io_address(INTEGRATOR_CP_CTL_BASE)
63#define INTCP_FLASHPROG 0x04 59#define INTCP_FLASHPROG 0x04
64#define CINTEGRATOR_FLASHPROG_FLVPPEN (1 << 0) 60#define CINTEGRATOR_FLASHPROG_FLVPPEN (1 << 0)
@@ -143,37 +139,6 @@ static void __init intcp_map_io(void)
143 iotable_init(intcp_io_desc, ARRAY_SIZE(intcp_io_desc)); 139 iotable_init(intcp_io_desc, ARRAY_SIZE(intcp_io_desc));
144} 140}
145 141
146static void __init intcp_init_irq(void)
147{
148 u32 pic_mask, cic_mask, sic_mask;
149
150 /* These masks are for the HW IRQ registers */
151 pic_mask = ~((~0u) << (11 - IRQ_PIC_START));
152 pic_mask |= (~((~0u) << (29 - 22))) << 22;
153 cic_mask = ~((~0u) << (1 + IRQ_CIC_END - IRQ_CIC_START));
154 sic_mask = ~((~0u) << (1 + IRQ_SIC_END - IRQ_SIC_START));
155
156 /*
157 * Disable all interrupt sources
158 */
159 writel(0xffffffff, INTCP_VA_PIC_BASE + IRQ_ENABLE_CLEAR);
160 writel(0xffffffff, INTCP_VA_PIC_BASE + FIQ_ENABLE_CLEAR);
161 writel(0xffffffff, INTCP_VA_CIC_BASE + IRQ_ENABLE_CLEAR);
162 writel(0xffffffff, INTCP_VA_CIC_BASE + FIQ_ENABLE_CLEAR);
163 writel(sic_mask, INTCP_VA_SIC_BASE + IRQ_ENABLE_CLEAR);
164 writel(sic_mask, INTCP_VA_SIC_BASE + FIQ_ENABLE_CLEAR);
165
166 fpga_irq_init(INTCP_VA_PIC_BASE, "PIC", IRQ_PIC_START,
167 -1, pic_mask, NULL);
168
169 fpga_irq_init(INTCP_VA_CIC_BASE, "CIC", IRQ_CIC_START,
170 -1, cic_mask, NULL);
171
172 fpga_irq_init(INTCP_VA_SIC_BASE, "SIC", IRQ_SIC_START,
173 IRQ_CP_CPPLDINT, sic_mask, NULL);
174 integrator_clk_init(true);
175}
176
177/* 142/*
178 * Flash handling. 143 * Flash handling.
179 */ 144 */
@@ -216,47 +181,6 @@ static struct physmap_flash_data intcp_flash_data = {
216 .set_vpp = intcp_flash_set_vpp, 181 .set_vpp = intcp_flash_set_vpp,
217}; 182};
218 183
219static struct resource intcp_flash_resource = {
220 .start = INTCP_PA_FLASH_BASE,
221 .end = INTCP_PA_FLASH_BASE + INTCP_FLASH_SIZE - 1,
222 .flags = IORESOURCE_MEM,
223};
224
225static struct platform_device intcp_flash_device = {
226 .name = "physmap-flash",
227 .id = 0,
228 .dev = {
229 .platform_data = &intcp_flash_data,
230 },
231 .num_resources = 1,
232 .resource = &intcp_flash_resource,
233};
234
235static struct resource smc91x_resources[] = {
236 [0] = {
237 .start = INTEGRATOR_CP_ETH_BASE,
238 .end = INTEGRATOR_CP_ETH_BASE + INTCP_ETH_SIZE - 1,
239 .flags = IORESOURCE_MEM,
240 },
241 [1] = {
242 .start = IRQ_CP_ETHINT,
243 .end = IRQ_CP_ETHINT,
244 .flags = IORESOURCE_IRQ,
245 },
246};
247
248static struct platform_device smc91x_device = {
249 .name = "smc91x",
250 .id = 0,
251 .num_resources = ARRAY_SIZE(smc91x_resources),
252 .resource = smc91x_resources,
253};
254
255static struct platform_device *intcp_devs[] __initdata = {
256 &intcp_flash_device,
257 &smc91x_device,
258};
259
260/* 184/*
261 * It seems that the card insertion interrupt remains active after 185 * It seems that the card insertion interrupt remains active after
262 * we've acknowledged it. We therefore ignore the interrupt, and 186 * we've acknowledged it. We therefore ignore the interrupt, and
@@ -278,16 +202,6 @@ static struct mmci_platform_data mmc_data = {
278 .gpio_cd = -1, 202 .gpio_cd = -1,
279}; 203};
280 204
281#define INTEGRATOR_CP_MMC_IRQS { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 }
282#define INTEGRATOR_CP_AACI_IRQS { IRQ_CP_AACIINT }
283
284static AMBA_APB_DEVICE(mmc, "mmci", 0, INTEGRATOR_CP_MMC_BASE,
285 INTEGRATOR_CP_MMC_IRQS, &mmc_data);
286
287static AMBA_APB_DEVICE(aaci, "aaci", 0, INTEGRATOR_CP_AACI_BASE,
288 INTEGRATOR_CP_AACI_IRQS, NULL);
289
290
291/* 205/*
292 * CLCD support 206 * CLCD support
293 */ 207 */
@@ -338,15 +252,6 @@ static struct clcd_board clcd_data = {
338 .remove = versatile_clcd_remove_dma, 252 .remove = versatile_clcd_remove_dma,
339}; 253};
340 254
341static AMBA_AHB_DEVICE(clcd, "clcd", 0, INTCP_PA_CLCD_BASE,
342 { IRQ_CP_CLCDCINT }, &clcd_data);
343
344static struct amba_device *amba_devs[] __initdata = {
345 &mmc_device,
346 &aaci_device,
347 &clcd_device,
348};
349
350#define REFCOUNTER (__io_address(INTEGRATOR_HDR_BASE) + 0x28) 255#define REFCOUNTER (__io_address(INTEGRATOR_HDR_BASE) + 0x28)
351 256
352static void __init intcp_init_early(void) 257static void __init intcp_init_early(void)
@@ -356,16 +261,193 @@ static void __init intcp_init_early(void)
356#endif 261#endif
357} 262}
358 263
359static void __init intcp_init(void) 264static void __init intcp_timer_init_of(void)
360{ 265{
361 int i; 266 struct device_node *node;
267 const char *path;
268 void __iomem *base;
269 int err;
270 int irq;
271
272 err = of_property_read_string(of_aliases,
273 "arm,timer-primary", &path);
274 if (WARN_ON(err))
275 return;
276 node = of_find_node_by_path(path);
277 base = of_iomap(node, 0);
278 if (WARN_ON(!base))
279 return;
280 writel(0, base + TIMER_CTRL);
281 sp804_clocksource_init(base, node->name);
282
283 err = of_property_read_string(of_aliases,
284 "arm,timer-secondary", &path);
285 if (WARN_ON(err))
286 return;
287 node = of_find_node_by_path(path);
288 base = of_iomap(node, 0);
289 if (WARN_ON(!base))
290 return;
291 irq = irq_of_parse_and_map(node, 0);
292 writel(0, base + TIMER_CTRL);
293 sp804_clockevents_init(base, irq, node->name);
294}
362 295
363 platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs)); 296static struct sys_timer cp_of_timer = {
297 .init = intcp_timer_init_of,
298};
364 299
365 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { 300#ifdef CONFIG_OF
366 struct amba_device *d = amba_devs[i]; 301
367 amba_device_register(d, &iomem_resource); 302static const struct of_device_id fpga_irq_of_match[] __initconst = {
368 } 303 { .compatible = "arm,versatile-fpga-irq", .data = fpga_irq_of_init, },
304 { /* Sentinel */ }
305};
306
307static void __init intcp_init_irq_of(void)
308{
309 of_irq_init(fpga_irq_of_match);
310 integrator_clk_init(true);
311}
312
313/*
314 * For the Device Tree, add in the UART, MMC and CLCD specifics as AUXDATA
315 * and enforce the bus names since these are used for clock lookups.
316 */
317static struct of_dev_auxdata intcp_auxdata_lookup[] __initdata = {
318 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_RTC_BASE,
319 "rtc", NULL),
320 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE,
321 "uart0", &integrator_uart_data),
322 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE,
323 "uart1", &integrator_uart_data),
324 OF_DEV_AUXDATA("arm,primecell", KMI0_BASE,
325 "kmi0", NULL),
326 OF_DEV_AUXDATA("arm,primecell", KMI1_BASE,
327 "kmi1", NULL),
328 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_CP_MMC_BASE,
329 "mmci", &mmc_data),
330 OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_CP_AACI_BASE,
331 "aaci", &mmc_data),
332 OF_DEV_AUXDATA("arm,primecell", INTCP_PA_CLCD_BASE,
333 "clcd", &clcd_data),
334 OF_DEV_AUXDATA("cfi-flash", INTCP_PA_FLASH_BASE,
335 "physmap-flash", &intcp_flash_data),
336 { /* sentinel */ },
337};
338
339static void __init intcp_init_of(void)
340{
341 of_platform_populate(NULL, of_default_bus_match_table,
342 intcp_auxdata_lookup, NULL);
343}
344
345static const char * intcp_dt_board_compat[] = {
346 "arm,integrator-cp",
347 NULL,
348};
349
350DT_MACHINE_START(INTEGRATOR_CP_DT, "ARM Integrator/CP (Device Tree)")
351 .reserve = integrator_reserve,
352 .map_io = intcp_map_io,
353 .nr_irqs = NR_IRQS_INTEGRATOR_CP,
354 .init_early = intcp_init_early,
355 .init_irq = intcp_init_irq_of,
356 .handle_irq = fpga_handle_irq,
357 .timer = &cp_of_timer,
358 .init_machine = intcp_init_of,
359 .restart = integrator_restart,
360 .dt_compat = intcp_dt_board_compat,
361MACHINE_END
362
363#endif
364
365#ifdef CONFIG_ATAGS
366
367/*
368 * This is where non-devicetree initialization code is collected and stashed
369 * for eventual deletion.
370 */
371
372#define INTCP_FLASH_SIZE SZ_32M
373
374static struct resource intcp_flash_resource = {
375 .start = INTCP_PA_FLASH_BASE,
376 .end = INTCP_PA_FLASH_BASE + INTCP_FLASH_SIZE - 1,
377 .flags = IORESOURCE_MEM,
378};
379
380static struct platform_device intcp_flash_device = {
381 .name = "physmap-flash",
382 .id = 0,
383 .dev = {
384 .platform_data = &intcp_flash_data,
385 },
386 .num_resources = 1,
387 .resource = &intcp_flash_resource,
388};
389
390#define INTCP_ETH_SIZE 0x10
391
392static struct resource smc91x_resources[] = {
393 [0] = {
394 .start = INTEGRATOR_CP_ETH_BASE,
395 .end = INTEGRATOR_CP_ETH_BASE + INTCP_ETH_SIZE - 1,
396 .flags = IORESOURCE_MEM,
397 },
398 [1] = {
399 .start = IRQ_CP_ETHINT,
400 .end = IRQ_CP_ETHINT,
401 .flags = IORESOURCE_IRQ,
402 },
403};
404
405static struct platform_device smc91x_device = {
406 .name = "smc91x",
407 .id = 0,
408 .num_resources = ARRAY_SIZE(smc91x_resources),
409 .resource = smc91x_resources,
410};
411
412static struct platform_device *intcp_devs[] __initdata = {
413 &intcp_flash_device,
414 &smc91x_device,
415};
416
417#define INTCP_VA_CIC_BASE __io_address(INTEGRATOR_HDR_BASE + 0x40)
418#define INTCP_VA_PIC_BASE __io_address(INTEGRATOR_IC_BASE)
419#define INTCP_VA_SIC_BASE __io_address(INTEGRATOR_CP_SIC_BASE)
420
421static void __init intcp_init_irq(void)
422{
423 u32 pic_mask, cic_mask, sic_mask;
424
425 /* These masks are for the HW IRQ registers */
426 pic_mask = ~((~0u) << (11 - IRQ_PIC_START));
427 pic_mask |= (~((~0u) << (29 - 22))) << 22;
428 cic_mask = ~((~0u) << (1 + IRQ_CIC_END - IRQ_CIC_START));
429 sic_mask = ~((~0u) << (1 + IRQ_SIC_END - IRQ_SIC_START));
430
431 /*
432 * Disable all interrupt sources
433 */
434 writel(0xffffffff, INTCP_VA_PIC_BASE + IRQ_ENABLE_CLEAR);
435 writel(0xffffffff, INTCP_VA_PIC_BASE + FIQ_ENABLE_CLEAR);
436 writel(0xffffffff, INTCP_VA_CIC_BASE + IRQ_ENABLE_CLEAR);
437 writel(0xffffffff, INTCP_VA_CIC_BASE + FIQ_ENABLE_CLEAR);
438 writel(sic_mask, INTCP_VA_SIC_BASE + IRQ_ENABLE_CLEAR);
439 writel(sic_mask, INTCP_VA_SIC_BASE + FIQ_ENABLE_CLEAR);
440
441 fpga_irq_init(INTCP_VA_PIC_BASE, "PIC", IRQ_PIC_START,
442 -1, pic_mask, NULL);
443
444 fpga_irq_init(INTCP_VA_CIC_BASE, "CIC", IRQ_CIC_START,
445 -1, cic_mask, NULL);
446
447 fpga_irq_init(INTCP_VA_SIC_BASE, "SIC", IRQ_SIC_START,
448 IRQ_CP_CPPLDINT, sic_mask, NULL);
449
450 integrator_clk_init(true);
369} 451}
370 452
371#define TIMER0_VA_BASE __io_address(INTEGRATOR_TIMER0_BASE) 453#define TIMER0_VA_BASE __io_address(INTEGRATOR_TIMER0_BASE)
@@ -386,6 +468,37 @@ static struct sys_timer cp_timer = {
386 .init = intcp_timer_init, 468 .init = intcp_timer_init,
387}; 469};
388 470
471#define INTEGRATOR_CP_MMC_IRQS { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 }
472#define INTEGRATOR_CP_AACI_IRQS { IRQ_CP_AACIINT }
473
474static AMBA_APB_DEVICE(mmc, "mmci", 0, INTEGRATOR_CP_MMC_BASE,
475 INTEGRATOR_CP_MMC_IRQS, &mmc_data);
476
477static AMBA_APB_DEVICE(aaci, "aaci", 0, INTEGRATOR_CP_AACI_BASE,
478 INTEGRATOR_CP_AACI_IRQS, NULL);
479
480static AMBA_AHB_DEVICE(clcd, "clcd", 0, INTCP_PA_CLCD_BASE,
481 { IRQ_CP_CLCDCINT }, &clcd_data);
482
483static struct amba_device *amba_devs[] __initdata = {
484 &mmc_device,
485 &aaci_device,
486 &clcd_device,
487};
488
489static void __init intcp_init(void)
490{
491 int i;
492
493 platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs));
494
495 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
496 struct amba_device *d = amba_devs[i];
497 amba_device_register(d, &iomem_resource);
498 }
499 integrator_init(true);
500}
501
389MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP") 502MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP")
390 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ 503 /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */
391 .atag_offset = 0x100, 504 .atag_offset = 0x100,
@@ -399,3 +512,5 @@ MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP")
399 .init_machine = intcp_init, 512 .init_machine = intcp_init,
400 .restart = integrator_restart, 513 .restart = integrator_restart,
401MACHINE_END 514MACHINE_END
515
516#endif