2 * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net>
4 * arch/arm/mach-kirkwood/board-dt.c
6 * Flattened Device Tree board initialization
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.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
16 #include <linux/of_platform.h>
17 #include <linux/clk-provider.h>
18 #include <linux/clocksource.h>
19 #include <linux/dma-mapping.h>
20 #include <linux/irqchip.h>
21 #include <linux/kexec.h>
22 #include <asm/mach/arch.h>
23 #include <asm/mach/map.h>
24 #include <mach/bridge-regs.h>
25 #include <linux/platform_data/usb-ehci-orion.h>
27 #include <plat/common.h>
31 * There are still devices that doesn't know about DT yet. Get clock
32 * gates here and add a clock lookup alias, so that old platform
36 static void __init kirkwood_legacy_clk_init(void)
39 struct device_node *np = of_find_compatible_node(
40 NULL, NULL, "marvell,kirkwood-gating-clock");
41 struct of_phandle_args clkspec;
45 clkspec.args_count = 1;
47 clkspec.args[0] = CGC_BIT_PEX0;
48 orion_clkdev_add("0", "pcie",
49 of_clk_get_from_provider(&clkspec));
51 clkspec.args[0] = CGC_BIT_PEX1;
52 orion_clkdev_add("1", "pcie",
53 of_clk_get_from_provider(&clkspec));
55 clkspec.args[0] = CGC_BIT_SDIO;
56 orion_clkdev_add(NULL, "mvsdio",
57 of_clk_get_from_provider(&clkspec));
60 * The ethernet interfaces forget the MAC address assigned by
61 * u-boot if the clocks are turned off. Until proper DT support
62 * is available we always enable them for now.
64 clkspec.args[0] = CGC_BIT_GE0;
65 clk = of_clk_get_from_provider(&clkspec);
66 clk_prepare_enable(clk);
68 clkspec.args[0] = CGC_BIT_GE1;
69 clk = of_clk_get_from_provider(&clkspec);
70 clk_prepare_enable(clk);
73 static void __init kirkwood_dt_time_init(void)
76 clocksource_of_init();
79 static void __init kirkwood_dt_init_early(void)
81 mvebu_mbus_init("marvell,kirkwood-mbus",
82 BRIDGE_WINS_BASE, BRIDGE_WINS_SZ,
83 DDR_WINDOW_CPU_BASE, DDR_WINDOW_CPU_SZ);
86 static void __init kirkwood_dt_init(void)
88 pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
91 * Disable propagation of mbus errors to the CPU local bus,
92 * as this causes mbus errors (which can occur for example
93 * for PCI aborts) to throw CPU aborts, which we're not set
96 writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
98 kirkwood_setup_wins();
102 kirkwood_cpufreq_init();
104 /* Setup clocks for legacy devices */
105 kirkwood_legacy_clk_init();
107 kirkwood_cpuidle_init();
110 kexec_reinit = kirkwood_enable_pcie;
113 if (of_machine_is_compatible("dlink,dns-kirkwood"))
116 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
119 static const char * const kirkwood_dt_board_compat[] = {
124 DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
125 /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
126 .map_io = kirkwood_map_io,
127 .init_early = kirkwood_dt_init_early,
128 .init_time = kirkwood_dt_time_init,
129 .init_machine = kirkwood_dt_init,
130 .restart = kirkwood_restart,
131 .dt_compat = kirkwood_dt_board_compat,