From patchwork Mon Mar 25 13:30:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 2331321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 9FD32DF24C for ; Mon, 25 Mar 2013 13:38:54 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UK7Yo-0005Qc-Eb; Mon, 25 Mar 2013 13:35:38 +0000 Received: from mail.free-electrons.com ([94.23.35.102]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UK7UA-0003Cr-TL for linux-arm-kernel@lists.infradead.org; Mon, 25 Mar 2013 13:30:56 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id 581A0E51; Mon, 25 Mar 2013 14:30:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mail.free-electrons.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.3.2 Received: from localhost (col31-4-88-188-83-94.fbx.proxad.net [88.188.83.94]) by mail.free-electrons.com (Postfix) with ESMTPSA id AEEDF864; Mon, 25 Mar 2013 14:30:49 +0100 (CET) From: Maxime Ripard To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 09/10] ARM: sunxi: Rework the restart code Date: Mon, 25 Mar 2013 14:30:32 +0100 Message-Id: <1364218233-29636-10-git-send-email-maxime.ripard@free-electrons.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1364218233-29636-1-git-send-email-maxime.ripard@free-electrons.com> References: <1364218233-29636-1-git-send-email-maxime.ripard@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130325_093051_174591_4D529972 X-CRM114-Status: GOOD ( 15.84 ) X-Spam-Score: -3.2 (---) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-3.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -1.3 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Russell King , linux-kernel@vger.kernel.org, sunny@allwinnertech.com, shuge@allwinnertech.com, Maxime Ripard , kevin@allwinnertech.com 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 The Allwinner sun6i (A31) has a slightly different watchdog, that doesn't allow to use the already existing restart code. Rework a bit the restart code to allow to plug in more easily different restart handlers depending on the device tree. In the past, we were also meaning sunxi as a generic name covering all Allwinner SoCs. This won't be true anymore with the A31 (sun6i) that differs pretty much from sun4i and sun5i, and we will end up having sunxi, for sun4i and sun5i, and sun6i, which is neither consistent nor convenient. So, while we're at it, also change sunxi to sun4i. Signed-off-by: Maxime Ripard --- arch/arm/mach-sunxi/sunxi.c | 58 ++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/arch/arm/mach-sunxi/sunxi.c b/arch/arm/mach-sunxi/sunxi.c index 634e335..e6f5101 100644 --- a/arch/arm/mach-sunxi/sunxi.c +++ b/arch/arm/mach-sunxi/sunxi.c @@ -22,50 +22,63 @@ #include #include +#include #include "sunxi.h" -#define WATCHDOG_CTRL_REG 0x00 -#define WATCHDOG_CTRL_RESTART (1 << 0) -#define WATCHDOG_MODE_REG 0x04 -#define WATCHDOG_MODE_ENABLE (1 << 0) -#define WATCHDOG_MODE_RESET_ENABLE (1 << 1) +#define SUN4I_WATCHDOG_CTRL_REG 0x00 +#define SUN4I_WATCHDOG_CTRL_RESTART (1 << 0) +#define SUN4I_WATCHDOG_MODE_REG 0x04 +#define SUN4I_WATCHDOG_MODE_ENABLE (1 << 0) +#define SUN4I_WATCHDOG_MODE_RESET_ENABLE (1 << 1) static void __iomem *wdt_base; -static void sunxi_setup_restart(void) -{ - struct device_node *np = of_find_compatible_node(NULL, NULL, - "allwinner,sunxi-wdt"); - if (WARN(!np, "unable to setup watchdog restart")) - return; - - wdt_base = of_iomap(np, 0); - WARN(!wdt_base, "failed to map watchdog base address"); -} - -static void sunxi_restart(char mode, const char *cmd) +static void sun4i_restart(char mode, const char *cmd) { if (!wdt_base) return; /* Enable timer and set reset bit in the watchdog */ - writel(WATCHDOG_MODE_ENABLE | WATCHDOG_MODE_RESET_ENABLE, - wdt_base + WATCHDOG_MODE_REG); + writel(SUN4I_WATCHDOG_MODE_ENABLE | SUN4I_WATCHDOG_MODE_RESET_ENABLE, + wdt_base + SUN4I_WATCHDOG_MODE_REG); /* * Restart the watchdog. The default (and lowest) interval * value for the watchdog is 0.5s. */ - writel(WATCHDOG_CTRL_RESTART, wdt_base + WATCHDOG_CTRL_REG); + writel(SUN4I_WATCHDOG_CTRL_RESTART, wdt_base + SUN4I_WATCHDOG_CTRL_REG); while (1) { mdelay(5); - writel(WATCHDOG_MODE_ENABLE | WATCHDOG_MODE_RESET_ENABLE, - wdt_base + WATCHDOG_MODE_REG); + writel(SUN4I_WATCHDOG_MODE_ENABLE | SUN4I_WATCHDOG_MODE_RESET_ENABLE, + wdt_base + SUN4I_WATCHDOG_MODE_REG); } } +static struct of_device_id sunxi_restart_ids[] = { + { .compatible = "allwinner,sun4i-wdt", .data = sun4i_restart }, + { /*sentinel*/ } +}; + +static void sunxi_setup_restart(void) +{ + const struct of_device_id *of_id; + struct device_node *np; + + np = of_find_matching_node(NULL, sunxi_restart_ids); + if (WARN(!np, "unable to setup watchdog restart")) + return; + + wdt_base = of_iomap(np, 0); + WARN(!wdt_base, "failed to map watchdog base address"); + + of_id = of_match_node(sunxi_restart_ids, np); + WARN(!of_id, "restart function not available"); + + arm_pm_restart = of_id->data; +} + static struct map_desc sunxi_io_desc[] __initdata = { { .virtual = (unsigned long) SUNXI_REGS_VIRT_BASE, @@ -97,7 +110,6 @@ DT_MACHINE_START(SUNXI_DT, "Allwinner A1X (Device Tree)") .init_machine = sunxi_dt_init, .map_io = sunxi_map_io, .init_irq = irqchip_init, - .restart = sunxi_restart, .init_time = clocksource_of_init, .dt_compat = sunxi_board_dt_compat, MACHINE_END