diff options
author | Markus Mayer <markus.mayer@linaro.org> | 2013-06-24 18:39:33 -0400 |
---|---|---|
committer | Christian Daudt <csd@broadcom.com> | 2013-08-08 18:19:19 -0400 |
commit | 257b49e3d8cd2b8e5a67c566e6db40a52f6185c0 (patch) | |
tree | b01a8204ffd734944c396d1372d10ee590d9c6de /arch/arm/mach-bcm/kona.c | |
parent | 6dea0df2e79850bb30f83b9e7f975a8470ca6e92 (diff) |
ARM: bcm281xx: Board specific reboot code
This patch adds the code needed to trigger a reboot on the bcm281xx
family.
Signed-off-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Matt Porter <matt.porter@linaro.org>
Reviewed-by: Alex Elder <alex.elder@linaro.org>
Acked-by: Christian Daudt <csd@broadcom.com>
Diffstat (limited to 'arch/arm/mach-bcm/kona.c')
-rw-r--r-- | arch/arm/mach-bcm/kona.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/arch/arm/mach-bcm/kona.c b/arch/arm/mach-bcm/kona.c new file mode 100644 index 000000000000..6939d9017f63 --- /dev/null +++ b/arch/arm/mach-bcm/kona.c | |||
@@ -0,0 +1,65 @@ | |||
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 | |||
19 | static void __iomem *watchdog_base; | ||
20 | |||
21 | void 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 | |||
48 | void 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 | } | ||