xref: /openbmc/linux/arch/arm/mach-bcm/board_bcm281xx.c (revision 0e8b860ac6d65209beea03ee9b718089838476ef)
1959faee9SChristian Daudt /*
2a21ea269SMarkus Mayer  * Copyright (C) 2012-2014 Broadcom Corporation
3959faee9SChristian Daudt  *
4959faee9SChristian Daudt  * This program is free software; you can redistribute it and/or
5959faee9SChristian Daudt  * modify it under the terms of the GNU General Public License as
6959faee9SChristian Daudt  * published by the Free Software Foundation version 2.
7959faee9SChristian Daudt  *
8959faee9SChristian Daudt  * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9959faee9SChristian Daudt  * kind, whether express or implied; without even the implied warranty
10959faee9SChristian Daudt  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11959faee9SChristian Daudt  * GNU General Public License for more details.
12959faee9SChristian Daudt  */
13959faee9SChristian Daudt 
14959faee9SChristian Daudt #include <linux/clocksource.h>
15389df036SMarkus Mayer #include <linux/of_address.h>
16389df036SMarkus Mayer #include <linux/of_platform.h>
17959faee9SChristian Daudt 
18959faee9SChristian Daudt #include <asm/mach/arch.h>
19959faee9SChristian Daudt 
20959faee9SChristian Daudt #include "kona.h"
21959faee9SChristian Daudt 
22a21ea269SMarkus Mayer #define SECWDOG_OFFSET			0x00000000
23a21ea269SMarkus Mayer #define SECWDOG_RESERVED_MASK		0xe2000000
24a21ea269SMarkus Mayer #define SECWDOG_WD_LOAD_FLAG_MASK	0x10000000
25a21ea269SMarkus Mayer #define SECWDOG_EN_MASK			0x08000000
26a21ea269SMarkus Mayer #define SECWDOG_SRSTEN_MASK		0x04000000
27a21ea269SMarkus Mayer #define SECWDOG_CLKS_SHIFT		20
28a21ea269SMarkus Mayer #define SECWDOG_COUNT_SHIFT		0
29959faee9SChristian Daudt 
30a21ea269SMarkus Mayer static void bcm281xx_restart(enum reboot_mode mode, const char *cmd)
31a21ea269SMarkus Mayer {
32a21ea269SMarkus Mayer 	uint32_t val;
33a21ea269SMarkus Mayer 	void __iomem *base;
34a21ea269SMarkus Mayer 	struct device_node *np_wdog;
35a21ea269SMarkus Mayer 
36a21ea269SMarkus Mayer 	np_wdog = of_find_compatible_node(NULL, NULL, "brcm,kona-wdt");
37a21ea269SMarkus Mayer 	if (!np_wdog) {
38a21ea269SMarkus Mayer 		pr_emerg("Couldn't find brcm,kona-wdt\n");
39a21ea269SMarkus Mayer 		return;
40959faee9SChristian Daudt 	}
41a21ea269SMarkus Mayer 	base = of_iomap(np_wdog, 0);
42a21ea269SMarkus Mayer 	if (!base) {
43a21ea269SMarkus Mayer 		pr_emerg("Couldn't map brcm,kona-wdt\n");
44a21ea269SMarkus Mayer 		return;
45a21ea269SMarkus Mayer 	}
46a21ea269SMarkus Mayer 
47a21ea269SMarkus Mayer 	/* Enable watchdog with short timeout (244us). */
48a21ea269SMarkus Mayer 	val = readl(base + SECWDOG_OFFSET);
49a21ea269SMarkus Mayer 	val &= SECWDOG_RESERVED_MASK | SECWDOG_WD_LOAD_FLAG_MASK;
50a21ea269SMarkus Mayer 	val |= SECWDOG_EN_MASK | SECWDOG_SRSTEN_MASK |
51a21ea269SMarkus Mayer 		(0x15 << SECWDOG_CLKS_SHIFT) |
52a21ea269SMarkus Mayer 		(0x8 << SECWDOG_COUNT_SHIFT);
53a21ea269SMarkus Mayer 	writel(val, base + SECWDOG_OFFSET);
54a21ea269SMarkus Mayer 
55a21ea269SMarkus Mayer 	/* Wait for reset */
56a21ea269SMarkus Mayer 	while (1);
57959faee9SChristian Daudt }
58959faee9SChristian Daudt 
59*0e8b860aSMarkus Mayer static void __init bcm281xx_init(void)
60959faee9SChristian Daudt {
61959faee9SChristian Daudt 	of_platform_populate(NULL, of_default_bus_match_table, NULL,
62959faee9SChristian Daudt 		&platform_bus);
63959faee9SChristian Daudt 	kona_l2_cache_init();
64959faee9SChristian Daudt }
65959faee9SChristian Daudt 
669c6423aaSAlex Elder static const char * const bcm281xx_dt_compat[] = {
679c6423aaSAlex Elder 	"brcm,bcm11351",	/* Have to use the first number upstreamed */
689c6423aaSAlex Elder 	NULL,
699c6423aaSAlex Elder };
70959faee9SChristian Daudt 
719c6423aaSAlex Elder DT_MACHINE_START(BCM281XX_DT, "BCM281xx Broadcom Application Processor")
72*0e8b860aSMarkus Mayer 	.init_machine = bcm281xx_init,
73a21ea269SMarkus Mayer 	.restart = bcm281xx_restart,
749c6423aaSAlex Elder 	.dt_compat = bcm281xx_dt_compat,
75959faee9SChristian Daudt MACHINE_END
76