]> Pileus Git - ~andy/linux/blob - arch/arm/mach-kirkwood/board-dt.c
ARM: kirkwood: convert to DT irqchip and clocksource
[~andy/linux] / 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/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>
26 #include <plat/irq.h>
27 #include <plat/common.h>
28 #include "common.h"
29
30 /*
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
33  * devices still work.
34 */
35
36 static void __init kirkwood_legacy_clk_init(void)
37 {
38
39         struct device_node *np = of_find_compatible_node(
40                 NULL, NULL, "marvell,kirkwood-gating-clock");
41         struct of_phandle_args clkspec;
42         struct clk *clk;
43
44         clkspec.np = np;
45         clkspec.args_count = 1;
46
47         clkspec.args[0] = CGC_BIT_PEX0;
48         orion_clkdev_add("0", "pcie",
49                          of_clk_get_from_provider(&clkspec));
50
51         clkspec.args[0] = CGC_BIT_PEX1;
52         orion_clkdev_add("1", "pcie",
53                          of_clk_get_from_provider(&clkspec));
54
55         clkspec.args[0] = CGC_BIT_SDIO;
56         orion_clkdev_add(NULL, "mvsdio",
57                          of_clk_get_from_provider(&clkspec));
58
59         /*
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.
63          */
64         clkspec.args[0] = CGC_BIT_GE0;
65         clk = of_clk_get_from_provider(&clkspec);
66         clk_prepare_enable(clk);
67
68         clkspec.args[0] = CGC_BIT_GE1;
69         clk = of_clk_get_from_provider(&clkspec);
70         clk_prepare_enable(clk);
71 }
72
73 static void __init kirkwood_dt_time_init(void)
74 {
75         of_clk_init(NULL);
76         clocksource_of_init();
77 }
78
79 static void __init kirkwood_dt_init_early(void)
80 {
81         mvebu_mbus_init("marvell,kirkwood-mbus",
82                         BRIDGE_WINS_BASE, BRIDGE_WINS_SZ,
83                         DDR_WINDOW_CPU_BASE, DDR_WINDOW_CPU_SZ);
84 }
85
86 static void __init kirkwood_dt_init(void)
87 {
88         pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
89
90         /*
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
94          * up to deal with.
95          */
96         writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
97
98         kirkwood_setup_wins();
99
100         kirkwood_l2_init();
101
102         kirkwood_cpufreq_init();
103
104         /* Setup clocks for legacy devices */
105         kirkwood_legacy_clk_init();
106
107         kirkwood_cpuidle_init();
108
109 #ifdef CONFIG_KEXEC
110         kexec_reinit = kirkwood_enable_pcie;
111 #endif
112
113         if (of_machine_is_compatible("dlink,dns-kirkwood"))
114                 dnskw_init();
115
116         of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
117 }
118
119 static const char * const kirkwood_dt_board_compat[] = {
120         "marvell,kirkwood",
121         NULL
122 };
123
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,
132 MACHINE_END