diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2012-09-06 04:08:47 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2012-09-17 18:20:22 -0400 |
commit | 4672cddff21f6edde857aa4b523bbc1bfc741cf8 (patch) | |
tree | 95af82598243419da14f78aab39474778071fed3 /arch/arm/mach-integrator | |
parent | 4980f9bc2cec0f8ff0e0f2b021d46c7606ae1849 (diff) |
ARM: 7518/1: integrator: convert AMBA devices to device tree
This converts the AMBA (PrimeCell) devices on the Integrator/AP
and Integrator/CP over to probing from the Device Tree if the
kernel is compiled for Device Tree support.
We continue to #ifdef out all non-DT code and vice versa on
respective boot type to get a clean cut.
We need to add a bunch of auxdata (compare to the Versatile)
to handle bus names and callbacks alike.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-integrator')
-rw-r--r-- | arch/arm/mach-integrator/common.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-integrator/core.c | 8 | ||||
-rw-r--r-- | arch/arm/mach-integrator/integrator_ap.c | 109 | ||||
-rw-r--r-- | arch/arm/mach-integrator/integrator_cp.c | 84 |
4 files changed, 150 insertions, 53 deletions
diff --git a/arch/arm/mach-integrator/common.h b/arch/arm/mach-integrator/common.h index c4338e2fc631..c3ff21b5ea24 100644 --- a/arch/arm/mach-integrator/common.h +++ b/arch/arm/mach-integrator/common.h | |||
@@ -1,3 +1,5 @@ | |||
1 | #include <linux/amba/serial.h> | ||
2 | extern struct amba_pl010_data integrator_uart_data; | ||
1 | void integrator_init_early(void); | 3 | void integrator_init_early(void); |
2 | int integrator_init(bool is_cp); | 4 | int integrator_init(bool is_cp); |
3 | void integrator_reserve(void); | 5 | void integrator_reserve(void); |
diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c index 268eadf6d3e6..1772c024e789 100644 --- a/arch/arm/mach-integrator/core.c +++ b/arch/arm/mach-integrator/core.c | |||
@@ -33,7 +33,9 @@ | |||
33 | #include <asm/mach/time.h> | 33 | #include <asm/mach/time.h> |
34 | #include <asm/pgtable.h> | 34 | #include <asm/pgtable.h> |
35 | 35 | ||
36 | static struct amba_pl010_data integrator_uart_data; | 36 | #include "common.h" |
37 | |||
38 | #ifdef CONFIG_ATAGS | ||
37 | 39 | ||
38 | #define INTEGRATOR_RTC_IRQ { IRQ_RTCINT } | 40 | #define INTEGRATOR_RTC_IRQ { IRQ_RTCINT } |
39 | #define INTEGRATOR_UART0_IRQ { IRQ_UARTINT0 } | 41 | #define INTEGRATOR_UART0_IRQ { IRQ_UARTINT0 } |
@@ -86,6 +88,8 @@ int __init integrator_init(bool is_cp) | |||
86 | return 0; | 88 | return 0; |
87 | } | 89 | } |
88 | 90 | ||
91 | #endif | ||
92 | |||
89 | /* | 93 | /* |
90 | * On the Integrator platform, the port RTS and DTR are provided by | 94 | * On the Integrator platform, the port RTS and DTR are provided by |
91 | * bits in the following SC_CTRLS register bits: | 95 | * bits in the following SC_CTRLS register bits: |
@@ -125,7 +129,7 @@ static void integrator_uart_set_mctrl(struct amba_device *dev, void __iomem *bas | |||
125 | __raw_writel(ctrlc, SC_CTRLC); | 129 | __raw_writel(ctrlc, SC_CTRLC); |
126 | } | 130 | } |
127 | 131 | ||
128 | static struct amba_pl010_data integrator_uart_data = { | 132 | struct amba_pl010_data integrator_uart_data = { |
129 | .set_mctrl = integrator_uart_set_mctrl, | 133 | .set_mctrl = integrator_uart_set_mctrl, |
130 | }; | 134 | }; |
131 | 135 | ||
diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c index 57add86c4a69..8cd05607435a 100644 --- a/arch/arm/mach-integrator/integrator_ap.c +++ b/arch/arm/mach-integrator/integrator_ap.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/platform_data/clk-integrator.h> | 36 | #include <linux/platform_data/clk-integrator.h> |
37 | #include <linux/of_irq.h> | 37 | #include <linux/of_irq.h> |
38 | #include <linux/of_address.h> | 38 | #include <linux/of_address.h> |
39 | #include <linux/of_platform.h> | ||
39 | #include <video/vga.h> | 40 | #include <video/vga.h> |
40 | 41 | ||
41 | #include <mach/hardware.h> | 42 | #include <mach/hardware.h> |
@@ -271,36 +272,6 @@ static struct platform_device cfi_flash_device = { | |||
271 | .resource = &cfi_flash_resource, | 272 | .resource = &cfi_flash_resource, |
272 | }; | 273 | }; |
273 | 274 | ||
274 | static void __init ap_init(void) | ||
275 | { | ||
276 | unsigned long sc_dec; | ||
277 | int i; | ||
278 | |||
279 | platform_device_register(&cfi_flash_device); | ||
280 | |||
281 | sc_dec = readl(VA_SC_BASE + INTEGRATOR_SC_DEC_OFFSET); | ||
282 | for (i = 0; i < 4; i++) { | ||
283 | struct lm_device *lmdev; | ||
284 | |||
285 | if ((sc_dec & (16 << i)) == 0) | ||
286 | continue; | ||
287 | |||
288 | lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL); | ||
289 | if (!lmdev) | ||
290 | continue; | ||
291 | |||
292 | lmdev->resource.start = 0xc0000000 + 0x10000000 * i; | ||
293 | lmdev->resource.end = lmdev->resource.start + 0x0fffffff; | ||
294 | lmdev->resource.flags = IORESOURCE_MEM; | ||
295 | lmdev->irq = IRQ_AP_EXPINT0 + i; | ||
296 | lmdev->id = i; | ||
297 | |||
298 | lm_device_register(lmdev); | ||
299 | } | ||
300 | |||
301 | integrator_init(false); | ||
302 | } | ||
303 | |||
304 | /* | 275 | /* |
305 | * Where is the timer (VA)? | 276 | * Where is the timer (VA)? |
306 | */ | 277 | */ |
@@ -493,6 +464,52 @@ static void __init ap_init_irq_of(void) | |||
493 | integrator_clk_init(false); | 464 | integrator_clk_init(false); |
494 | } | 465 | } |
495 | 466 | ||
467 | /* For the Device Tree, add in the UART callbacks as AUXDATA */ | ||
468 | static struct of_dev_auxdata ap_auxdata_lookup[] __initdata = { | ||
469 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_RTC_BASE, | ||
470 | "rtc", NULL), | ||
471 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE, | ||
472 | "uart0", &integrator_uart_data), | ||
473 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE, | ||
474 | "uart1", &integrator_uart_data), | ||
475 | OF_DEV_AUXDATA("arm,primecell", KMI0_BASE, | ||
476 | "kmi0", NULL), | ||
477 | OF_DEV_AUXDATA("arm,primecell", KMI1_BASE, | ||
478 | "kmi1", NULL), | ||
479 | { /* sentinel */ }, | ||
480 | }; | ||
481 | |||
482 | static void __init ap_init_of(void) | ||
483 | { | ||
484 | unsigned long sc_dec; | ||
485 | int i; | ||
486 | |||
487 | of_platform_populate(NULL, of_default_bus_match_table, | ||
488 | ap_auxdata_lookup, NULL); | ||
489 | |||
490 | platform_device_register(&cfi_flash_device); | ||
491 | |||
492 | sc_dec = readl(VA_SC_BASE + INTEGRATOR_SC_DEC_OFFSET); | ||
493 | for (i = 0; i < 4; i++) { | ||
494 | struct lm_device *lmdev; | ||
495 | |||
496 | if ((sc_dec & (16 << i)) == 0) | ||
497 | continue; | ||
498 | |||
499 | lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL); | ||
500 | if (!lmdev) | ||
501 | continue; | ||
502 | |||
503 | lmdev->resource.start = 0xc0000000 + 0x10000000 * i; | ||
504 | lmdev->resource.end = lmdev->resource.start + 0x0fffffff; | ||
505 | lmdev->resource.flags = IORESOURCE_MEM; | ||
506 | lmdev->irq = IRQ_AP_EXPINT0 + i; | ||
507 | lmdev->id = i; | ||
508 | |||
509 | lm_device_register(lmdev); | ||
510 | } | ||
511 | } | ||
512 | |||
496 | static const char * ap_dt_board_compat[] = { | 513 | static const char * ap_dt_board_compat[] = { |
497 | "arm,integrator-ap", | 514 | "arm,integrator-ap", |
498 | NULL, | 515 | NULL, |
@@ -506,7 +523,7 @@ DT_MACHINE_START(INTEGRATOR_AP_DT, "ARM Integrator/AP (Device Tree)") | |||
506 | .init_irq = ap_init_irq_of, | 523 | .init_irq = ap_init_irq_of, |
507 | .handle_irq = fpga_handle_irq, | 524 | .handle_irq = fpga_handle_irq, |
508 | .timer = &ap_of_timer, | 525 | .timer = &ap_of_timer, |
509 | .init_machine = ap_init, | 526 | .init_machine = ap_init_of, |
510 | .restart = integrator_restart, | 527 | .restart = integrator_restart, |
511 | .dt_compat = ap_dt_board_compat, | 528 | .dt_compat = ap_dt_board_compat, |
512 | MACHINE_END | 529 | MACHINE_END |
@@ -560,6 +577,36 @@ static void __init ap_init_irq(void) | |||
560 | integrator_clk_init(false); | 577 | integrator_clk_init(false); |
561 | } | 578 | } |
562 | 579 | ||
580 | static void __init ap_init(void) | ||
581 | { | ||
582 | unsigned long sc_dec; | ||
583 | int i; | ||
584 | |||
585 | platform_device_register(&cfi_flash_device); | ||
586 | |||
587 | sc_dec = readl(VA_SC_BASE + INTEGRATOR_SC_DEC_OFFSET); | ||
588 | for (i = 0; i < 4; i++) { | ||
589 | struct lm_device *lmdev; | ||
590 | |||
591 | if ((sc_dec & (16 << i)) == 0) | ||
592 | continue; | ||
593 | |||
594 | lmdev = kzalloc(sizeof(struct lm_device), GFP_KERNEL); | ||
595 | if (!lmdev) | ||
596 | continue; | ||
597 | |||
598 | lmdev->resource.start = 0xc0000000 + 0x10000000 * i; | ||
599 | lmdev->resource.end = lmdev->resource.start + 0x0fffffff; | ||
600 | lmdev->resource.flags = IORESOURCE_MEM; | ||
601 | lmdev->irq = IRQ_AP_EXPINT0 + i; | ||
602 | lmdev->id = i; | ||
603 | |||
604 | lm_device_register(lmdev); | ||
605 | } | ||
606 | |||
607 | integrator_init(false); | ||
608 | } | ||
609 | |||
563 | MACHINE_START(INTEGRATOR, "ARM-Integrator") | 610 | MACHINE_START(INTEGRATOR, "ARM-Integrator") |
564 | /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ | 611 | /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ |
565 | .atag_offset = 0x100, | 612 | .atag_offset = 0x100, |
diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c index 6a2293a28a84..f032238c1f9f 100644 --- a/arch/arm/mach-integrator/integrator_cp.c +++ b/arch/arm/mach-integrator/integrator_cp.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/platform_data/clk-integrator.h> | 25 | #include <linux/platform_data/clk-integrator.h> |
26 | #include <linux/of_irq.h> | 26 | #include <linux/of_irq.h> |
27 | #include <linux/of_address.h> | 27 | #include <linux/of_address.h> |
28 | #include <linux/of_platform.h> | ||
28 | 29 | ||
29 | #include <mach/hardware.h> | 30 | #include <mach/hardware.h> |
30 | #include <mach/platform.h> | 31 | #include <mach/platform.h> |
@@ -245,16 +246,6 @@ static struct mmci_platform_data mmc_data = { | |||
245 | .gpio_cd = -1, | 246 | .gpio_cd = -1, |
246 | }; | 247 | }; |
247 | 248 | ||
248 | #define INTEGRATOR_CP_MMC_IRQS { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 } | ||
249 | #define INTEGRATOR_CP_AACI_IRQS { IRQ_CP_AACIINT } | ||
250 | |||
251 | static AMBA_APB_DEVICE(mmc, "mmci", 0, INTEGRATOR_CP_MMC_BASE, | ||
252 | INTEGRATOR_CP_MMC_IRQS, &mmc_data); | ||
253 | |||
254 | static AMBA_APB_DEVICE(aaci, "aaci", 0, INTEGRATOR_CP_AACI_BASE, | ||
255 | INTEGRATOR_CP_AACI_IRQS, NULL); | ||
256 | |||
257 | |||
258 | /* | 249 | /* |
259 | * CLCD support | 250 | * CLCD support |
260 | */ | 251 | */ |
@@ -305,15 +296,6 @@ static struct clcd_board clcd_data = { | |||
305 | .remove = versatile_clcd_remove_dma, | 296 | .remove = versatile_clcd_remove_dma, |
306 | }; | 297 | }; |
307 | 298 | ||
308 | static AMBA_AHB_DEVICE(clcd, "clcd", 0, INTCP_PA_CLCD_BASE, | ||
309 | { IRQ_CP_CLCDCINT }, &clcd_data); | ||
310 | |||
311 | static struct amba_device *amba_devs[] __initdata = { | ||
312 | &mmc_device, | ||
313 | &aaci_device, | ||
314 | &clcd_device, | ||
315 | }; | ||
316 | |||
317 | #define REFCOUNTER (__io_address(INTEGRATOR_HDR_BASE) + 0x28) | 299 | #define REFCOUNTER (__io_address(INTEGRATOR_HDR_BASE) + 0x28) |
318 | 300 | ||
319 | static void __init intcp_init_early(void) | 301 | static void __init intcp_init_early(void) |
@@ -372,6 +354,37 @@ static void __init intcp_init_irq_of(void) | |||
372 | integrator_clk_init(true); | 354 | integrator_clk_init(true); |
373 | } | 355 | } |
374 | 356 | ||
357 | /* | ||
358 | * For the Device Tree, add in the UART, MMC and CLCD specifics as AUXDATA | ||
359 | * and enforce the bus names since these are used for clock lookups. | ||
360 | */ | ||
361 | static struct of_dev_auxdata intcp_auxdata_lookup[] __initdata = { | ||
362 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_RTC_BASE, | ||
363 | "rtc", NULL), | ||
364 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART0_BASE, | ||
365 | "uart0", &integrator_uart_data), | ||
366 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_UART1_BASE, | ||
367 | "uart1", &integrator_uart_data), | ||
368 | OF_DEV_AUXDATA("arm,primecell", KMI0_BASE, | ||
369 | "kmi0", NULL), | ||
370 | OF_DEV_AUXDATA("arm,primecell", KMI1_BASE, | ||
371 | "kmi1", NULL), | ||
372 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_CP_MMC_BASE, | ||
373 | "mmci", &mmc_data), | ||
374 | OF_DEV_AUXDATA("arm,primecell", INTEGRATOR_CP_AACI_BASE, | ||
375 | "aaci", &mmc_data), | ||
376 | OF_DEV_AUXDATA("arm,primecell", INTCP_PA_CLCD_BASE, | ||
377 | "clcd", &clcd_data), | ||
378 | { /* sentinel */ }, | ||
379 | }; | ||
380 | |||
381 | static void __init intcp_init_of(void) | ||
382 | { | ||
383 | of_platform_populate(NULL, of_default_bus_match_table, | ||
384 | intcp_auxdata_lookup, NULL); | ||
385 | platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs)); | ||
386 | } | ||
387 | |||
375 | static const char * intcp_dt_board_compat[] = { | 388 | static const char * intcp_dt_board_compat[] = { |
376 | "arm,integrator-cp", | 389 | "arm,integrator-cp", |
377 | NULL, | 390 | NULL, |
@@ -385,7 +398,7 @@ DT_MACHINE_START(INTEGRATOR_CP_DT, "ARM Integrator/CP (Device Tree)") | |||
385 | .init_irq = intcp_init_irq_of, | 398 | .init_irq = intcp_init_irq_of, |
386 | .handle_irq = fpga_handle_irq, | 399 | .handle_irq = fpga_handle_irq, |
387 | .timer = &cp_of_timer, | 400 | .timer = &cp_of_timer, |
388 | .init_machine = intcp_init, | 401 | .init_machine = intcp_init_of, |
389 | .restart = integrator_restart, | 402 | .restart = integrator_restart, |
390 | .dt_compat = intcp_dt_board_compat, | 403 | .dt_compat = intcp_dt_board_compat, |
391 | MACHINE_END | 404 | MACHINE_END |
@@ -453,6 +466,37 @@ static struct sys_timer cp_timer = { | |||
453 | .init = intcp_timer_init, | 466 | .init = intcp_timer_init, |
454 | }; | 467 | }; |
455 | 468 | ||
469 | #define INTEGRATOR_CP_MMC_IRQS { IRQ_CP_MMCIINT0, IRQ_CP_MMCIINT1 } | ||
470 | #define INTEGRATOR_CP_AACI_IRQS { IRQ_CP_AACIINT } | ||
471 | |||
472 | static AMBA_APB_DEVICE(mmc, "mmci", 0, INTEGRATOR_CP_MMC_BASE, | ||
473 | INTEGRATOR_CP_MMC_IRQS, &mmc_data); | ||
474 | |||
475 | static AMBA_APB_DEVICE(aaci, "aaci", 0, INTEGRATOR_CP_AACI_BASE, | ||
476 | INTEGRATOR_CP_AACI_IRQS, NULL); | ||
477 | |||
478 | static AMBA_AHB_DEVICE(clcd, "clcd", 0, INTCP_PA_CLCD_BASE, | ||
479 | { IRQ_CP_CLCDCINT }, &clcd_data); | ||
480 | |||
481 | static struct amba_device *amba_devs[] __initdata = { | ||
482 | &mmc_device, | ||
483 | &aaci_device, | ||
484 | &clcd_device, | ||
485 | }; | ||
486 | |||
487 | static void __init intcp_init(void) | ||
488 | { | ||
489 | int i; | ||
490 | |||
491 | platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs)); | ||
492 | |||
493 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { | ||
494 | struct amba_device *d = amba_devs[i]; | ||
495 | amba_device_register(d, &iomem_resource); | ||
496 | } | ||
497 | integrator_init(true); | ||
498 | } | ||
499 | |||
456 | MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP") | 500 | MACHINE_START(CINTEGRATOR, "ARM-IntegratorCP") |
457 | /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ | 501 | /* Maintainer: ARM Ltd/Deep Blue Solutions Ltd */ |
458 | .atag_offset = 0x100, | 502 | .atag_offset = 0x100, |