From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 54CC4CA101B for ; Fri, 30 Aug 2024 22:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bdFbgMzvJfpDhPePQ3r4tXcwVqtf83V3DSLfXhWmeh4=; b=BUqnJUH9wnk6eNieglBrDqc7nN QUS5+esM3Nj0VX03B8xWrI9WmTTZt8f3GylCnjoQlAtYMuRbUNJBOVgqkK22ZtMZzvJu5QfSd+Gzp +FKwQKdvihSbweIu3N5uehxQ3U1UrSPhAdFm/pDUAdXjJjMmfnuE7hdmYYpTLrdOVQa6XTGWN5OSi wIziVnM0xeyzvlL7uooCRarKPI8Rcr5+x+t1X4ca4gb6zDB4Z0uHe5nbYriPLVmiIoeznAii/yrkF q5swArvSxlauU68QwUP5Py8pWDCUgmyP3w/7cMncCMECk7/k+2DwdyJ1JnKI0zcX1JbvnkmkdppyB dGPtzHeA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1skA5R-00000007rqi-0aWc; Fri, 30 Aug 2024 22:27:21 +0000 Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1skA3t-00000007rXV-2oew for linux-arm-kernel@lists.infradead.org; Fri, 30 Aug 2024 22:25:47 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id E80FAE0002; Fri, 30 Aug 2024 22:25:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1725056743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=bdFbgMzvJfpDhPePQ3r4tXcwVqtf83V3DSLfXhWmeh4=; b=i6DCz8Df3DS85Yq0zFUf7EEIoONfr6gr2r9oB4Ay9Kx3Tm9eLlszQ+nmQlYYQyozSnV/lO I8wvFRcRbAyBxV+1jgT86KlYUS4JjTbYQpzZnFUmViYmBnLVU9vp7jaLmZoAgCbNIEYlEw riRw3LDrJ2HDtXPfTaCcctoG+IO2iQDWHDDs69PlHf08cLLZ344FCtXR3ydIEv6/X90c2w tL051qgA6Hlu8O235aadAdFtrsdsmh44Gp0UBwOl/jnVtta922z5lpmODpAIcUT+suPbP5 YGk/HJn7ZE8+ogAoSLmnIi1AP2BN+2FPtIfOZVzCi+lmWWEspAWRUpNYJTyCjA== Date: Sat, 31 Aug 2024 00:25:41 +0200 From: Alexandre Belloni To: Claudiu Cc: geert+renesas@glider.be, mturquette@baylibre.com, sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, magnus.damm@gmail.com, p.zabel@pengutronix.de, linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Claudiu Beznea , kernel test robot Subject: Re: [PATCH v3 06/12] rtc: renesas-rtca3: Add driver for RTCA-3 available on Renesas RZ/G3S SoC Message-ID: <202408302225417622f1e7@mail.local> References: <20240830130218.3377060-1-claudiu.beznea.uj@bp.renesas.com> <20240830130218.3377060-7-claudiu.beznea.uj@bp.renesas.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240830130218.3377060-7-claudiu.beznea.uj@bp.renesas.com> X-GND-Sasl: alexandre.belloni@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240830_152546_166718_AD77B265 X-CRM114-Status: GOOD ( 21.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 30/08/2024 16:02:12+0300, Claudiu wrote: > + priv->rtc_dev->range_min = mktime64(2000, 1, 1, 0, 0, 0); RTC_TIMESTAMP_BEGIN_2000 > + priv->rtc_dev->range_max = mktime64(2099, 12, 31, 23, 59, 59); RTC_TIMESTAMP_END_2099 > + > + return devm_rtc_register_device(priv->rtc_dev); > +} > + > +static void rtca3_remove(struct platform_device *pdev) > +{ > + struct rtca3_priv *priv = platform_get_drvdata(pdev); > + > + guard(spinlock_irqsave)(&priv->lock); > + > + /* Disable alarm, periodic interrupts. */ > + rtca3_alarm_irq_set_helper(priv, RTCA3_RCR1_AIE | RTCA3_RCR1_PIE, 0); Why do you disable alarms on driver remove? I think you need to add a comment if this is because it can't system up, else this is a bad practice. > + > +static int rtca3_clean_alarm(struct rtca3_priv *priv) > +{ > + struct rtc_device *rtc_dev = priv->rtc_dev; > + time64_t alarm_time, now; > + struct rtc_wkalrm alarm; > + struct rtc_time tm; > + u8 pending; > + int ret; > + > + ret = rtc_read_alarm(rtc_dev, &alarm); > + if (ret) > + return ret; > + > + if (!alarm.enabled) > + return 0; > + > + ret = rtc_read_time(rtc_dev, &tm); > + if (ret) > + return ret; > + > + alarm_time = rtc_tm_to_time64(&alarm.time); > + now = rtc_tm_to_time64(&tm); > + if (alarm_time >= now) > + return 0; > + > + /* > + * Heuristically, it has been determined that when returning from deep > + * sleep state the RTCA3_RSR.AF is zero even though the alarm expired. > + * Call again the rtc_update_irq() if alarm helper detects this. > + */ > + > + guard(spinlock_irqsave)(&priv->lock); > + > + pending = rtca3_alarm_handler_helper(priv); > + if (!pending) > + rtc_update_irq(priv->rtc_dev, 1, RTC_AF | RTC_IRQF); > + > + return 0; > +} > + > +static int rtca3_resume(struct device *dev) > +{ > + struct rtca3_priv *priv = dev_get_drvdata(dev); > + > + if (!device_may_wakeup(dev)) > + return 0; > + > + disable_irq_wake(priv->wakeup_irq); > + > + /* > + * According to the HW manual (section 22.6.4 Notes on writing to > + * and reading from registers) we need to wait 1/128 seconds while > + * RCR2.START = 1 to be able to read the counters after a return from low > + * power consumption state. > + */ > + mdelay(8); > + > + /* > + * The alarm cannot wake the system from deep sleep states. In case > + * we return from deep sleep states and the alarm expired we need > + * to disable it to avoid failures when setting another alarm. > + */ > + return rtca3_clean_alarm(priv); > +} > + > +static DEFINE_SIMPLE_DEV_PM_OPS(rtca3_pm_ops, rtca3_suspend, rtca3_resume); > + > +static const struct of_device_id rtca3_of_match[] = { > + { .compatible = "renesas,rz-rtca3", }, > + { /* sentinel */ } > +}; > +MODULE_DEVICE_TABLE(of, rtca3_of_match); > + > +static struct platform_driver rtca3_platform_driver = { > + .driver = { > + .name = "rtc-rtca3", > + .pm = pm_ptr(&rtca3_pm_ops), > + .of_match_table = rtca3_of_match, > + }, > + .probe = rtca3_probe, > + .remove_new = rtca3_remove, > +}; > +module_platform_driver(rtca3_platform_driver); > + > +MODULE_DESCRIPTION("Renesas RTCA-3 RTC driver"); > +MODULE_AUTHOR("Claudiu Beznea "); > +MODULE_LICENSE("GPL"); > -- > 2.39.2 > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com