diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-09-20 08:59:36 -0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-11-12 06:11:17 -0500 |
commit | ef4bac5532fcc678a77ee2b16836458f58407056 (patch) | |
tree | e4a5215f5ecf27abe244e36db32e91eb917463c0 /arch | |
parent | f6d3346f950f49b23c174931786d10d8aba51c8c (diff) |
ARM i.MX25: Add devicetree support
This adds a i.MX25 dt machine descriptor and changes the clock
support to optionally initialize from dt.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-imx/Kconfig | 7 | ||||
-rw-r--r-- | arch/arm/mach-imx/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-imx/clk-imx25.c | 56 | ||||
-rw-r--r-- | arch/arm/mach-imx/common.h | 1 | ||||
-rw-r--r-- | arch/arm/mach-imx/imx25-dt.c | 48 |
5 files changed, 109 insertions, 4 deletions
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig index f1bf610e2900..ff702c3f35b7 100644 --- a/arch/arm/mach-imx/Kconfig +++ b/arch/arm/mach-imx/Kconfig | |||
@@ -272,6 +272,13 @@ config MACH_EUKREA_MBIMXSD25_BASEBOARD | |||
272 | 272 | ||
273 | endchoice | 273 | endchoice |
274 | 274 | ||
275 | config MACH_IMX25_DT | ||
276 | bool "Support i.MX25 platforms from device tree" | ||
277 | select SOC_IMX25 | ||
278 | help | ||
279 | Include support for Freescale i.MX25 based platforms | ||
280 | using the device tree for discovery | ||
281 | |||
275 | comment "MX27 platforms:" | 282 | comment "MX27 platforms:" |
276 | 283 | ||
277 | config MACH_MX27ADS | 284 | config MACH_MX27ADS |
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index fe47b71469c9..0634b3152c24 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile | |||
@@ -50,6 +50,7 @@ obj-$(CONFIG_MACH_MX21ADS) += mach-mx21ads.o | |||
50 | obj-$(CONFIG_MACH_MX25_3DS) += mach-mx25_3ds.o | 50 | obj-$(CONFIG_MACH_MX25_3DS) += mach-mx25_3ds.o |
51 | obj-$(CONFIG_MACH_EUKREA_CPUIMX25SD) += mach-eukrea_cpuimx25.o | 51 | obj-$(CONFIG_MACH_EUKREA_CPUIMX25SD) += mach-eukrea_cpuimx25.o |
52 | obj-$(CONFIG_MACH_EUKREA_MBIMXSD25_BASEBOARD) += eukrea_mbimxsd25-baseboard.o | 52 | obj-$(CONFIG_MACH_EUKREA_MBIMXSD25_BASEBOARD) += eukrea_mbimxsd25-baseboard.o |
53 | obj-$(CONFIG_MACH_IMX25_DT) += imx25-dt.o | ||
53 | 54 | ||
54 | # i.MX27 based machines | 55 | # i.MX27 based machines |
55 | obj-$(CONFIG_MACH_MX27ADS) += mach-mx27ads.o | 56 | obj-$(CONFIG_MACH_MX27ADS) += mach-mx27ads.o |
diff --git a/arch/arm/mach-imx/clk-imx25.c b/arch/arm/mach-imx/clk-imx25.c index 78a754f7dc7c..b197aa73dc4b 100644 --- a/arch/arm/mach-imx/clk-imx25.c +++ b/arch/arm/mach-imx/clk-imx25.c | |||
@@ -23,6 +23,9 @@ | |||
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/clkdev.h> | 24 | #include <linux/clkdev.h> |
25 | #include <linux/err.h> | 25 | #include <linux/err.h> |
26 | #include <linux/of.h> | ||
27 | #include <linux/of_address.h> | ||
28 | #include <linux/of_irq.h> | ||
26 | 29 | ||
27 | #include "clk.h" | 30 | #include "clk.h" |
28 | #include "common.h" | 31 | #include "common.h" |
@@ -55,6 +58,8 @@ | |||
55 | 58 | ||
56 | #define ccm(x) (CRM_BASE + (x)) | 59 | #define ccm(x) (CRM_BASE + (x)) |
57 | 60 | ||
61 | static struct clk_onecell_data clk_data; | ||
62 | |||
58 | static const char *cpu_sel_clks[] = { "mpll", "mpll_cpu_3_4", }; | 63 | static const char *cpu_sel_clks[] = { "mpll", "mpll_cpu_3_4", }; |
59 | static const char *per_sel_clks[] = { "ahb", "upll", }; | 64 | static const char *per_sel_clks[] = { "ahb", "upll", }; |
60 | 65 | ||
@@ -82,12 +87,12 @@ enum mx25_clks { | |||
82 | 87 | ||
83 | static struct clk *clk[clk_max]; | 88 | static struct clk *clk[clk_max]; |
84 | 89 | ||
85 | int __init mx25_clocks_init(void) | 90 | static int __init __mx25_clocks_init(unsigned long osc_rate) |
86 | { | 91 | { |
87 | int i; | 92 | int i; |
88 | 93 | ||
89 | clk[dummy] = imx_clk_fixed("dummy", 0); | 94 | clk[dummy] = imx_clk_fixed("dummy", 0); |
90 | clk[osc] = imx_clk_fixed("osc", 24000000); | 95 | clk[osc] = imx_clk_fixed("osc", osc_rate); |
91 | clk[mpll] = imx_clk_pllv1("mpll", "osc", ccm(CCM_MPCTL)); | 96 | clk[mpll] = imx_clk_pllv1("mpll", "osc", ccm(CCM_MPCTL)); |
92 | clk[upll] = imx_clk_pllv1("upll", "osc", ccm(CCM_UPCTL)); | 97 | clk[upll] = imx_clk_pllv1("upll", "osc", ccm(CCM_UPCTL)); |
93 | clk[mpll_cpu_3_4] = imx_clk_fixed_factor("mpll_cpu_3_4", "mpll", 3, 4); | 98 | clk[mpll_cpu_3_4] = imx_clk_fixed_factor("mpll_cpu_3_4", "mpll", 3, 4); |
@@ -219,6 +224,16 @@ int __init mx25_clocks_init(void) | |||
219 | 224 | ||
220 | clk_prepare_enable(clk[emi_ahb]); | 225 | clk_prepare_enable(clk[emi_ahb]); |
221 | 226 | ||
227 | clk_register_clkdev(clk[ipg], "ipg", "imx-gpt.0"); | ||
228 | clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0"); | ||
229 | |||
230 | return 0; | ||
231 | } | ||
232 | |||
233 | int __init mx25_clocks_init(void) | ||
234 | { | ||
235 | __mx25_clocks_init(24000000); | ||
236 | |||
222 | /* i.mx25 has the i.mx21 type uart */ | 237 | /* i.mx25 has the i.mx21 type uart */ |
223 | clk_register_clkdev(clk[uart1_ipg], "ipg", "imx21-uart.0"); | 238 | clk_register_clkdev(clk[uart1_ipg], "ipg", "imx21-uart.0"); |
224 | clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.0"); | 239 | clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.0"); |
@@ -230,8 +245,6 @@ int __init mx25_clocks_init(void) | |||
230 | clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.3"); | 245 | clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.3"); |
231 | clk_register_clkdev(clk[uart5_ipg], "ipg", "imx21-uart.4"); | 246 | clk_register_clkdev(clk[uart5_ipg], "ipg", "imx21-uart.4"); |
232 | clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.4"); | 247 | clk_register_clkdev(clk[uart_ipg_per], "per", "imx21-uart.4"); |
233 | clk_register_clkdev(clk[ipg], "ipg", "imx-gpt.0"); | ||
234 | clk_register_clkdev(clk[gpt_ipg_per], "per", "imx-gpt.0"); | ||
235 | clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.0"); | 248 | clk_register_clkdev(clk[ipg], "ipg", "mxc-ehci.0"); |
236 | clk_register_clkdev(clk[usbotg_ahb], "ahb", "mxc-ehci.0"); | 249 | clk_register_clkdev(clk[usbotg_ahb], "ahb", "mxc-ehci.0"); |
237 | clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.0"); | 250 | clk_register_clkdev(clk[usb_div], "per", "mxc-ehci.0"); |
@@ -289,5 +302,40 @@ int __init mx25_clocks_init(void) | |||
289 | clk_register_clkdev(clk[iim_ipg], "iim", NULL); | 302 | clk_register_clkdev(clk[iim_ipg], "iim", NULL); |
290 | 303 | ||
291 | mxc_timer_init(MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), MX25_INT_GPT1); | 304 | mxc_timer_init(MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), MX25_INT_GPT1); |
305 | |||
306 | return 0; | ||
307 | } | ||
308 | |||
309 | int __init mx25_clocks_init_dt(void) | ||
310 | { | ||
311 | struct device_node *np; | ||
312 | void __iomem *base; | ||
313 | int irq; | ||
314 | unsigned long osc_rate = 24000000; | ||
315 | |||
316 | /* retrieve the freqency of fixed clocks from device tree */ | ||
317 | for_each_compatible_node(np, NULL, "fixed-clock") { | ||
318 | u32 rate; | ||
319 | if (of_property_read_u32(np, "clock-frequency", &rate)) | ||
320 | continue; | ||
321 | |||
322 | if (of_device_is_compatible(np, "fsl,imx-osc")) | ||
323 | osc_rate = rate; | ||
324 | } | ||
325 | |||
326 | np = of_find_compatible_node(NULL, NULL, "fsl,imx25-ccm"); | ||
327 | clk_data.clks = clk; | ||
328 | clk_data.clk_num = ARRAY_SIZE(clk); | ||
329 | of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); | ||
330 | |||
331 | __mx25_clocks_init(osc_rate); | ||
332 | |||
333 | np = of_find_compatible_node(NULL, NULL, "fsl,imx25-gpt"); | ||
334 | base = of_iomap(np, 0); | ||
335 | WARN_ON(!base); | ||
336 | irq = irq_of_parse_and_map(np, 0); | ||
337 | |||
338 | mxc_timer_init(base, irq); | ||
339 | |||
292 | return 0; | 340 | return 0; |
293 | } | 341 | } |
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h index ef8db6b34841..7191ab4434e5 100644 --- a/arch/arm/mach-imx/common.h +++ b/arch/arm/mach-imx/common.h | |||
@@ -66,6 +66,7 @@ extern int mx51_clocks_init(unsigned long ckil, unsigned long osc, | |||
66 | unsigned long ckih1, unsigned long ckih2); | 66 | unsigned long ckih1, unsigned long ckih2); |
67 | extern int mx53_clocks_init(unsigned long ckil, unsigned long osc, | 67 | extern int mx53_clocks_init(unsigned long ckil, unsigned long osc, |
68 | unsigned long ckih1, unsigned long ckih2); | 68 | unsigned long ckih1, unsigned long ckih2); |
69 | extern int mx25_clocks_init_dt(void); | ||
69 | extern int mx27_clocks_init_dt(void); | 70 | extern int mx27_clocks_init_dt(void); |
70 | extern int mx31_clocks_init_dt(void); | 71 | extern int mx31_clocks_init_dt(void); |
71 | extern int mx51_clocks_init_dt(void); | 72 | extern int mx51_clocks_init_dt(void); |
diff --git a/arch/arm/mach-imx/imx25-dt.c b/arch/arm/mach-imx/imx25-dt.c new file mode 100644 index 000000000000..e17dfbc42192 --- /dev/null +++ b/arch/arm/mach-imx/imx25-dt.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Copyright 2012 Sascha Hauer, Pengutronix | ||
3 | * | ||
4 | * The code contained herein is licensed under the GNU General Public | ||
5 | * License. You may obtain a copy of the GNU General Public License | ||
6 | * Version 2 or later at the following locations: | ||
7 | * | ||
8 | * http://www.opensource.org/licenses/gpl-license.html | ||
9 | * http://www.gnu.org/copyleft/gpl.html | ||
10 | */ | ||
11 | |||
12 | #include <linux/irq.h> | ||
13 | #include <linux/of_irq.h> | ||
14 | #include <linux/of_platform.h> | ||
15 | #include <asm/mach/arch.h> | ||
16 | #include <asm/mach/time.h> | ||
17 | #include "common.h" | ||
18 | #include "mx25.h" | ||
19 | |||
20 | static void __init imx25_dt_init(void) | ||
21 | { | ||
22 | of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); | ||
23 | } | ||
24 | |||
25 | static void __init imx25_timer_init(void) | ||
26 | { | ||
27 | mx25_clocks_init_dt(); | ||
28 | } | ||
29 | |||
30 | static struct sys_timer imx25_timer = { | ||
31 | .init = imx25_timer_init, | ||
32 | }; | ||
33 | |||
34 | static const char * const imx25_dt_board_compat[] __initconst = { | ||
35 | "fsl,imx25", | ||
36 | NULL | ||
37 | }; | ||
38 | |||
39 | DT_MACHINE_START(IMX25_DT, "Freescale i.MX25 (Device Tree Support)") | ||
40 | .map_io = mx25_map_io, | ||
41 | .init_early = imx25_init_early, | ||
42 | .init_irq = mx25_init_irq, | ||
43 | .handle_irq = imx25_handle_irq, | ||
44 | .timer = &imx25_timer, | ||
45 | .init_machine = imx25_dt_init, | ||
46 | .dt_compat = imx25_dt_board_compat, | ||
47 | .restart = mxc_restart, | ||
48 | MACHINE_END | ||