All of lore.kernel.org
 help / color / mirror / Atom feed
From: Domenico Andreoli <domenico.andreoli@linux.com>
To: linux-arch@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
	linux-mips@lvger.kernel.org,
	Russell King <linux@arm.linux.org.uk>,
	Arnd Bergmann <arnd@arndb.de>, Olof Johansson <olof@lixom.net>,
	Ralf Baechle <ralf@linux-mips.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Domenico Andreoli <domenico.andreoli@linux.com>
Subject: [PATCH 07/11] ARM: bcm2835: use the common machine reset handling
Date: Thu, 31 Oct 2013 07:27:15 +0100	[thread overview]
Message-ID: <20131031063000.108307682@linux.com> (raw)
In-Reply-To: 20131031062708.520968323@linux.com

[-- Attachment #1: arm-machine-reset-bcm2835.patch --]
[-- Type: text/plain, Size: 3733 bytes --]

From: Domenico Andreoli <domenico.andreoli@linux.com>

Proof of concept: bcm2835 as provider of reset hooks.

Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Olof Johansson <olof@lixom.net>
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Domenico Andreoli <domenico.andreoli@linux.com>
---
 arch/arm/mach-bcm2835/Kconfig   |    1 +
 arch/arm/mach-bcm2835/bcm2835.c |   30 ++++++++++++++++++------------
 2 files changed, 19 insertions(+), 12 deletions(-)

Index: b/arch/arm/mach-bcm2835/Kconfig
===================================================================
--- a/arch/arm/mach-bcm2835/Kconfig
+++ b/arch/arm/mach-bcm2835/Kconfig
@@ -8,6 +8,7 @@ config ARCH_BCM2835
 	select CLKSRC_OF
 	select CPU_V6
 	select GENERIC_CLOCKEVENTS
+	select MACHINE_RESET
 	select PINCTRL
 	select PINCTRL_BCM2835
 	help
Index: b/arch/arm/mach-bcm2835/bcm2835.c
===================================================================
--- a/arch/arm/mach-bcm2835/bcm2835.c
+++ b/arch/arm/mach-bcm2835/bcm2835.c
@@ -19,6 +19,7 @@
 #include <linux/of_platform.h>
 #include <linux/clk/bcm2835.h>
 #include <linux/clocksource.h>
+#include <linux/machine_reset.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
@@ -36,7 +37,8 @@
 #define BCM2835_PERIPH_VIRT	0xf0000000
 #define BCM2835_PERIPH_SIZE	SZ_16M
 
-static void __iomem *wdt_regs;
+static void bcm2835_restart(void *dev, enum reboot_mode mode, const char *cmd);
+static void bcm2835_power_off(void *dev);
 
 /*
  * The machine restart method can be called from an atomic context so we won't
@@ -44,21 +46,28 @@ static void __iomem *wdt_regs;
  */
 static void bcm2835_setup_restart(void)
 {
+	struct reset_hook hook;
+	void __iomem *wdt_regs;
 	struct device_node *np = of_find_compatible_node(NULL, NULL,
 						"brcm,bcm2835-pm-wdt");
 	if (WARN(!np, "unable to setup watchdog restart"))
 		return;
 
 	wdt_regs = of_iomap(np, 0);
-	WARN(!wdt_regs, "failed to remap watchdog regs");
+	if (WARN(!wdt_regs, "failed to remap watchdog regs"))
+		return;
+
+	reset_hook_init(&hook);
+	hook.restart = bcm2835_restart;
+	set_machine_reset(RESET_RESTART, &hook, wdt_regs);
+	hook.power_off = bcm2835_power_off;
+	set_machine_reset(RESET_POWER_OFF, &hook, wdt_regs);
 }
 
-static void bcm2835_restart(enum reboot_mode mode, const char *cmd)
+static void bcm2835_restart(void *dev, enum reboot_mode mode, const char *cmd)
 {
 	u32 val;
-
-	if (!wdt_regs)
-		return;
+	void __iomem *wdt_regs = dev;
 
 	/* use a timeout of 10 ticks (~150us) */
 	writel_relaxed(10 | PM_PASSWORD, wdt_regs + PM_WDOG);
@@ -76,9 +85,10 @@ static void bcm2835_restart(enum reboot_
  * indicate to bootcode.bin not to reboot, then most of the chip will be
  * powered off.
  */
-static void bcm2835_power_off(void)
+static void bcm2835_power_off(void *dev)
 {
 	u32 val;
+	void __iomem *wdt_regs = dev;
 
 	/*
 	 * We set the watchdog hard reset bit here to distinguish this reset
@@ -91,7 +101,7 @@ static void bcm2835_power_off(void)
 	writel_relaxed(val, wdt_regs + PM_RSTS);
 
 	/* Continue with normal reset mechanism */
-	bcm2835_restart(REBOOT_HARD, "");
+	bcm2835_restart(dev, REBOOT_HARD, "");
 }
 
 static struct map_desc io_map __initdata = {
@@ -111,9 +121,6 @@ static void __init bcm2835_init(void)
 	int ret;
 
 	bcm2835_setup_restart();
-	if (wdt_regs)
-		pm_power_off = bcm2835_power_off;
-
 	bcm2835_init_clocks();
 
 	ret = of_platform_populate(NULL, of_default_bus_match_table, NULL,
@@ -135,6 +142,5 @@ DT_MACHINE_START(BCM2835, "BCM2835")
 	.handle_irq = bcm2835_handle_irq,
 	.init_machine = bcm2835_init,
 	.init_time = clocksource_of_init,
-	.restart = bcm2835_restart,
 	.dt_compat = bcm2835_compat
 MACHINE_END

WARNING: multiple messages have this Message-ID (diff)
From: domenico.andreoli@linux.com (Domenico Andreoli)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 07/11] ARM: bcm2835: use the common machine reset handling
Date: Thu, 31 Oct 2013 07:27:15 +0100	[thread overview]
Message-ID: <20131031063000.108307682@linux.com> (raw)
In-Reply-To: 20131031062708.520968323@linux.com

An embedded and charset-unspecified text was scrubbed...
Name: arm-machine-reset-bcm2835.patch
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131031/0b56201b/attachment.ksh>

  parent reply	other threads:[~2013-10-31  6:30 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-31  6:27 [PATCH 00/11] RFC: Common machine reset handling Domenico Andreoli
2013-10-31  6:27 ` Domenico Andreoli
2013-10-31  6:27 ` [PATCH 01/11] machine-reset: platform generic handling Domenico Andreoli
2013-10-31  6:27   ` Domenico Andreoli
2013-10-31  6:27 ` [PATCH 02/11] ARM: use the common machine reset handling Domenico Andreoli
2013-10-31  6:27   ` Domenico Andreoli
2013-10-31  6:27 ` [PATCH 03/11] ARM64: " Domenico Andreoli
2013-10-31  6:27   ` Domenico Andreoli
2013-10-31  6:27 ` [PATCH 04/11] MIPS: " Domenico Andreoli
2013-10-31  6:27   ` Domenico Andreoli
2013-11-01  5:11   ` Vineet Gupta
2013-11-01  5:11     ` Vineet Gupta
2013-11-01  5:26     ` Domenico Andreoli
2013-11-01  5:26       ` Domenico Andreoli
2013-10-31  6:27 ` [PATCH 05/11] ARM: vexpress: consolidate machine reset func Domenico Andreoli
2013-10-31  6:27   ` Domenico Andreoli
2013-10-31  6:27 ` [PATCH 06/11] ARM: vexpress: use the common machine reset handling Domenico Andreoli
2013-10-31  6:27   ` Domenico Andreoli
2013-10-31  6:27 ` Domenico Andreoli [this message]
2013-10-31  6:27   ` [PATCH 07/11] ARM: bcm2835: " Domenico Andreoli
2013-10-31  6:27 ` [PATCH 08/11] ARM: u300: " Domenico Andreoli
2013-10-31  6:27   ` Domenico Andreoli
2013-10-31 14:40   ` Linus Walleij
2013-10-31 14:40     ` Linus Walleij
2013-10-31 15:19     ` Domenico Andreoli
2013-10-31 15:19       ` Domenico Andreoli
2013-10-31  6:27 ` [PATCH 09/11] ARM: tps65910: " Domenico Andreoli
2013-10-31  6:27   ` Domenico Andreoli
2013-10-31  6:27 ` [PATCH 10/11] max8907: " Domenico Andreoli
2013-10-31  6:27   ` Domenico Andreoli
2013-10-31  6:27 ` [PATCH 11/11] ARM: sp805: " Domenico Andreoli
2013-10-31  6:27   ` Domenico Andreoli
2013-10-31 10:21 ` [PATCH 00/11] RFC: Common " Russell King - ARM Linux
2013-10-31 10:21   ` Russell King - ARM Linux
2013-10-31 21:49 ` Stephen Warren
2013-10-31 21:49   ` Stephen Warren
2013-11-01  5:16   ` Domenico Andreoli
2013-11-01  5:16     ` Domenico Andreoli
2013-11-01 15:58     ` Stephen Warren
2013-11-01 15:58       ` Stephen Warren
2013-11-01 16:12       ` Russell King - ARM Linux
2013-11-01 16:12         ` Russell King - ARM Linux

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=20131031063000.108307682@linux.com \
    --to=domenico.andreoli@linux.com \
    --cc=arnd@arndb.de \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mips@lvger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=olof@lixom.net \
    --cc=ralf@linux-mips.org \
    --cc=swarren@wwwdotorg.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.