ARM: kirkwood: Drop printing the SoC type and revision
[deliverable/linux.git] / arch / arm / mach-kirkwood / board-dt.c
CommitLineData
3d468b6d
JC
1/*
2 * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net>
3 *
4 * arch/arm/mach-kirkwood/board-dt.c
5 *
6fa6b878 6 * Flattened Device Tree board initialization
3d468b6d
JC
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
e3e8e588 13#include <linux/clk.h>
3d468b6d
JC
14#include <linux/kernel.h>
15#include <linux/init.h>
3d468b6d 16#include <linux/of.h>
ebd7d3ab
SH
17#include <linux/of_address.h>
18#include <linux/of_net.h>
3d468b6d 19#include <linux/of_platform.h>
2326f043
SH
20#include <linux/dma-mapping.h>
21#include <linux/irqchip.h>
a7ac56de 22#include <linux/kexec.h>
3d468b6d 23#include <asm/mach/arch.h>
2b45e05f 24#include <mach/bridge-regs.h>
1611f872 25#include <plat/common.h>
3d468b6d 26#include "common.h"
c3b6144a 27#include "pm.h"
3d468b6d 28
ebd7d3ab
SH
29#define MV643XX_ETH_MAC_ADDR_LOW 0x0414
30#define MV643XX_ETH_MAC_ADDR_HIGH 0x0418
31
32static void __init kirkwood_dt_eth_fixup(void)
33{
34 struct device_node *np;
35
36 /*
37 * The ethernet interfaces forget the MAC address assigned by u-boot
38 * if the clocks are turned off. Usually, u-boot on kirkwood boards
39 * has no DT support to properly set local-mac-address property.
40 * As a workaround, we get the MAC address from mv643xx_eth registers
41 * and update the port device node if no valid MAC address is set.
42 */
43 for_each_compatible_node(np, NULL, "marvell,kirkwood-eth-port") {
44 struct device_node *pnp = of_get_parent(np);
45 struct clk *clk;
46 struct property *pmac;
47 void __iomem *io;
48 u8 *macaddr;
49 u32 reg;
50
51 if (!pnp)
52 continue;
53
54 /* skip disabled nodes or nodes with valid MAC address*/
55 if (!of_device_is_available(pnp) || of_get_mac_address(np))
56 goto eth_fixup_skip;
57
58 clk = of_clk_get(pnp, 0);
59 if (IS_ERR(clk))
60 goto eth_fixup_skip;
61
62 io = of_iomap(pnp, 0);
63 if (!io)
64 goto eth_fixup_no_map;
65
66 /* ensure port clock is not gated to not hang CPU */
67 clk_prepare_enable(clk);
68
69 /* store MAC address register contents in local-mac-address */
70 pr_err(FW_INFO "%s: local-mac-address is not set\n",
71 np->full_name);
72
73 pmac = kzalloc(sizeof(*pmac) + 6, GFP_KERNEL);
74 if (!pmac)
75 goto eth_fixup_no_mem;
76
77 pmac->value = pmac + 1;
78 pmac->length = 6;
79 pmac->name = kstrdup("local-mac-address", GFP_KERNEL);
80 if (!pmac->name) {
81 kfree(pmac);
82 goto eth_fixup_no_mem;
83 }
84
85 macaddr = pmac->value;
86 reg = readl(io + MV643XX_ETH_MAC_ADDR_HIGH);
87 macaddr[0] = (reg >> 24) & 0xff;
88 macaddr[1] = (reg >> 16) & 0xff;
89 macaddr[2] = (reg >> 8) & 0xff;
90 macaddr[3] = reg & 0xff;
91
92 reg = readl(io + MV643XX_ETH_MAC_ADDR_LOW);
93 macaddr[4] = (reg >> 8) & 0xff;
94 macaddr[5] = reg & 0xff;
95
96 of_update_property(np, pmac);
97
98eth_fixup_no_mem:
99 iounmap(io);
100 clk_disable_unprepare(clk);
101eth_fixup_no_map:
102 clk_put(clk);
103eth_fixup_skip:
104 of_node_put(pnp);
105 }
106}
107
3d468b6d
JC
108static void __init kirkwood_dt_init(void)
109{
2b45e05f
JC
110 /*
111 * Disable propagation of mbus errors to the CPU local bus,
112 * as this causes mbus errors (which can occur for example
113 * for PCI aborts) to throw CPU aborts, which we're not set
114 * up to deal with.
115 */
116 writel(readl(CPU_CONFIG) & ~CPU_CONFIG_ERROR_PROP, CPU_CONFIG);
117
0789d0b2 118 BUG_ON(mvebu_mbus_dt_init());
2b45e05f 119
2b45e05f 120 kirkwood_l2_init();
2b45e05f 121
0e2ee0c0 122 kirkwood_cpufreq_init();
ebd7d3ab 123 kirkwood_cpuidle_init();
2b45e05f 124
e1cb367d 125 kirkwood_pm_init();
ebd7d3ab 126 kirkwood_dt_eth_fixup();
9cfc94eb 127
2b45e05f
JC
128#ifdef CONFIG_KEXEC
129 kexec_reinit = kirkwood_enable_pcie;
130#endif
3d468b6d 131
3207792e 132 of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
3d468b6d
JC
133}
134
98adf932 135static const char * const kirkwood_dt_board_compat[] = {
a977e18e 136 "marvell,kirkwood",
3d468b6d
JC
137 NULL
138};
139
140DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
141 /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
142 .map_io = kirkwood_map_io,
3d468b6d
JC
143 .init_machine = kirkwood_dt_init,
144 .restart = kirkwood_restart,
145 .dt_compat = kirkwood_dt_board_compat,
146MACHINE_END
This page took 0.102564 seconds and 5 git commands to generate.