blob: 56d4a5eb853a4fcbce1e8ab2c5336376a465055a [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 clkspec.args[0] = CGC_BIT_SDIO;
56 orion_clkdev_add(NULL, "mvsdio",
Andrew Lunn1611f872012-11-17 15:22:28 +010057 of_clk_get_from_provider(&clkspec));
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010058
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);
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010066 clk_prepare_enable(clk);
67
68 clkspec.args[0] = CGC_BIT_GE1;
69 clk = of_clk_get_from_provider(&clkspec);
Sebastian Hesselbarth7bf5b402013-01-30 21:29:58 +010070 clk_prepare_enable(clk);
Andrew Lunn1611f872012-11-17 15:22:28 +010071}
72
Sebastian Hesselbarth2326f042013-07-02 15:15:07 +020073static void __init kirkwood_dt_time_init(void)
Andrew Lunn1611f872012-11-17 15:22:28 +010074{
Sebastian Hesselbarthed9f30a2013-05-11 03:08:08 +020075 of_clk_init(NULL);
Sebastian Hesselbarth2326f042013-07-02 15:15:07 +020076 clocksource_of_init();
77}
78
79static 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);
Andrew Lunn1611f872012-11-17 15:22:28 +010084}
Michael Walle76372122012-06-06 20:30:57 +020085
Jason Cooper3d468b62012-02-27 16:07:13 +000086static void __init kirkwood_dt_init(void)
87{
Jason Cooper2b45e052012-02-29 17:39:08 +000088 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
Thomas Petazzoni5cc06732013-03-21 17:59:16 +010098 kirkwood_setup_wins();
Jason Cooper2b45e052012-02-29 17:39:08 +000099
Jason Cooper2b45e052012-02-29 17:39:08 +0000100 kirkwood_l2_init();
Jason Cooper2b45e052012-02-29 17:39:08 +0000101
Andrew Lunn0e2ee0c2013-01-27 11:07:23 +0100102 kirkwood_cpufreq_init();
103
Sebastian Hesselbarth2326f042013-07-02 15:15:07 +0200104 /* Setup clocks for legacy devices */
105 kirkwood_legacy_clk_init();
Jason Cooper2b45e052012-02-29 17:39:08 +0000106
Andrew Lunn9cfc94e2013-01-09 13:22:15 +0100107 kirkwood_cpuidle_init();
108
Jason Cooper2b45e052012-02-29 17:39:08 +0000109#ifdef CONFIG_KEXEC
110 kexec_reinit = kirkwood_enable_pcie;
111#endif
Jason Cooper3d468b62012-02-27 16:07:13 +0000112
Jamie Lentin9007d102012-04-18 11:06:40 +0100113 if (of_machine_is_compatible("dlink,dns-kirkwood"))
114 dnskw_init();
115
Thomas Petazzoni32077922013-05-15 16:04:59 +0200116 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
Jason Cooper3d468b62012-02-27 16:07:13 +0000117}
118
Andrew Lunn98adf932012-10-20 13:23:16 +0200119static const char * const kirkwood_dt_board_compat[] = {
Sebastian Hesselbartha977e182013-07-03 18:57:51 +0200120 "marvell,kirkwood",
Jason Cooper3d468b62012-02-27 16:07:13 +0000121 NULL
122};
123
124DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
125 /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
126 .map_io = kirkwood_map_io,
Sebastian Hesselbarth2326f042013-07-02 15:15:07 +0200127 .init_early = kirkwood_dt_init_early,
128 .init_time = kirkwood_dt_time_init,
Jason Cooper3d468b62012-02-27 16:07:13 +0000129 .init_machine = kirkwood_dt_init,
130 .restart = kirkwood_restart,
131 .dt_compat = kirkwood_dt_board_compat,
132MACHINE_END