From patchwork Sun Jan 7 03:10:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 10148097 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E928D60247 for ; Sun, 7 Jan 2018 03:11:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC98628906 for ; Sun, 7 Jan 2018 03:11:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF9902890B; Sun, 7 Jan 2018 03:11:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8F89328906 for ; Sun, 7 Jan 2018 03:11:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ms47q1GrMdfE2p6V/8Bun0ifrKHEp1YSBVqZyf6czXg=; b=ojuersuQNGJVvZWcNq0/bN5X5M qzQHYa7CSjMuu9ltbvaRYGYdBZvB7Q0Jctk4maW0pSpR8Ts5QlrH64DQSZkZ6bPkIab9M3K5FaAmP EkwJDpQELlus93tj3OCgflqGfeQpVHLEXmABWwDQSvKHXuSPqYPIjmWt1mnXsiZP9qxdWCuAC9wrO wxb9meKnNOTapJoZQOFjmcd7/S6ArAVZ7KmRAPS1sW/cwrJA207B8cmdCnXoku4EiZMFLBSfOLZdj xYahx1UL6CNoXBSKkvECaa7r+tRhtfGX4R/zAlKWTLYSfeERR6eDOyXHL+MoFdnWeQPQKU/ZSeTQR MnZSXi7Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eY1Mq-0008VC-9z; Sun, 07 Jan 2018 03:11:24 +0000 Received: from vern.gendns.com ([206.190.152.46]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eY1Ml-0008Q0-NB for linux-arm-kernel@lists.infradead.org; Sun, 07 Jan 2018 03:11:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lechnology.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject :Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=7Ath/+9bacl7lLcUsZjkxM+ReIz4+MYY9yAm36GGlnU=; b=mPkk4YQ83GeH77VgFG8pc/ubV STdhs4zzwfpePc2+WUC4y28EXLZAluNxUlp2dj0z59g1V4qJZQ7IJ4x93LKpCJwDA8OcZFMbyC4Og hAAIhGC5z7+uC07gCDe6ZzxdymwkSPFGEn+TzDPhpo2Fo7wgw2BrG2KfVhCb6Zi1kYM5ZBH6dhJrA w1peL5VZ1QRGg+m/7h19PhSogwhGb6FiXbiTSxpBNMtDuIYRqOONGpW95w7+K3DtuZtB2X3TriMvz 1gVJ3n+ZfkZeeMAfQ8i9KMTTdQUM23OZmQrEWwUM0xuVpg3pTL5gBzWOpIflffz20X7iS8KfZGWQ8 UU0Gj1lZA==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:41534 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.89) (envelope-from ) id 1eY1Ln-000Y7e-48; Sat, 06 Jan 2018 22:10:19 -0500 From: David Lechner To: linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org Subject: [PATCH v2 1/2] watchdog: davinci_wdt: add restart function Date: Sat, 6 Jan 2018 21:10:14 -0600 Message-Id: <1515294615-5473-2-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515294615-5473-1-git-send-email-david@lechnology.com> References: <1515294615-5473-1-git-send-email-david@lechnology.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - lists.infradead.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180106_191119_793642_BCCF46FA X-CRM114-Status: UNSURE ( 8.63 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Lechner , Kevin Hilman , Sekhar Nori , linux-kernel@vger.kernel.org, Wim Van Sebroeck , Guenter Roeck MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This adds a restart function to the davinci watchdog timer driver. This is copied from arch/arm/mach-davinci/time.c and will allow us to remove the code from there. Signed-off-by: David Lechner Reviewed-by: Guenter Roeck --- drivers/watchdog/davinci_wdt.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c index 2f46487..3e4c592 100644 --- a/drivers/watchdog/davinci_wdt.c +++ b/drivers/watchdog/davinci_wdt.c @@ -140,6 +140,42 @@ static unsigned int davinci_wdt_get_timeleft(struct watchdog_device *wdd) return wdd->timeout - timer_counter; } +static int davinci_wdt_restart(struct watchdog_device *wdd, + unsigned long action, void *data) +{ + struct davinci_wdt_device *davinci_wdt = watchdog_get_drvdata(wdd); + u32 tgcr, wdtcr; + + /* disable, internal clock source */ + iowrite32(0, davinci_wdt->base + TCR); + + /* reset timer, set mode to 64-bit watchdog, and unreset */ + tgcr = 0; + iowrite32(tgcr, davinci_wdt->base + TGCR); + tgcr = TIMMODE_64BIT_WDOG | TIM12RS_UNRESET | TIM34RS_UNRESET; + iowrite32(tgcr, davinci_wdt->base + TGCR); + + /* clear counter and period regs */ + iowrite32(0, davinci_wdt->base + TIM12); + iowrite32(0, davinci_wdt->base + TIM34); + iowrite32(0, davinci_wdt->base + PRD12); + iowrite32(0, davinci_wdt->base + PRD34); + + /* put watchdog in pre-active state */ + wdtcr = WDKEY_SEQ0 | WDEN; + iowrite32(wdtcr, davinci_wdt->base + WDTCR); + + /* put watchdog in active state */ + wdtcr = WDKEY_SEQ1 | WDEN; + iowrite32(wdtcr, davinci_wdt->base + WDTCR); + + /* write an invalid value to the WDKEY field to trigger a restart */ + wdtcr = 0x00004000; + iowrite32(wdtcr, davinci_wdt->base + WDTCR); + + return 0; +} + static const struct watchdog_info davinci_wdt_info = { .options = WDIOF_KEEPALIVEPING, .identity = "DaVinci/Keystone Watchdog", @@ -151,6 +187,7 @@ static const struct watchdog_ops davinci_wdt_ops = { .stop = davinci_wdt_ping, .ping = davinci_wdt_ping, .get_timeleft = davinci_wdt_get_timeleft, + .restart = davinci_wdt_restart, }; static int davinci_wdt_probe(struct platform_device *pdev) @@ -195,6 +232,7 @@ static int davinci_wdt_probe(struct platform_device *pdev) watchdog_set_drvdata(wdd, davinci_wdt); watchdog_set_nowayout(wdd, 1); + watchdog_set_restart_priority(wdd, 128); wdt_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); davinci_wdt->base = devm_ioremap_resource(dev, wdt_mem);