Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5695126ybn; Sun, 29 Sep 2019 03:58:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwH7xVh3DFCTqSsJKwJ6AvBUN/5IaYKz+QFAyBlXGbrA3Ei17H7TqR18KVCdNNOoIat4wrO X-Received: by 2002:a50:b6a8:: with SMTP id d37mr14008575ede.63.1569754699019; Sun, 29 Sep 2019 03:58:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569754699; cv=none; d=google.com; s=arc-20160816; b=SJiUvGJNtVTDrESKHWosCs3vf8fq0z9JNG8Aqbl5qiIrm++IM1SBNEpu3hgmJT9LOZ 2uqb6s0rMRBBAY30/EJWsE0KQXYp2zIidG8NC7d/LTD/MPni2kWwhkkhxBQ00l8lvS/B h1SNe4qSJ2zhYs2dBWctLaaOai28+I3nFoUb5DtFqmoKLvcgCHtGLEMSCdTjsWad19Ab 2/EuBtDApkdHxMoRnant3mgMPP1Oy/APrMBnHw5bMVNd+mmoKYHfywYJ5YOp40ezcYnH lbeWBAcOJruWmBjTgDBPgJVz/x2HlJxSUhkTd2Dun53LDMVTGH4N9YiYUrObNlDM4v5H oTGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=tfEUSxGJuV/k2L7STmI1nsyUMH9st+U/7AAQSpJp3B4=; b=xD0lkUF8bgtLjgLUesIeGqML2FNNCzSoX/ICteoeSmE8EfxCmbtOSD6j06YbGwHngq bOh5+pRxJC2W7wX7vilNT35+tRF4vNSBdcj9qwp8MJ7IPTHaF0XNJJExteZ04PEtc45J NLwc+EG0NLb4sQ4W0ydmO6sHEqXNWfMBiyoEJQXxI971iFGlcizNImDLPPWg2UBRNaCp 8vmRI8gVh+w4Bzfle3HyG3Ida6v1bmqrBWmDwnzT1jlLH4g/dM5eYynSThyUkQz2AM/7 arIN3JQZYnONNGK2+q42hWb94DMozsIIppL7cvaUlMZmWeucUxtyw3AsVYo0csTTnIWi bqnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6si5218030edb.235.2019.09.29.03.57.54; Sun, 29 Sep 2019 03:58:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728994AbfI2Kxz (ORCPT + 99 others); Sun, 29 Sep 2019 06:53:55 -0400 Received: from mail-sz.amlogic.com ([211.162.65.117]:6100 "EHLO mail-sz.amlogic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725974AbfI2Kxz (ORCPT ); Sun, 29 Sep 2019 06:53:55 -0400 Received: from droid12-sz.software.amlogic (10.28.8.22) by mail-sz.amlogic.com (10.28.11.5) with Microsoft SMTP Server id 15.1.1591.10; Sun, 29 Sep 2019 18:53:53 +0800 From: Xingyu Chen To: Wim Van Sebroeck , Guenter Roeck , Kevin Hilman , Neil Armstrong CC: Xingyu Chen , Jerome Brunet , Qianggui Song , Jianxin Pan , , , , Subject: [PATCH] watchdog: meson: Fix the wrong value of left time Date: Sun, 29 Sep 2019 18:53:49 +0800 Message-ID: <1569754429-17287-1-git-send-email-xingyu.chen@amlogic.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.28.8.22] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The left time value is wrong when we get it by sysfs. The left time value should be equal to preset timeout value minus elapsed time value. According to the Meson-GXB/GXL datasheets which can be found at [0], the timeout value is saved to BIT[0-15] of the WATCHDOG_TCNT, and elapsed time value is saved to BIT[16-31] of the WATCHDOG_TCNT. [0]: http://linux-meson.com Fixes: 683fa50f0e18 ("watchdog: Add Meson GXBB Watchdog Driver") Signed-off-by: Xingyu Chen --- drivers/watchdog/meson_gxbb_wdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/meson_gxbb_wdt.c b/drivers/watchdog/meson_gxbb_wdt.c index d17c1a6..5a9ca10 100644 --- a/drivers/watchdog/meson_gxbb_wdt.c +++ b/drivers/watchdog/meson_gxbb_wdt.c @@ -89,8 +89,8 @@ static unsigned int meson_gxbb_wdt_get_timeleft(struct watchdog_device *wdt_dev) reg = readl(data->reg_base + GXBB_WDT_TCNT_REG); - return ((reg >> GXBB_WDT_TCNT_CNT_SHIFT) - - (reg & GXBB_WDT_TCNT_SETUP_MASK)) / 1000; + return ((reg & GXBB_WDT_TCNT_SETUP_MASK) - + (reg >> GXBB_WDT_TCNT_CNT_SHIFT)) / 1000; } static const struct watchdog_ops meson_gxbb_wdt_ops = { -- 2.7.4