]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/arm/mach-kirkwood/board-dt.c
Merge branch 'next/dt' into for-next
[karo-tx-linux.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/dma-mapping.h>
19 #include <linux/irqchip.h>
20 #include <linux/kexec.h>
21 #include <asm/mach/arch.h>
22 #include <asm/mach/map.h>
23 #include <mach/bridge-regs.h>
24 #include <linux/platform_data/usb-ehci-orion.h>
25 #include <plat/irq.h>
26 #include <plat/common.h>
27 #include "common.h"
28
29 /*
30  * There are still devices that doesn't know about DT yet.  Get clock
31  * gates here and add a clock lookup alias, so that old platform
32  * devices still work.
33 */
34
35 static void __init kirkwood_legacy_clk_init(void)
36 {
37
38         struct device_node *np = of_find_compatible_node(
39                 NULL, NULL, "marvell,kirkwood-gating-clock");
40         struct of_phandle_args clkspec;
41         struct clk *clk;
42
43         clkspec.np = np;
44         clkspec.args_count = 1;
45
46         clkspec.args[0] = CGC_BIT_PEX0;
47         orion_clkdev_add("0", "pcie",
48                          of_clk_get_from_provider(&clkspec));
49
50         clkspec.args[0] = CGC_BIT_PEX1;
51         orion_clkdev_add("1", "pcie",
52                          of_clk_get_from_provider(&clkspec));
53
54         /*
55          * The ethernet interfaces forget the MAC address assigned by
56          * u-boot if the clocks are turned off. Until proper DT support
57          * is available we always enable them for now.
58          */
59         clkspec.args[0] = CGC_BIT_GE0;
60         clk = of_clk_get_from_provider(&clkspec);
61         clk_prepare_enable(clk);
62
63         clkspec.args[0] = CGC_BIT_GE1;
64         clk = of_clk_get_from_provider(&clkspec);
65         clk_prepare_enable(clk);
66 }
67
68 static void __init kirkwood_dt_init_early(void)
69 {
70         mvebu_mbus_init("marvell,kirkwood-mbus",
71                         BRIDGE_WINS_BASE, BRIDGE_WINS_SZ,
72                         DDR_WINDOW_CPU_BASE, DDR_WINDOW_CPU_SZ);
73 }
74
75 static void __init kirkwood_dt_init(void)
76 {
77         pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
78
79         /*
80          * Disable propagation of mbus errors to the CPU local bus,
81          * as this causes mbus errors (which can occur for example
82          * for PCI aborts) to throw CPU aborts, which we're not set
83          * up to deal with.
84          */
85         writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
86
87         BUG_ON(mvebu_mbus_dt_init());
88
89         kirkwood_l2_init();
90
91         kirkwood_cpufreq_init();
92
93         /* Setup clocks for legacy devices */
94         kirkwood_legacy_clk_init();
95
96         kirkwood_cpuidle_init();
97
98 #ifdef CONFIG_KEXEC
99         kexec_reinit = kirkwood_enable_pcie;
100 #endif
101
102         if (of_machine_is_compatible("marvell,mv88f6281gtw-ge"))
103                 mv88f6281gtw_ge_init();
104
105         of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
106 }
107
108 static const char * const kirkwood_dt_board_compat[] = {
109         "marvell,kirkwood",
110         NULL
111 };
112
113 DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
114         /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
115         .map_io         = kirkwood_map_io,
116         .init_early     = kirkwood_dt_init_early,
117         .init_machine   = kirkwood_dt_init,
118         .restart        = kirkwood_restart,
119         .dt_compat      = kirkwood_dt_board_compat,
120 MACHINE_END