x86/efi: Enforce CONFIG_RELOCATABLE for EFI boot stub
[linux/fpc-iii.git] / arch / arm / mach-bcm / kona.c
blob6939d9017f63369c3c34cba1921869ea7a873583
1 /*
2 * Copyright (C) 2013 Broadcom Corporation
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.
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.
14 #include <linux/of_address.h>
15 #include <asm/io.h>
17 #include "kona.h"
19 static void __iomem *watchdog_base;
21 void bcm_kona_setup_restart(void)
23 struct device_node *np_wdog;
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.
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;
35 watchdog_base = of_iomap(np_wdog, 0);
36 WARN(!watchdog_base, "failed to map watchdog base");
37 of_node_put(np_wdog);
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
48 void bcm_kona_restart(enum reboot_mode mode, const char *cmd)
50 uint32_t val;
52 if (!watchdog_base)
53 panic("Watchdog not mapped. Reboot failed.\n");
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);
63 while (1)