From patchwork Thu Feb 16 19:30:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 9578219 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 74253600C5 for ; Thu, 16 Feb 2017 19:31:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 686C22866A for ; Thu, 16 Feb 2017 19:31:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D47E2866D; Thu, 16 Feb 2017 19:31:37 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham 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 2458D2866A for ; Thu, 16 Feb 2017 19:31:36 +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=50FdoT7qOlcuRtxgKiCJh41gvYFVhFEJ1hvaSGni3QI=; b=M6Q3ZVSXHjSpQsudWgTy9eh7jg 2AwCM1jG+tf+9xRUl9NHi+kl6G7fC5fCwosYUDBvw0TiPuDNUcjUsSPAbM3iZ74tpe5YwjZhH6bfk Ye8l9Vv/XY2Ll4E/wpcM0oERuTRWvaStkKCj8VKz5U0LeY+xyjGW0r/A3K6wZ8feBFNftO4qZWY3Z 7fi8lkNDYa7rtaqBmrBQ3VBy8GaFthmCcERc6HAXeoOaYQCNCZDACg8twHTcEZZ+ZoBFaBtmqEyFU N4o0RQ0ktiQ1US2byZ8jJQ0FW3OeAONnIFnL11yDSyHNyMYE26sc81nPzb3kSb9J5xTJp0IpkXHQ+ 9oDiyyag==; 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 1ceRmB-0002sU-Nw; Thu, 16 Feb 2017 19:31:35 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ceRlv-0002eJ-Bc for linux-arm-kernel@lists.infradead.org; Thu, 16 Feb 2017 19:31:21 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id 0657220BA3; Thu, 16 Feb 2017 20:30:57 +0100 (CET) Received: from localhost (unknown [88.191.26.124]) by mail.free-electrons.com (Postfix) with ESMTPSA id D6ACD20B7A; Thu, 16 Feb 2017 20:30:56 +0100 (CET) From: Alexandre Belloni To: Guenter Roeck Subject: [PATCH v2 2/3] watchdog: sama5d4: Fix setting timeout when watchdog is disabled Date: Thu, 16 Feb 2017 20:30:52 +0100 Message-Id: <20170216193053.5546-2-alexandre.belloni@free-electrons.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170216193053.5546-1-alexandre.belloni@free-electrons.com> References: <20170216193053.5546-1-alexandre.belloni@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170216_113119_570417_34FC07E9 X-CRM114-Status: GOOD ( 10.64 ) 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: linux-watchdog@vger.kernel.org, Nicolas Ferre , linux-kernel@vger.kernel.org, Wim Van Sebroeck , Alexandre Belloni , linux-arm-kernel@lists.infradead.org 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 The datasheet states: "When setting the WDDIS bit, and while it is set, the fields WDV and WDD must not be modified." Ensure WDDIS is not set when changing the timeout and set it afterwards if the watchdog was disabled. Signed-off-by: Alexandre Belloni --- Changes in v2: - new patch drivers/watchdog/sama5d4_wdt.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c index 2c6f5a70ae67..2a60251806d2 100644 --- a/drivers/watchdog/sama5d4_wdt.c +++ b/drivers/watchdog/sama5d4_wdt.c @@ -90,11 +90,18 @@ static int sama5d4_wdt_set_timeout(struct watchdog_device *wdd, u32 reg; reg = wdt_read(wdt, AT91_WDT_MR); + + if (reg & AT91_WDT_WDDIS) + wdt_write(wdt, AT91_WDT_MR, reg & ~AT91_WDT_WDDIS); + reg &= ~AT91_WDT_WDV; reg &= ~AT91_WDT_WDD; reg |= AT91_WDT_SET_WDV(value); reg |= AT91_WDT_SET_WDD(value); - wdt_write(wdt, AT91_WDT_MR, reg); + wdt_write(wdt, AT91_WDT_MR, reg & ~AT91_WDT_WDDIS); + + if (reg & AT91_WDT_WDDIS) + wdt_write(wdt, AT91_WDT_MR, reg); wdd->timeout = timeout;