From patchwork Thu Oct 31 06:27:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Andreoli X-Patchwork-Id: 3118921 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 01752BF924 for ; Thu, 31 Oct 2013 06:33:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A857203E6 for ; Thu, 31 Oct 2013 06:33:53 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 50CD7203E9 for ; Thu, 31 Oct 2013 06:33:52 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VblnW-0005OL-Ae; Thu, 31 Oct 2013 06:32:04 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vbln2-0008K5-OY; Thu, 31 Oct 2013 06:31:32 +0000 Received: from mail-ea0-x232.google.com ([2a00:1450:4013:c01::232]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vblm1-0008C1-5L for linux-arm-kernel@lists.infradead.org; Thu, 31 Oct 2013 06:30:39 +0000 Received: by mail-ea0-f178.google.com with SMTP id a15so1150738eae.9 for ; Wed, 30 Oct 2013 23:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:user-agent:date:from:to:cc:subject:references :content-disposition; bh=LF2FQ+u44MfeHpHIWPmfqGWysv8+zIli45yranKiwoY=; b=LW2zoslULqrFUL2FpCCbZrNswrGpPimwc8yglQxuO8AwT9nt1pFEQwdbItBC7ksRIP ti/w9zzn9YQ4nAD11kSNNpW+RLLKH3Guc6hx9z0VIpJyCg1uVHdwSufFGWWOxnR34XoA aQe6+Cs7NzV5v1A6WQ5Cobj0bQVJi9UGc2jNvb10jrhft8n4sDuudN6yqC3Ix1BnwmZS +vXYYP8+4auRoIMbs6n8BpcmjTZj9Aw2n323/xDOJAXqjn9cB25e+X41zkYJWLkxqrnb rm0XisQjbPRG7Ne3O4UbS/FWxTxomhjjv5cjidNumcUiXI3hgfXkACVKJqWzMHOT9J+5 i/Hg== X-Received: by 10.15.21.12 with SMTP id c12mr969034eeu.114.1383201007276; Wed, 30 Oct 2013 23:30:07 -0700 (PDT) Received: from shock.dandreoli.com (j115181.upc-j.chello.nl. [24.132.115.181]) by mx.google.com with ESMTPSA id j7sm4372449eeo.15.2013.10.30.23.30.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Oct 2013 23:30:04 -0700 (PDT) Received: by shock.dandreoli.com (Postfix, from userid 1000) id 53940340295; Thu, 31 Oct 2013 07:30:00 +0100 (CET) Message-Id: <20131031063000.108307682@linux.com> User-Agent: quilt/0.60-1 Date: Thu, 31 Oct 2013 07:27:15 +0100 From: Domenico Andreoli To: linux-arch@vger.kernel.org Subject: [PATCH 07/11] ARM: bcm2835: use the common machine reset handling References: <20131031062708.520968323@linux.com> Content-Disposition: inline; filename=arm-machine-reset-bcm2835.patch X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131031_023029_525291_1724556A X-CRM114-Status: GOOD ( 15.92 ) X-Spam-Score: -1.9 (-) Cc: Russell King , Arnd Bergmann , Stephen Warren , Ralf Baechle , Domenico Andreoli , linux-mips@lvger.kernel.org, Olof Johansson , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Domenico Andreoli Proof of concept: bcm2835 as provider of reset hooks. Cc: Stephen Warren Cc: Russell King Cc: Arnd Bergmann Cc: Olof Johansson Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Domenico Andreoli --- 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 #include #include +#include #include #include @@ -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