From: cavokz@gmail.com (Domenico Andreoli)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/6] ARM: bcm476x: Add restart hook
Date: Sun, 07 Oct 2012 03:53:05 +0200 [thread overview]
Message-ID: <20121007015407.522256287@gmail.com> (raw)
In-Reply-To: 20121007015300.828366635@gmail.com
An embedded and charset-unspecified text was scrubbed...
Name: arm-bcm476x-add-restart-hook.patch
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121007/d0a941f9/attachment.ksh>
WARNING: multiple messages have this Message-ID (diff)
From: Domenico Andreoli <cavokz@gmail.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Domenico Andreoli <domenico.andreoli@linux.com>,
devicetree-discuss@lists.ozlabs.org
Subject: [PATCH 5/6] ARM: bcm476x: Add restart hook
Date: Sun, 07 Oct 2012 03:53:05 +0200 [thread overview]
Message-ID: <20121007015407.522256287@gmail.com> (raw)
In-Reply-To: 20121007015300.828366635@gmail.com
[-- Attachment #1: arm-bcm476x-add-restart-hook.patch --]
[-- Type: text/plain, Size: 4203 bytes --]
From: Domenico Andreoli <domenico.andreoli@linux.com>
Restart hook implementation for the BCM476x SoC (uses the watchdog).
Signed-off-by: Domenico Andreoli <domenico.andreoli@linux.com>
---
Documentation/devicetree/bindings/watchdog/brcm,bcm476x-pm-wdt.txt | 13 ++
arch/arm/boot/dts/bcm476x.dtsi | 5 +
arch/arm/mach-bcm476x/bcm476x.c | 66 ++++++++++
3 files changed, 84 insertions(+)
Index: b/Documentation/devicetree/bindings/watchdog/brcm,bcm476x-pm-wdt.txt
===================================================================
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/brcm,bcm476x-pm-wdt.txt
@@ -0,0 +1,13 @@
+BCM476x Watchdog timer
+
+Required properties:
+
+- compatible : should be "brcm,bcm476x-pm-wdt"
+- reg : Specifies base physical address and size of the registers.
+
+Example:
+
+watchdog {
+ compatible = "brcm,bcm476x-pm-wdt";
+ reg = <0xbd000 0x1000>;
+};
Index: b/arch/arm/boot/dts/bcm476x.dtsi
===================================================================
--- a/arch/arm/boot/dts/bcm476x.dtsi
+++ b/arch/arm/boot/dts/bcm476x.dtsi
@@ -28,6 +28,11 @@
clock-frequency = <32000>;
};
+ watchdog {
+ compatible = "brcm,bcm476x-pm-wdt";
+ reg = <0xbd000 0x1000>;
+ };
+
vic0: interrupt-controller@80000 {
compatible = "brcm,bcm476x-pl192", "arm,pl192-vic", "arm,primecell";
reg = <0x80000 0x1000>;
Index: b/arch/arm/mach-bcm476x/bcm476x.c
===================================================================
--- a/arch/arm/mach-bcm476x/bcm476x.c
+++ b/arch/arm/mach-bcm476x/bcm476x.c
@@ -15,7 +15,9 @@
*/
#include <linux/init.h>
+#include <linux/delay.h>
#include <linux/of_irq.h>
+#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/bcm476x_timer.h>
#include <linux/clk/bcm476x.h>
@@ -28,6 +30,17 @@
#define BCM476X_PERIPH_VIRT 0xd0080000
#define BCM476X_PERIPH_SIZE SZ_512K
+#define BCM476X_WDT_LOAD 0x000
+#define BCM476X_WDT_CTRL 0x008
+#define BCM476X_WDT_INTCLR 0x00c
+#define BCM476X_WDT_LOCK 0xc00
+
+#define BCM476X_WDT_PASSWORD 0x1acce551
+#define BCM476X_WDT_INTEN BIT(0)
+#define BCM476X_WDT_RESEN BIT(1)
+
+static void __iomem *wdt_regs;
+
static struct map_desc io_map __initdata = {
.virtual = BCM476X_PERIPH_VIRT,
.pfn = __phys_to_pfn(BCM476X_PERIPH_PHYS),
@@ -40,10 +53,62 @@ void __init bcm476x_map_io(void)
iotable_init(&io_map, 1);
}
+/*
+ * The machine restart method can be called from an atomic context so we won't
+ * be able to ioremap the regs then.
+ */
+static void bcm476x_setup_restart(void)
+{
+ struct device_node *np;
+
+ np = of_find_compatible_node(NULL, NULL, "brcm,bcm476x-pm-wdt");
+ if (WARN(!np, "unable to setup watchdog restart"))
+ return;
+
+ wdt_regs = of_iomap(np, 0);
+ WARN(!wdt_regs, "Can't remap watchdog registers");
+
+ /* unlock watchdog registers */
+ writel(BCM476X_WDT_PASSWORD, wdt_regs + BCM476X_WDT_LOCK);
+ /* disable watchdog */
+ writel(0, wdt_regs + BCM476X_WDT_CTRL);
+ /* lock watchdog registers */
+ writel(1, wdt_regs + BCM476X_WDT_LOCK);
+}
+
+static void bcm476x_restart(char mode, const char *cmd)
+{
+ if (!wdt_regs)
+ return;
+
+ /* unlock watchdog registers */
+ writel(BCM476X_WDT_PASSWORD, wdt_regs + BCM476X_WDT_LOCK);
+
+ /* disable watchdog */
+ writel(0, wdt_regs + BCM476X_WDT_CTRL);
+ udelay(20);
+
+ /* clear the irq status */
+ writel(1, wdt_regs + BCM476X_WDT_INTCLR);
+ udelay(20);
+
+ /* expire after 5 cycles (~156us) */
+ writel(5, wdt_regs + BCM476X_WDT_LOAD);
+ /* enable watchdog */
+ writel(BCM476X_WDT_INTEN | BCM476X_WDT_RESEN,
+ wdt_regs + BCM476X_WDT_CTRL);
+
+ /* lock watchdog registers */
+ writel(1, wdt_regs + BCM476X_WDT_LOCK);
+ /* wait the bite */
+ udelay(400);
+}
+
void __init bcm476x_init(void)
{
int ret;
+ bcm476x_setup_restart();
bcm476x_init_clocks();
ret = of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
@@ -74,5 +139,6 @@ DT_MACHINE_START(BCM476X, "Broadcom BCM4
.handle_irq = vic_handle_irq,
.init_machine = bcm476x_init,
.timer = &bcm476x_timer,
+ .restart = bcm476x_restart,
.dt_compat = bcm476x_compat
MACHINE_END
next prev parent reply other threads:[~2012-10-07 1:53 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-07 1:53 [PATCH 0/6] ARM: Add support for Broadcom BCM476x SoCs Domenico Andreoli
2012-10-07 1:53 ` Domenico Andreoli
2012-10-07 1:53 ` [PATCH 1/6] ARM: bcm476x: Add infrastructure Domenico Andreoli
2012-10-07 1:53 ` Domenico Andreoli
2012-10-07 19:57 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-07 19:57 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-07 22:54 ` Domenico Andreoli
2012-10-07 22:54 ` Domenico Andreoli
2012-10-08 13:13 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-08 13:13 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-09 2:37 ` Stephen Warren
2012-10-09 2:37 ` Stephen Warren
2012-10-09 11:50 ` Domenico Andreoli
2012-10-09 11:50 ` Domenico Andreoli
2012-10-08 11:50 ` Florian Fainelli
2012-10-08 11:50 ` Florian Fainelli
2012-10-09 2:41 ` Stephen Warren
2012-10-09 2:41 ` Stephen Warren
2012-10-08 12:14 ` Thomas Petazzoni
2012-10-08 12:14 ` Thomas Petazzoni
2012-10-09 11:52 ` Domenico Andreoli
2012-10-09 11:52 ` Domenico Andreoli
2012-10-09 2:48 ` Stephen Warren
2012-10-09 2:48 ` Stephen Warren
2012-10-09 11:54 ` Domenico Andreoli
2012-10-09 11:54 ` Domenico Andreoli
2012-10-09 3:08 ` Stephen Warren
2012-10-09 3:08 ` Stephen Warren
2012-10-09 11:55 ` Domenico Andreoli
2012-10-09 11:55 ` Domenico Andreoli
2012-10-09 9:18 ` Arnd Bergmann
2012-10-09 9:18 ` Arnd Bergmann
2012-10-09 22:58 ` Domenico Andreoli
2012-10-09 22:58 ` Domenico Andreoli
2012-10-10 6:29 ` Arnd Bergmann
2012-10-10 6:29 ` Arnd Bergmann
2012-10-12 7:06 ` Domenico Andreoli
2012-10-12 7:06 ` Domenico Andreoli
2012-10-12 7:26 ` Thomas Petazzoni
2012-10-12 7:26 ` Thomas Petazzoni
2012-10-12 8:03 ` Arnd Bergmann
2012-10-12 8:03 ` Arnd Bergmann
2012-10-12 8:12 ` Thomas Petazzoni
2012-10-12 8:12 ` Thomas Petazzoni
2012-10-12 10:48 ` Arnd Bergmann
2012-10-12 10:48 ` Arnd Bergmann
2012-10-12 11:01 ` Thomas Petazzoni
2012-10-12 11:01 ` Thomas Petazzoni
2012-10-12 11:17 ` Arnd Bergmann
2012-10-12 11:17 ` Arnd Bergmann
2012-10-07 1:53 ` [PATCH 2/6] ARM: bcm476x: Add system timer Domenico Andreoli
2012-10-07 1:53 ` Domenico Andreoli
2012-10-08 11:50 ` Florian Fainelli
2012-10-08 11:50 ` Florian Fainelli
2012-10-09 2:43 ` Stephen Warren
2012-10-09 2:43 ` Stephen Warren
2012-10-09 23:04 ` Domenico Andreoli
2012-10-09 23:04 ` Domenico Andreoli
2012-10-07 1:53 ` [PATCH 3/6] ARM: bcm476x: Add sched clock Domenico Andreoli
2012-10-07 1:53 ` Domenico Andreoli
2012-10-09 2:54 ` Stephen Warren
2012-10-09 2:54 ` Stephen Warren
2012-10-07 1:53 ` [PATCH 4/6] ARM: bcm476x: Add stub clock driver Domenico Andreoli
2012-10-07 1:53 ` Domenico Andreoli
2012-10-09 3:00 ` Stephen Warren
2012-10-09 3:00 ` Stephen Warren
2012-10-12 14:52 ` Mike Turquette
2012-10-12 14:52 ` Mike Turquette
2012-10-12 15:28 ` Domenico Andreoli
2012-10-12 15:28 ` Domenico Andreoli
2012-10-07 1:53 ` Domenico Andreoli [this message]
2012-10-07 1:53 ` [PATCH 5/6] ARM: bcm476x: Add restart hook Domenico Andreoli
2012-10-07 1:53 ` [PATCH 6/6] ARM: bcm476x: Instantiate console UART Domenico Andreoli
2012-10-07 1:53 ` Domenico Andreoli
2012-10-07 20:03 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-07 20:03 ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-07 23:14 ` Domenico Andreoli
2012-10-07 23:14 ` Domenico Andreoli
2012-10-09 3:06 ` Stephen Warren
2012-10-09 3:06 ` Stephen Warren
2012-10-09 23:37 ` Domenico Andreoli
2012-10-09 23:37 ` Domenico Andreoli
2012-10-07 5:22 ` [PATCH 0/6] ARM: Add support for Broadcom BCM476x SoCs Stephen Warren
2012-10-07 5:22 ` Stephen Warren
2012-10-07 10:14 ` Domenico Andreoli
2012-10-07 10:14 ` Domenico Andreoli
2012-10-09 2:44 ` Stephen Warren
2012-10-09 2:44 ` Stephen Warren
2012-10-09 23:57 ` Domenico Andreoli
2012-10-09 23:57 ` Domenico Andreoli
2012-10-07 19:47 ` Olof Johansson
2012-10-07 19:47 ` Olof Johansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121007015407.522256287@gmail.com \
--to=cavokz@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.