Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp409863pxu; Tue, 1 Dec 2020 14:34:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJy2CZmTy38vsOi19uuWWWGnBqI60E5sf0nbRFyPl5QMaxiXWFHZ2gOb4/1iXDE31A8gb7Ok X-Received: by 2002:a17:906:6a45:: with SMTP id n5mr5358163ejs.514.1606862047267; Tue, 01 Dec 2020 14:34:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606862047; cv=none; d=google.com; s=arc-20160816; b=aKyVGSd/2AAShmaDqjZbAQzVP/zokK/G+WeWy/2Fiv4ZxpZp/eblVRcJDdcdPo0XMc HsGzqbFnEDKtF7n+fPAEfaWidLcc0So+mvdyBhTC5p0CkxjGYntw1OxCT1BGhP0CxKyQ z5uGYI+cf3T7paCa4wMc8efUuwh1CU31q4oT7+FZ7zYT7v5aglPAYd07sjBcHAkykFzn kPepildYN5wezazfx5KnTJGmgmB+N8Fa7q7hlAmJCxisfxXnfsXu0hLRWRCEoFXAHXPp lpbVQjuV2GYLkejhBzDbyvx+eqzlYUWO+TBTnbwJrJcx/aFNS7brW4iSChq79f0swHBx fqGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=vEG75gVaYZavUOYGFxIsW6IiX8kAkQEFQnpm6EkGxA0=; b=j2QBbtOehVcTkvEzgNasLLcEAbdib/P3YZGIqZie9jCjlp7mma/Y9g1Qp60ggRiAHS UoODiq+HHGYWPMFVGQWBgu7W+Py4qB70xYtEVlDYzA+1ZIYaLTfqFgGKROZpKFUWIZ23 +QnajQZcOJKPVDOUqFyDwJT5FoMJHBP2JTHItSNpXdXAwtP16nlMeNCKJZirLe3lHeu0 49QqCqWr279imuQzNroaMhTi+NFVALpe+dWaCRC9gpCVPYnfYhc9BMq98JDQXPDTpPoL 4kfYe2ly/lqNWktwusuWZp7p1M0u6f39aUzL4/Qf5aINqVuL7i2n6KvFBuatUZ4gsRbi s9sg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si848804ejb.512.2020.12.01.14.33.44; Tue, 01 Dec 2020 14:34:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730270AbgLALDS (ORCPT + 99 others); Tue, 1 Dec 2020 06:03:18 -0500 Received: from relay10.mail.gandi.net ([217.70.178.230]:45183 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729425AbgLALDS (ORCPT ); Tue, 1 Dec 2020 06:03:18 -0500 Received: from localhost (lfbn-lyo-1-997-19.w86-194.abo.wanadoo.fr [86.194.74.19]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 71838240014; Tue, 1 Dec 2020 11:02:35 +0000 (UTC) Date: Tue, 1 Dec 2020 12:02:35 +0100 From: Alexandre Belloni To: Biwen Li Cc: leoyang.li@nxp.com, anson.huang@nxp.com, aisheng.dong@nxp.com, linux-kernel@vger.kernel.org, jiafei.pan@nxp.com, linux-rtc@vger.kernel.org, Biwen Li Subject: Re: [PATCH] rtc: pcf2127: clear the flag TSF1 before enabling interrupt generation Message-ID: <20201201110235.GC2401593@piout.net> References: <20201201084746.20135-1-biwen.li@oss.nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201201084746.20135-1-biwen.li@oss.nxp.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 01/12/2020 16:47:46+0800, Biwen Li wrote: > From: Biwen Li > > - clear the flag TSF1 before enabling interrupt generation > - properly set flag WD_CD for rtc chips(pcf2129, pca2129) > This change has to be a separate patch. > Signed-off-by: Biwen Li > --- > drivers/rtc/rtc-pcf2127.c | 21 ++++++++++++++++++++- > 1 file changed, 20 insertions(+), 1 deletion(-) > > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c > index 07a5630ec841..0a45e2512258 100644 > --- a/drivers/rtc/rtc-pcf2127.c > +++ b/drivers/rtc/rtc-pcf2127.c > @@ -601,6 +601,10 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap, > * Watchdog timer enabled and reset pin /RST activated when timed out. > * Select 1Hz clock source for watchdog timer. > * Note: Countdown timer disabled and not available. > + * For pca2129, pcf2129, only bit[7] is for Symbol WD_CD > + * of register watchdg_tim_ctl. The bit[6] is labeled > + * as T. Bits labeled as T must always be written with > + * logic 0. > */ > ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_WD_CTL, > PCF2127_BIT_WD_CTL_CD1 | > @@ -608,7 +612,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap, > PCF2127_BIT_WD_CTL_TF1 | > PCF2127_BIT_WD_CTL_TF0, > PCF2127_BIT_WD_CTL_CD1 | > - PCF2127_BIT_WD_CTL_CD0 | > + has_nvmem ? (PCF2127_BIT_WD_CTL_CD0) : (0) | I don't like that because has_nvmem has nothing to do with PCF2127_BIT_WD_CTL_CD0 and nothing guarantees that we won't ever get an RTC without RST but with NVRAM and that willprobbly be overlooked. > PCF2127_BIT_WD_CTL_TF1); > if (ret) { > dev_err(dev, "%s: watchdog config (wd_ctl) failed\n", __func__); > @@ -659,6 +663,21 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap, > return ret; > } > > + /* > + * Clear TSF1 field of ctrl1 register to clear interrupt > + * before enabling interrupt generation when > + * timestamp flag set. Unless the flag TSF1 won't > + * be cleared and the interrupt(INT pin) is > + * triggered continueously. > + */ > + ret = regmap_update_bits(pcf2127->regmap, PCF2127_REG_CTRL1, > + PCF2127_BIT_CTRL1_TSF1, > + 0); > + if (ret) { > + dev_err(dev, "%s: control and status register 1 (ctrl1) failed, ret = 0x%x\n", > + __func__, ret); > + return ret; > + } Doing that means ignoring timestamps taken while the system is offline. It also doesn't fully solve the issue because you are not clearing TSF2 here and also it never gets cleared by the driver later on so I guess you will get the interrupt storm once a timestamp is taken. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com