ARM: bcm281xx: Board specific reboot code
[deliverable/linux.git] / arch / arm / mach-bcm / kona.c
CommitLineData
257b49e3
MM
1/*
2 * Copyright (C) 2013 Broadcom Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation version 2.
7 *
8 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 * kind, whether express or implied; without even the implied warranty
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/of_address.h>
15#include <asm/io.h>
16
17#include "kona.h"
18
19static void __iomem *watchdog_base;
20
21void bcm_kona_setup_restart(void)
22{
23 struct device_node *np_wdog;
24
25 /*
26 * The assumption is that whoever calls bcm_kona_setup_restart()
27 * also needs a Kona Watchdog Timer entry in Device Tree, i.e. we
28 * report an error if the DT entry is missing.
29 */
30 np_wdog = of_find_compatible_node(NULL, NULL, "brcm,kona-wdt");
31 if (!np_wdog) {
32 pr_err("brcm,kona-wdt not found in DT, reboot disabled\n");
33 return;
34 }
35 watchdog_base = of_iomap(np_wdog, 0);
36 WARN(!watchdog_base, "failed to map watchdog base");
37 of_node_put(np_wdog);
38}
39
40#define SECWDOG_OFFSET 0x00000000
41#define SECWDOG_RESERVED_MASK 0xE2000000
42#define SECWDOG_WD_LOAD_FLAG_MASK 0x10000000
43#define SECWDOG_EN_MASK 0x08000000
44#define SECWDOG_SRSTEN_MASK 0x04000000
45#define SECWDOG_CLKS_SHIFT 20
46#define SECWDOG_LOCK_SHIFT 0
47
48void bcm_kona_restart(enum reboot_mode mode, const char *cmd)
49{
50 uint32_t val;
51
52 if (!watchdog_base)
53 panic("Watchdog not mapped. Reboot failed.\n");
54
55 /* Enable watchdog2 with very short timeout. */
56 val = readl(watchdog_base + SECWDOG_OFFSET);
57 val &= SECWDOG_RESERVED_MASK | SECWDOG_WD_LOAD_FLAG_MASK;
58 val |= SECWDOG_EN_MASK | SECWDOG_SRSTEN_MASK |
59 (0x8 << SECWDOG_CLKS_SHIFT) |
60 (0x8 << SECWDOG_LOCK_SHIFT);
61 writel(val, watchdog_base + SECWDOG_OFFSET);
62
63 while (1)
64 ;
65}
This page took 0.025301 seconds and 5 git commands to generate.