From patchwork Mon Dec 11 17:21:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Lechner X-Patchwork-Id: 10105623 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 D7E8060360 for ; Mon, 11 Dec 2017 17:28:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB148296D7 for ; Mon, 11 Dec 2017 17:28:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFE67297F3; Mon, 11 Dec 2017 17:28:57 +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 43EDC296D7 for ; Mon, 11 Dec 2017 17:28:57 +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=3TSJPFF24YRwJHlLLi4JnSgDC4EIFLnKrVlgnhQH5KU=; b=Hj8rc4xY4qeI/zAqTngzWyRWbe G/iiFs6sNK6wSRX9+S89A1fgfHyhHtS4EqaXV8lygo36QAMPuvAogs012CpCb6oJYfYnMTxjJuT8x cJvehHpE5g55lpk9fZOZOblS02k7dTX7h9L/rBgnMU8rD6r+qYqrRc7L130lrgvO/brppfBqV55sI 2pmy2GOz6CHKh+yfHgV4sRZJ15aLHWYF/BYtVPmaGjahfMKhvk7SviV2mBd6OTYQmCgkkuBl2DaLY djcKfJ/zDeAdQdQ2wtxkam1k5pc4rE5XPqbnybbMIzkCk3LANl+M8OKax2Y0eBClDK7Na1HIIxk5F n7qFmXrA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eORso-0003aG-BW; Mon, 11 Dec 2017 17:28:50 +0000 Received: from vern.gendns.com ([206.190.152.46]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eORmp-0007AB-Rw for linux-arm-kernel@lists.infradead.org; Mon, 11 Dec 2017 17:22:42 +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=Jt8TVJrH3hNbs9jaNxMGXKeBQDnSa6PHZAMZDHa8hi8=; b=jYk/KqN2MWXBhU4CguDD2oSD4 CIJB+M3JVBxUN5fsu7QPdlPLS9X477GHVFP5ck3XiHJ3S87mGVC9uPhtmB2fwNpjjNUAeATFQixOE 4KB1nAM07t7cLoJzRkbPYpV+Cycwq236wGttI09ycmY/2/6unDphvirUOg14zIa5OI36XdGalvYrT sve2Ygj/kMVPO9a0JZX+VnmEqiAOxyGous9k2E6YpHROC71rbm/gncYLJGs9zQYnNfAUFq5aT29O6 2LjfSH4ZPAXCvQNm1Xmidnr5GJcYj4cwIqQ1yJ6fjplXlKL6dzMUHtyMwCEb+tApHo0ZvS4c46l8r gEZF94SBA==; Received: from 108-198-5-147.lightspeed.okcbok.sbcglobal.net ([108.198.5.147]:54388 helo=freyr.lechnology.com) by vern.gendns.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-SHA256:128) (Exim 4.89) (envelope-from ) id 1eORjn-001ga6-OW; Mon, 11 Dec 2017 12:19:32 -0500 From: David Lechner To: linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org Subject: [PATCH 1/2] watchdog: davinci_wdt: add restart function Date: Mon, 11 Dec 2017 11:21:08 -0600 Message-Id: <1513012869-7647-2-git-send-email-david@lechnology.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513012869-7647-1-git-send-email-david@lechnology.com> References: <1513012869-7647-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-20171211_092239_925524_464A1E1C X-CRM114-Status: UNSURE ( 8.76 ) 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);