xref: /openbmc/linux/arch/arm/mach-mvebu/board-v7.c (revision 9aa30f1c13d1df2fc82ef0d0fd506306d8c8cef2)
199b3d294SThomas Petazzoni /*
299b3d294SThomas Petazzoni  * Device Tree support for Armada 370 and XP platforms.
399b3d294SThomas Petazzoni  *
499b3d294SThomas Petazzoni  * Copyright (C) 2012 Marvell
599b3d294SThomas Petazzoni  *
699b3d294SThomas Petazzoni  * Lior Amsalem <alior@marvell.com>
799b3d294SThomas Petazzoni  * Gregory CLEMENT <gregory.clement@free-electrons.com>
899b3d294SThomas Petazzoni  * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
999b3d294SThomas Petazzoni  *
1099b3d294SThomas Petazzoni  * This file is licensed under the terms of the GNU General Public
1199b3d294SThomas Petazzoni  * License version 2.  This program is licensed "as is" without any
1299b3d294SThomas Petazzoni  * warranty of any kind, whether express or implied.
1399b3d294SThomas Petazzoni  */
1499b3d294SThomas Petazzoni 
1599b3d294SThomas Petazzoni #include <linux/kernel.h>
1699b3d294SThomas Petazzoni #include <linux/init.h>
1799b3d294SThomas Petazzoni #include <linux/clk-provider.h>
1899b3d294SThomas Petazzoni #include <linux/of_address.h>
1999b3d294SThomas Petazzoni #include <linux/of_platform.h>
2099b3d294SThomas Petazzoni #include <linux/io.h>
2199b3d294SThomas Petazzoni #include <linux/clocksource.h>
2299b3d294SThomas Petazzoni #include <linux/dma-mapping.h>
2399b3d294SThomas Petazzoni #include <linux/mbus.h>
2499b3d294SThomas Petazzoni #include <linux/slab.h>
2599b3d294SThomas Petazzoni #include <asm/hardware/cache-l2x0.h>
2699b3d294SThomas Petazzoni #include <asm/mach/arch.h>
2799b3d294SThomas Petazzoni #include <asm/mach/map.h>
2899b3d294SThomas Petazzoni #include <asm/mach/time.h>
2999b3d294SThomas Petazzoni #include "armada-370-xp.h"
3099b3d294SThomas Petazzoni #include "common.h"
3199b3d294SThomas Petazzoni #include "coherency.h"
3299b3d294SThomas Petazzoni #include "mvebu-soc-id.h"
3399b3d294SThomas Petazzoni 
34ca4a6f87SThomas Petazzoni /*
35ca4a6f87SThomas Petazzoni  * Early versions of Armada 375 SoC have a bug where the BootROM
36ca4a6f87SThomas Petazzoni  * leaves an external data abort pending. The kernel is hit by this
37ca4a6f87SThomas Petazzoni  * data abort as soon as it enters userspace, because it unmasks the
38ca4a6f87SThomas Petazzoni  * data aborts at this moment. We register a custom abort handler
39ca4a6f87SThomas Petazzoni  * below to ignore the first data abort to work around this
40ca4a6f87SThomas Petazzoni  * problem.
41ca4a6f87SThomas Petazzoni  */
42ca4a6f87SThomas Petazzoni static int armada_375_external_abort_wa(unsigned long addr, unsigned int fsr,
43ca4a6f87SThomas Petazzoni 					struct pt_regs *regs)
44ca4a6f87SThomas Petazzoni {
45ca4a6f87SThomas Petazzoni 	static int ignore_first;
46ca4a6f87SThomas Petazzoni 
47ca4a6f87SThomas Petazzoni 	if (!ignore_first && fsr == 0x1406) {
48ca4a6f87SThomas Petazzoni 		ignore_first = 1;
49ca4a6f87SThomas Petazzoni 		return 0;
50ca4a6f87SThomas Petazzoni 	}
51ca4a6f87SThomas Petazzoni 
52ca4a6f87SThomas Petazzoni 	return 1;
53ca4a6f87SThomas Petazzoni }
54ca4a6f87SThomas Petazzoni 
5599b3d294SThomas Petazzoni static void __init mvebu_timer_and_clk_init(void)
5699b3d294SThomas Petazzoni {
5799b3d294SThomas Petazzoni 	of_clk_init(NULL);
5899b3d294SThomas Petazzoni 	clocksource_of_init();
5999b3d294SThomas Petazzoni 	coherency_init();
6099b3d294SThomas Petazzoni 	BUG_ON(mvebu_mbus_dt_init());
6199b3d294SThomas Petazzoni #ifdef CONFIG_CACHE_L2X0
6299b3d294SThomas Petazzoni 	l2x0_of_init(0, ~0UL);
6399b3d294SThomas Petazzoni #endif
64ca4a6f87SThomas Petazzoni 
65ca4a6f87SThomas Petazzoni 	if (of_machine_is_compatible("marvell,armada375"))
66ca4a6f87SThomas Petazzoni 		hook_fault_code(16 + 6, armada_375_external_abort_wa, SIGBUS, 0,
67ca4a6f87SThomas Petazzoni 				"imprecise external abort");
6899b3d294SThomas Petazzoni }
6999b3d294SThomas Petazzoni 
7099b3d294SThomas Petazzoni static void __init i2c_quirk(void)
7199b3d294SThomas Petazzoni {
7299b3d294SThomas Petazzoni 	struct device_node *np;
7399b3d294SThomas Petazzoni 	u32 dev, rev;
7499b3d294SThomas Petazzoni 
7599b3d294SThomas Petazzoni 	/*
7699b3d294SThomas Petazzoni 	 * Only revisons more recent than A0 support the offload
7799b3d294SThomas Petazzoni 	 * mechanism. We can exit only if we are sure that we can
7899b3d294SThomas Petazzoni 	 * get the SoC revision and it is more recent than A0.
7999b3d294SThomas Petazzoni 	 */
8099b3d294SThomas Petazzoni 	if (mvebu_get_soc_id(&rev, &dev) == 0 && dev > MV78XX0_A0_REV)
8199b3d294SThomas Petazzoni 		return;
8299b3d294SThomas Petazzoni 
8399b3d294SThomas Petazzoni 	for_each_compatible_node(np, NULL, "marvell,mv78230-i2c") {
8499b3d294SThomas Petazzoni 		struct property *new_compat;
8599b3d294SThomas Petazzoni 
8699b3d294SThomas Petazzoni 		new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL);
8799b3d294SThomas Petazzoni 
8899b3d294SThomas Petazzoni 		new_compat->name = kstrdup("compatible", GFP_KERNEL);
8999b3d294SThomas Petazzoni 		new_compat->length = sizeof("marvell,mv78230-a0-i2c");
9099b3d294SThomas Petazzoni 		new_compat->value = kstrdup("marvell,mv78230-a0-i2c",
9199b3d294SThomas Petazzoni 						GFP_KERNEL);
9299b3d294SThomas Petazzoni 
9399b3d294SThomas Petazzoni 		of_update_property(np, new_compat);
9499b3d294SThomas Petazzoni 	}
9599b3d294SThomas Petazzoni 	return;
9699b3d294SThomas Petazzoni }
9799b3d294SThomas Petazzoni 
9899b3d294SThomas Petazzoni static void __init mvebu_dt_init(void)
9999b3d294SThomas Petazzoni {
10099b3d294SThomas Petazzoni 	if (of_machine_is_compatible("plathome,openblocks-ax3-4"))
10199b3d294SThomas Petazzoni 		i2c_quirk();
10299b3d294SThomas Petazzoni 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
10399b3d294SThomas Petazzoni }
10499b3d294SThomas Petazzoni 
10599b3d294SThomas Petazzoni static const char * const armada_370_xp_dt_compat[] = {
10699b3d294SThomas Petazzoni 	"marvell,armada-370-xp",
10799b3d294SThomas Petazzoni 	NULL,
10899b3d294SThomas Petazzoni };
10999b3d294SThomas Petazzoni 
110a017dbb6SThomas Petazzoni DT_MACHINE_START(ARMADA_370_XP_DT, "Marvell Armada 370/XP (Device Tree)")
11199b3d294SThomas Petazzoni 	.smp		= smp_ops(armada_xp_smp_ops),
11299b3d294SThomas Petazzoni 	.init_machine	= mvebu_dt_init,
11399b3d294SThomas Petazzoni 	.init_time	= mvebu_timer_and_clk_init,
11499b3d294SThomas Petazzoni 	.restart	= mvebu_restart,
11599b3d294SThomas Petazzoni 	.dt_compat	= armada_370_xp_dt_compat,
11699b3d294SThomas Petazzoni MACHINE_END
117d3ce7f25SGregory CLEMENT 
118d3ce7f25SGregory CLEMENT static const char * const armada_375_dt_compat[] = {
119d3ce7f25SGregory CLEMENT 	"marvell,armada375",
120d3ce7f25SGregory CLEMENT 	NULL,
121d3ce7f25SGregory CLEMENT };
122d3ce7f25SGregory CLEMENT 
123d3ce7f25SGregory CLEMENT DT_MACHINE_START(ARMADA_375_DT, "Marvell Armada 375 (Device Tree)")
124d3ce7f25SGregory CLEMENT 	.init_time	= mvebu_timer_and_clk_init,
125d3ce7f25SGregory CLEMENT 	.restart	= mvebu_restart,
126d3ce7f25SGregory CLEMENT 	.dt_compat	= armada_375_dt_compat,
127d3ce7f25SGregory CLEMENT MACHINE_END
128*9aa30f1cSThomas Petazzoni 
129*9aa30f1cSThomas Petazzoni static const char * const armada_38x_dt_compat[] = {
130*9aa30f1cSThomas Petazzoni 	"marvell,armada380",
131*9aa30f1cSThomas Petazzoni 	"marvell,armada385",
132*9aa30f1cSThomas Petazzoni 	NULL,
133*9aa30f1cSThomas Petazzoni };
134*9aa30f1cSThomas Petazzoni 
135*9aa30f1cSThomas Petazzoni DT_MACHINE_START(ARMADA_38X_DT, "Marvell Armada 380/385 (Device Tree)")
136*9aa30f1cSThomas Petazzoni 	.init_time	= mvebu_timer_and_clk_init,
137*9aa30f1cSThomas Petazzoni 	.restart	= mvebu_restart,
138*9aa30f1cSThomas Petazzoni 	.dt_compat	= armada_38x_dt_compat,
139*9aa30f1cSThomas Petazzoni MACHINE_END
140