Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp760629rwl; Thu, 10 Aug 2023 00:47:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVvDaX58ZgXrJFngWKVL4Awx4SmntqrVY6IJK+ar2yUf+Q93sRJ87mX/l81Aeul0/ikdc/ X-Received: by 2002:a17:902:b90a:b0:1bb:b91b:2b40 with SMTP id bf10-20020a170902b90a00b001bbb91b2b40mr1612731plb.60.1691653630780; Thu, 10 Aug 2023 00:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691653630; cv=none; d=google.com; s=arc-20160816; b=geYIS8LIhzXMq/DtRZSEkfCXPABfwA/p4LoSbpLDN+IvozFF6i/kGtRGgZcUKDRbm8 5X0yMUaX0rMoRv8Gqob58iMWe3oD7O8XAu8K/RDJkf6262/uUc3UJRLRwJRMVj4bEjQp MV/Al0CBXyCglhkTnEQelLVYQpuCmwI/Gr98b7/TsW2IVKHrJo5AWpJG+OWdw8B7inl3 68UECot/qweVTcmk1i57Ef9kqmRvmGrEXwOWDgMGlxLcMR51dYMlIGUA827BG+WFO8JL F7dXmUd9YCuqqUK9MBcmHJCz816aBnkzcCO8Gpbwx0PGjzyHljhIIU9EYQxsmHdiUTnH b9JQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=iuypy1p6ook3tCaKkFtNgD/qaSVZXlKQHOWGSdH8/vs=; fh=VUpQ4rIPHHBA9pd7VY6gqVO0LWARpeuPm9qvwNIbKKE=; b=zB0B3wK30PCRiY2+YdmP34fQ8AOgXNx/KYR5MqpD5XOV5aGTzlIW2e+8bCkItEdo1n 2D0Px2f+GyDfZdz41mzY96ZcWTGBP5jbhYtgA4AsZRtLv0BuwvJIXOVcvT6aEPWUUuuR PBsNmAOZa9aYD5dsPQYSRgqxmXitJKLzhiGakCrk9DAHSA2Xweu9s5uo75CFbPphdBGD minSaZTnzGTJoRr0pSM1gZ7OeXoM0ucFRIR5pWo3WcO+ZCPHOvCMX1pPed+UxOU4Nox3 uBAZ53TJCOPTi04osd+LAQXmyU/oWNrmGAybEiLVc6SjLLIHF+kkKk/EJDr1S44rd/bB L8gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=O8+LzBWA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ld11-20020a170902facb00b001bbb5f82fecsi956688plb.182.2023.08.10.00.46.59; Thu, 10 Aug 2023 00:47:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=O8+LzBWA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231721AbjHJHaU (ORCPT + 99 others); Thu, 10 Aug 2023 03:30:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjHJHaT (ORCPT ); Thu, 10 Aug 2023 03:30:19 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DB15A3; Thu, 10 Aug 2023 00:30:17 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 3E8A3C000C; Thu, 10 Aug 2023 07:30:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1691652616; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iuypy1p6ook3tCaKkFtNgD/qaSVZXlKQHOWGSdH8/vs=; b=O8+LzBWAp0Cie7swpzb3xVJSTCbbwdVDbCDyoIuO62ahqPrcNZfg9CD2+MRXGXF1u5ku3x sC+GxVNAkSZex6QwVABp0u6reTfOB+OKgUfqEAC7JXfvrKgeSw/sRyXT4AioYJG0Yn9WId vKZPoKQELeD68eQJpAaKfpY0iq3pXjesTqgJrlXRxlKnZVKLqBBwYT4p6zNjQ9hzmxuquU Ye3LE3ozc1xr8xZrrgTJkyEPSbPL2V4POcKLD5cfFBgME2wyIKtPZIMbqsT7UeGnld0TTS 1D8X/fQ6W28aO615atqWv2kgdELriff5TnE852M/5gnfBfEZn0R4GKP4eTgBug== Date: Thu, 10 Aug 2023 09:30:15 +0200 From: Alexandre Belloni To: Jacky Huang Cc: a.zummo@towertech.it, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, soc@kernel.org, mjchen@nuvoton.com, schung@nuvoton.com, Jacky Huang Subject: Re: [RESEND PATCH v2 3/3] rtc: Add driver for Nuvoton ma35d1 rtc controller Message-ID: <20230810073015d5545903@mail.local> References: <20230809011542.429945-1-ychuang570808@gmail.com> <20230809011542.429945-4-ychuang570808@gmail.com> <20230809021025a7c0daec@mail.local> <426130f6-7b8a-91f9-559b-afc5afdc656e@gmail.com> <2023080922515326db190e@mail.local> <347cf148-bda8-852b-768c-fa2b57ce5bcb@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <347cf148-bda8-852b-768c-fa2b57ce5bcb@gmail.com> X-GND-Sasl: alexandre.belloni@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/08/2023 15:21:47+0800, Jacky Huang wrote: > > > > > + return 0; > > > > > +} > > > > > + > > > > > +static int ma35d1_rtc_suspend(struct platform_device *pdev, pm_message_t state) > > > > > +{ > > > > > + struct ma35_rtc *rtc = platform_get_drvdata(pdev); > > > > > + u32 regval; > > > > > + > > > > > + if (device_may_wakeup(&pdev->dev)) > > > > > + enable_irq_wake(rtc->irq_num); > > > > > + > > > > > + regval = rtc_reg_read(rtc, MA35_REG_RTC_INTEN); > > > > > + regval &= ~RTC_INTEN_TICKIEN; > > > > > + rtc_reg_write(rtc, MA35_REG_RTC_INTEN, regval); > > > > This is not what the user is asking, don't do this. Also, how was this > > > > tested? > > > Sure, I will remove these three lines of code. > > > > > > We test it with "echo mem > /sys/power/state". > > > > > Yes, my point is that if UIE is enabled, then the user wants to be woken > > up every second. If this is not what is wanted, then UIE has to be > > disabled before going to suspend. > > > > My question is why are you enabling RTC_INTEN_TICKIEN in probe? I don't > > expect anyone to use an actual hardware tick interrupt, unless the alarm > > is broken and can't be set every second. This is why I questioned the > > RTC_UF path because I don't expect it to be taken at all. > > Yes, we will remove TICKIEN from probe and modify ma35d1_alarm_irq_enable(). > TICKIEN will be enabled only if UIE is enabled. > > static int ma35d1_alarm_irq_enable(struct device *dev, unsigned int enabled) > { > ?? ?struct ma35d1_rtc *rtc = dev_get_drvdata(dev); > > ?? ?if (enabled) { > ?? ???? if (rtc->rtc->uie_rtctimer.enabled) > ?? ???? ??? rtc_reg_write(rtc, NVT_RTC_INTEN, > ?? ???? ??? ??? ????? (rtc_reg_read(rtc, > NVT_RTC_INTEN)|(RTC_INTEN_TICKIEN))); Don't do that unless the regular alarm can't be set every second. Simply always use ALMIEN, then check rtctest is passing properly. > ?? ???? if (rtc->rtc->aie_timer.enabled) > ?? ???? ??? rtc_reg_write(rtc, NVT_RTC_INTEN, > ?? ???? ??? ??? ????? (rtc_reg_read(rtc, > NVT_RTC_INTEN)|(RTC_INTEN_ALMIEN))); > ?? ?} else { > ?? ???? if (rtc->rtc->uie_rtctimer.enabled) > ?? ???? ??? rtc_reg_write(rtc, NVT_RTC_INTEN, > ?? ???? ??? ??? ????? (rtc_reg_read(rtc, NVT_RTC_INTEN) & > (~RTC_INTEN_TICKIEN))); > ?? ???? if (rtc->rtc->aie_timer.enabled) > ?? ???? ??? rtc_reg_write(rtc, NVT_RTC_INTEN, > ?? ???? ??? ??? ????? (rtc_reg_read(rtc, NVT_RTC_INTEN) & > (~RTC_INTEN_ALMIEN))); > ?? ?} > ?? ?return 0; > } > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com