blob: b129c65c23a46f97d04ae49001e7d290dcffc8b3 [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>
Sebastian Hesselbarth2326f042013-07-02 15:15:07 +020018#include <linux/clocksource.h>
19#include <linux/dma-mapping.h>
20#include <linux/irqchip.h>
Ian Campbella7ac56d2012-04-29 14:40:42 +010021#include <linux/kexec.h>
Jason Cooper3d468b62012-02-27 16:07:13 +000022#include <asm/mach/arch.h>
Jason Cooper2b45e052012-02-29 17:39:08 +000023#include <asm/mach/map.h>
Jason Cooper2b45e052012-02-29 17:39:08 +000024#include <mach/bridge-regs.h>
Andrew Lunn1611f872012-11-17 15:22:28 +010025#include <linux/platform_data/usb-ehci-orion.h>
Andrew Lunn278b45b2012-06-27 13:40:04 +020026#include <plat/irq.h>
Andrew Lunn1611f872012-11-17 15:22:28 +010027#include <plat/common.h>
Jason Cooper3d468b62012-02-27 16:07:13 +000028#include "common.h"
Jason Cooper3d468b62012-02-27 16:07:13 +000029
Andrew Lunn1611f872012-11-17 15:22:28 +010030/*
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
36static 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");
Andrew Lunn1611f872012-11-17 15:22:28 +010041 struct of_phandle_args clkspec;
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010042 struct clk *clk;
Andrew Lunn1611f872012-11-17 15:22:28 +010043
44 clkspec.np = np;
45 clkspec.args_count = 1;
46
Andrew Lunn1611f872012-11-17 15:22:28 +010047 clkspec.args[0] = CGC_BIT_PEX0;
48 orion_clkdev_add("0", "pcie",
49 of_clk_get_from_provider(&clkspec));
50
Andrew Lunn1611f872012-11-17 15:22:28 +010051 clkspec.args[0] = CGC_BIT_PEX1;
52 orion_clkdev_add("1", "pcie",
53 of_clk_get_from_provider(&clkspec));
54
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010055 /*
56 * The ethernet interfaces forget the MAC address assigned by
57 * u-boot if the clocks are turned off. Until proper DT support
58 * is available we always enable them for now.
59 */
60 clkspec.args[0] = CGC_BIT_GE0;
61 clk = of_clk_get_from_provider(&clkspec);
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010062 clk_prepare_enable(clk);
63
64 clkspec.args[0] = CGC_BIT_GE1;
65 clk = of_clk_get_from_provider(&clkspec);
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010066 clk_prepare_enable(clk);
Andrew Lunn1611f872012-11-17 15:22:28 +010067}
68
Sebastian Hesselbarth2326f042013-07-02 15:15:07 +020069static void __init kirkwood_dt_time_init(void)
Andrew Lunn1611f872012-11-17 15:22:28 +010070{
Sebastian Hesselbarthed9f30a2013-05-11 03:08:08 +020071 of_clk_init(NULL);
Sebastian Hesselbarth2326f042013-07-02 15:15:07 +020072 clocksource_of_init();
73}
74
75static void __init kirkwood_dt_init_early(void)
76{
77 mvebu_mbus_init("marvell,kirkwood-mbus",
78 BRIDGE_WINS_BASE, BRIDGE_WINS_SZ,
79 DDR_WINDOW_CPU_BASE, DDR_WINDOW_CPU_SZ);
Andrew Lunn1611f872012-11-17 15:22:28 +010080}
Michael Walle76372122012-06-06 20:30:57 +020081
Jason Cooper3d468b62012-02-27 16:07:13 +000082static void __init kirkwood_dt_init(void)
83{
Jason Cooper2b45e052012-02-29 17:39:08 +000084 pr_info("Kirkwood: %s, TCLK=%d.\n", kirkwood_id(), kirkwood_tclk);
85
86 /*
87 * Disable propagation of mbus errors to the CPU local bus,
88 * as this causes mbus errors (which can occur for example
89 * for PCI aborts) to throw CPU aborts, which we're not set
90 * up to deal with.
91 */
92 writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
93
Thomas Petazzoni5cc06732013-03-21 17:59:16 +010094 kirkwood_setup_wins();
Jason Cooper2b45e052012-02-29 17:39:08 +000095
Jason Cooper2b45e052012-02-29 17:39:08 +000096 kirkwood_l2_init();
Jason Cooper2b45e052012-02-29 17:39:08 +000097
Andrew Lunn0e2ee0c2013-01-27 11:07:23 +010098 kirkwood_cpufreq_init();
99
Sebastian Hesselbarth2326f042013-07-02 15:15:07 +0200100 /* Setup clocks for legacy devices */
101 kirkwood_legacy_clk_init();
Jason Cooper2b45e052012-02-29 17:39:08 +0000102
Andrew Lunn9cfc94e2013-01-09 13:22:15 +0100103 kirkwood_cpuidle_init();
104
Jason Cooper2b45e052012-02-29 17:39:08 +0000105#ifdef CONFIG_KEXEC
106 kexec_reinit = kirkwood_enable_pcie;
107#endif
Jason Cooper3d468b62012-02-27 16:07:13 +0000108
Jamie Lentin9007d102012-04-18 11:06:40 +0100109 if (of_machine_is_compatible("dlink,dns-kirkwood"))
110 dnskw_init();
111
Thomas Petazzoni37ae08c2013-08-01 17:07:32 +0200112 if (of_machine_is_compatible("marvell,mv88f6281gtw-ge"))
113 mv88f6281gtw_ge_init();
114
Thomas Petazzoni32077922013-05-15 16:04:59 +0200115 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
Jason Cooper3d468b62012-02-27 16:07:13 +0000116}
117
Andrew Lunn98adf932012-10-20 13:23:16 +0200118static const char * const kirkwood_dt_board_compat[] = {
Sebastian Hesselbartha977e182013-07-03 18:57:51 +0200119 "marvell,kirkwood",
Jason Cooper3d468b62012-02-27 16:07:13 +0000120 NULL
121};
122
123DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
124 /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
125 .map_io = kirkwood_map_io,
Sebastian Hesselbarth2326f042013-07-02 15:15:07 +0200126 .init_early = kirkwood_dt_init_early,
127 .init_time = kirkwood_dt_time_init,
Jason Cooper3d468b62012-02-27 16:07:13 +0000128 .init_machine = kirkwood_dt_init,
129 .restart = kirkwood_restart,
130 .dt_compat = kirkwood_dt_board_compat,
131MACHINE_END