diff options
Diffstat (limited to 'arch/arm/mach-bcm/kona.c')
-rw-r--r-- | arch/arm/mach-bcm/kona.c | 64 |
1 files changed, 21 insertions, 43 deletions
diff --git a/arch/arm/mach-bcm/kona.c b/arch/arm/mach-bcm/kona.c index 6939d9017f63..768bc2837bf5 100644 --- a/arch/arm/mach-bcm/kona.c +++ b/arch/arm/mach-bcm/kona.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2013 Broadcom Corporation | 2 | * Copyright (C) 2012-2014 Broadcom Corporation |
3 | * | 3 | * |
4 | * This program is free software; you can redistribute it and/or | 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 | 5 | * modify it under the terms of the GNU General Public License as |
@@ -11,55 +11,33 @@ | |||
11 | * GNU General Public License for more details. | 11 | * GNU General Public License for more details. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/of_address.h> | 14 | #include <linux/of_platform.h> |
15 | #include <asm/io.h> | 15 | #include <asm/hardware/cache-l2x0.h> |
16 | 16 | ||
17 | #include "bcm_kona_smc.h" | ||
17 | #include "kona.h" | 18 | #include "kona.h" |
18 | 19 | ||
19 | static void __iomem *watchdog_base; | 20 | void __init kona_l2_cache_init(void) |
20 | |||
21 | void bcm_kona_setup_restart(void) | ||
22 | { | 21 | { |
23 | struct device_node *np_wdog; | 22 | int ret; |
24 | 23 | ||
25 | /* | 24 | if (!IS_ENABLED(CONFIG_CACHE_L2X0)) |
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; | 25 | 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 | 26 | ||
48 | void bcm_kona_restart(enum reboot_mode mode, const char *cmd) | 27 | ret = bcm_kona_smc_init(); |
49 | { | 28 | if (ret) { |
50 | uint32_t val; | 29 | pr_info("Secure API not available (%d). Skipping L2 init.\n", |
51 | 30 | ret); | |
52 | if (!watchdog_base) | 31 | return; |
53 | panic("Watchdog not mapped. Reboot failed.\n"); | 32 | } |
54 | 33 | ||
55 | /* Enable watchdog2 with very short timeout. */ | 34 | bcm_kona_smc(SSAPI_ENABLE_L2_CACHE, 0, 0, 0, 0); |
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 | 35 | ||
63 | while (1) | 36 | /* |
64 | ; | 37 | * The aux_val and aux_mask have no effect since L2 cache is already |
38 | * enabled. Pass 0s for aux_val and 1s for aux_mask for default value. | ||
39 | */ | ||
40 | ret = l2x0_of_init(0, ~0); | ||
41 | if (ret) | ||
42 | pr_err("Couldn't enable L2 cache: %d\n", ret); | ||
65 | } | 43 | } |