board-dt.c 5.0 KB
Newer Older
1 2 3 4 5
/*
 * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net>
 *
 * arch/arm/mach-kirkwood/board-dt.c
 *
6
 * Flattened Device Tree board initialization
7 8 9 10 11 12 13 14 15 16
 *
 * This file is licensed under the terms of the GNU General Public
 * License version 2.  This program is licensed "as is" without any
 * warranty of any kind, whether express or implied.
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/of.h>
#include <linux/of_platform.h>
17 18
#include <linux/clk-provider.h>
#include <linux/clk/mvebu.h>
19
#include <linux/kexec.h>
20
#include <asm/mach/arch.h>
21 22
#include <asm/mach/map.h>
#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 27
#include "common.h"

28 29 30 31 32 33 34 35 36 37 38 39
/*
 * There are still devices that doesn't know about DT yet.  Get clock
 * gates here and add a clock lookup alias, so that old platform
 * devices still work.
*/

static void __init kirkwood_legacy_clk_init(void)
{

	struct device_node *np = of_find_compatible_node(
		NULL, NULL, "marvell,kirkwood-gating-clock");
	struct of_phandle_args clkspec;
40
	struct clk *clk;
41 42 43 44 45 46 47 48 49 50 51 52

	clkspec.np = np;
	clkspec.args_count = 1;

	clkspec.args[0] = CGC_BIT_PEX0;
	orion_clkdev_add("0", "pcie",
			 of_clk_get_from_provider(&clkspec));

	clkspec.args[0] = CGC_BIT_PEX1;
	orion_clkdev_add("1", "pcie",
			 of_clk_get_from_provider(&clkspec));

53 54
	clkspec.args[0] = CGC_BIT_SDIO;
	orion_clkdev_add(NULL, "mvsdio",
55
			 of_clk_get_from_provider(&clkspec));
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70

	/*
	 * The ethernet interfaces forget the MAC address assigned by
	 * u-boot if the clocks are turned off. Until proper DT support
	 * is available we always enable them for now.
	 */
	clkspec.args[0] = CGC_BIT_GE0;
	clk = of_clk_get_from_provider(&clkspec);
	orion_clkdev_add(NULL, "mv643xx_eth_port.0", clk);
	clk_prepare_enable(clk);

	clkspec.args[0] = CGC_BIT_GE1;
	clk = of_clk_get_from_provider(&clkspec);
	orion_clkdev_add(NULL, "mv643xx_eth_port.1", clk);
	clk_prepare_enable(clk);
71 72 73 74 75 76 77
}

static void __init kirkwood_of_clk_init(void)
{
	mvebu_clocks_init();
	kirkwood_legacy_clk_init();
}
78

79 80
static void __init kirkwood_dt_init(void)
{
81 82 83 84 85 86 87 88 89 90
	pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);

	/*
	 * Disable propagation of mbus errors to the CPU local bus,
	 * as this causes mbus errors (which can occur for example
	 * for PCI aborts) to throw CPU aborts, which we're not set
	 * up to deal with.
	 */
	writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);

91
	kirkwood_setup_wins();
92 93 94

	kirkwood_l2_init();

95 96
	kirkwood_cpufreq_init();

97
	/* Setup root of clk tree */
98
	kirkwood_of_clk_init();
99

100 101
	kirkwood_cpuidle_init();

102 103 104
#ifdef CONFIG_KEXEC
	kexec_reinit = kirkwood_enable_pcie;
#endif
105 106 107 108

	if (of_machine_is_compatible("globalscale,dreamplug"))
		dreamplug_init();

109 110 111
	if (of_machine_is_compatible("globalscale,guruplug"))
		guruplug_dt_init();

112 113 114
	if (of_machine_is_compatible("dlink,dns-kirkwood"))
		dnskw_init();

115 116 117
	if (of_machine_is_compatible("iom,iconnect"))
		iconnect_init();

118 119 120
	if (of_machine_is_compatible("raidsonic,ib-nas62x0"))
		ib62x0_init();

121 122 123
	if (of_machine_is_compatible("qnap,ts219"))
		qnap_dt_ts219_init();

124 125 126
	if (of_machine_is_compatible("seagate,dockstar"))
		dockstar_dt_init();

127 128 129
	if (of_machine_is_compatible("seagate,goflexnet"))
		goflexnet_init();

130 131 132
	if (of_machine_is_compatible("buffalo,lsxl"))
		lsxl_init();

133 134 135
	if (of_machine_is_compatible("iom,ix2-200"))
		iomega_ix2_200_init();

136 137 138
	if (of_machine_is_compatible("keymile,km_kirkwood"))
		km_kirkwood_init();

139 140
	if (of_machine_is_compatible("lacie,cloudbox") ||
	    of_machine_is_compatible("lacie,inetspace_v2") ||
141
	    of_machine_is_compatible("lacie,netspace_lite_v2") ||
142 143 144
	    of_machine_is_compatible("lacie,netspace_max_v2") ||
	    of_machine_is_compatible("lacie,netspace_mini_v2") ||
	    of_machine_is_compatible("lacie,netspace_v2"))
145 146
		ns2_init();

147 148 149
	if (of_machine_is_compatible("mpl,cec4"))
		mplcec4_init();

150 151 152
	if (of_machine_is_compatible("netgear,readynas-duo-v2"))
		netgear_readynas_init();

153 154 155
	if (of_machine_is_compatible("plathome,openblocks-a6"))
		openblocks_a6_init();

156 157 158
	if (of_machine_is_compatible("usi,topkick"))
		usi_topkick_init();

159
	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
160 161
}

A
Andrew Lunn 已提交
162
static const char * const kirkwood_dt_board_compat[] = {
163
	"globalscale,dreamplug",
164
	"globalscale,guruplug",
165 166
	"dlink,dns-320",
	"dlink,dns-325",
167
	"iom,iconnect",
168
	"raidsonic,ib-nas62x0",
169
	"qnap,ts219",
170
	"seagate,dockstar",
171
	"seagate,goflexnet",
172
	"buffalo,lsxl",
173
	"iom,ix2-200",
174
	"keymile,km_kirkwood",
175
	"lacie,cloudbox",
176
	"lacie,inetspace_v2",
177
	"lacie,netspace_lite_v2",
178
	"lacie,netspace_max_v2",
179
	"lacie,netspace_mini_v2",
180
	"lacie,netspace_v2",
181
	"mpl,cec4",
182
	"netgear,readynas-duo-v2",
183
	"plathome,openblocks-a6",
184
	"usi,topkick",
185
	"zyxel,nsa310",
186 187 188 189 190 191 192
	NULL
};

DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
	/* Maintainer: Jason Cooper <jason@lakedaemon.net> */
	.map_io		= kirkwood_map_io,
	.init_early	= kirkwood_init_early,
193
	.init_irq	= orion_dt_init_irq,
S
Stephen Warren 已提交
194
	.init_time	= kirkwood_timer_init,
195 196 197 198
	.init_machine	= kirkwood_dt_init,
	.restart	= kirkwood_restart,
	.dt_compat	= kirkwood_dt_board_compat,
MACHINE_END