]> Pileus Git - ~andy/linux/blob - arch/arm/mach-mxs/mach-mxs.c
ARM: mxs: add initial device tree support for imx23-evk board
[~andy/linux] / arch / arm / mach-mxs / mach-mxs.c
1 /*
2  * Copyright 2012 Freescale Semiconductor, Inc.
3  * Copyright 2012 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/clk.h>
14 #include <linux/clkdev.h>
15 #include <linux/err.h>
16 #include <linux/init.h>
17 #include <linux/init.h>
18 #include <linux/irqdomain.h>
19 #include <linux/of_irq.h>
20 #include <linux/of_platform.h>
21 #include <asm/mach/arch.h>
22 #include <asm/mach/time.h>
23 #include <mach/common.h>
24
25 static int __init mxs_icoll_add_irq_domain(struct device_node *np,
26                                 struct device_node *interrupt_parent)
27 {
28         irq_domain_add_legacy(np, 128, 0, 0, &irq_domain_simple_ops, NULL);
29
30         return 0;
31 }
32
33 static const struct of_device_id mxs_irq_match[] __initconst = {
34         { .compatible = "fsl,mxs-icoll", .data = mxs_icoll_add_irq_domain, },
35         { /* sentinel */ }
36 };
37
38 static void __init mxs_dt_init_irq(void)
39 {
40         icoll_init_irq();
41         of_irq_init(mxs_irq_match);
42 }
43
44 static void __init imx23_timer_init(void)
45 {
46         mx23_clocks_init();
47 }
48
49 static struct sys_timer imx23_timer = {
50         .init = imx23_timer_init,
51 };
52
53 static void __init imx28_timer_init(void)
54 {
55         mx28_clocks_init();
56 }
57
58 static struct sys_timer imx28_timer = {
59         .init = imx28_timer_init,
60 };
61
62 static void __init imx28_evk_init(void)
63 {
64         struct clk *clk;
65
66         /* Enable fec phy clock */
67         clk = clk_get_sys("enet_out", NULL);
68         if (!IS_ERR(clk))
69                 clk_prepare_enable(clk);
70 }
71
72 static void __init mxs_machine_init(void)
73 {
74         if (of_machine_is_compatible("fsl,imx28-evk"))
75                 imx28_evk_init();
76
77         of_platform_populate(NULL, of_default_bus_match_table,
78                                 NULL, NULL);
79 }
80
81 static const char *imx23_dt_compat[] __initdata = {
82         "fsl,imx23-evk",
83         "fsl,imx23",
84         NULL,
85 };
86
87 static const char *imx28_dt_compat[] __initdata = {
88         "fsl,imx28-evk",
89         "fsl,imx28",
90         NULL,
91 };
92
93 DT_MACHINE_START(IMX23, "Freescale i.MX23 (Device Tree)")
94         .map_io         = mx23_map_io,
95         .init_irq       = mxs_dt_init_irq,
96         .timer          = &imx23_timer,
97         .init_machine   = mxs_machine_init,
98         .dt_compat      = imx23_dt_compat,
99         .restart        = mxs_restart,
100 MACHINE_END
101
102 DT_MACHINE_START(IMX28, "Freescale i.MX28 (Device Tree)")
103         .map_io         = mx28_map_io,
104         .init_irq       = mxs_dt_init_irq,
105         .timer          = &imx28_timer,
106         .init_machine   = mxs_machine_init,
107         .dt_compat      = imx28_dt_compat,
108         .restart        = mxs_restart,
109 MACHINE_END