diff options
author | Markus Mayer <markus.mayer@linaro.org> | 2014-02-25 17:17:44 -0500 |
---|---|---|
committer | Matt Porter <mporter@linaro.org> | 2014-03-06 03:17:59 -0500 |
commit | a21ea269b99e6b627c86c29fb1b45b859e3840b6 (patch) | |
tree | fdb3c17d0b0745e631032f780fdaa1ff41cecf58 | |
parent | 8b1c342629ecf7c2c52600dbe626d74cffc8d6cc (diff) |
ARM: bcm281xx: Consolidate reboot code
Consolidate reboot code and remove unnecessary functions.
Signed-off-by: Markus Mayer <markus.mayer@linaro.org>
Signed-off-by: Matt Porter <mporter@linaro.org>
-rw-r--r-- | arch/arm/mach-bcm/board_bcm281xx.c | 46 | ||||
-rw-r--r-- | arch/arm/mach-bcm/kona.c | 50 | ||||
-rw-r--r-- | arch/arm/mach-bcm/kona.h | 4 |
3 files changed, 34 insertions, 66 deletions
diff --git a/arch/arm/mach-bcm/board_bcm281xx.c b/arch/arm/mach-bcm/board_bcm281xx.c index 5494e9146761..d7fa3aef6213 100644 --- a/arch/arm/mach-bcm/board_bcm281xx.c +++ b/arch/arm/mach-bcm/board_bcm281xx.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2012-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 |
@@ -19,25 +19,47 @@ | |||
19 | 19 | ||
20 | #include "kona.h" | 20 | #include "kona.h" |
21 | 21 | ||
22 | static void bcm_board_setup_restart(void) | 22 | #define SECWDOG_OFFSET 0x00000000 |
23 | #define SECWDOG_RESERVED_MASK 0xe2000000 | ||
24 | #define SECWDOG_WD_LOAD_FLAG_MASK 0x10000000 | ||
25 | #define SECWDOG_EN_MASK 0x08000000 | ||
26 | #define SECWDOG_SRSTEN_MASK 0x04000000 | ||
27 | #define SECWDOG_CLKS_SHIFT 20 | ||
28 | #define SECWDOG_COUNT_SHIFT 0 | ||
29 | |||
30 | static void bcm281xx_restart(enum reboot_mode mode, const char *cmd) | ||
23 | { | 31 | { |
24 | struct device_node *np; | 32 | uint32_t val; |
33 | void __iomem *base; | ||
34 | struct device_node *np_wdog; | ||
25 | 35 | ||
26 | np = of_find_compatible_node(NULL, NULL, "brcm,bcm11351"); | 36 | np_wdog = of_find_compatible_node(NULL, NULL, "brcm,kona-wdt"); |
27 | if (np) { | 37 | if (!np_wdog) { |
28 | if (of_device_is_available(np)) | 38 | pr_emerg("Couldn't find brcm,kona-wdt\n"); |
29 | bcm_kona_setup_restart(); | 39 | return; |
30 | of_node_put(np); | 40 | } |
41 | base = of_iomap(np_wdog, 0); | ||
42 | if (!base) { | ||
43 | pr_emerg("Couldn't map brcm,kona-wdt\n"); | ||
44 | return; | ||
31 | } | 45 | } |
32 | /* Restart setup for other boards goes here */ | 46 | |
47 | /* Enable watchdog with short timeout (244us). */ | ||
48 | val = readl(base + SECWDOG_OFFSET); | ||
49 | val &= SECWDOG_RESERVED_MASK | SECWDOG_WD_LOAD_FLAG_MASK; | ||
50 | val |= SECWDOG_EN_MASK | SECWDOG_SRSTEN_MASK | | ||
51 | (0x15 << SECWDOG_CLKS_SHIFT) | | ||
52 | (0x8 << SECWDOG_COUNT_SHIFT); | ||
53 | writel(val, base + SECWDOG_OFFSET); | ||
54 | |||
55 | /* Wait for reset */ | ||
56 | while (1); | ||
33 | } | 57 | } |
34 | 58 | ||
35 | static void __init board_init(void) | 59 | static void __init board_init(void) |
36 | { | 60 | { |
37 | of_platform_populate(NULL, of_default_bus_match_table, NULL, | 61 | of_platform_populate(NULL, of_default_bus_match_table, NULL, |
38 | &platform_bus); | 62 | &platform_bus); |
39 | |||
40 | bcm_board_setup_restart(); | ||
41 | kona_l2_cache_init(); | 63 | kona_l2_cache_init(); |
42 | } | 64 | } |
43 | 65 | ||
@@ -48,6 +70,6 @@ static const char * const bcm281xx_dt_compat[] = { | |||
48 | 70 | ||
49 | DT_MACHINE_START(BCM281XX_DT, "BCM281xx Broadcom Application Processor") | 71 | DT_MACHINE_START(BCM281XX_DT, "BCM281xx Broadcom Application Processor") |
50 | .init_machine = board_init, | 72 | .init_machine = board_init, |
51 | .restart = bcm_kona_restart, | 73 | .restart = bcm281xx_restart, |
52 | .dt_compat = bcm281xx_dt_compat, | 74 | .dt_compat = bcm281xx_dt_compat, |
53 | MACHINE_END | 75 | MACHINE_END |
diff --git a/arch/arm/mach-bcm/kona.c b/arch/arm/mach-bcm/kona.c index 2f1db29291fe..768bc2837bf5 100644 --- a/arch/arm/mach-bcm/kona.c +++ b/arch/arm/mach-bcm/kona.c | |||
@@ -11,10 +11,8 @@ | |||
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> | ||
15 | #include <linux/of_platform.h> | 14 | #include <linux/of_platform.h> |
16 | #include <asm/hardware/cache-l2x0.h> | 15 | #include <asm/hardware/cache-l2x0.h> |
17 | #include <asm/io.h> | ||
18 | 16 | ||
19 | #include "bcm_kona_smc.h" | 17 | #include "bcm_kona_smc.h" |
20 | #include "kona.h" | 18 | #include "kona.h" |
@@ -43,51 +41,3 @@ void __init kona_l2_cache_init(void) | |||
43 | if (ret) | 41 | if (ret) |
44 | pr_err("Couldn't enable L2 cache: %d\n", ret); | 42 | pr_err("Couldn't enable L2 cache: %d\n", ret); |
45 | } | 43 | } |
46 | |||
47 | static void __iomem *watchdog_base; | ||
48 | |||
49 | void bcm_kona_setup_restart(void) | ||
50 | { | ||
51 | struct device_node *np_wdog; | ||
52 | |||
53 | /* | ||
54 | * The assumption is that whoever calls bcm_kona_setup_restart() | ||
55 | * also needs a Kona Watchdog Timer entry in Device Tree, i.e. we | ||
56 | * report an error if the DT entry is missing. | ||
57 | */ | ||
58 | np_wdog = of_find_compatible_node(NULL, NULL, "brcm,kona-wdt"); | ||
59 | if (!np_wdog) { | ||
60 | pr_err("brcm,kona-wdt not found in DT, reboot disabled\n"); | ||
61 | return; | ||
62 | } | ||
63 | watchdog_base = of_iomap(np_wdog, 0); | ||
64 | WARN(!watchdog_base, "failed to map watchdog base"); | ||
65 | of_node_put(np_wdog); | ||
66 | } | ||
67 | |||
68 | #define SECWDOG_OFFSET 0x00000000 | ||
69 | #define SECWDOG_RESERVED_MASK 0xE2000000 | ||
70 | #define SECWDOG_WD_LOAD_FLAG_MASK 0x10000000 | ||
71 | #define SECWDOG_EN_MASK 0x08000000 | ||
72 | #define SECWDOG_SRSTEN_MASK 0x04000000 | ||
73 | #define SECWDOG_CLKS_SHIFT 20 | ||
74 | #define SECWDOG_LOCK_SHIFT 0 | ||
75 | |||
76 | void bcm_kona_restart(enum reboot_mode mode, const char *cmd) | ||
77 | { | ||
78 | uint32_t val; | ||
79 | |||
80 | if (!watchdog_base) | ||
81 | panic("Watchdog not mapped. Reboot failed.\n"); | ||
82 | |||
83 | /* Enable watchdog2 with very short timeout. */ | ||
84 | val = readl(watchdog_base + SECWDOG_OFFSET); | ||
85 | val &= SECWDOG_RESERVED_MASK | SECWDOG_WD_LOAD_FLAG_MASK; | ||
86 | val |= SECWDOG_EN_MASK | SECWDOG_SRSTEN_MASK | | ||
87 | (0x8 << SECWDOG_CLKS_SHIFT) | | ||
88 | (0x8 << SECWDOG_LOCK_SHIFT); | ||
89 | writel(val, watchdog_base + SECWDOG_OFFSET); | ||
90 | |||
91 | while (1) | ||
92 | ; | ||
93 | } | ||
diff --git a/arch/arm/mach-bcm/kona.h b/arch/arm/mach-bcm/kona.h index f42aef837444..3a7a017c29cd 100644 --- a/arch/arm/mach-bcm/kona.h +++ b/arch/arm/mach-bcm/kona.h | |||
@@ -11,8 +11,4 @@ | |||
11 | * GNU General Public License for more details. | 11 | * GNU General Public License for more details. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/reboot.h> | ||
15 | |||
16 | void __init kona_l2_cache_init(void); | 14 | void __init kona_l2_cache_init(void); |
17 | void bcm_kona_setup_restart(void); | ||
18 | void bcm_kona_restart(enum reboot_mode mode, const char *cmd); | ||