xref: /openbmc/linux/arch/arm/mach-bcm/board_bcm281xx.c (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1*52e6676eSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2*52e6676eSThomas Gleixner // Copyright (C) 2012-2014 Broadcom Corporation
3959faee9SChristian Daudt 
4959faee9SChristian Daudt #include <linux/clocksource.h>
5389df036SMarkus Mayer #include <linux/of_address.h>
6959faee9SChristian Daudt 
7959faee9SChristian Daudt #include <asm/mach/arch.h>
8959faee9SChristian Daudt 
9eeda4cb9SAlex Elder #include "kona_l2_cache.h"
10959faee9SChristian Daudt 
11a21ea269SMarkus Mayer #define SECWDOG_OFFSET			0x00000000
12a21ea269SMarkus Mayer #define SECWDOG_RESERVED_MASK		0xe2000000
13a21ea269SMarkus Mayer #define SECWDOG_WD_LOAD_FLAG_MASK	0x10000000
14a21ea269SMarkus Mayer #define SECWDOG_EN_MASK			0x08000000
15a21ea269SMarkus Mayer #define SECWDOG_SRSTEN_MASK		0x04000000
16a21ea269SMarkus Mayer #define SECWDOG_CLKS_SHIFT		20
17a21ea269SMarkus Mayer #define SECWDOG_COUNT_SHIFT		0
18959faee9SChristian Daudt 
bcm281xx_restart(enum reboot_mode mode,const char * cmd)19a21ea269SMarkus Mayer static void bcm281xx_restart(enum reboot_mode mode, const char *cmd)
20a21ea269SMarkus Mayer {
21a21ea269SMarkus Mayer 	uint32_t val;
22a21ea269SMarkus Mayer 	void __iomem *base;
23a21ea269SMarkus Mayer 	struct device_node *np_wdog;
24a21ea269SMarkus Mayer 
25a21ea269SMarkus Mayer 	np_wdog = of_find_compatible_node(NULL, NULL, "brcm,kona-wdt");
26a21ea269SMarkus Mayer 	if (!np_wdog) {
27a21ea269SMarkus Mayer 		pr_emerg("Couldn't find brcm,kona-wdt\n");
28a21ea269SMarkus Mayer 		return;
29959faee9SChristian Daudt 	}
30a21ea269SMarkus Mayer 	base = of_iomap(np_wdog, 0);
318abc5a7cSWen Yang 	of_node_put(np_wdog);
32a21ea269SMarkus Mayer 	if (!base) {
33a21ea269SMarkus Mayer 		pr_emerg("Couldn't map brcm,kona-wdt\n");
34a21ea269SMarkus Mayer 		return;
35a21ea269SMarkus Mayer 	}
36a21ea269SMarkus Mayer 
37a21ea269SMarkus Mayer 	/* Enable watchdog with short timeout (244us). */
38a21ea269SMarkus Mayer 	val = readl(base + SECWDOG_OFFSET);
39a21ea269SMarkus Mayer 	val &= SECWDOG_RESERVED_MASK | SECWDOG_WD_LOAD_FLAG_MASK;
40a21ea269SMarkus Mayer 	val |= SECWDOG_EN_MASK | SECWDOG_SRSTEN_MASK |
41a21ea269SMarkus Mayer 		(0x15 << SECWDOG_CLKS_SHIFT) |
42a21ea269SMarkus Mayer 		(0x8 << SECWDOG_COUNT_SHIFT);
43a21ea269SMarkus Mayer 	writel(val, base + SECWDOG_OFFSET);
44a21ea269SMarkus Mayer 
45a21ea269SMarkus Mayer 	/* Wait for reset */
46a21ea269SMarkus Mayer 	while (1);
47959faee9SChristian Daudt }
48959faee9SChristian Daudt 
bcm281xx_init(void)490e8b860aSMarkus Mayer static void __init bcm281xx_init(void)
50959faee9SChristian Daudt {
51959faee9SChristian Daudt 	kona_l2_cache_init();
52959faee9SChristian Daudt }
53959faee9SChristian Daudt 
549c6423aaSAlex Elder static const char * const bcm281xx_dt_compat[] = {
559c6423aaSAlex Elder 	"brcm,bcm11351",	/* Have to use the first number upstreamed */
569c6423aaSAlex Elder 	NULL,
579c6423aaSAlex Elder };
58959faee9SChristian Daudt 
599c6423aaSAlex Elder DT_MACHINE_START(BCM281XX_DT, "BCM281xx Broadcom Application Processor")
600e8b860aSMarkus Mayer 	.init_machine = bcm281xx_init,
61a21ea269SMarkus Mayer 	.restart = bcm281xx_restart,
629c6423aaSAlex Elder 	.dt_compat = bcm281xx_dt_compat,
63959faee9SChristian Daudt MACHINE_END
64