diff options
Diffstat (limited to 'arch/arm/mach-mx5')
-rw-r--r-- | arch/arm/mach-mx5/Kconfig | 21 | ||||
-rw-r--r-- | arch/arm/mach-mx5/Makefile | 3 | ||||
-rw-r--r-- | arch/arm/mach-mx5/board-mx51_babbage.c | 9 | ||||
-rw-r--r-- | arch/arm/mach-mx5/board-mx53_ard.c | 12 | ||||
-rw-r--r-- | arch/arm/mach-mx5/board-mx53_evk.c | 9 | ||||
-rw-r--r-- | arch/arm/mach-mx5/board-mx53_loco.c | 9 | ||||
-rw-r--r-- | arch/arm/mach-mx5/board-mx53_smd.c | 9 | ||||
-rw-r--r-- | arch/arm/mach-mx5/clock-mx51-mx53.c | 39 | ||||
-rw-r--r-- | arch/arm/mach-mx5/imx51-dt.c | 116 | ||||
-rw-r--r-- | arch/arm/mach-mx5/imx53-dt.c | 126 |
10 files changed, 341 insertions, 12 deletions
diff --git a/arch/arm/mach-mx5/Kconfig b/arch/arm/mach-mx5/Kconfig index b4e7c58bbb38..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 |
@@ -172,6 +181,18 @@ endif # ARCH_MX51 | |||
172 | if ARCH_MX53_SUPPORTED | 181 | if ARCH_MX53_SUPPORTED |
173 | comment "i.MX53 machines:" | 182 | comment "i.MX53 machines:" |
174 | 183 | ||
184 | config MACH_IMX53_DT | ||
185 | bool "Support i.MX53 platforms from device tree" | ||
186 | select SOC_IMX53 | ||
187 | select USE_OF | ||
188 | select MACH_MX53_ARD | ||
189 | select MACH_MX53_EVK | ||
190 | select MACH_MX53_LOCO | ||
191 | select MACH_MX53_SMD | ||
192 | help | ||
193 | Include support for Freescale i.MX53 based platforms | ||
194 | using the device tree for discovery | ||
195 | |||
175 | config MACH_MX53_EVK | 196 | config MACH_MX53_EVK |
176 | bool "Support MX53 EVK platforms" | 197 | bool "Support MX53 EVK platforms" |
177 | select SOC_IMX53 | 198 | select SOC_IMX53 |
diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile index 383e7cd3fbcb..a3c75f368f4b 100644 --- a/arch/arm/mach-mx5/Makefile +++ b/arch/arm/mach-mx5/Makefile | |||
@@ -22,3 +22,6 @@ obj-$(CONFIG_MX51_EFIKA_COMMON) += mx51_efika.o | |||
22 | obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o | 22 | 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 | |||
26 | obj-$(CONFIG_MACH_IMX51_DT) += imx51-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/board-mx53_ard.c b/arch/arm/mach-mx5/board-mx53_ard.c index 76a67c4a2a0b..9b4395d7a07c 100644 --- a/arch/arm/mach-mx5/board-mx53_ard.c +++ b/arch/arm/mach-mx5/board-mx53_ard.c | |||
@@ -171,9 +171,6 @@ static struct imxi2c_platform_data mx53_ard_i2c3_data = { | |||
171 | 171 | ||
172 | static void __init mx53_ard_io_init(void) | 172 | static void __init mx53_ard_io_init(void) |
173 | { | 173 | { |
174 | mxc_iomux_v3_setup_multiple_pads(mx53_ard_pads, | ||
175 | ARRAY_SIZE(mx53_ard_pads)); | ||
176 | |||
177 | gpio_request(ARD_ETHERNET_INT_B, "eth-int-b"); | 174 | gpio_request(ARD_ETHERNET_INT_B, "eth-int-b"); |
178 | gpio_direction_input(ARD_ETHERNET_INT_B); | 175 | gpio_direction_input(ARD_ETHERNET_INT_B); |
179 | 176 | ||
@@ -216,6 +213,13 @@ static int weim_cs_config(void) | |||
216 | return 0; | 213 | return 0; |
217 | } | 214 | } |
218 | 215 | ||
216 | void __init imx53_ard_common_init(void) | ||
217 | { | ||
218 | mxc_iomux_v3_setup_multiple_pads(mx53_ard_pads, | ||
219 | ARRAY_SIZE(mx53_ard_pads)); | ||
220 | weim_cs_config(); | ||
221 | } | ||
222 | |||
219 | static struct platform_device *devices[] __initdata = { | 223 | static struct platform_device *devices[] __initdata = { |
220 | &ard_smsc_lan9220_device, | 224 | &ard_smsc_lan9220_device, |
221 | }; | 225 | }; |
@@ -225,8 +229,8 @@ static void __init mx53_ard_board_init(void) | |||
225 | imx53_soc_init(); | 229 | imx53_soc_init(); |
226 | imx53_add_imx_uart(0, NULL); | 230 | imx53_add_imx_uart(0, NULL); |
227 | 231 | ||
232 | imx53_ard_common_init(); | ||
228 | mx53_ard_io_init(); | 233 | mx53_ard_io_init(); |
229 | weim_cs_config(); | ||
230 | platform_add_devices(devices, ARRAY_SIZE(devices)); | 234 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
231 | 235 | ||
232 | imx53_add_sdhci_esdhc_imx(0, &mx53_ard_sd1_data); | 236 | imx53_add_sdhci_esdhc_imx(0, &mx53_ard_sd1_data); |
diff --git a/arch/arm/mach-mx5/board-mx53_evk.c b/arch/arm/mach-mx5/board-mx53_evk.c index 1b417b06b736..7663905d5c6d 100644 --- a/arch/arm/mach-mx5/board-mx53_evk.c +++ b/arch/arm/mach-mx5/board-mx53_evk.c | |||
@@ -131,12 +131,17 @@ static const struct spi_imx_master mx53_evk_spi_data __initconst = { | |||
131 | .num_chipselect = ARRAY_SIZE(mx53_evk_spi_cs), | 131 | .num_chipselect = ARRAY_SIZE(mx53_evk_spi_cs), |
132 | }; | 132 | }; |
133 | 133 | ||
134 | void __init imx53_evk_common_init(void) | ||
135 | { | ||
136 | mxc_iomux_v3_setup_multiple_pads(mx53_evk_pads, | ||
137 | ARRAY_SIZE(mx53_evk_pads)); | ||
138 | } | ||
139 | |||
134 | static void __init mx53_evk_board_init(void) | 140 | static void __init mx53_evk_board_init(void) |
135 | { | 141 | { |
136 | imx53_soc_init(); | 142 | imx53_soc_init(); |
143 | imx53_evk_common_init(); | ||
137 | 144 | ||
138 | mxc_iomux_v3_setup_multiple_pads(mx53_evk_pads, | ||
139 | ARRAY_SIZE(mx53_evk_pads)); | ||
140 | mx53_evk_init_uart(); | 145 | mx53_evk_init_uart(); |
141 | mx53_evk_fec_reset(); | 146 | mx53_evk_fec_reset(); |
142 | imx53_add_fec(&mx53_evk_fec_pdata); | 147 | imx53_add_fec(&mx53_evk_fec_pdata); |
diff --git a/arch/arm/mach-mx5/board-mx53_loco.c b/arch/arm/mach-mx5/board-mx53_loco.c index 4e1d51d252dc..3922cd5ea854 100644 --- a/arch/arm/mach-mx5/board-mx53_loco.c +++ b/arch/arm/mach-mx5/board-mx53_loco.c | |||
@@ -257,12 +257,17 @@ static const struct gpio_led_platform_data mx53loco_leds_data __initconst = { | |||
257 | .num_leds = ARRAY_SIZE(mx53loco_leds), | 257 | .num_leds = ARRAY_SIZE(mx53loco_leds), |
258 | }; | 258 | }; |
259 | 259 | ||
260 | void __init imx53_qsb_common_init(void) | ||
261 | { | ||
262 | mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads, | ||
263 | ARRAY_SIZE(mx53_loco_pads)); | ||
264 | } | ||
265 | |||
260 | static void __init mx53_loco_board_init(void) | 266 | static void __init mx53_loco_board_init(void) |
261 | { | 267 | { |
262 | imx53_soc_init(); | 268 | imx53_soc_init(); |
269 | imx53_qsb_common_init(); | ||
263 | 270 | ||
264 | mxc_iomux_v3_setup_multiple_pads(mx53_loco_pads, | ||
265 | ARRAY_SIZE(mx53_loco_pads)); | ||
266 | imx53_add_imx_uart(0, NULL); | 271 | imx53_add_imx_uart(0, NULL); |
267 | mx53_loco_fec_reset(); | 272 | mx53_loco_fec_reset(); |
268 | imx53_add_fec(&mx53_loco_fec_data); | 273 | imx53_add_fec(&mx53_loco_fec_data); |
diff --git a/arch/arm/mach-mx5/board-mx53_smd.c b/arch/arm/mach-mx5/board-mx53_smd.c index bc02894eafef..b10c89982fbc 100644 --- a/arch/arm/mach-mx5/board-mx53_smd.c +++ b/arch/arm/mach-mx5/board-mx53_smd.c | |||
@@ -111,12 +111,17 @@ static const struct imxi2c_platform_data mx53_smd_i2c_data __initconst = { | |||
111 | .bitrate = 100000, | 111 | .bitrate = 100000, |
112 | }; | 112 | }; |
113 | 113 | ||
114 | void __init imx53_smd_common_init(void) | ||
115 | { | ||
116 | mxc_iomux_v3_setup_multiple_pads(mx53_smd_pads, | ||
117 | ARRAY_SIZE(mx53_smd_pads)); | ||
118 | } | ||
119 | |||
114 | static void __init mx53_smd_board_init(void) | 120 | static void __init mx53_smd_board_init(void) |
115 | { | 121 | { |
116 | imx53_soc_init(); | 122 | imx53_soc_init(); |
123 | imx53_smd_common_init(); | ||
117 | 124 | ||
118 | mxc_iomux_v3_setup_multiple_pads(mx53_smd_pads, | ||
119 | ARRAY_SIZE(mx53_smd_pads)); | ||
120 | mx53_smd_init_uart(); | 125 | mx53_smd_init_uart(); |
121 | mx53_smd_fec_reset(); | 126 | mx53_smd_fec_reset(); |
122 | imx53_add_fec(&mx53_smd_fec_data); | 127 | imx53_add_fec(&mx53_smd_fec_data); |
diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c index f7bf996f463b..cc3547c88261 100644 --- a/arch/arm/mach-mx5/clock-mx51-mx53.c +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/clk.h> | 15 | #include <linux/clk.h> |
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/clkdev.h> | 17 | #include <linux/clkdev.h> |
18 | #include <linux/of.h> | ||
18 | 19 | ||
19 | #include <asm/div64.h> | 20 | #include <asm/div64.h> |
20 | 21 | ||
@@ -1609,3 +1610,41 @@ int __init mx53_clocks_init(unsigned long ckil, unsigned long osc, | |||
1609 | MX53_INT_GPT); | 1610 | MX53_INT_GPT); |
1610 | return 0; | 1611 | return 0; |
1611 | } | 1612 | } |
1613 | |||
1614 | static void __init clk_get_freq_dt(unsigned long *ckil, unsigned long *osc, | ||
1615 | unsigned long *ckih1, unsigned long *ckih2) | ||
1616 | { | ||
1617 | struct device_node *np; | ||
1618 | |||
1619 | /* retrieve the freqency of fixed clocks from device tree */ | ||
1620 | for_each_compatible_node(np, NULL, "fixed-clock") { | ||
1621 | u32 rate; | ||
1622 | if (of_property_read_u32(np, "clock-frequency", &rate)) | ||
1623 | continue; | ||
1624 | |||
1625 | if (of_device_is_compatible(np, "fsl,imx-ckil")) | ||
1626 | *ckil = rate; | ||
1627 | else if (of_device_is_compatible(np, "fsl,imx-osc")) | ||
1628 | *osc = rate; | ||
1629 | else if (of_device_is_compatible(np, "fsl,imx-ckih1")) | ||
1630 | *ckih1 = rate; | ||
1631 | else if (of_device_is_compatible(np, "fsl,imx-ckih2")) | ||
1632 | *ckih2 = rate; | ||
1633 | } | ||
1634 | } | ||
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 | |||
1644 | int __init mx53_clocks_init_dt(void) | ||
1645 | { | ||
1646 | unsigned long ckil, osc, ckih1, ckih2; | ||
1647 | |||
1648 | clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2); | ||
1649 | return mx53_clocks_init(ckil, osc, ckih1, ckih2); | ||
1650 | } | ||
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 | ||
diff --git a/arch/arm/mach-mx5/imx53-dt.c b/arch/arm/mach-mx5/imx53-dt.c new file mode 100644 index 000000000000..ccaa0b81b768 --- /dev/null +++ b/arch/arm/mach-mx5/imx53-dt.c | |||
@@ -0,0 +1,126 @@ | |||
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/io.h> | ||
14 | #include <linux/irq.h> | ||
15 | #include <linux/irqdomain.h> | ||
16 | #include <linux/of_irq.h> | ||
17 | #include <linux/of_platform.h> | ||
18 | #include <asm/mach/arch.h> | ||
19 | #include <asm/mach/time.h> | ||
20 | #include <mach/common.h> | ||
21 | #include <mach/mx53.h> | ||
22 | |||
23 | /* | ||
24 | * Lookup table for attaching a specific name and platform_data pointer to | ||
25 | * devices as they get created by of_platform_populate(). Ideally this table | ||
26 | * would not exist, but the current clock implementation depends on some devices | ||
27 | * having a specific name. | ||
28 | */ | ||
29 | static const struct of_dev_auxdata imx53_auxdata_lookup[] __initconst = { | ||
30 | OF_DEV_AUXDATA("fsl,imx53-uart", MX53_UART1_BASE_ADDR, "imx21-uart.0", NULL), | ||
31 | OF_DEV_AUXDATA("fsl,imx53-uart", MX53_UART2_BASE_ADDR, "imx21-uart.1", NULL), | ||
32 | OF_DEV_AUXDATA("fsl,imx53-uart", MX53_UART3_BASE_ADDR, "imx21-uart.2", NULL), | ||
33 | OF_DEV_AUXDATA("fsl,imx53-uart", MX53_UART4_BASE_ADDR, "imx21-uart.3", NULL), | ||
34 | OF_DEV_AUXDATA("fsl,imx53-uart", MX53_UART5_BASE_ADDR, "imx21-uart.4", NULL), | ||
35 | OF_DEV_AUXDATA("fsl,imx53-fec", MX53_FEC_BASE_ADDR, "imx25-fec.0", NULL), | ||
36 | OF_DEV_AUXDATA("fsl,imx53-esdhc", MX53_ESDHC1_BASE_ADDR, "sdhci-esdhc-imx53.0", NULL), | ||
37 | OF_DEV_AUXDATA("fsl,imx53-esdhc", MX53_ESDHC2_BASE_ADDR, "sdhci-esdhc-imx53.1", NULL), | ||
38 | OF_DEV_AUXDATA("fsl,imx53-esdhc", MX53_ESDHC3_BASE_ADDR, "sdhci-esdhc-imx53.2", NULL), | ||
39 | OF_DEV_AUXDATA("fsl,imx53-esdhc", MX53_ESDHC4_BASE_ADDR, "sdhci-esdhc-imx53.3", NULL), | ||
40 | OF_DEV_AUXDATA("fsl,imx53-ecspi", MX53_ECSPI1_BASE_ADDR, "imx51-ecspi.0", NULL), | ||
41 | OF_DEV_AUXDATA("fsl,imx53-ecspi", MX53_ECSPI2_BASE_ADDR, "imx51-ecspi.1", NULL), | ||
42 | OF_DEV_AUXDATA("fsl,imx53-cspi", MX53_CSPI_BASE_ADDR, "imx35-cspi.0", NULL), | ||
43 | OF_DEV_AUXDATA("fsl,imx53-i2c", MX53_I2C1_BASE_ADDR, "imx-i2c.0", NULL), | ||
44 | OF_DEV_AUXDATA("fsl,imx53-i2c", MX53_I2C2_BASE_ADDR, "imx-i2c.1", NULL), | ||
45 | OF_DEV_AUXDATA("fsl,imx53-i2c", MX53_I2C3_BASE_ADDR, "imx-i2c.2", NULL), | ||
46 | OF_DEV_AUXDATA("fsl,imx53-sdma", MX53_SDMA_BASE_ADDR, "imx35-sdma", NULL), | ||
47 | OF_DEV_AUXDATA("fsl,imx53-wdt", MX53_WDOG1_BASE_ADDR, "imx2-wdt.0", NULL), | ||
48 | { /* sentinel */ } | ||
49 | }; | ||
50 | |||
51 | static void __init imx53_tzic_add_irq_domain(struct device_node *np, | ||
52 | struct device_node *interrupt_parent) | ||
53 | { | ||
54 | irq_domain_add_simple(np, 0); | ||
55 | } | ||
56 | |||
57 | static void __init imx53_gpio_add_irq_domain(struct device_node *np, | ||
58 | struct device_node *interrupt_parent) | ||
59 | { | ||
60 | static int gpio_irq_base = MXC_GPIO_IRQ_START + ARCH_NR_GPIOS - | ||
61 | 32 * 7; /* imx53 gets 7 gpio ports */ | ||
62 | |||
63 | irq_domain_add_simple(np, gpio_irq_base); | ||
64 | gpio_irq_base += 32; | ||
65 | } | ||
66 | |||
67 | static const struct of_device_id imx53_irq_match[] __initconst = { | ||
68 | { .compatible = "fsl,imx53-tzic", .data = imx53_tzic_add_irq_domain, }, | ||
69 | { .compatible = "fsl,imx53-gpio", .data = imx53_gpio_add_irq_domain, }, | ||
70 | { /* sentinel */ } | ||
71 | }; | ||
72 | |||
73 | static const struct of_device_id imx53_iomuxc_of_match[] __initconst = { | ||
74 | { .compatible = "fsl,imx53-iomuxc-ard", .data = imx53_ard_common_init, }, | ||
75 | { .compatible = "fsl,imx53-iomuxc-evk", .data = imx53_evk_common_init, }, | ||
76 | { .compatible = "fsl,imx53-iomuxc-qsb", .data = imx53_qsb_common_init, }, | ||
77 | { .compatible = "fsl,imx53-iomuxc-smd", .data = imx53_smd_common_init, }, | ||
78 | { /* sentinel */ } | ||
79 | }; | ||
80 | |||
81 | static void __init imx53_dt_init(void) | ||
82 | { | ||
83 | struct device_node *node; | ||
84 | const struct of_device_id *of_id; | ||
85 | void (*func)(void); | ||
86 | |||
87 | of_irq_init(imx53_irq_match); | ||
88 | |||
89 | node = of_find_matching_node(NULL, imx53_iomuxc_of_match); | ||
90 | if (node) { | ||
91 | of_id = of_match_node(imx53_iomuxc_of_match, node); | ||
92 | func = of_id->data; | ||
93 | func(); | ||
94 | of_node_put(node); | ||
95 | } | ||
96 | |||
97 | of_platform_populate(NULL, of_default_bus_match_table, | ||
98 | imx53_auxdata_lookup, NULL); | ||
99 | } | ||
100 | |||
101 | static void __init imx53_timer_init(void) | ||
102 | { | ||
103 | mx53_clocks_init_dt(); | ||
104 | } | ||
105 | |||
106 | static struct sys_timer imx53_timer = { | ||
107 | .init = imx53_timer_init, | ||
108 | }; | ||
109 | |||
110 | static const char *imx53_dt_board_compat[] __initdata = { | ||
111 | "fsl,imx53-ard", | ||
112 | "fsl,imx53-evk", | ||
113 | "fsl,imx53-qsb", | ||
114 | "fsl,imx53-smd", | ||
115 | NULL | ||
116 | }; | ||
117 | |||
118 | DT_MACHINE_START(IMX53_DT, "Freescale i.MX53 (Device Tree Support)") | ||
119 | .map_io = mx53_map_io, | ||
120 | .init_early = imx53_init_early, | ||
121 | .init_irq = mx53_init_irq, | ||
122 | .handle_irq = imx53_handle_irq, | ||
123 | .timer = &imx53_timer, | ||
124 | .init_machine = imx53_dt_init, | ||
125 | .dt_compat = imx53_dt_board_compat, | ||
126 | MACHINE_END | ||