blob: 4cc9edf39865c90741ea5fe43b92b90cde26a3cc [file] [log] [blame]
Jason Cooper3d468b62012-02-27 16:07:13 +00001/*
2 * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net>
3 *
4 * arch/arm/mach-kirkwood/board-dt.c
5 *
Jason Cooper6fa6b872012-03-15 00:52:31 +00006 * Flattened Device Tree board initialization
Jason Cooper3d468b62012-02-27 16:07:13 +00007 *
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>
Jason Cooper3d468b62012-02-27 16:07:13 +000015#include <linux/of.h>
Jason Cooper3d468b62012-02-27 16:07:13 +000016#include <linux/of_platform.h>
Andrew Lunn1611f872012-11-17 15:22:28 +010017#include <linux/clk-provider.h>
18#include <linux/clk/mvebu.h>
Ian Campbella7ac56d2012-04-29 14:40:42 +010019#include <linux/kexec.h>
Jason Cooper3d468b62012-02-27 16:07:13 +000020#include <asm/mach/arch.h>
Jason Cooper2b45e052012-02-29 17:39:08 +000021#include <asm/mach/map.h>
Jason Cooper2b45e052012-02-29 17:39:08 +000022#include <mach/bridge-regs.h>
Andrew Lunn1611f872012-11-17 15:22:28 +010023#include <linux/platform_data/usb-ehci-orion.h>
Andrew Lunn278b45b2012-06-27 13:40:04 +020024#include <plat/irq.h>
Andrew Lunn1611f872012-11-17 15:22:28 +010025#include <plat/common.h>
Jason Cooper3d468b62012-02-27 16:07:13 +000026#include "common.h"
Jason Cooper3d468b62012-02-27 16:07:13 +000027
Andrew Lunn1611f872012-11-17 15:22:28 +010028/*
29 * There are still devices that doesn't know about DT yet. Get clock
30 * gates here and add a clock lookup alias, so that old platform
31 * devices still work.
32*/
33
34static void __init kirkwood_legacy_clk_init(void)
35{
36
37 struct device_node *np = of_find_compatible_node(
38 NULL, NULL, "marvell,kirkwood-gating-clock");
Andrew Lunn1611f872012-11-17 15:22:28 +010039 struct of_phandle_args clkspec;
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010040 struct clk *clk;
Andrew Lunn1611f872012-11-17 15:22:28 +010041
42 clkspec.np = np;
43 clkspec.args_count = 1;
44
Andrew Lunn1611f872012-11-17 15:22:28 +010045 clkspec.args[0] = CGC_BIT_PEX0;
46 orion_clkdev_add("0", "pcie",
47 of_clk_get_from_provider(&clkspec));
48
Andrew Lunn1611f872012-11-17 15:22:28 +010049 clkspec.args[0] = CGC_BIT_PEX1;
50 orion_clkdev_add("1", "pcie",
51 of_clk_get_from_provider(&clkspec));
52
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010053 clkspec.args[0] = CGC_BIT_SDIO;
54 orion_clkdev_add(NULL, "mvsdio",
Andrew Lunn1611f872012-11-17 15:22:28 +010055 of_clk_get_from_provider(&clkspec));
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010056
57 /*
58 * The ethernet interfaces forget the MAC address assigned by
59 * u-boot if the clocks are turned off. Until proper DT support
60 * is available we always enable them for now.
61 */
62 clkspec.args[0] = CGC_BIT_GE0;
63 clk = of_clk_get_from_provider(&clkspec);
64 orion_clkdev_add(NULL, "mv643xx_eth_port.0", clk);
65 clk_prepare_enable(clk);
66
67 clkspec.args[0] = CGC_BIT_GE1;
68 clk = of_clk_get_from_provider(&clkspec);
69 orion_clkdev_add(NULL, "mv643xx_eth_port.1", clk);
70 clk_prepare_enable(clk);
Andrew Lunn1611f872012-11-17 15:22:28 +010071}
72
73static void __init kirkwood_of_clk_init(void)
74{
75 mvebu_clocks_init();
76 kirkwood_legacy_clk_init();
77}
Michael Walle76372122012-06-06 20:30:57 +020078
Jason Cooper3d468b62012-02-27 16:07:13 +000079static void __init kirkwood_dt_init(void)
80{
Jason Cooper2b45e052012-02-29 17:39:08 +000081 pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
82
83 /*
84 * Disable propagation of mbus errors to the CPU local bus,
85 * as this causes mbus errors (which can occur for example
86 * for PCI aborts) to throw CPU aborts, which we're not set
87 * up to deal with.
88 */
89 writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
90
Thomas Petazzoni5cc06732013-03-21 17:59:16 +010091 kirkwood_setup_wins();
Jason Cooper2b45e052012-02-29 17:39:08 +000092
Jason Cooper2b45e052012-02-29 17:39:08 +000093 kirkwood_l2_init();
Jason Cooper2b45e052012-02-29 17:39:08 +000094
Andrew Lunn0e2ee0c2013-01-27 11:07:23 +010095 kirkwood_cpufreq_init();
96
Andrew Lunn2f129bf2011-12-15 08:15:07 +010097 /* Setup root of clk tree */
Andrew Lunn1611f872012-11-17 15:22:28 +010098 kirkwood_of_clk_init();
Jason Cooper2b45e052012-02-29 17:39:08 +000099
Andrew Lunn9cfc94e2013-01-09 13:22:15 +0100100 kirkwood_cpuidle_init();
101
Jason Cooper2b45e052012-02-29 17:39:08 +0000102#ifdef CONFIG_KEXEC
103 kexec_reinit = kirkwood_enable_pcie;
104#endif
Jason Cooper3d468b62012-02-27 16:07:13 +0000105
106 if (of_machine_is_compatible("globalscale,dreamplug"))
107 dreamplug_init();
108
Willy Tarreau9b47a4f2012-12-09 19:40:04 +0100109 if (of_machine_is_compatible("globalscale,guruplug"))
110 guruplug_dt_init();
111
Jamie Lentin9007d102012-04-18 11:06:40 +0100112 if (of_machine_is_compatible("dlink,dns-kirkwood"))
113 dnskw_init();
114
Arnaud Patard (Rtp)c06cd9b2012-04-18 23:16:41 +0200115 if (of_machine_is_compatible("iom,iconnect"))
116 iconnect_init();
117
Simon Baatzf5520362012-04-30 23:55:17 +0200118 if (of_machine_is_compatible("raidsonic,ib-nas62x0"))
119 ib62x0_init();
120
Andrew Lunn9eb61f42012-05-12 14:57:59 +0200121 if (of_machine_is_compatible("qnap,ts219"))
122 qnap_dt_ts219_init();
123
Sebastian Hesselbarthdd88db72012-08-14 22:43:41 +0200124 if (of_machine_is_compatible("seagate,dockstar"))
125 dockstar_dt_init();
126
Josh Coombs5136b2a2012-07-16 11:52:50 +0200127 if (of_machine_is_compatible("seagate,goflexnet"))
128 goflexnet_init();
129
Michael Walle4aff38a2012-07-17 07:25:55 +0200130 if (of_machine_is_compatible("buffalo,lsxl"))
131 lsxl_init();
132
Alan M Butler4f48b7f2012-08-20 15:29:07 +0100133 if (of_machine_is_compatible("iom,ix2-200"))
134 iomega_ix2_200_init();
135
Valentin Longchamp0510c8a2012-09-04 11:55:02 +0200136 if (of_machine_is_compatible("keymile,km_kirkwood"))
137 km_kirkwood_init();
138
Simon Guinot98d4f2a2013-04-09 00:41:28 +0200139 if (of_machine_is_compatible("lacie,cloudbox") ||
140 of_machine_is_compatible("lacie,inetspace_v2") ||
Simon Guinot7f9871d2012-10-17 12:09:06 +0200141 of_machine_is_compatible("lacie,netspace_lite_v2") ||
Simon Guinot98d4f2a2013-04-09 00:41:28 +0200142 of_machine_is_compatible("lacie,netspace_max_v2") ||
143 of_machine_is_compatible("lacie,netspace_mini_v2") ||
144 of_machine_is_compatible("lacie,netspace_v2"))
Simon Guinotecee1e42012-10-17 12:09:04 +0200145 ns2_init();
146
Stefan Peter5492a112012-11-18 16:46:16 +0100147 if (of_machine_is_compatible("mpl,cec4"))
148 mplcec4_init();
149
Arnaud Ebalardf236f5a2013-03-19 23:28:06 +0100150 if (of_machine_is_compatible("netgear,readynas-duo-v2"))
151 netgear_readynas_init();
152
Nobuhiro Iwamatsuf17073a2012-11-13 16:43:09 +0900153 if (of_machine_is_compatible("plathome,openblocks-a6"))
154 openblocks_a6_init();
155
Jason Cooper767fc1e2012-10-22 02:15:35 +0000156 if (of_machine_is_compatible("usi,topkick"))
157 usi_topkick_init();
158
Thomas Petazzoni32077922013-05-15 16:04:59 +0200159 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
Jason Cooper3d468b62012-02-27 16:07:13 +0000160}
161
Andrew Lunn98adf9322012-10-20 13:23:16 +0200162static const char * const kirkwood_dt_board_compat[] = {
Jason Cooper3d468b62012-02-27 16:07:13 +0000163 "globalscale,dreamplug",
Willy Tarreau9b47a4f2012-12-09 19:40:04 +0100164 "globalscale,guruplug",
Jamie Lentin9007d102012-04-18 11:06:40 +0100165 "dlink,dns-320",
166 "dlink,dns-325",
Arnaud Patard (Rtp)c06cd9b2012-04-18 23:16:41 +0200167 "iom,iconnect",
Simon Baatzf5520362012-04-30 23:55:17 +0200168 "raidsonic,ib-nas62x0",
Andrew Lunn9eb61f42012-05-12 14:57:59 +0200169 "qnap,ts219",
Sebastian Hesselbarthdd88db72012-08-14 22:43:41 +0200170 "seagate,dockstar",
Josh Coombs5136b2a2012-07-16 11:52:50 +0200171 "seagate,goflexnet",
Michael Walle4aff38a2012-07-17 07:25:55 +0200172 "buffalo,lsxl",
Alan M Butler4f48b7f2012-08-20 15:29:07 +0100173 "iom,ix2-200",
Valentin Longchamp0510c8a2012-09-04 11:55:02 +0200174 "keymile,km_kirkwood",
Simon Guinot98d4f2a2013-04-09 00:41:28 +0200175 "lacie,cloudbox",
Simon Guinotecee1e42012-10-17 12:09:04 +0200176 "lacie,inetspace_v2",
Simon Guinotca7d9452012-10-17 12:09:05 +0200177 "lacie,netspace_lite_v2",
Simon Guinot98d4f2a2013-04-09 00:41:28 +0200178 "lacie,netspace_max_v2",
Simon Guinot7f9871d2012-10-17 12:09:06 +0200179 "lacie,netspace_mini_v2",
Simon Guinot98d4f2a2013-04-09 00:41:28 +0200180 "lacie,netspace_v2",
Stefan Peter5492a112012-11-18 16:46:16 +0100181 "mpl,cec4",
Arnaud Ebalardf236f5a2013-03-19 23:28:06 +0100182 "netgear,readynas-duo-v2",
Nobuhiro Iwamatsuf17073a2012-11-13 16:43:09 +0900183 "plathome,openblocks-a6",
Jason Cooper767fc1e2012-10-22 02:15:35 +0000184 "usi,topkick",
Tero Jaaskoafcad882012-10-26 18:56:16 +0300185 "zyxel,nsa310",
Jason Cooper3d468b62012-02-27 16:07:13 +0000186 NULL
187};
188
189DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
190 /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
191 .map_io = kirkwood_map_io,
192 .init_early = kirkwood_init_early,
Andrew Lunn278b45b2012-06-27 13:40:04 +0200193 .init_irq = orion_dt_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700194 .init_time = kirkwood_timer_init,
Jason Cooper3d468b62012-02-27 16:07:13 +0000195 .init_machine = kirkwood_dt_init,
196 .restart = kirkwood_restart,
197 .dt_compat = kirkwood_dt_board_compat,
198MACHINE_END