aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Mayer <markus.mayer@linaro.org>2013-06-24 18:39:33 -0400
committerChristian Daudt <csd@broadcom.com>2013-08-08 18:19:19 -0400
commit257b49e3d8cd2b8e5a67c566e6db40a52f6185c0 (patch)
treeb01a8204ffd734944c396d1372d10ee590d9c6de
parent6dea0df2e79850bb30f83b9e7f975a8470ca6e92 (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>
-rw-r--r--arch/arm/mach-bcm/Makefile4
-rw-r--r--arch/arm/mach-bcm/board_bcm.c20
-rw-r--r--arch/arm/mach-bcm/kona.c65
-rw-r--r--arch/arm/mach-bcm/kona.h17
4 files changed, 101 insertions, 5 deletions
diff --git a/arch/arm/mach-bcm/Makefile b/arch/arm/mach-bcm/Makefile
index 6adb6aecf48f..7e5ca0a90358 100644
--- a/arch/arm/mach-bcm/Makefile
+++ b/arch/arm/mach-bcm/Makefile
@@ -1,5 +1,5 @@
1# 1#
2# Copyright (C) 2012 Broadcom Corporation 2# Copyright (C) 2012-2013 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
@@ -10,6 +10,6 @@
10# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details. 11# GNU General Public License for more details.
12 12
13obj-$(CONFIG_ARCH_BCM) := board_bcm.o bcm_kona_smc.o bcm_kona_smc_asm.o 13obj-$(CONFIG_ARCH_BCM) := board_bcm.o bcm_kona_smc.o bcm_kona_smc_asm.o kona.o
14plus_sec := $(call as-instr,.arch_extension sec,+sec) 14plus_sec := $(call as-instr,.arch_extension sec,+sec)
15AFLAGS_bcm_kona_smc_asm.o :=-Wa,-march=armv7-a$(plus_sec) 15AFLAGS_bcm_kona_smc_asm.o :=-Wa,-march=armv7-a$(plus_sec)
diff --git a/arch/arm/mach-bcm/board_bcm.c b/arch/arm/mach-bcm/board_bcm.c
index 28599326d4ad..1e49ec0399ad 100644
--- a/arch/arm/mach-bcm/board_bcm.c
+++ b/arch/arm/mach-bcm/board_bcm.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (C) 2012 Broadcom Corporation 2 * Copyright (C) 2012-2013 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
@@ -21,8 +21,8 @@
21#include <asm/mach/time.h> 21#include <asm/mach/time.h>
22#include <asm/hardware/cache-l2x0.h> 22#include <asm/hardware/cache-l2x0.h>
23 23
24
25#include "bcm_kona_smc.h" 24#include "bcm_kona_smc.h"
25#include "kona.h"
26 26
27static int __init kona_l2_cache_init(void) 27static int __init kona_l2_cache_init(void)
28{ 28{
@@ -40,13 +40,26 @@ static int __init kona_l2_cache_init(void)
40 return 0; 40 return 0;
41} 41}
42 42
43static void bcm_board_setup_restart(void)
44{
45 struct device_node *np;
46
47 np = of_find_compatible_node(NULL, NULL, "bcm,bcm11351");
48 if (np) {
49 if (of_device_is_available(np))
50 bcm_kona_setup_restart();
51 of_node_put(np);
52 }
53 /* Restart setup for other boards goes here */
54}
55
43static void __init board_init(void) 56static void __init board_init(void)
44{ 57{
45 of_platform_populate(NULL, of_default_bus_match_table, NULL, 58 of_platform_populate(NULL, of_default_bus_match_table, NULL,
46 &platform_bus); 59 &platform_bus);
47 60
48 bcm_kona_smc_init(); 61 bcm_kona_smc_init();
49 62 bcm_board_setup_restart();
50 kona_l2_cache_init(); 63 kona_l2_cache_init();
51} 64}
52 65
@@ -55,5 +68,6 @@ static const char * const bcm11351_dt_compat[] = { "bcm,bcm11351", NULL, };
55DT_MACHINE_START(BCM11351_DT, "Broadcom Application Processor") 68DT_MACHINE_START(BCM11351_DT, "Broadcom Application Processor")
56 .init_time = clocksource_of_init, 69 .init_time = clocksource_of_init,
57 .init_machine = board_init, 70 .init_machine = board_init,
71 .restart = bcm_kona_restart,
58 .dt_compat = bcm11351_dt_compat, 72 .dt_compat = bcm11351_dt_compat,
59MACHINE_END 73MACHINE_END
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
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}
diff --git a/arch/arm/mach-bcm/kona.h b/arch/arm/mach-bcm/kona.h
new file mode 100644
index 000000000000..291eca3e06ff
--- /dev/null
+++ b/arch/arm/mach-bcm/kona.h
@@ -0,0 +1,17 @@
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/reboot.h>
15
16void bcm_kona_setup_restart(void);
17void bcm_kona_restart(enum reboot_mode mode, const char *cmd);