iommu/omap: Check for failure of a call to omap_iommu_dump_ctx
[linux/fpc-iii.git] / arch / arm / mach-mvebu / kirkwood.c
blobceaad6d5927e57e67a4622f74ebbd0e7269bc901
1 /*
2 * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net>
4 * arch/arm/mach-mvebu/kirkwood.c
6 * Flattened Device Tree board initialization
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.
13 #include <linux/clk.h>
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/mbus.h>
17 #include <linux/of.h>
18 #include <linux/of_address.h>
19 #include <linux/of_net.h>
20 #include <linux/of_platform.h>
21 #include <linux/slab.h>
22 #include <asm/hardware/cache-feroceon-l2.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/map.h>
25 #include "kirkwood.h"
26 #include "kirkwood-pm.h"
27 #include "common.h"
29 static struct resource kirkwood_cpufreq_resources[] = {
30 [0] = {
31 .start = CPU_CONTROL_PHYS,
32 .end = CPU_CONTROL_PHYS + 3,
33 .flags = IORESOURCE_MEM,
37 static struct platform_device kirkwood_cpufreq_device = {
38 .name = "kirkwood-cpufreq",
39 .id = -1,
40 .num_resources = ARRAY_SIZE(kirkwood_cpufreq_resources),
41 .resource = kirkwood_cpufreq_resources,
44 static void __init kirkwood_cpufreq_init(void)
46 platform_device_register(&kirkwood_cpufreq_device);
49 static struct resource kirkwood_cpuidle_resource[] = {
51 .flags = IORESOURCE_MEM,
52 .start = DDR_OPERATION_BASE,
53 .end = DDR_OPERATION_BASE + 3,
57 static struct platform_device kirkwood_cpuidle = {
58 .name = "kirkwood_cpuidle",
59 .id = -1,
60 .resource = kirkwood_cpuidle_resource,
61 .num_resources = 1,
64 static void __init kirkwood_cpuidle_init(void)
66 platform_device_register(&kirkwood_cpuidle);
69 #define MV643XX_ETH_MAC_ADDR_LOW 0x0414
70 #define MV643XX_ETH_MAC_ADDR_HIGH 0x0418
72 static void __init kirkwood_dt_eth_fixup(void)
74 struct device_node *np;
77 * The ethernet interfaces forget the MAC address assigned by u-boot
78 * if the clocks are turned off. Usually, u-boot on kirkwood boards
79 * has no DT support to properly set local-mac-address property.
80 * As a workaround, we get the MAC address from mv643xx_eth registers
81 * and update the port device node if no valid MAC address is set.
83 for_each_compatible_node(np, NULL, "marvell,kirkwood-eth-port") {
84 struct device_node *pnp = of_get_parent(np);
85 struct clk *clk;
86 struct property *pmac;
87 void __iomem *io;
88 u8 *macaddr;
89 u32 reg;
91 if (!pnp)
92 continue;
94 /* skip disabled nodes or nodes with valid MAC address*/
95 if (!of_device_is_available(pnp) ||
96 !IS_ERR(of_get_mac_address(np)))
97 goto eth_fixup_skip;
99 clk = of_clk_get(pnp, 0);
100 if (IS_ERR(clk))
101 goto eth_fixup_skip;
103 io = of_iomap(pnp, 0);
104 if (!io)
105 goto eth_fixup_no_map;
107 /* ensure port clock is not gated to not hang CPU */
108 clk_prepare_enable(clk);
110 /* store MAC address register contents in local-mac-address */
111 pmac = kzalloc(sizeof(*pmac) + 6, GFP_KERNEL);
112 if (!pmac)
113 goto eth_fixup_no_mem;
115 pmac->value = pmac + 1;
116 pmac->length = 6;
117 pmac->name = kstrdup("local-mac-address", GFP_KERNEL);
118 if (!pmac->name) {
119 kfree(pmac);
120 goto eth_fixup_no_mem;
123 macaddr = pmac->value;
124 reg = readl(io + MV643XX_ETH_MAC_ADDR_HIGH);
125 macaddr[0] = (reg >> 24) & 0xff;
126 macaddr[1] = (reg >> 16) & 0xff;
127 macaddr[2] = (reg >> 8) & 0xff;
128 macaddr[3] = reg & 0xff;
130 reg = readl(io + MV643XX_ETH_MAC_ADDR_LOW);
131 macaddr[4] = (reg >> 8) & 0xff;
132 macaddr[5] = reg & 0xff;
134 of_update_property(np, pmac);
136 eth_fixup_no_mem:
137 iounmap(io);
138 clk_disable_unprepare(clk);
139 eth_fixup_no_map:
140 clk_put(clk);
141 eth_fixup_skip:
142 of_node_put(pnp);
147 * Disable propagation of mbus errors to the CPU local bus, as this
148 * causes mbus errors (which can occur for example for PCI aborts) to
149 * throw CPU aborts, which we're not set up to deal with.
151 static void kirkwood_disable_mbus_error_propagation(void)
153 void __iomem *cpu_config;
155 cpu_config = ioremap(CPU_CONFIG_PHYS, 4);
156 writel(readl(cpu_config) & ~CPU_CONFIG_ERROR_PROP, cpu_config);
159 static struct of_dev_auxdata auxdata[] __initdata = {
160 OF_DEV_AUXDATA("marvell,kirkwood-audio", 0xf10a0000,
161 "mvebu-audio", NULL),
162 { /* sentinel */ }
165 static void __init kirkwood_dt_init(void)
167 kirkwood_disable_mbus_error_propagation();
169 BUG_ON(mvebu_mbus_dt_init(false));
171 #ifdef CONFIG_CACHE_FEROCEON_L2
172 feroceon_of_init();
173 #endif
174 kirkwood_cpufreq_init();
175 kirkwood_cpuidle_init();
177 kirkwood_pm_init();
178 kirkwood_dt_eth_fixup();
180 of_platform_default_populate(NULL, auxdata, NULL);
183 static const char * const kirkwood_dt_board_compat[] __initconst = {
184 "marvell,kirkwood",
185 NULL
188 DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)")
189 /* Maintainer: Jason Cooper <jason@lakedaemon.net> */
190 .init_machine = kirkwood_dt_init,
191 .restart = mvebu_restart,
192 .dt_compat = kirkwood_dt_board_compat,
193 MACHINE_END