Merge remote-tracking branch 'korg_arm-soc/timer/cleanup' into cleanup
[linux-3.10.git] / arch / arm / mach-kirkwood / board-dt.c
1 /*
2  * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net>
3  *
4  * arch/arm/mach-kirkwood/board-dt.c
5  *
6  * Flattened Device Tree board initialization
7  *
8  * This file is licensed under the terms of the GNU General Public
9  * License version 2.  This program is licensed "as is" without any
10  * warranty of any kind, whether express or implied.
11  */
12
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/of.h>
16 #include <linux/of_platform.h>
17 #include <linux/clk-provider.h>
18 #include <linux/clk/mvebu.h>
19 #include <linux/kexec.h>
20 #include <asm/mach/arch.h>
21 #include <asm/mach/map.h>
22 #include <mach/bridge-regs.h>
23 #include <linux/platform_data/usb-ehci-orion.h>
24 #include <plat/irq.h>
25 #include <plat/common.h>
26 #include "common.h"
27
28 static struct of_device_id kirkwood_dt_match_table[] __initdata = {
29         { .compatible = "simple-bus", },
30         { }
31 };
32
33 /*
34  * There are still devices that doesn't know about DT yet.  Get clock
35  * gates here and add a clock lookup alias, so that old platform
36  * devices still work.
37 */
38
39 static void __init kirkwood_legacy_clk_init(void)
40 {
41
42         struct device_node *np = of_find_compatible_node(
43                 NULL, NULL, "marvell,kirkwood-gating-clock");
44
45         struct of_phandle_args clkspec;
46
47         clkspec.np = np;
48         clkspec.args_count = 1;
49
50         clkspec.args[0] = CGC_BIT_GE0;
51         orion_clkdev_add(NULL, "mv643xx_eth_port.0",
52                          of_clk_get_from_provider(&clkspec));
53
54         clkspec.args[0] = CGC_BIT_PEX0;
55         orion_clkdev_add("0", "pcie",
56                          of_clk_get_from_provider(&clkspec));
57
58         clkspec.args[0] = CGC_BIT_USB0;
59         orion_clkdev_add(NULL, "orion-ehci.0",
60                          of_clk_get_from_provider(&clkspec));
61
62         clkspec.args[0] = CGC_BIT_PEX1;
63         orion_clkdev_add("1", "pcie",
64                          of_clk_get_from_provider(&clkspec));
65
66         clkspec.args[0] = CGC_BIT_GE1;
67         orion_clkdev_add(NULL, "mv643xx_eth_port.1",
68                          of_clk_get_from_provider(&clkspec));
69
70         clkspec.args[0] = CGC_BIT_SDIO;
71         orion_clkdev_add(NULL, "mvsdio",
72                          of_clk_get_from_provider(&clkspec));
73
74 }
75
76 static void __init kirkwood_of_clk_init(void)
77 {
78         mvebu_clocks_init();
79         kirkwood_legacy_clk_init();
80 }
81
82 static void __init kirkwood_dt_init(void)
83 {
84         pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
85
86         /*
87          * Disable propagation of mbus errors to the CPU local bus,
88          * as this causes mbus errors (which can occur for example
89          * for PCI aborts) to throw CPU aborts, which we're not set
90          * up to deal with.
91          */
92         writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
93
94         kirkwood_setup_cpu_mbus();
95
96         kirkwood_l2_init();
97
98         /* Setup root of clk tree */
99         kirkwood_of_clk_init();
100
101 #ifdef CONFIG_KEXEC
102         kexec_reinit = kirkwood_enable_pcie;
103 #endif
104
105         if (of_machine_is_compatible("globalscale,dreamplug"))
106                 dreamplug_init();
107
108         if (of_machine_is_compatible("dlink,dns-kirkwood"))
109                 dnskw_init();
110
111         if (of_machine_is_compatible("iom,iconnect"))
112                 iconnect_init();
113
114         if (of_machine_is_compatible("raidsonic,ib-nas62x0"))
115                 ib62x0_init();
116
117         if (of_machine_is_compatible("qnap,ts219"))
118                 qnap_dt_ts219_init();
119
120         if (of_machine_is_compatible("seagate,dockstar"))
121                 dockstar_dt_init();
122
123         if (of_machine_is_compatible("seagate,goflexnet"))
124                 goflexnet_init();
125
126         if (of_machine_is_compatible("buffalo,lsxl"))
127                 lsxl_init();
128
129         if (of_machine_is_compatible("iom,ix2-200"))
130                 iomega_ix2_200_init();
131
132         if (of_machine_is_compatible("keymile,km_kirkwood"))
133                 km_kirkwood_init();
134
135         if (of_machine_is_compatible("lacie,inetspace_v2") ||
136             of_machine_is_compatible("lacie,netspace_v2") ||
137             of_machine_is_compatible("lacie,netspace_max_v2") ||
138             of_machine_is_compatible("lacie,netspace_lite_v2") ||
139             of_machine_is_compatible("lacie,netspace_mini_v2"))
140                 ns2_init();
141
142         if (of_machine_is_compatible("mpl,cec4"))
143                 mplcec4_init();
144
145         if (of_machine_is_compatible("plathome,openblocks-a6"))
146                 openblocks_a6_init();
147
148         if (of_machine_is_compatible("usi,topkick"))
149                 usi_topkick_init();
150
151         if (of_machine_is_compatible("zyxel,nsa310"))
152                 nsa310_init();
153
154         of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL);
155 }
156
157 static const char * const kirkwood_dt_board_compat[] = {
158         "globalscale,dreamplug",
159         "dlink,dns-320",
160         "dlink,dns-325",
161         "iom,iconnect",
162         "raidsonic,ib-nas62x0",
163         "qnap,ts219",
164         "seagate,dockstar",
165         "seagate,goflexnet",
166         "buffalo,lsxl",
167         "iom,ix2-200",
168         "keymile,km_kirkwood",
169         "lacie,inetspace_v2",
170         "lacie,netspace_max_v2",
171         "lacie,netspace_v2",
172         "lacie,netspace_lite_v2",
173         "lacie,netspace_mini_v2",
174         "mpl,cec4",
175         "plathome,openblocks-a6",
176         "usi,topkick",
177         "zyxel,nsa310",
178         NULL
179 };
180
181 DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
182         /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
183         .map_io         = kirkwood_map_io,
184         .init_early     = kirkwood_init_early,
185         .init_irq       = orion_dt_init_irq,
186         .init_time      = kirkwood_timer_init,
187         .init_machine   = kirkwood_dt_init,
188         .restart        = kirkwood_restart,
189         .dt_compat      = kirkwood_dt_board_compat,
190 MACHINE_END