blob: 6e122ed3282f514d51f9c6cfc6d04f3be39cf3b9 [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>
Ian Campbella7ac56d2012-04-29 14:40:42 +010018#include <linux/kexec.h>
Jason Cooper3d468b62012-02-27 16:07:13 +000019#include <asm/mach/arch.h>
Jason Cooper2b45e052012-02-29 17:39:08 +000020#include <asm/mach/map.h>
Jason Cooper2b45e052012-02-29 17:39:08 +000021#include <mach/bridge-regs.h>
Andrew Lunn1611f872012-11-17 15:22:28 +010022#include <linux/platform_data/usb-ehci-orion.h>
Andrew Lunn278b45b2012-06-27 13:40:04 +020023#include <plat/irq.h>
Andrew Lunn1611f872012-11-17 15:22:28 +010024#include <plat/common.h>
Jason Cooper3d468b62012-02-27 16:07:13 +000025#include "common.h"
Jason Cooper3d468b62012-02-27 16:07:13 +000026
Andrew Lunn1611f872012-11-17 15:22:28 +010027/*
28 * There are still devices that doesn't know about DT yet. Get clock
29 * gates here and add a clock lookup alias, so that old platform
30 * devices still work.
31*/
32
33static void __init kirkwood_legacy_clk_init(void)
34{
35
36 struct device_node *np = of_find_compatible_node(
37 NULL, NULL, "marvell,kirkwood-gating-clock");
Andrew Lunn1611f872012-11-17 15:22:28 +010038 struct of_phandle_args clkspec;
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010039 struct clk *clk;
Andrew Lunn1611f872012-11-17 15:22:28 +010040
41 clkspec.np = np;
42 clkspec.args_count = 1;
43
Andrew Lunn1611f872012-11-17 15:22:28 +010044 clkspec.args[0] = CGC_BIT_PEX0;
45 orion_clkdev_add("0", "pcie",
46 of_clk_get_from_provider(&clkspec));
47
Andrew Lunn1611f872012-11-17 15:22:28 +010048 clkspec.args[0] = CGC_BIT_PEX1;
49 orion_clkdev_add("1", "pcie",
50 of_clk_get_from_provider(&clkspec));
51
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010052 clkspec.args[0] = CGC_BIT_SDIO;
53 orion_clkdev_add(NULL, "mvsdio",
Andrew Lunn1611f872012-11-17 15:22:28 +010054 of_clk_get_from_provider(&clkspec));
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010055
56 /*
57 * The ethernet interfaces forget the MAC address assigned by
58 * u-boot if the clocks are turned off. Until proper DT support
59 * is available we always enable them for now.
60 */
61 clkspec.args[0] = CGC_BIT_GE0;
62 clk = of_clk_get_from_provider(&clkspec);
63 orion_clkdev_add(NULL, "mv643xx_eth_port.0", clk);
64 clk_prepare_enable(clk);
65
66 clkspec.args[0] = CGC_BIT_GE1;
67 clk = of_clk_get_from_provider(&clkspec);
68 orion_clkdev_add(NULL, "mv643xx_eth_port.1", clk);
69 clk_prepare_enable(clk);
Andrew Lunn1611f872012-11-17 15:22:28 +010070}
71
72static void __init kirkwood_of_clk_init(void)
73{
Sebastian Hesselbarthed9f30a2013-05-11 03:08:08 +020074 of_clk_init(NULL);
Andrew Lunn1611f872012-11-17 15:22:28 +010075 kirkwood_legacy_clk_init();
76}
Michael Walle76372122012-06-06 20:30:57 +020077
Jason Cooper3d468b62012-02-27 16:07:13 +000078static void __init kirkwood_dt_init(void)
79{
Jason Cooper2b45e052012-02-29 17:39:08 +000080 pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
81
82 /*
83 * Disable propagation of mbus errors to the CPU local bus,
84 * as this causes mbus errors (which can occur for example
85 * for PCI aborts) to throw CPU aborts, which we're not set
86 * up to deal with.
87 */
88 writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
89
Thomas Petazzoni5cc06732013-03-21 17:59:16 +010090 kirkwood_setup_wins();
Jason Cooper2b45e052012-02-29 17:39:08 +000091
Jason Cooper2b45e052012-02-29 17:39:08 +000092 kirkwood_l2_init();
Jason Cooper2b45e052012-02-29 17:39:08 +000093
Andrew Lunn0e2ee0c2013-01-27 11:07:23 +010094 kirkwood_cpufreq_init();
95
Andrew Lunn2f129bf2011-12-15 08:15:07 +010096 /* Setup root of clk tree */
Andrew Lunn1611f872012-11-17 15:22:28 +010097 kirkwood_of_clk_init();
Jason Cooper2b45e052012-02-29 17:39:08 +000098
Andrew Lunn9cfc94e2013-01-09 13:22:15 +010099 kirkwood_cpuidle_init();
100
Jason Cooper2b45e052012-02-29 17:39:08 +0000101#ifdef CONFIG_KEXEC
102 kexec_reinit = kirkwood_enable_pcie;
103#endif
Jason Cooper3d468b62012-02-27 16:07:13 +0000104
105 if (of_machine_is_compatible("globalscale,dreamplug"))
106 dreamplug_init();
107
Willy Tarreau9b47a4f2012-12-09 19:40:04 +0100108 if (of_machine_is_compatible("globalscale,guruplug"))
109 guruplug_dt_init();
110
Simon Baatz193da782013-05-13 23:19:01 +0200111 if (of_machine_is_compatible("globalscale,sheevaplug"))
112 sheevaplug_dt_init();
113
Jamie Lentin9007d102012-04-18 11:06:40 +0100114 if (of_machine_is_compatible("dlink,dns-kirkwood"))
115 dnskw_init();
116
Arnaud Patard (Rtp)c06cd9b2012-04-18 23:16:41 +0200117 if (of_machine_is_compatible("iom,iconnect"))
118 iconnect_init();
119
Simon Baatzf5520362012-04-30 23:55:17 +0200120 if (of_machine_is_compatible("raidsonic,ib-nas62x0"))
121 ib62x0_init();
122
Andrew Lunn9eb61f42012-05-12 14:57:59 +0200123 if (of_machine_is_compatible("qnap,ts219"))
124 qnap_dt_ts219_init();
125
Sebastian Hesselbarthdd88db72012-08-14 22:43:41 +0200126 if (of_machine_is_compatible("seagate,dockstar"))
127 dockstar_dt_init();
128
Josh Coombs5136b2a2012-07-16 11:52:50 +0200129 if (of_machine_is_compatible("seagate,goflexnet"))
130 goflexnet_init();
131
Michael Walle4aff38a2012-07-17 07:25:55 +0200132 if (of_machine_is_compatible("buffalo,lsxl"))
133 lsxl_init();
134
Alan M Butler4f48b7f2012-08-20 15:29:07 +0100135 if (of_machine_is_compatible("iom,ix2-200"))
136 iomega_ix2_200_init();
137
Valentin Longchamp0510c8a2012-09-04 11:55:02 +0200138 if (of_machine_is_compatible("keymile,km_kirkwood"))
139 km_kirkwood_init();
140
Simon Guinot98d4f2a2013-04-09 00:41:28 +0200141 if (of_machine_is_compatible("lacie,cloudbox") ||
142 of_machine_is_compatible("lacie,inetspace_v2") ||
Simon Guinot7f9871d2012-10-17 12:09:06 +0200143 of_machine_is_compatible("lacie,netspace_lite_v2") ||
Simon Guinot98d4f2a2013-04-09 00:41:28 +0200144 of_machine_is_compatible("lacie,netspace_max_v2") ||
145 of_machine_is_compatible("lacie,netspace_mini_v2") ||
146 of_machine_is_compatible("lacie,netspace_v2"))
Simon Guinotecee1e42012-10-17 12:09:04 +0200147 ns2_init();
148
Thomas Petazzoni0d0632f2013-05-15 15:37:01 +0200149 if (of_machine_is_compatible("marvell,db-88f6281-bp") ||
150 of_machine_is_compatible("marvell,db-88f6282-bp"))
151 db88f628x_init();
152
Stefan Peter5492a112012-11-18 16:46:16 +0100153 if (of_machine_is_compatible("mpl,cec4"))
154 mplcec4_init();
155
Arnaud Ebalardf236f5a2013-03-19 23:28:06 +0100156 if (of_machine_is_compatible("netgear,readynas-duo-v2"))
157 netgear_readynas_init();
158
Nobuhiro Iwamatsuf17073a2012-11-13 16:43:09 +0900159 if (of_machine_is_compatible("plathome,openblocks-a6"))
160 openblocks_a6_init();
161
Jason Cooper767fc1e2012-10-22 02:15:35 +0000162 if (of_machine_is_compatible("usi,topkick"))
163 usi_topkick_init();
164
Thomas Petazzoni32077922013-05-15 16:04:59 +0200165 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
Jason Cooper3d468b62012-02-27 16:07:13 +0000166}
167
Andrew Lunn98adf9322012-10-20 13:23:16 +0200168static const char * const kirkwood_dt_board_compat[] = {
Jason Cooper3d468b62012-02-27 16:07:13 +0000169 "globalscale,dreamplug",
Willy Tarreau9b47a4f2012-12-09 19:40:04 +0100170 "globalscale,guruplug",
Simon Baatz193da782013-05-13 23:19:01 +0200171 "globalscale,sheevaplug",
Jamie Lentin9007d102012-04-18 11:06:40 +0100172 "dlink,dns-320",
173 "dlink,dns-325",
Arnaud Patard (Rtp)c06cd9b2012-04-18 23:16:41 +0200174 "iom,iconnect",
Simon Baatzf5520362012-04-30 23:55:17 +0200175 "raidsonic,ib-nas62x0",
Andrew Lunn9eb61f42012-05-12 14:57:59 +0200176 "qnap,ts219",
Sebastian Hesselbarthdd88db72012-08-14 22:43:41 +0200177 "seagate,dockstar",
Josh Coombs5136b2a2012-07-16 11:52:50 +0200178 "seagate,goflexnet",
Michael Walle4aff38a2012-07-17 07:25:55 +0200179 "buffalo,lsxl",
Alan M Butler4f48b7f2012-08-20 15:29:07 +0100180 "iom,ix2-200",
Valentin Longchamp0510c8a2012-09-04 11:55:02 +0200181 "keymile,km_kirkwood",
Simon Guinot98d4f2a2013-04-09 00:41:28 +0200182 "lacie,cloudbox",
Simon Guinotecee1e42012-10-17 12:09:04 +0200183 "lacie,inetspace_v2",
Simon Guinotca7d9452012-10-17 12:09:05 +0200184 "lacie,netspace_lite_v2",
Simon Guinot98d4f2a2013-04-09 00:41:28 +0200185 "lacie,netspace_max_v2",
Simon Guinot7f9871d2012-10-17 12:09:06 +0200186 "lacie,netspace_mini_v2",
Simon Guinot98d4f2a2013-04-09 00:41:28 +0200187 "lacie,netspace_v2",
Thomas Petazzoni0d0632f2013-05-15 15:37:01 +0200188 "marvell,db-88f6281-bp",
189 "marvell,db-88f6282-bp",
Stefan Peter5492a112012-11-18 16:46:16 +0100190 "mpl,cec4",
Arnaud Ebalardf236f5a2013-03-19 23:28:06 +0100191 "netgear,readynas-duo-v2",
Nobuhiro Iwamatsuf17073a2012-11-13 16:43:09 +0900192 "plathome,openblocks-a6",
Jason Cooper767fc1e2012-10-22 02:15:35 +0000193 "usi,topkick",
Tero Jaaskoafcad882012-10-26 18:56:16 +0300194 "zyxel,nsa310",
Jason Cooper3d468b62012-02-27 16:07:13 +0000195 NULL
196};
197
198DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
199 /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
200 .map_io = kirkwood_map_io,
201 .init_early = kirkwood_init_early,
Andrew Lunn278b45b2012-06-27 13:40:04 +0200202 .init_irq = orion_dt_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700203 .init_time = kirkwood_timer_init,
Jason Cooper3d468b62012-02-27 16:07:13 +0000204 .init_machine = kirkwood_dt_init,
205 .restart = kirkwood_restart,
206 .dt_compat = kirkwood_dt_board_compat,
207MACHINE_END