From patchwork Wed Dec 18 15:18:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Jensen X-Patchwork-Id: 3370541 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7DDA49F314 for ; Wed, 18 Dec 2013 15:18:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 68F4D205D4 for ; Wed, 18 Dec 2013 15:18:52 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E8D8420430 for ; Wed, 18 Dec 2013 15:18:50 +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 1VtItY-0000Kc-43; Wed, 18 Dec 2013 15:18:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VtItV-0000iF-KU; Wed, 18 Dec 2013 15:18:41 +0000 Received: from mail-la0-x22f.google.com ([2a00:1450:4010:c03::22f]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VtItR-0000hV-IZ for linux-arm-kernel@lists.infradead.org; Wed, 18 Dec 2013 15:18:39 +0000 Received: by mail-la0-f47.google.com with SMTP id ep20so3938255lab.34 for ; Wed, 18 Dec 2013 07:18:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=O38qiY/Yed+AOtJuBoVCSX4XO6Czl9JhlHfe/63SvCE=; b=v7fNzQD0dA61YsDWm/NILgc1pzKeqQaT7zJQE9jJEH8P73rxzf6Ok2bf8dkAjcYeqM SZ2ByEUBRTpWhd638NDp3kUMflnn9Wxw85Vmy8d8BAMIuNpNqOoUBRWLJvIfJo04DRmt d+L9n+EbyD8BJ6rQ7NKjLxfkIjzxaOn7sHJgMG9T3SYHWUZeie1OXZGR8Ycm3obI9UL6 U4pAyXh9kZT7MZ/zS/KXdmHu5ym2ViTU8hO5ln3wSC+L0VW95DRKWUtfy2allBxO51qk /RYSJiiGTdNLVpYjSDkybRpYN0lIDZrguiqsqtWXbK6MlnUmX9zo651Bjmf5noJCTJsE 5iuQ== X-Received: by 10.112.181.232 with SMTP id dz8mr1789818lbc.8.1387379895007; Wed, 18 Dec 2013 07:18:15 -0800 (PST) Received: from Ildjarn.ath.cx (static-213-115-41-10.sme.bredbandsbolaget.se. [213.115.41.10]) by mx.google.com with ESMTPSA id h11sm212968lbg.8.2013.12.18.07.18.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 18 Dec 2013 07:18:14 -0800 (PST) From: Jonas Jensen To: linux-watchdog@vger.kernel.org Subject: [PATCH] watchdog: mach-moxart: add restart handler Date: Wed, 18 Dec 2013 16:18:03 +0100 Message-Id: <1387379883-16525-1-git-send-email-jonas.jensen@gmail.com> X-Mailer: git-send-email 1.8.2.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131218_101837_769264_F501CD60 X-CRM114-Status: GOOD ( 12.16 ) X-Spam-Score: -2.0 (--) Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, Jonas Jensen , wim@iguana.be, arm@kernel.org, linux@roeck-us.net, 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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 mach-moxart lacks a separate register for reset; as a workaround, add a function that can be hooked to arm_pm_restart. Signed-off-by: Jonas Jensen Acked-by: Arnd Bergmann --- Notes: During review of this driver, the restart handler for moxart was removed, and moved to platform code under arch/arm/mach-moxart/. Since then, new considerations arrived, see replies from Arnd and Guenter: "[PATCH v4 1/2] ARM: mach-moxart: add MOXA ART SoC platform files" http://lists.infradead.org/pipermail/linux-arm-kernel/2013-December/219175.html I can move this to a new power/restart driver, but first, I want to hear what Wim or others think. Until there is a better solution, my motivation is that this uses the watchdog. The way I see it, the problem is that there is no separate register for reset, this was always a workaround for that. Applies to next-20131218 drivers/watchdog/moxart_wdt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/watchdog/moxart_wdt.c b/drivers/watchdog/moxart_wdt.c index 4166e4d..4aa3a8a 100644 --- a/drivers/watchdog/moxart_wdt.c +++ b/drivers/watchdog/moxart_wdt.c @@ -19,6 +19,8 @@ #include #include +#include + #define REG_COUNT 0x4 #define REG_MODE 0x8 #define REG_ENABLE 0xC @@ -29,8 +31,17 @@ struct moxart_wdt_dev { unsigned int clock_frequency; }; +static struct moxart_wdt_dev *moxart_restart_ctx; + static int heartbeat; +static void moxart_wdt_restart(enum reboot_mode reboot_mode, const char *cmd) +{ + writel(1, moxart_restart_ctx->base + REG_COUNT); + writel(0x5ab9, moxart_restart_ctx->base + REG_MODE); + writel(0x03, moxart_restart_ctx->base + REG_ENABLE); +} + static int moxart_wdt_stop(struct watchdog_device *wdt_dev) { struct moxart_wdt_dev *moxart_wdt = watchdog_get_drvdata(wdt_dev); @@ -125,6 +136,9 @@ static int moxart_wdt_probe(struct platform_device *pdev) if (err) return err; + moxart_restart_ctx = moxart_wdt; + arm_pm_restart = moxart_wdt_restart; + dev_dbg(dev, "Watchdog enabled (heartbeat=%d sec, nowayout=%d)\n", moxart_wdt->dev.timeout, nowayout); @@ -135,6 +149,7 @@ static int moxart_wdt_remove(struct platform_device *pdev) { struct moxart_wdt_dev *moxart_wdt = platform_get_drvdata(pdev); + arm_pm_restart = NULL; moxart_wdt_stop(&moxart_wdt->dev); watchdog_unregister_device(&moxart_wdt->dev);