diff options
author | Shawn Guo <shawn.guo@linaro.org> | 2011-10-16 20:42:17 -0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-10-18 06:43:19 -0400 |
commit | 9daaf31a8cc9c98751b7b71198307e47d5bf6a4d (patch) | |
tree | 652301a4dd70a11462199237ca869047070e8fea /arch/arm/mach-mx5 | |
parent | 73d2b4cdfc09a7a858b3ea1f32f6218b21439b96 (diff) |
arm/mx5: add device tree support for imx51 babbage
It adds device tree support for imx51 babbage board.
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-mx5')
-rw-r--r-- | arch/arm/mach-mx5/Kconfig | 9 | ||||
-rw-r--r-- | arch/arm/mach-mx5/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-mx5/board-mx51_babbage.c | 9 | ||||
-rw-r--r-- | arch/arm/mach-mx5/clock-mx51-mx53.c | 8 | ||||
-rw-r--r-- | arch/arm/mach-mx5/imx51-dt.c | 116 |
5 files changed, 141 insertions, 2 deletions
diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig index 0ac676c5256d..bda12e84429a 100644 --- a/arch/arm/mach-mx5/Kconfig +++ b/arch/arm/mach-mx5/Kconfig | |||
@@ -62,6 +62,15 @@ endif # ARCH_MX50_SUPPORTED | |||
62 | if ARCH_MX51 | 62 | if ARCH_MX51 |
63 | comment "i.MX51 machines:" | 63 | comment "i.MX51 machines:" |
64 | 64 | ||
65 | config MACH_IMX51_DT | ||
66 | bool "Support i.MX51 platforms from device tree" | ||
67 | select SOC_IMX51 | ||
68 | select USE_OF | ||
69 | select MACH_MX51_BABBAGE | ||
70 | help | ||
71 | Include support for Freescale i.MX51 based platforms | ||
72 | using the device tree for discovery | ||
73 | |||
65 | config MACH_MX51_BABBAGE | 74 | config MACH_MX51_BABBAGE |
66 | bool "Support MX51 BABBAGE platforms" | 75 | bool "Support MX51 BABBAGE platforms" |
67 | select SOC_IMX51 | 76 | select SOC_IMX51 |
diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile index 3dbe5e26a51b..a3c75f368f4b 100644 --- a/arch/arm/mach-mx5/Makefile +++ b/arch/arm/mach-mx5/Makefile | |||
@@ -23,4 +23,5 @@ obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o | |||
23 | obj-$(CONFIG_MACH_MX51_EFIKASB) += board-mx51_efikasb.o | 23 | obj-$(CONFIG_MACH_MX51_EFIKASB) += board-mx51_efikasb.o |
24 | obj-$(CONFIG_MACH_MX50_RDP) += board-mx50_rdp.o | 24 | obj-$(CONFIG_MACH_MX50_RDP) += board-mx50_rdp.o |
25 | 25 | ||
26 | obj-$(CONFIG_MACH_IMX51_DT) += imx51-dt.o | ||
26 | obj-$(CONFIG_MACH_IMX53_DT) += imx53-dt.o | 27 | obj-$(CONFIG_MACH_IMX53_DT) += imx53-dt.o |
diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c index 11b0ff67f89d..5cc28e0ce3e5 100644 --- a/arch/arm/mach-mx5/board-mx51_babbage.c +++ b/arch/arm/mach-mx5/board-mx51_babbage.c | |||
@@ -351,6 +351,12 @@ static const struct esdhc_platform_data mx51_babbage_sd2_data __initconst = { | |||
351 | .wp_type = ESDHC_WP_GPIO, | 351 | .wp_type = ESDHC_WP_GPIO, |
352 | }; | 352 | }; |
353 | 353 | ||
354 | void __init imx51_babbage_common_init(void) | ||
355 | { | ||
356 | mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads, | ||
357 | ARRAY_SIZE(mx51babbage_pads)); | ||
358 | } | ||
359 | |||
354 | /* | 360 | /* |
355 | * Board specific initialization. | 361 | * Board specific initialization. |
356 | */ | 362 | */ |
@@ -365,8 +371,7 @@ static void __init mx51_babbage_init(void) | |||
365 | #if defined(CONFIG_CPU_FREQ_IMX) | 371 | #if defined(CONFIG_CPU_FREQ_IMX) |
366 | get_cpu_op = mx51_get_cpu_op; | 372 | get_cpu_op = mx51_get_cpu_op; |
367 | #endif | 373 | #endif |
368 | mxc_iomux_v3_setup_multiple_pads(mx51babbage_pads, | 374 | imx51_babbage_common_init(); |
369 | ARRAY_SIZE(mx51babbage_pads)); | ||
370 | 375 | ||
371 | imx51_add_imx_uart(0, &uart_pdata); | 376 | imx51_add_imx_uart(0, &uart_pdata); |
372 | imx51_add_imx_uart(1, NULL); | 377 | imx51_add_imx_uart(1, NULL); |
diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c index d9b03d4dba6d..cc3547c88261 100644 --- a/arch/arm/mach-mx5/clock-mx51-mx53.c +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c | |||
@@ -1633,6 +1633,14 @@ static void __init clk_get_freq_dt(unsigned long *ckil, unsigned long *osc, | |||
1633 | } | 1633 | } |
1634 | } | 1634 | } |
1635 | 1635 | ||
1636 | int __init mx51_clocks_init_dt(void) | ||
1637 | { | ||
1638 | unsigned long ckil, osc, ckih1, ckih2; | ||
1639 | |||
1640 | clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2); | ||
1641 | return mx51_clocks_init(ckil, osc, ckih1, ckih2); | ||
1642 | } | ||
1643 | |||
1636 | int __init mx53_clocks_init_dt(void) | 1644 | int __init mx53_clocks_init_dt(void) |
1637 | { | 1645 | { |
1638 | unsigned long ckil, osc, ckih1, ckih2; | 1646 | unsigned long ckil, osc, ckih1, ckih2; |
diff --git a/arch/arm/mach-mx5/imx51-dt.c b/arch/arm/mach-mx5/imx51-dt.c new file mode 100644 index 000000000000..ccc61585659b --- /dev/null +++ b/arch/arm/mach-mx5/imx51-dt.c | |||
@@ -0,0 +1,116 @@ | |||
1 | /* | ||
2 | * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * Copyright 2011 Linaro Ltd. | ||
4 | * | ||
5 | * The code contained herein is licensed under the GNU General Public | ||
6 | * License. You may obtain a copy of the GNU General Public License | ||
7 | * Version 2 or later at the following locations: | ||
8 | * | ||
9 | * http://www.opensource.org/licenses/gpl-license.html | ||
10 | * http://www.gnu.org/copyleft/gpl.html | ||
11 | */ | ||
12 | |||
13 | #include <linux/irq.h> | ||
14 | #include <linux/irqdomain.h> | ||
15 | #include <linux/of_irq.h> | ||
16 | #include <linux/of_platform.h> | ||
17 | #include <asm/mach/arch.h> | ||
18 | #include <asm/mach/time.h> | ||
19 | #include <mach/common.h> | ||
20 | #include <mach/mx51.h> | ||
21 | |||
22 | /* | ||
23 | * Lookup table for attaching a specific name and platform_data pointer to | ||
24 | * devices as they get created by of_platform_populate(). Ideally this table | ||
25 | * would not exist, but the current clock implementation depends on some devices | ||
26 | * having a specific name. | ||
27 | */ | ||
28 | static const struct of_dev_auxdata imx51_auxdata_lookup[] __initconst = { | ||
29 | OF_DEV_AUXDATA("fsl,imx51-uart", MX51_UART1_BASE_ADDR, "imx21-uart.0", NULL), | ||
30 | OF_DEV_AUXDATA("fsl,imx51-uart", MX51_UART2_BASE_ADDR, "imx21-uart.1", NULL), | ||
31 | OF_DEV_AUXDATA("fsl,imx51-uart", MX51_UART3_BASE_ADDR, "imx21-uart.2", NULL), | ||
32 | OF_DEV_AUXDATA("fsl,imx51-fec", MX51_FEC_BASE_ADDR, "imx27-fec.0", NULL), | ||
33 | OF_DEV_AUXDATA("fsl,imx51-esdhc", MX51_ESDHC1_BASE_ADDR, "sdhci-esdhc-imx51.0", NULL), | ||
34 | OF_DEV_AUXDATA("fsl,imx51-esdhc", MX51_ESDHC2_BASE_ADDR, "sdhci-esdhc-imx51.1", NULL), | ||
35 | OF_DEV_AUXDATA("fsl,imx51-esdhc", MX51_ESDHC3_BASE_ADDR, "sdhci-esdhc-imx51.2", NULL), | ||
36 | OF_DEV_AUXDATA("fsl,imx51-esdhc", MX51_ESDHC4_BASE_ADDR, "sdhci-esdhc-imx51.3", NULL), | ||
37 | OF_DEV_AUXDATA("fsl,imx51-ecspi", MX51_ECSPI1_BASE_ADDR, "imx51-ecspi.0", NULL), | ||
38 | OF_DEV_AUXDATA("fsl,imx51-ecspi", MX51_ECSPI2_BASE_ADDR, "imx51-ecspi.1", NULL), | ||
39 | OF_DEV_AUXDATA("fsl,imx51-cspi", MX51_CSPI_BASE_ADDR, "imx35-cspi.0", NULL), | ||
40 | OF_DEV_AUXDATA("fsl,imx51-i2c", MX51_I2C1_BASE_ADDR, "imx-i2c.0", NULL), | ||
41 | OF_DEV_AUXDATA("fsl,imx51-i2c", MX51_I2C2_BASE_ADDR, "imx-i2c.1", NULL), | ||
42 | OF_DEV_AUXDATA("fsl,imx51-sdma", MX51_SDMA_BASE_ADDR, "imx35-sdma", NULL), | ||
43 | OF_DEV_AUXDATA("fsl,imx51-wdt", MX51_WDOG1_BASE_ADDR, "imx2-wdt.0", NULL), | ||
44 | { /* sentinel */ } | ||
45 | }; | ||
46 | |||
47 | static void __init imx51_tzic_add_irq_domain(struct device_node *np, | ||
48 | struct device_node *interrupt_parent) | ||
49 | { | ||
50 | irq_domain_add_simple(np, 0); | ||
51 | } | ||
52 | |||
53 | static void __init imx51_gpio_add_irq_domain(struct device_node *np, | ||
54 | struct device_node *interrupt_parent) | ||
55 | { | ||
56 | static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS - | ||
57 | 32 * 4; /* imx51 gets 4 gpio ports */ | ||
58 | |||
59 | irq_domain_add_simple(np, gpio_irq_base); | ||
60 | gpio_irq_base += 32; | ||
61 | } | ||
62 | |||
63 | static const struct of_device_id imx51_irq_match[] __initconst = { | ||
64 | { .compatible = "fsl,imx51-tzic", .data = imx51_tzic_add_irq_domain, }, | ||
65 | { .compatible = "fsl,imx51-gpio", .data = imx51_gpio_add_irq_domain, }, | ||
66 | { /* sentinel */ } | ||
67 | }; | ||
68 | |||
69 | static const struct of_device_id imx51_iomuxc_of_match[] __initconst = { | ||
70 | { .compatible = "fsl,imx51-iomuxc-babbage", .data = imx51_babbage_common_init, }, | ||
71 | { /* sentinel */ } | ||
72 | }; | ||
73 | |||
74 | static void __init imx51_dt_init(void) | ||
75 | { | ||
76 | struct device_node *node; | ||
77 | const struct of_device_id *of_id; | ||
78 | void (*func)(void); | ||
79 | |||
80 | of_irq_init(imx51_irq_match); | ||
81 | |||
82 | node = of_find_matching_node(NULL, imx51_iomuxc_of_match); | ||
83 | if (node) { | ||
84 | of_id = of_match_node(imx51_iomuxc_of_match, node); | ||
85 | func = of_id->data; | ||
86 | func(); | ||
87 | of_node_put(node); | ||
88 | } | ||
89 | |||
90 | of_platform_populate(NULL, of_default_bus_match_table, | ||
91 | imx51_auxdata_lookup, NULL); | ||
92 | } | ||
93 | |||
94 | static void __init imx51_timer_init(void) | ||
95 | { | ||
96 | mx51_clocks_init_dt(); | ||
97 | } | ||
98 | |||
99 | static struct sys_timer imx51_timer = { | ||
100 | .init = imx51_timer_init, | ||
101 | }; | ||
102 | |||
103 | static const char *imx51_dt_board_compat[] __initdata = { | ||
104 | "fsl,imx51-babbage", | ||
105 | NULL | ||
106 | }; | ||
107 | |||
108 | DT_MACHINE_START(IMX51_DT, "Freescale i.MX51 (Device Tree Support)") | ||
109 | .map_io = mx51_map_io, | ||
110 | .init_early = imx51_init_early, | ||
111 | .init_irq = mx51_init_irq, | ||
112 | .handle_irq = imx51_handle_irq, | ||
113 | .timer = &imx51_timer, | ||
114 | .init_machine = imx51_dt_init, | ||
115 | .dt_compat = imx51_dt_board_compat, | ||
116 | MACHINE_END | ||