From patchwork Thu Jan 26 14:20:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp296360wrn; Thu, 26 Jan 2023 06:23:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXtM4s96fOMIDQ17/pOSzu0+u4ePmAJ7z0/Ya+ArBmFDyog40epeQtrHJdwaZoe1P3/aKpDj X-Received: by 2002:a17:907:d094:b0:7c9:6e0e:1427 with SMTP id vc20-20020a170907d09400b007c96e0e1427mr34818715ejc.6.1674743018283; Thu, 26 Jan 2023 06:23:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743018; cv=none; d=google.com; s=arc-20160816; b=tYkKVjRKAmDd39DqQZ/GdYpjklHYtLVZlVilN63/2z0KyJK4nLlQUNiOCHIJhjImuW VGfgmPSWlvSZZ6dk2hdkRSQwwprWO+DhQyk3Gwng9nW3/tm8oTMyzOTIXZC/DM1O5zOS PY1udaijvBmgzb2iAc8ku2BC+0RvdUhICNQ/TXpYgz9APiylhsY8yELVl7DbyAleM91d OnWfQ69abI8mBhSdOAWr7LsRvN4KJSzrvCGX5GK+cZlIvJ1ge7nAIKP8Bn+nZbUApyV1 RFo3wA98cTjIg86TLBCGzryUzzbQdZF/fxyAJQGX6FVxTuUeRXl6QxofotomZa7Gqa8M 9XgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vVqlC9ge1hHuk79ia3sbPtZ3NGpNDhdOZk72He/hH7c=; b=WeMADiUwYXiumj4XntRpZZG2QjQK+sVbur+0LPHcFQJGzOjAEQhG1ykfEN//LnyQfU L9c2TrP9mU3B2ZAUFU4wXS7wXKbOGq+fV5tfg+4DE14Ad0n2YvaSiewsrCiGLY7FlEeE NymMKw91EZ6xhaQqZAZIMbdaNSLc95wAxcBYwyxHxNI91JU/BM1SR4W7UqHwlrBLiKGa rvQE+gBedyyXtvpeWCVUilbOvJ9kunW9kUUH/LL2YwD9w1BZBycejhvXzlG8ss9Nalmw tDZyQpOIu+oQ9bmzLHqi41LoesfTGWvp1MzLUAQDOeXSgxbSdODDx7zyXpCm51z84rF3 utIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lyvjj+++; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020a056402040900b0048c1bb5d23bsi1848469edv.67.2023.01.26.06.23.13; Thu, 26 Jan 2023 06:23:38 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=lyvjj+++; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231950AbjAZOXE (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230287AbjAZOW7 (ORCPT ); Thu, 26 Jan 2023 09:22:59 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CE65113E4; Thu, 26 Jan 2023 06:22:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2928661844; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D67DC4339C; Thu, 26 Jan 2023 14:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742977; bh=DNEhyu7u4f062FvvbtsFWr1nXt0qu/y1C2h9iu3ZUpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lyvjj+++zBplLPtJ3Fe6CTaq9zUg02yWKvoLq+i3X1BqE1/faXTCQLfga0vyVbHAi 8DdC1cfRTNkWd4dPYrRaY/l9T157clSt4RXJmvfkRKBojoC4tTEvKtp6B+y7BbC0aT K44y8f8AYiuCf1Y4cEXM/kyLVK1RX4rTYDoQ0MNYoHY3NUFy1raebW375ckHPoea2b qUHhfYUxah8JfAVY55E99k2inM6PC7sFHdx2L1Mjm2ce3KNhyEl28dm+PT5RLZ8Mme osL36OMJlZlVXW8nLAsrSFOGie4Y3YQDKFFc5Paz4XyJ4RR3F5uuUmAKgcIOfpg28g 3uUZcg39+hkaw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39c-0006iE-01; Thu, 26 Jan 2023 15:23:04 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 01/24] rtc: pm8xxx: fix set-alarm race Date: Thu, 26 Jan 2023 15:20:34 +0100 Message-Id: <20230126142057.25715-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095334850324030?= X-GMAIL-MSGID: =?utf-8?q?1756095334850324030?= Make sure to disable the alarm before updating the four alarm time registers to avoid spurious alarms during the update. Note that the disable needs to be done outside of the ctrl_reg_lock section to prevent a racing alarm interrupt from disabling the newly set alarm when the lock is released. Fixes: 9a9a54ad7aa2 ("drivers/rtc: add support for Qualcomm PMIC8xxx RTC") Cc: stable@vger.kernel.org # 3.1 Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 716e5d9ad74d..d114f0da537d 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -221,7 +221,6 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { int rc, i; u8 value[NUM_8_BIT_RTC_REGS]; - unsigned int ctrl_reg; unsigned long secs, irq_flags; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; @@ -233,6 +232,11 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) secs >>= 8; } + rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, + regs->alarm_en, 0); + if (rc) + return rc; + spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw, value, @@ -242,19 +246,11 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) goto rtc_rw_fail; } - rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg); - if (rc) - goto rtc_rw_fail; - - if (alarm->enabled) - ctrl_reg |= regs->alarm_en; - else - ctrl_reg &= ~regs->alarm_en; - - rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); - if (rc) { - dev_err(dev, "Write to RTC alarm control register failed\n"); - goto rtc_rw_fail; + if (alarm->enabled) { + rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, + regs->alarm_en, regs->alarm_en); + if (rc) + goto rtc_rw_fail; } dev_dbg(dev, "Alarm Set for h:m:s=%ptRt, y-m-d=%ptRdr\n", From patchwork Thu Jan 26 14:20:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48705 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp296409wrn; Thu, 26 Jan 2023 06:23:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXtVP5qs3wtNdMfQzRokMMBQA8Kjl2JfWyDsfgKZ4fOFAFpsRdX8aMd9iimwuF9rDDYgrk01 X-Received: by 2002:a05:6402:1764:b0:49b:7416:e3fc with SMTP id da4-20020a056402176400b0049b7416e3fcmr37886845edb.36.1674743023355; Thu, 26 Jan 2023 06:23:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743023; cv=none; d=google.com; s=arc-20160816; b=njNZ7eU7GAxZj0F1WoYVyCFGlIaHZX9oCSLboalsOnb090hLdS/p2iU5fn0deezEyC V+vrA/NZlMF+2yH4FIze7gd3S+hRkk6JCjtPjVunrXRetGpQQDrNe4aSOVhjg1EIiF7N qBMLHxAmu71WwnaHoe8a7gqdN5gR+mqZo7jLa8nojqWbVO/70vccBIKHk1IeCZw7ELlE u+kpZV4gDtH7CNYeFFilX5IfjRhge4sJ6sy/CNIR2S7NCRjwES2HtFbNGpQnZCjTdY9T /WIHukDahLSZwg93KYNGM/cPG+LRY/jfzbYDwkZMFWrIXE/QNIm7A7Unea+ZwCSCXzUO hOVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vB8J+nvLGapG9lUFDhXlphHZIpvYRrFG44f33nh9GyU=; b=scnqSTw6pSa/OgAAqHrc8PliQMCqjTP3+jHG9quhySqc3s7qW+D3IAGtTy9YDp75vH Rg2AZQsTyrUFvmOOqb2nRmEFzelgznsIQpZ9JqagMemcv5RBBCwbcz3WBRNf8KQ/OzoE Es72osl2Vrme8ScKSrvUWbNeeGyULMuCogUfaIBksbJMdTqBhuUEKgTISzomqxEhyZ0D kn/vy2YrTbkswZydTPHYkQamUB2IjcwfLNqFwgEEBx9c0SpVDNyv+BxXr5LjcNaL32oV xWyUIYmJEPlIvhmPHkm2+qSiHBISLP0EsDBhNIsCcvoQqneGezttPgkBM0JC+MLrjCve r2LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V4XKfhvg; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y8-20020a50e608000000b0048c0b5672e4si2050186edm.37.2023.01.26.06.23.18; Thu, 26 Jan 2023 06:23:43 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=V4XKfhvg; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232000AbjAZOXG (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231603AbjAZOXA (ORCPT ); Thu, 26 Jan 2023 09:23:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E183113E5; Thu, 26 Jan 2023 06:22:58 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 29C0361846; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 821F6C4339B; Thu, 26 Jan 2023 14:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742977; bh=12u1vORkka94MbRRqgLlh8ZafR0J0iVA3PYzmbaNfEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V4XKfhvgXqSaWLQLZ/mqtZmY2hh/qdyPnFadZsmNNDeNRgSrypLpTPcLcEuDCh8mq r3KJvlBgrD8IQb/jM4jaFO8HzslJ2ljUwrE4NC7YR78jBLsFKhJKOS3CZntmX4i+tT mUP/cNjw2LvbVfXTRr1ocQh+9sF6l1vG2A7KTpMMlCUfJgRmIq2yJVMwRe5DtH980E fOJBcssv/q84TKRV0unRQz7XuBzA0sc0vOLNdRexe3hxfXauzArcplvcjL7qoaBPoG TCQY3BmPbK4OxSU9Pb1ZXGIP6s5rFre8BZ4sb51eQqGZXH4jiU8UW7T0IqpLpc+zuI jn2nygOW48jFA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39c-0006iG-3G; Thu, 26 Jan 2023 15:23:04 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 02/24] rtc: pm8xxx: drop spmi error messages Date: Thu, 26 Jan 2023 15:20:35 +0100 Message-Id: <20230126142057.25715-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095340288691834?= X-GMAIL-MSGID: =?utf-8?q?1756095340288691834?= Drop the unnecessary error messages after every spmi regmap access, which are not expected to fail. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 71 ++++++++++------------------------------ 1 file changed, 17 insertions(+), 54 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index d114f0da537d..f49bda999e02 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -105,10 +105,8 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) alarm_enabled = 1; ctrl_reg &= ~regs->alarm_en; rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); - if (rc) { - dev_err(dev, "Write to RTC Alarm control register failed\n"); + if (rc) goto rtc_rw_fail; - } } /* Disable RTC H/w before writing on RTC register */ @@ -120,51 +118,39 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) rtc_disabled = 1; rtc_ctrl_reg &= ~PM8xxx_RTC_ENABLE; rc = regmap_write(rtc_dd->regmap, regs->ctrl, rtc_ctrl_reg); - if (rc) { - dev_err(dev, "Write to RTC control register failed\n"); + if (rc) goto rtc_rw_fail; - } } /* Write 0 to Byte[0] */ rc = regmap_write(rtc_dd->regmap, regs->write, 0); - if (rc) { - dev_err(dev, "Write to RTC write data register failed\n"); + if (rc) goto rtc_rw_fail; - } /* Write Byte[1], Byte[2], Byte[3] */ rc = regmap_bulk_write(rtc_dd->regmap, regs->write + 1, &value[1], sizeof(value) - 1); - if (rc) { - dev_err(dev, "Write to RTC write data register failed\n"); + if (rc) goto rtc_rw_fail; - } /* Write Byte[0] */ rc = regmap_write(rtc_dd->regmap, regs->write, value[0]); - if (rc) { - dev_err(dev, "Write to RTC write data register failed\n"); + if (rc) goto rtc_rw_fail; - } /* Enable RTC H/w after writing on RTC register */ if (rtc_disabled) { rtc_ctrl_reg |= PM8xxx_RTC_ENABLE; rc = regmap_write(rtc_dd->regmap, regs->ctrl, rtc_ctrl_reg); - if (rc) { - dev_err(dev, "Write to RTC control register failed\n"); + if (rc) goto rtc_rw_fail; - } } if (alarm_enabled) { ctrl_reg |= regs->alarm_en; rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); - if (rc) { - dev_err(dev, "Write to RTC Alarm control register failed\n"); + if (rc) goto rtc_rw_fail; - } } rtc_rw_fail: @@ -183,28 +169,22 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; rc = regmap_bulk_read(rtc_dd->regmap, regs->read, value, sizeof(value)); - if (rc) { - dev_err(dev, "RTC read data register failed\n"); + if (rc) return rc; - } /* * Read the LSB again and check if there has been a carry over. * If there is, redo the read operation. */ rc = regmap_read(rtc_dd->regmap, regs->read, ®); - if (rc < 0) { - dev_err(dev, "RTC read data register failed\n"); + if (rc < 0) return rc; - } if (unlikely(reg < value[0])) { rc = regmap_bulk_read(rtc_dd->regmap, regs->read, value, sizeof(value)); - if (rc) { - dev_err(dev, "RTC read data register failed\n"); + if (rc) return rc; - } } secs = value[0] | (value[1] << 8) | (value[2] << 16) | @@ -241,10 +221,8 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw, value, sizeof(value)); - if (rc) { - dev_err(dev, "Write to RTC ALARM register failed\n"); + if (rc) goto rtc_rw_fail; - } if (alarm->enabled) { rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, @@ -271,10 +249,8 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) rc = regmap_bulk_read(rtc_dd->regmap, regs->alarm_rw, value, sizeof(value)); - if (rc) { - dev_err(dev, "RTC alarm time read failed\n"); + if (rc) return rc; - } secs = value[0] | (value[1] << 8) | (value[2] << 16) | ((unsigned long)value[3] << 24); @@ -282,10 +258,9 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) rtc_time64_to_tm(secs, &alarm->time); rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg); - if (rc) { - dev_err(dev, "Read from RTC alarm control register failed\n"); + if (rc) return rc; - } + alarm->enabled = !!(ctrl_reg & PM8xxx_RTC_ALARM_ENABLE); dev_dbg(dev, "Alarm set for - h:m:s=%ptRt, y-m-d=%ptRdr\n", @@ -315,19 +290,15 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) ctrl_reg &= ~regs->alarm_en; rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); - if (rc) { - dev_err(dev, "Write to RTC control register failed\n"); + if (rc) goto rtc_rw_fail; - } /* Clear Alarm register */ if (!enable) { rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw, value, sizeof(value)); - if (rc) { - dev_err(dev, "Clear RTC ALARM register failed\n"); + if (rc) goto rtc_rw_fail; - } } rtc_rw_fail: @@ -366,8 +337,6 @@ static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id) rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); if (rc) { spin_unlock(&rtc_dd->ctrl_reg_lock); - dev_err(rtc_dd->rtc_dev, - "Write to alarm control register failed\n"); goto rtc_alarm_handled; } @@ -375,17 +344,11 @@ static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id) /* Clear RTC alarm register */ rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl2, &ctrl_reg); - if (rc) { - dev_err(rtc_dd->rtc_dev, - "RTC Alarm control2 register read failed\n"); + if (rc) goto rtc_alarm_handled; - } ctrl_reg |= PM8xxx_RTC_ALARM_CLEAR; rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl2, ctrl_reg); - if (rc) - dev_err(rtc_dd->rtc_dev, - "Write to RTC Alarm control2 register failed\n"); rtc_alarm_handled: return IRQ_HANDLED; From patchwork Thu Jan 26 14:20:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp296604wrn; Thu, 26 Jan 2023 06:24:06 -0800 (PST) X-Google-Smtp-Source: AK7set/mdXkr4Crxkizsph/uo9sXjjA1OHK2tZvm924nfceJosSgkSogQAluX6+DoQT7T5JzNatE X-Received: by 2002:a17:906:7851:b0:878:4edf:4e06 with SMTP id p17-20020a170906785100b008784edf4e06mr4022108ejm.62.1674743046698; Thu, 26 Jan 2023 06:24:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743046; cv=none; d=google.com; s=arc-20160816; b=EtRaQz23z2E1JN4LY6ufCx3dKjTzIgVo26h9b2cvSPdQWTUXZt29UNZJ30seS7Unjg PTTZdInYoYtcQMRE9aO3vq9godGZsZ/TK3l2l7kG9wyF3MmbMAamE6h9QXLRh4ZavSGb 5Y3CfIPFYL9LX4ziire1IKnQhseSS8zkIVxGtqvkStEG2DbeBWPtKn+mqn9QijqpZKHi WypKhUgQYOyu8CChS8q3JT+cLrTM4UsGjYFiaZDfROn4iuyMN+9JpPPceZwTGHnmDXZ2 i+MYDEX7LkR5bPh3ea/kq4y7nYTeumXENtrTSOrutp3+NAQj4ut4yrKZW5fngnK82o9M FSeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OCncvAqm9xyMvXsGTmku4VWOILduN1kK6CMN2vjI+/o=; b=0c8YrmlPj5huQzUnmaotSdRvlRe/BgA5T3x97rs1YaB6gnUey21BumqBZUSo1j3OZA nFlDsPx8acMBfnqhlgqcebMBlbQBNbl/0AnebHMsl38il9NkJWRdWS7oDfXawsfHkS/3 uVAflH73BvQj5LArQxkrxx25Z72YTkwvpFbx1Bt74xxxN/2nQjx1AWWsUy/kd7tG7FNm FAjgcfE7ZLbK9nA9NE66Ony4MnCeSWqWFKFRytuL9BrWtknJ4loXJvrC7sTYG3Qk9W6b cWuCJ+gRYIFbYuzUQqxBeiYbNrMP7aC7hKf67UOd29o9ndb5SkJ86SQfgHR+3q+Qnlcw G9xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lZFyf+90; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wi19-20020a170906fd5300b0086c7dc4fd9bsi1289337ejb.538.2023.01.26.06.23.41; Thu, 26 Jan 2023 06:24:06 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=lZFyf+90; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231964AbjAZOXS (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231867AbjAZOXC (ORCPT ); Thu, 26 Jan 2023 09:23:02 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C56C12583; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D16EAB81DE6; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7B873C433D2; Thu, 26 Jan 2023 14:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742977; bh=PJLRhF0N1IQ7Gq3TQcph77IiU5e79uPUOVm8qGIdNmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lZFyf+904uF5h0zs0Np8I+y9pVSqrwQLkwm98FKmRRVNg9VR22fdIF3CPCoTi6btN N7QFo42YR8ODqaIjMQ7snZrw/DWSoqcG8Jw4LWOb1B5x6hBBVv88tZR4zudiDzEUQo 4XvUQZhdANOsp3XPfy1hLqCZJ1LQVUXW1hMniQ2MCMWBo3dUedqObg/sbMd7Ny9r0o PTImEEoUmUITcx8yGjOoSxjJl7qTGZFi96fXmEcmNXzM+YagBTcFUK0u8Ynm1yu0Ai aQUtQawoTBpAAem8rfv7HkVA9ajHZ/a7ti6fMTwtMfyg1NcEUwzvmUdOKNQifxFKgk wnQ/9qTueCHtg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39c-0006iI-6U; Thu, 26 Jan 2023 15:23:04 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 03/24] rtc: pm8xxx: use regmap_update_bits() Date: Thu, 26 Jan 2023 15:20:36 +0100 Message-Id: <20230126142057.25715-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095365293507849?= X-GMAIL-MSGID: =?utf-8?q?1756095365293507849?= Switch to using regmap_update_bits() instead of open coding read-modify-write accesses. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 87 ++++++++++------------------------------ 1 file changed, 22 insertions(+), 65 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index f49bda999e02..8c2847ac64f4 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -78,10 +78,10 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) { int rc, i; unsigned long secs, irq_flags; - u8 value[NUM_8_BIT_RTC_REGS], alarm_enabled = 0, rtc_disabled = 0; - unsigned int ctrl_reg, rtc_ctrl_reg; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; + u8 value[NUM_8_BIT_RTC_REGS]; + bool alarm_enabled; if (!rtc_dd->allow_set_time) return -ENODEV; @@ -97,31 +97,16 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); - rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg); + rc = regmap_update_bits_check(rtc_dd->regmap, regs->alarm_ctrl, + regs->alarm_en, 0, &alarm_enabled); if (rc) goto rtc_rw_fail; - if (ctrl_reg & regs->alarm_en) { - alarm_enabled = 1; - ctrl_reg &= ~regs->alarm_en; - rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); - if (rc) - goto rtc_rw_fail; - } - /* Disable RTC H/w before writing on RTC register */ - rc = regmap_read(rtc_dd->regmap, regs->ctrl, &rtc_ctrl_reg); + rc = regmap_update_bits(rtc_dd->regmap, regs->ctrl, PM8xxx_RTC_ENABLE, 0); if (rc) goto rtc_rw_fail; - if (rtc_ctrl_reg & PM8xxx_RTC_ENABLE) { - rtc_disabled = 1; - rtc_ctrl_reg &= ~PM8xxx_RTC_ENABLE; - rc = regmap_write(rtc_dd->regmap, regs->ctrl, rtc_ctrl_reg); - if (rc) - goto rtc_rw_fail; - } - /* Write 0 to Byte[0] */ rc = regmap_write(rtc_dd->regmap, regs->write, 0); if (rc) @@ -139,16 +124,14 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) goto rtc_rw_fail; /* Enable RTC H/w after writing on RTC register */ - if (rtc_disabled) { - rtc_ctrl_reg |= PM8xxx_RTC_ENABLE; - rc = regmap_write(rtc_dd->regmap, regs->ctrl, rtc_ctrl_reg); - if (rc) - goto rtc_rw_fail; - } + rc = regmap_update_bits(rtc_dd->regmap, regs->ctrl, PM8xxx_RTC_ENABLE, + PM8xxx_RTC_ENABLE); + if (rc) + goto rtc_rw_fail; if (alarm_enabled) { - ctrl_reg |= regs->alarm_en; - rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); + rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, + regs->alarm_en, regs->alarm_en); if (rc) goto rtc_rw_fail; } @@ -275,21 +258,18 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) unsigned long irq_flags; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; - unsigned int ctrl_reg; u8 value[NUM_8_BIT_RTC_REGS] = {0}; + unsigned int val; spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); - rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg); - if (rc) - goto rtc_rw_fail; - if (enable) - ctrl_reg |= regs->alarm_en; + val = regs->alarm_en; else - ctrl_reg &= ~regs->alarm_en; + val = 0; - rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); + rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, + regs->alarm_en, val); if (rc) goto rtc_rw_fail; @@ -318,7 +298,6 @@ static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id) { struct pm8xxx_rtc *rtc_dd = dev_id; const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; - unsigned int ctrl_reg; int rc; rtc_update_irq(rtc_dd->rtc, 1, RTC_IRQF | RTC_AF); @@ -326,15 +305,8 @@ static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id) spin_lock(&rtc_dd->ctrl_reg_lock); /* Clear the alarm enable bit */ - rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg); - if (rc) { - spin_unlock(&rtc_dd->ctrl_reg_lock); - goto rtc_alarm_handled; - } - - ctrl_reg &= ~regs->alarm_en; - - rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl, ctrl_reg); + rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, + regs->alarm_en, 0); if (rc) { spin_unlock(&rtc_dd->ctrl_reg_lock); goto rtc_alarm_handled; @@ -343,13 +315,11 @@ static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id) spin_unlock(&rtc_dd->ctrl_reg_lock); /* Clear RTC alarm register */ - rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl2, &ctrl_reg); + rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl2, + PM8xxx_RTC_ALARM_CLEAR, 0); if (rc) goto rtc_alarm_handled; - ctrl_reg |= PM8xxx_RTC_ALARM_CLEAR; - rc = regmap_write(rtc_dd->regmap, regs->alarm_ctrl2, ctrl_reg); - rtc_alarm_handled: return IRQ_HANDLED; } @@ -357,22 +327,9 @@ static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id) static int pm8xxx_rtc_enable(struct pm8xxx_rtc *rtc_dd) { const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; - unsigned int ctrl_reg; - int rc; - - /* Check if the RTC is on, else turn it on */ - rc = regmap_read(rtc_dd->regmap, regs->ctrl, &ctrl_reg); - if (rc) - return rc; - if (!(ctrl_reg & PM8xxx_RTC_ENABLE)) { - ctrl_reg |= PM8xxx_RTC_ENABLE; - rc = regmap_write(rtc_dd->regmap, regs->ctrl, ctrl_reg); - if (rc) - return rc; - } - - return 0; + return regmap_update_bits(rtc_dd->regmap, regs->ctrl, PM8xxx_RTC_ENABLE, + PM8xxx_RTC_ENABLE); } static const struct pm8xxx_rtc_regs pm8921_regs = { From patchwork Thu Jan 26 14:20:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48717 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp297268wrn; Thu, 26 Jan 2023 06:25:34 -0800 (PST) X-Google-Smtp-Source: AK7set9d9EKT/XZxyYQvDGHPc218Y4vkq0NC61JQgyHVl2tj2Jvd0HHuzElp0MzIGukgKakRq7Nt X-Received: by 2002:a17:906:94f:b0:878:7921:2240 with SMTP id j15-20020a170906094f00b0087879212240mr865115ejd.64.1674743134132; Thu, 26 Jan 2023 06:25:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743134; cv=none; d=google.com; s=arc-20160816; b=nkvIkHiuuXJnb8GoCYb3Y3aQrzbq9nUBuq7rJCpSxIr1A2mUC6wDp+fIhilXhQ4ktt doWJBFTKBxOTEnr/Gst14yRAasaRCStsOR3Nde1Th9653X+rblx/emcoWCRjK9CrMTsN uOq9nljC5AhZG/HBWhJPVtwwGBitqX++43mLC3aM0ZLHGDJ29kpN58/C4vme/PZqtYMg qcWMPiZYYdg+Jak3qIVwMQEp5ktW21r/r94O+QFbkZRTNwsHi+rmSoxaVDRTilESyBwG A37TDHqdw2MHhnyyhQiV5AZNqGCSxDtbYZpHsl+WbGmgRTkX4XWbWd9/DGOUVEVM317g JiVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sae48iak0jyIJnVd4jjOc1Yk3WyreChByRKDjMDBWoU=; b=iALKK/bjAFN639QylTe9/Z3s2H7EianmblsxpB4Uc9MNOdWj6h8qGKcInsS9yleD8a nrbJFmo/GEVMTz0X40ck3PH46Hf9ShHe30K+1+0Fsfi0/cdKpdTWJvZjYiFSOWvBMVRu RqS5YZxiGYpMG1Rnn/cK8zakyY0wuKrq3PYkFjpA+UejWkLFIO0+y37fmvFV9oWDWxlk FnVFWByaaFaWKuiXL2cJ3FF5U0yVkCrF3aFPJu1WOhoDD90B4pWeZjNRPFdCfGD5T1qC CnXcMwYRgcesmY/LEWPQ1bZO/CB0+7XAURv9f5GmqlgfUCrVsIpOTpew3DBn9BwQHG4P dacA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EoGIpxvx; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kb16-20020a170907925000b0087777e65f7esi1214376ejb.504.2023.01.26.06.25.09; Thu, 26 Jan 2023 06:25:34 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=EoGIpxvx; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231969AbjAZOX0 (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231898AbjAZOXD (ORCPT ); Thu, 26 Jan 2023 09:23:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AB361CF59; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E6B9BB81DEF; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 866A4C4339E; Thu, 26 Jan 2023 14:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742977; bh=hhCtw+HmTT9km9pBv0XwTlPCeUZBnbPGQDj+D0a9Ak0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EoGIpxvxks3Jv93NwXx2MehlRrAaHGlX2AMteW1QHAc74iTCc1j23iQ4prhVv9O4p oBCWBawvl92ki/iuJNcaYsYSbxAJHmOFVwchirtR/xqr85w2/HpzDFhu7x9d55mD0q zre/9ZXCWzHKNNVmxyDAKGMvD2beQe7PCICu3ouKmleiVMAVH9HufD+XU3fDlOuUbN P8Qbd/a5c1s7FZ8jfogwRgDxLf30aqtfGSVWPbz7yBYdoZ4O1b7EY3saUFKcxQOvEa bZCF3y/n/vRuEo48Xtw4eUWmKXkDNvYNGTamVvPRpzScdn9yJ09imLHDJniMusmun1 qdV2ERuz0Z9ww== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39c-0006iL-9j; Thu, 26 Jan 2023 15:23:04 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 04/24] rtc: pm8xxx: drop bogus locking Date: Thu, 26 Jan 2023 15:20:37 +0100 Message-Id: <20230126142057.25715-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095456583337748?= X-GMAIL-MSGID: =?utf-8?q?1756095456583337748?= Since commit c8d523a4b053 ("drivers/rtc/rtc-pm8xxx.c: rework to support pm8941 rtc") which removed the shadow control register there is no need for a driver lock. Specifically, the rtc ops are serialised by rtc core and the interrupt handler only unconditionally disables the alarm using the alarm_ctrl register. Note that since only the alarm enable bit of alarm_ctrl is used after enabling the RTC at probe, the locking was not needed when doing open coded read-modify-write cycles either. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 67 +++++++++++++--------------------------- 1 file changed, 21 insertions(+), 46 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 8c2847ac64f4..053a04f74a91 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -53,7 +53,6 @@ struct pm8xxx_rtc_regs { * @rtc_alarm_irq: rtc alarm irq number. * @regs: rtc registers description. * @rtc_dev: device structure. - * @ctrl_reg_lock: spinlock protecting access to ctrl_reg. */ struct pm8xxx_rtc { struct rtc_device *rtc; @@ -62,7 +61,6 @@ struct pm8xxx_rtc { int rtc_alarm_irq; const struct pm8xxx_rtc_regs *regs; struct device *rtc_dev; - spinlock_t ctrl_reg_lock; }; /* @@ -77,11 +75,11 @@ struct pm8xxx_rtc { static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) { int rc, i; - unsigned long secs, irq_flags; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; u8 value[NUM_8_BIT_RTC_REGS]; bool alarm_enabled; + unsigned long secs; if (!rtc_dd->allow_set_time) return -ENODEV; @@ -95,51 +93,46 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) secs >>= 8; } - spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); - rc = regmap_update_bits_check(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, 0, &alarm_enabled); if (rc) - goto rtc_rw_fail; + return rc; /* Disable RTC H/w before writing on RTC register */ rc = regmap_update_bits(rtc_dd->regmap, regs->ctrl, PM8xxx_RTC_ENABLE, 0); if (rc) - goto rtc_rw_fail; + return rc; /* Write 0 to Byte[0] */ rc = regmap_write(rtc_dd->regmap, regs->write, 0); if (rc) - goto rtc_rw_fail; + return rc; /* Write Byte[1], Byte[2], Byte[3] */ rc = regmap_bulk_write(rtc_dd->regmap, regs->write + 1, &value[1], sizeof(value) - 1); if (rc) - goto rtc_rw_fail; + return rc; /* Write Byte[0] */ rc = regmap_write(rtc_dd->regmap, regs->write, value[0]); if (rc) - goto rtc_rw_fail; + return rc; /* Enable RTC H/w after writing on RTC register */ rc = regmap_update_bits(rtc_dd->regmap, regs->ctrl, PM8xxx_RTC_ENABLE, PM8xxx_RTC_ENABLE); if (rc) - goto rtc_rw_fail; + return rc; if (alarm_enabled) { rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, regs->alarm_en); if (rc) - goto rtc_rw_fail; + return rc; } -rtc_rw_fail: - spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); - - return rc; + return 0; } static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) @@ -184,9 +177,9 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { int rc, i; u8 value[NUM_8_BIT_RTC_REGS]; - unsigned long secs, irq_flags; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; + unsigned long secs; secs = rtc_tm_to_time64(&alarm->time); @@ -200,25 +193,22 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) if (rc) return rc; - spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); - rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw, value, sizeof(value)); if (rc) - goto rtc_rw_fail; + return rc; if (alarm->enabled) { rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, regs->alarm_en); if (rc) - goto rtc_rw_fail; + return rc; } dev_dbg(dev, "Alarm Set for h:m:s=%ptRt, y-m-d=%ptRdr\n", &alarm->time, &alarm->time); -rtc_rw_fail: - spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); - return rc; + + return 0; } static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) @@ -255,14 +245,11 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) { int rc; - unsigned long irq_flags; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; u8 value[NUM_8_BIT_RTC_REGS] = {0}; unsigned int val; - spin_lock_irqsave(&rtc_dd->ctrl_reg_lock, irq_flags); - if (enable) val = regs->alarm_en; else @@ -271,19 +258,17 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, val); if (rc) - goto rtc_rw_fail; + return rc; /* Clear Alarm register */ if (!enable) { rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw, value, sizeof(value)); if (rc) - goto rtc_rw_fail; + return rc; } -rtc_rw_fail: - spin_unlock_irqrestore(&rtc_dd->ctrl_reg_lock, irq_flags); - return rc; + return 0; } static const struct rtc_class_ops pm8xxx_rtc_ops = { @@ -302,25 +287,18 @@ static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id) rtc_update_irq(rtc_dd->rtc, 1, RTC_IRQF | RTC_AF); - spin_lock(&rtc_dd->ctrl_reg_lock); - /* Clear the alarm enable bit */ rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, 0); - if (rc) { - spin_unlock(&rtc_dd->ctrl_reg_lock); - goto rtc_alarm_handled; - } - - spin_unlock(&rtc_dd->ctrl_reg_lock); + if (rc) + goto out; /* Clear RTC alarm register */ rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl2, PM8xxx_RTC_ALARM_CLEAR, 0); if (rc) - goto rtc_alarm_handled; - -rtc_alarm_handled: + goto out; +out: return IRQ_HANDLED; } @@ -398,9 +376,6 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) if (rtc_dd == NULL) return -ENOMEM; - /* Initialise spinlock to protect RTC control register */ - spin_lock_init(&rtc_dd->ctrl_reg_lock); - rtc_dd->regmap = dev_get_regmap(pdev->dev.parent, NULL); if (!rtc_dd->regmap) { dev_err(&pdev->dev, "Parent regmap unavailable.\n"); From patchwork Thu Jan 26 14:20:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48729 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp305113wrn; Thu, 26 Jan 2023 06:42:10 -0800 (PST) X-Google-Smtp-Source: AK7set/uqJHaXZmWuDc6byvmzzeL6FraG29fM61MOWQfVP1NGPMii6sg+7cWgneNYBdAKfeKeh6G X-Received: by 2002:a17:906:44f:b0:878:8074:713b with SMTP id e15-20020a170906044f00b008788074713bmr293617eja.53.1674744130697; Thu, 26 Jan 2023 06:42:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674744130; cv=none; d=google.com; s=arc-20160816; b=um5H7SGtqactOeXUC17e3tCsxXrhUHWTW//GrmKj+i1ul/5bAyBMPvOpoHhobDpjvU CtOeEqFkpK+TKhXtm8Pu3gxl/+ys3E9Tc/x7bwRNRCzHEEaKAOGFU8wdMUE5ACs1hUU8 p6L+5XrXI90HKT+q52zpbcQWNoqeNsJb4k6TDjHvit0yXNu/63p+reSvuyiMEFfSDQ6J ocVI/8HO7FHETLXPXas16953ViULWSVPpaE7BjTAoKFY98KhTyX9msjNO0ZJtV548vxP 5VtLRW/9ikgZ8M7rEe95HpdP8PG7MBzqwqo1a9V1gzsyW/mdqbWMQLraMlpZHr8j4yAT FbvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vbCPPJzRn4gWF+/NZrpcEqvBf6zXgpEdp6O5rEftu1I=; b=xTGXWhx9LafiVBUUnx/wRy6HQdpkcuJ8zEcTrf2waB72FtFdgOE/2uL5LhnRx/wZtw v4xz8EX5QiYessIjc9fghgZoVZSiJnNACh0lEtgZukCSpqy1LCVQFD+g+w89g1E0EfRk C5GWMGcGX67vQ/Fx6nRL6rdpMTKqc1sgk2Bm3CRi9Pb/5CzM7Aj1+mERo6fnpPxipY6b eL2wL47P93NxzgVl5cN+VxCSxJs22AMBnfWLnT3v9Hm84pY+EiR9p5GAnlWCc3M+Rrai 5Fm0D0G1tJ/yRd/HyV+aVutmL7hWvp6Gb3ZY0PMM/VyoWtrePC6zLHGz8PcgWwPqDxfT IxiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BnoJ2Siv; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fb15-20020a1709073a0f00b00857aca4163dsi1349596ejc.569.2023.01.26.06.41.33; Thu, 26 Jan 2023 06:42:10 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=BnoJ2Siv; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232187AbjAZO2Z (ORCPT + 99 others); Thu, 26 Jan 2023 09:28:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232164AbjAZO2Y (ORCPT ); Thu, 26 Jan 2023 09:28:24 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26E16274A1; Thu, 26 Jan 2023 06:28:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 34282B81DF0; Thu, 26 Jan 2023 14:27:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF04FC433D2; Thu, 26 Jan 2023 14:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674743277; bh=fkNCWGzpN9noJHpG5tIoZbVO7VTTQDfyVLycvpHMucI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BnoJ2SivmQHSNSxLclMx3tGin0IOcWk+i8F5yh3Im0HS4601HW5zys6GhNdTcjU0c nltddIK3DgM8O9SF7tGgODjpje4V/rLiISSSzYvYH1I0tbR1Z3vP4ZrCfIjIzhH6JO R00h9P+HBHYdIYl0jv4vJVaD/Sc9D6HuGjpMWelFw6QFSEqVGogmhLNl3IAt/Z6BC7 6vNvI2hahYP104gb1urzQyY+YbrBBI4gj9OubbxJjiMCPIaTjmmWs2GYLNqgfYq7ej 5/JZgFX98ODk/gmjo+1T2HRRGv1NSEzLkFCFINLAsDDBnDdK+avbfjrSapwwPF8wL6 91HkiS8vS0NmQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39c-0006iO-Cy; Thu, 26 Jan 2023 15:23:04 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 05/24] rtc: pm8xxx: return IRQ_NONE on errors Date: Thu, 26 Jan 2023 15:20:38 +0100 Message-Id: <20230126142057.25715-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756096501927007377?= X-GMAIL-MSGID: =?utf-8?q?1756096501927007377?= In the unlikely event that disabling the alarm and clearing the status ever fails, return IRQ_NONE instead of IRQ_HANDLED. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 053a04f74a91..dc7e659cbb2a 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -291,14 +291,14 @@ static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id) rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, 0); if (rc) - goto out; + return IRQ_NONE; /* Clear RTC alarm register */ rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl2, PM8xxx_RTC_ALARM_CLEAR, 0); if (rc) - goto out; -out: + return IRQ_NONE; + return IRQ_HANDLED; } From patchwork Thu Jan 26 14:20:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48707 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp296490wrn; Thu, 26 Jan 2023 06:23:54 -0800 (PST) X-Google-Smtp-Source: AK7set9sjjxxnEWQyBXiL9gqjpnN2JARXqW8y3xCJbR+p/pdXjXlv0+AObODlpQUfvZ0dcN4RlNF X-Received: by 2002:aa7:dd12:0:b0:4a0:e241:a312 with SMTP id i18-20020aa7dd12000000b004a0e241a312mr1768974edv.35.1674743034665; Thu, 26 Jan 2023 06:23:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743034; cv=none; d=google.com; s=arc-20160816; b=E4Dl4YriK9aHdSEv/r0UUEP16AtPXSuF2sa3N8z5R8cFrvBvq889pgAlWOF86b9W0N RX07a82fyX76sKqVLQdnG5bWPTT6qmjr7bgQdpD75HBvX1g52H72DSwv1NJ9tlpXefxX Wt5Fc24bpk/b/pAASCJ4NhGAguVGJlrBF9zTgb5h4rbR6e9wEJ4MqkuM6zn11f2e9qZw Yu9zL4oTf8Tlv65hqMXlG81m68sB6ApiUQssexvX0lIxmMUvy25bxM8FqfQLZSmSC0Ws rAzppJhNSra/UhX+FBzfIybQzKY8TqqgR64f4LXmv3JJKxzZfbPc4aIqAcPvI8aK+aE2 rzKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oTe4wVcqYHta913zSSxrHjWj97TrzZrYL3aDfAt/ySI=; b=pt2r5MOFYi6pliirE6zJgojD7TvQ0Njn7pp4FZJE6b7rlg+x2yHQa35lTZ4uK30XbF Y/FqaqLIgy7UDXFzEeTogAzr+81fl/V5ADSbEACNMiIst3BZV4lencxeAUkJNATNFOhI B08S2oypiuV3HgFuGG5p7xaXrQJbOiiRpGchdzrTq9qjYXzQKEorecAZloLgB8uqpk7P vlaBtbY5h7pnqwNjPV/owcw/Cuj/x3wjou+I5pqGg+JiQnm2X+3g2QJ8DGWNWTsbNQWw uMfWN6+2Y+SeC8RloX68boB9cirQ+RWwXAierzgEb4Gk8ePHeSzcsAExEFfdtwnMEwNL PCXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZjJB62qs; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f22-20020a056402005600b0045fca739593si1682775edu.188.2023.01.26.06.23.29; Thu, 26 Jan 2023 06:23:54 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=ZjJB62qs; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232039AbjAZOXN (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231754AbjAZOXA (ORCPT ); Thu, 26 Jan 2023 09:23:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 199E511677; Thu, 26 Jan 2023 06:22:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AAB1161847; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A826FC43323; Thu, 26 Jan 2023 14:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742977; bh=+e6vabk7nnIxKnRB4DqirjDl+9Kx3GaOJxRWKeLLfb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZjJB62qscy8LcgCb/9NniHw+V1AN4aTmdvyP7U3LXDGUv95N47VxOkiaBlK3paSrL rcjTE9yYmN/+gOzvz/fyRJy4SIgmc4xh1EZlq8bj3qgVwnW20XROWy6XhIG0zcQmuJ fdalaJn7BuTpa3kmdPUmQwpSyxFa5OGXTK76ZSM7njEVbZwr1pN1TRGGIeRd3BbHNr DvTLMffxuKc8gfQUuxS2lXQZVf8tH3R9/csZeOh55aSkltKjKsLUyshqKt711fn+RJ 5FyjhCA3N5VrXQFF9eoPkNjYZGLqdcuPtg7+Z8pOzgRFFXTLHrcfbjXNmWzTnPni3J V/aJg0OtUa4Ig== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39c-0006iR-Fq; Thu, 26 Jan 2023 15:23:04 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 06/24] rtc: pm8xxx: drop unused register defines Date: Thu, 26 Jan 2023 15:20:39 +0100 Message-Id: <20230126142057.25715-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095352018105916?= X-GMAIL-MSGID: =?utf-8?q?1756095352018105916?= Drop the original register defines which have been used since commit c8d523a4b053 ("drivers/rtc/rtc-pm8xxx.c: rework to support pm8941 rtc"). Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index dc7e659cbb2a..90027a7cfb12 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -12,12 +12,6 @@ #include #include -/* RTC Register offsets from RTC CTRL REG */ -#define PM8XXX_ALARM_CTRL_OFFSET 0x01 -#define PM8XXX_RTC_WRITE_OFFSET 0x02 -#define PM8XXX_RTC_READ_OFFSET 0x06 -#define PM8XXX_ALARM_RW_OFFSET 0x0A - /* RTC_CTRL register bit fields */ #define PM8xxx_RTC_ENABLE BIT(7) #define PM8xxx_RTC_ALARM_CLEAR BIT(0) From patchwork Thu Jan 26 14:20:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48706 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp296466wrn; Thu, 26 Jan 2023 06:23:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXsh0Hh7V22MBaZOTXpPFwnFWxsdjuv9HYX84rtvhxsa1JIT6hJhuWrRNPkUVpRuV1OkPFwR X-Received: by 2002:aa7:cd86:0:b0:499:27e8:94a3 with SMTP id x6-20020aa7cd86000000b0049927e894a3mr38819947edv.13.1674743031566; Thu, 26 Jan 2023 06:23:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743031; cv=none; d=google.com; s=arc-20160816; b=qdxxBY31XgnVzznX3Yd5FccURizk8bKECasXUndvurF5vxyKXl0b2zon8ZN42Nhda/ ExWFuirP/mPgSnUC6RJKZMsFXYWeWgZGJ5mGzQGn/BkYnzzhTXJjk7Su3dDJ8e2vVGL6 iIaWXmxuhma6+dHbg+yAvt5BmdV59SioeK6KZOjII7Tqnkd8vUOllrbcbz6RCFwfmgGp DhmGwTvldtrOpO1sBt1oAQLpRYyYt+RiTF6pnDQUUTNbxR9MyPRipN9ghWOMKvTgoeNv c8l8g7Q/eFiYmbNGib44JreiZYfIvuKRQ3iCSTBtFcqEXmOXIZqPLofWzHgrb4JRhKwJ CYtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CiLkavwtzRpj3TFtBrtZgEJtwVc4KNGFX6AP4WVRhQ4=; b=VBR9hKBnizDyQzB4VTvYLQVK2QIcgO01ss00wTs6bNo7QqWpClKLc0SJ8iPQCGoK91 /rvs6eAt4UYqk8CaECggWj0XHZCrIgbh3WaQsR4fdcLNeStzvq8ZNhJdOBoD5vqNzx96 y5TGxbhYDHWe0q4aH3L2HfTciZrFfFueh+sai6nS3X27VFPH3AjpFhVP0aYMhHtBoFN7 9Q13K3WJuodvW/L1Y71tBbCbbVflDY56V3NaMfM76gMHDVTf9RCJgzkBZT9JzP3Ih7pv wjK38IdFyVXOfBgXEHvthnIyYRNPVuA6hFDg1SJJvRyKnQ/gtsWi1Y8QVa4kLYKsfuZq CfvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gpfDILN2; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h13-20020a056402280d00b0049d221b4b39si2853479ede.187.2023.01.26.06.23.25; Thu, 26 Jan 2023 06:23:51 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=gpfDILN2; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232022AbjAZOXK (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231741AbjAZOXA (ORCPT ); Thu, 26 Jan 2023 09:23:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 195D011658; Thu, 26 Jan 2023 06:22:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A834761759; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6B1EC4331F; Thu, 26 Jan 2023 14:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742977; bh=INUNOAIIyLUZq0CCEN/lm/WexHT7eTy04ZYkgnZoeqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gpfDILN2/jmt5IWV20uE5H1mYQBcSmwIwqTbLLvoYOEp/zNi5IrgiHZzkKAwwjRki pjFVGhFRxXyl19M7GNrx6Lpqt2rndcbq0KhBb0VQJ4W6qv2sbzslQDQu7baw2IMYxa GQFjj5Z8y4tMNitdpflXU2dlyIRBOBMWxvuioZXCbtuPARuabznAnJ3d5UT+QdAUGh sZR2rLlkEPSkaDtpiwuJePe3tZObN0KJ12hPVdjCBh4iPYcVh4vChnbqiE1z+biknV cVfW47SIwsnWU0JYNpPR6PvxI04GLPQ5A6m/0/cToyuSoygGDZ5qnATab5lRJOQFgw Bg/szEjH6j9yA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39c-0006iT-Ik; Thu, 26 Jan 2023 15:23:04 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 07/24] rtc: pm8xxx: use unaligned le32 helpers Date: Thu, 26 Jan 2023 15:20:40 +0100 Message-Id: <20230126142057.25715-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095349306858999?= X-GMAIL-MSGID: =?utf-8?q?1756095349306858999?= Use the unaligned le32 helpers instead of open coding when accessing the time and alarm registers. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 90027a7cfb12..5ff6898bcace 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -12,6 +12,8 @@ #include #include +#include + /* RTC_CTRL register bit fields */ #define PM8xxx_RTC_ENABLE BIT(7) #define PM8xxx_RTC_ALARM_CLEAR BIT(0) @@ -68,25 +70,21 @@ struct pm8xxx_rtc { */ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) { - int rc, i; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; u8 value[NUM_8_BIT_RTC_REGS]; bool alarm_enabled; unsigned long secs; + int rc; if (!rtc_dd->allow_set_time) return -ENODEV; secs = rtc_tm_to_time64(tm); + put_unaligned_le32(secs, value); dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs); - for (i = 0; i < NUM_8_BIT_RTC_REGS; i++) { - value[i] = secs & 0xFF; - secs >>= 8; - } - rc = regmap_update_bits_check(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, 0, &alarm_enabled); if (rc) @@ -157,9 +155,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) return rc; } - secs = value[0] | (value[1] << 8) | (value[2] << 16) | - ((unsigned long)value[3] << 24); - + secs = get_unaligned_le32(value); rtc_time64_to_tm(secs, tm); dev_dbg(dev, "secs = %lu, h:m:s == %ptRt, y-m-d = %ptRdr\n", secs, tm, tm); @@ -169,18 +165,14 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { - int rc, i; u8 value[NUM_8_BIT_RTC_REGS]; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; unsigned long secs; + int rc; secs = rtc_tm_to_time64(&alarm->time); - - for (i = 0; i < NUM_8_BIT_RTC_REGS; i++) { - value[i] = secs & 0xFF; - secs >>= 8; - } + put_unaligned_le32(secs, value); rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, 0); @@ -219,9 +211,7 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) if (rc) return rc; - secs = value[0] | (value[1] << 8) | (value[2] << 16) | - ((unsigned long)value[3] << 24); - + secs = get_unaligned_le32(value); rtc_time64_to_tm(secs, &alarm->time); rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg); From patchwork Thu Jan 26 14:20:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp297692wrn; Thu, 26 Jan 2023 06:26:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXuCLupM0eQw2YCsZ06Pfg03m43UuuiAxn85OdTg0Yvm7ND+QB59/iYYcKbS4MW1SOJb1QOc X-Received: by 2002:a05:6402:5299:b0:49c:5a27:c1fa with SMTP id en25-20020a056402529900b0049c5a27c1famr38739231edb.24.1674743181774; Thu, 26 Jan 2023 06:26:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743181; cv=none; d=google.com; s=arc-20160816; b=FGo3qybkDhPDoUu9wjtVjsPdytwIlJRb/GRBsSYJT2pGxeqOZ1pkusBgWg04yP8VY+ gncIRmoqH1qyPMbLHDQrP6J1ra8VwhfxCAIcGfQFvwP8fYCp0aNo4piWqSdXEUcRdvAf bHTA0sX07yBltv03XMOzwUloFu/nzFsyqbpAmniLTmFMtVLh2EIPbpM+X8RhX4bcBwgH uCdGJ8VotFHlFhqLRF5Jtab0XdJdqq5lHD3PTyAK25Ah+oCovfqVFXs4Z/Fl5VTTu/s5 vqdCHq+a04ijI29AZ5Ii1SfHLWC+SU83MLknp7w9tMC2WSRECAQ+l4mVoihmKUbWKgZo ZsQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vaUYy90/PHNKIrVu6QK4plfScfZX3wscOZT1g/ltw08=; b=ztdYgVhFWhpqQmGxgBv7DwL0cVZtCi++PT5bHABmxUF1gFB5N4IsipLCfk4AH0b9sr oVHFMRDcqLAGtbn6gk/My/sjHH7gRn7qqvUBwJ7XxgViES+u4O6S1UYfOlVgAB+TOTBs txLI5YzulH7aVeI06UAx8aiWDfsWaJW9gZbLm3Pxrx8TfLv2Sm53TKoZwiHMsMCQIoRA jQTdwbXk0k6AoAADH/89xDOe2/hastdN5EZlq2FsiI+82xjUq0mPvJoap2cB+iO2HWFM +h9YbxN69ZDqPjTIRtlCOxiXlp8MxhlvYUCC+MlnwK/FOmtQuLeA6HvmEjpxUfpsmo65 bX3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XCmLjoe7; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z22-20020aa7c656000000b0049cf9c21eb4si1808760edr.409.2023.01.26.06.25.58; Thu, 26 Jan 2023 06:26:21 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=XCmLjoe7; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232172AbjAZOXj (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231908AbjAZOXD (ORCPT ); Thu, 26 Jan 2023 09:23:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEE3711677; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 767B6B81DF4; Thu, 26 Jan 2023 14:22:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E35B2C4332C; Thu, 26 Jan 2023 14:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742977; bh=BIFSHNu7yn057HMpG1CPNyOgFjAwXeeB7J7A6POE7cc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XCmLjoe7BYsfcHll6t/6Pa8YrJoTH67+L+22S86k6yRv9G3bg7Qr27TPFBTdEjCJn wxKZuUv1NBKvuxWrBmZhd/lV3rsz5bOPe9PY0wz2PQg/wGpcyjFxd+9HwMUGLPazMr OCMmhyzN4SIid3raBv/+zD5lCixhR1QzsnbOPggsdnUKIn7XZJGfKaacFIBZuVsLwx VIk1rwZ0iySaHQ7ZOZzFXXrkt5Lua8wi3KK29hWbRavXBwBDN5KJbbGhnlXG/ksfjn ud/5Ob7aaHKGfWPK873k1sDj+PfEt38Ald+vea0PUR13fKI8MHZknBXRN0Z36dLiZj 8srZpHBfx2dfA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39c-0006iW-LH; Thu, 26 Jan 2023 15:23:04 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 08/24] rtc: pm8xxx: clean up time and alarm debugging Date: Thu, 26 Jan 2023 15:20:41 +0100 Message-Id: <20230126142057.25715-9-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095506287251533?= X-GMAIL-MSGID: =?utf-8?q?1756095506287251533?= Clean up the time and alarm callback debugging by using a consistent and succinct human-readable (i.e. non-raw) format. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 5ff6898bcace..8c364e5d3b57 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -83,7 +83,7 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) secs = rtc_tm_to_time64(tm); put_unaligned_le32(secs, value); - dev_dbg(dev, "Seconds value to be written to RTC = %lu\n", secs); + dev_dbg(dev, "set time: %ptRd %ptRt (%lu)\n", tm, tm, secs); rc = regmap_update_bits_check(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, 0, &alarm_enabled); @@ -158,7 +158,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) secs = get_unaligned_le32(value); rtc_time64_to_tm(secs, tm); - dev_dbg(dev, "secs = %lu, h:m:s == %ptRt, y-m-d = %ptRdr\n", secs, tm, tm); + dev_dbg(dev, "read time: %ptRd %ptRt (%lu)\n", tm, tm, secs); return 0; } @@ -191,8 +191,7 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) return rc; } - dev_dbg(dev, "Alarm Set for h:m:s=%ptRt, y-m-d=%ptRdr\n", - &alarm->time, &alarm->time); + dev_dbg(dev, "set alarm: %ptRd %ptRt\n", &alarm->time, &alarm->time); return 0; } @@ -220,8 +219,7 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) alarm->enabled = !!(ctrl_reg & PM8xxx_RTC_ALARM_ENABLE); - dev_dbg(dev, "Alarm set for - h:m:s=%ptRt, y-m-d=%ptRdr\n", - &alarm->time, &alarm->time); + dev_dbg(dev, "read alarm: %ptRd %ptRt\n", &alarm->time, &alarm->time); return 0; } From patchwork Thu Jan 26 14:20:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp297752wrn; Thu, 26 Jan 2023 06:26:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXtxxYDFAsWmeUffs0diny0yvjDlnUROYWsK0vo6BxmqfpWxHQXdovPVt4sAaKuci4lr84hm X-Received: by 2002:a17:906:804e:b0:86b:6a54:36e0 with SMTP id x14-20020a170906804e00b0086b6a5436e0mr35566674ejw.36.1674743187089; Thu, 26 Jan 2023 06:26:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743187; cv=none; d=google.com; s=arc-20160816; b=aO/N0AViQAEKypm1L8qsmg2jczlTLh+rHkNkl4ojUrjKfvFKfDRG/wkXiVRsSOKw0C SnrphH8uDpuwUtIzdTumZZSYR8s9tzkPPSrdBJ46XhGCLmlTFuM2mySfF4RWsihyXo1B Dk5xejdZ/e9EtrMVbAdomEBAL3hAiufQGikAoe7wq+X9aO6GX6513LGpy64WjV6WztLV LGua9j2YLlS5Lm/XDK0aOpd1jo5Qw/2WIdILy3iiABrfO/sm3zJguGDLGBdo5WwnxLHX 783BN8oMeYrRr+f54Lpq3iXq+xEsrN8dbBtZfOOY1Ty8tcM8CRDoGwsTNgTFAAHYi1JY NTQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8VPqI1lr1S+vZ33VYud0BLGI9EQiN3BYFbqtmMviyHo=; b=SKiJX4UGaq1cfCLlTJLc4BqWCVIZQK3sL3z23PwEEV73kXG5U/sm323iSizDrJSMQ0 dpKEkO5MffigP51XTR9wqgne0uXDWXHGXpmblnZp51bvIsQxU6PC70ExoOjSHungVybD g0BohlSTG2u+DKTyiFPZWWByJe1zmK2xSdUk6LFRC6a5ea15CP3X6lSpAcRNR6wEI6Y4 xXYn168Z07IG4D/2FAO95VOqHQn0rtaO0w4yfH6lOBYGftp66KuIfJrFNRA+23HFmPXg t3h/0BK+eHChY1PQOzhFUMwyxCKK+2AATT46icPy6KQGWHsRckDHl2jRHXbSRrAbR24w 6Zgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uAOGAGpN; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wc13-20020a170907124d00b008779c9c6ba1si1460698ejb.43.2023.01.26.06.26.02; Thu, 26 Jan 2023 06:26:27 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=uAOGAGpN; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232093AbjAZOXl (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231879AbjAZOXC (ORCPT ); Thu, 26 Jan 2023 09:23:02 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF2A01D91F; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6C5A4B81DF0; Thu, 26 Jan 2023 14:22:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3E2BC43324; Thu, 26 Jan 2023 14:22:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742977; bh=7/HQf6/GGIuDaxy+2slvzMSyzdgxzdXhyFV520wU3YQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uAOGAGpNA3ePLe//qEtVZpQq7P/FHcAbDUvjWAtzzuqXNaCArPvXkWSXv4AloYJJ0 YzzqlF1q8GUUQITiqe8Z/C9qm/BANog3AMA33CIBYVs27E94yId7Uk940ZdvOS7TCR 4FKq61ydVoO39kvuepnXVxJjtc6zasLIr/1N8P18jfCUH5vfzJYfHr7h8y6AHgZbtN 9BMXsHFD39o3Hie9tOBN7G+Y6WcZ/8I1n6PuE4c3S3kj4jpSwkUx9EUOvQGaHwrsJ9 XNkt9vwwIFraChOyUCXCozyp/z7KHBAAPSo2p4Fe/0y2W2xco+qIsGW92b2CiENBL6 /rzdMAa4SpaIQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39c-0006iZ-OG; Thu, 26 Jan 2023 15:23:04 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 09/24] rtc: pm8xxx: rename struct device pointer Date: Thu, 26 Jan 2023 15:20:42 +0100 Message-Id: <20230126142057.25715-10-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095512315451439?= X-GMAIL-MSGID: =?utf-8?q?1756095512315451439?= Rename the driver-data struct device pointer by dropping the "rtc" prefix which is both redundant and misleading (as this is a pointer to the platform device and not the rtc class device). Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 8c364e5d3b57..0fdbd233b10e 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -48,7 +48,7 @@ struct pm8xxx_rtc_regs { * @allow_set_time: indicates whether writing to the RTC is allowed * @rtc_alarm_irq: rtc alarm irq number. * @regs: rtc registers description. - * @rtc_dev: device structure. + * @dev: device structure */ struct pm8xxx_rtc { struct rtc_device *rtc; @@ -56,7 +56,7 @@ struct pm8xxx_rtc { bool allow_set_time; int rtc_alarm_irq; const struct pm8xxx_rtc_regs *regs; - struct device *rtc_dev; + struct device *dev; }; /* @@ -372,7 +372,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) "allow-set-time"); rtc_dd->regs = match->data; - rtc_dd->rtc_dev = &pdev->dev; + rtc_dd->dev = &pdev->dev; rc = pm8xxx_rtc_enable(rtc_dd); if (rc) From patchwork Thu Jan 26 14:20:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp297903wrn; Thu, 26 Jan 2023 06:26:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXt7+UOBE749gkNjwzs9GPZdYGY67hTKLFA43sbg1uS2gSqzX51wHkjHMRk/ckZmR5zV3lev X-Received: by 2002:a05:6402:1956:b0:45c:835b:9448 with SMTP id f22-20020a056402195600b0045c835b9448mr42475812edz.4.1674743206020; Thu, 26 Jan 2023 06:26:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743206; cv=none; d=google.com; s=arc-20160816; b=aeNsBUkM5OWiA+GzsNMhbNDRuUA5kpHW9y1tjCkiABi7FQ0CDxhhu33rOVewL3QA8F EMGjIZrfHct49qmNGpL1lRElqmd23IkqiNck+DCSRbiE37MKOFypIpbfxfI/eHDez570 WriaylVPtrOhXCnzmmlcl8z6vbiA2TGQDBg49NQcGrC8Mvphazhn+e2fnGO4RSq8viVg B3zouzy/j6YSUonGZWrU5J/8iemp+8jBZ6w0EH91KZSI6h6IakbVbiaUUaw2aKvmo0sH uR7mLCQO6YXMRQxIPgorOgom7g1fwauYGe8RB84436nUPzls0eKHQGjvc7Jw8zKKeRlC oc/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mfknoiBDActZcfeSUhOB1aIk78VzOi+HIcs8AUthTxo=; b=T8kahueG8hDPOTKHbUt4GSk9JAFaJ4j6aatTXC8OCcylJFIOhiedAwAA4vsQ8ndsu5 rQNO28Qnb0lK5N1OrvXUcF/DO53zBcebBiGyJZDkyWhmiEjfEO3Unlhn9oX7QZbzul40 TF1ONLGRlWeWXStu/Mn39pclTkbDbBoiut9GYDCZtyiHTgWV2FalpQSkC1tqRfFvtV7H Mjw3hxZeF28dmT+k6V35l9lYTEUonSccuLkBsUTs1Fly38tnDwRJ8u/EH+i3hHYVwHkh DWzplVfVhhHMKM135ZG1V50CM17QPz4BTxmoPxjQTqf8u2cPA2xeqKgKeEKwghzV2SZY Z+/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LBQT9bNA; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a31-20020a509ea2000000b00499b3f1fb6fsi1881717edf.159.2023.01.26.06.26.22; Thu, 26 Jan 2023 06:26:45 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=LBQT9bNA; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232231AbjAZOXy (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231979AbjAZOXF (ORCPT ); Thu, 26 Jan 2023 09:23:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94ADB34021; Thu, 26 Jan 2023 06:23:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7AE43B81DF5; Thu, 26 Jan 2023 14:22:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15EDDC43339; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742978; bh=4z6TJNCwS8qAM3wHcv2tU/0WELTPhAMwIRU/5y7TjEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LBQT9bNAxaKz3msJlHyveDXtH9yd1HKLE5fDUuw8OD2p7etlbFJPb2qRBztfKhuYF rUxQClpzfTQaRpRQa4CSoCp9T/Wl93TVXapwPn+FYBuONDOb74X6RIN37Fj8oD++SG z1AsFAaBUmD783R10QNTVWZR21BwgdyEKS2dZ+oJ9W4IdWROZ/zEDqU8rSj7BqzI7L qGMmjB/v+QqBKj+Up2tC8YiraDoyW0uzoh34MjZN9+L4RcytiIPb9vaft6pSNNhYFD MEbIBK4TO9YL3rH86ppK60lMlB3mW5w1p1Juu/hqcVjinkWL0oREeZXJ1JXegeCHok wi4F9K1A1yubA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39c-0006id-RQ; Thu, 26 Jan 2023 15:23:04 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 10/24] rtc: pm8xxx: rename alarm irq variable Date: Thu, 26 Jan 2023 15:20:43 +0100 Message-Id: <20230126142057.25715-11-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095532259595158?= X-GMAIL-MSGID: =?utf-8?q?1756095532259595158?= Clean up the driver somewhat by renaming the driver-data alarm irq variable by dropping the redundant "rtc" prefix. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 0fdbd233b10e..ea867b20573a 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -46,7 +46,7 @@ struct pm8xxx_rtc_regs { * @rtc: rtc device for this driver. * @regmap: regmap used to access RTC registers * @allow_set_time: indicates whether writing to the RTC is allowed - * @rtc_alarm_irq: rtc alarm irq number. + * @alarm_irq: alarm irq number * @regs: rtc registers description. * @dev: device structure */ @@ -54,7 +54,7 @@ struct pm8xxx_rtc { struct rtc_device *rtc; struct regmap *regmap; bool allow_set_time; - int rtc_alarm_irq; + int alarm_irq; const struct pm8xxx_rtc_regs *regs; struct device *dev; }; @@ -364,8 +364,8 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) return -ENXIO; } - rtc_dd->rtc_alarm_irq = platform_get_irq(pdev, 0); - if (rtc_dd->rtc_alarm_irq < 0) + rtc_dd->alarm_irq = platform_get_irq(pdev, 0); + if (rtc_dd->alarm_irq < 0) return -ENXIO; rtc_dd->allow_set_time = of_property_read_bool(pdev->dev.of_node, @@ -391,7 +391,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) rtc_dd->rtc->range_max = U32_MAX; /* Request the alarm IRQ */ - rc = devm_request_any_context_irq(&pdev->dev, rtc_dd->rtc_alarm_irq, + rc = devm_request_any_context_irq(&pdev->dev, rtc_dd->alarm_irq, pm8xxx_alarm_trigger, IRQF_TRIGGER_RISING, "pm8xxx_rtc_alarm", rtc_dd); @@ -404,7 +404,7 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) if (rc) return rc; - rc = dev_pm_set_wake_irq(&pdev->dev, rtc_dd->rtc_alarm_irq); + rc = dev_pm_set_wake_irq(&pdev->dev, rtc_dd->alarm_irq); if (rc) return rc; From patchwork Thu Jan 26 14:20:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48714 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp296800wrn; Thu, 26 Jan 2023 06:24:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXsg4d0A4hdRBtq8UJhCL29r6FbPpJDr2TAbzCTOnbdLpr8jERrvSmjCQ36bwrHyZ42CoX4x X-Received: by 2002:a17:907:1110:b0:872:bb39:a6e1 with SMTP id qu16-20020a170907111000b00872bb39a6e1mr36664105ejb.52.1674743074705; Thu, 26 Jan 2023 06:24:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743074; cv=none; d=google.com; s=arc-20160816; b=zsNYngEYSqSENlfq6wcdJ+aOCzhb1Q4dkjnrsKDEXuF7AIZJGy8Mjt6AIYWxaPkNGw A7f6QSqdtxHSqLfGvx+zjyz7/NmhDtq9HFxBxXAo2PsmS8il7PxNt69cfU1y9BMklO2x NKNmmVQDo6syg9S77Fcfdvjw9AsoFv+xLZr8e9+eLK12FEsoxDDoRJnQrOhzewYTis8Q KOKcNMNjF/F5giG7PoHZtUGgC0F/+cEuHFsGc0zMs87alM8wYNUG9QeaNVrKcQ7A6Ovs cLfpYexrAienxX0IS0ijpzCe050rAjYeN33iUker9SCbPk/zE2+qxwPPf3FxjEAvK6T3 8pEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XLkxmDTG6dvT5xcTSlQXIbY0X3Vo9HrvaU3pkclajCk=; b=IZprxskw0ErUahTihtqo4g0f1H5t3kdKiws8QDBDslSLILmkpz6QaEIp1/ZQ+GjaGa Sjona48lX4cGUW+VHE5e+/cPBlE/5BsLJB6Z9Wfc/qbaVks5bGt/vz2LXwNzM4Qb1Wiq a5DlZnZQSXt79+IqYZE0asvRGqMNdGa8R0WE5iHQGWu+l6rqA1qIuLUKgt9i4bXYPzq5 guBeqGsHMHlrzWwqWOZWvrYEtHKqwP4C/73MZM0XsISN5Pal7RDCDIwUcZZAtcVUwJRr Nkh9YBnf2lTK9ycnHUrSbTahIwlIm23UdQ5K+uyL2P+KW7V95IpzMK3YAQ6tSAWzAazm U9/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y2P++exf; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn19-20020a1709070d1300b0087777bb4127si1861762ejc.172.2023.01.26.06.24.10; Thu, 26 Jan 2023 06:24:34 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=Y2P++exf; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232167AbjAZOXh (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231912AbjAZOXD (ORCPT ); Thu, 26 Jan 2023 09:23:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E03DD1D932; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 7022AB81DF1; Thu, 26 Jan 2023 14:22:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1158CC43335; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742978; bh=WgIpMYi4FWB9ExPnYPbTqydDNPPFYwbTWNzEsRMkHfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y2P++exfhCPS0wl63NfNlZ9YTF6VV4ZmZvL2VWcAMqTbPOuagVa/Sr1rEJOCUDJB2 8/sV9t+VcsLmLR3hDIuEwQjOC0Qy9SPfnffxUx8E+Iqd3hrRieU2nd1FUbbwgItkOf kltAkxHnKaDgV7ItPF0wptnJPqaJZaxusnLf45/yILWIBMnAoxlfLcCZYPfkDLQ3O5 hnjhKC1jZqiVaaDkuNPHYafSNyXx+PsLJ0V74KfrtE9nRJyhUPuh8+MuRs66y66hiB ANKnLvvbCL6Q+OmLTkwEJBCoWtStshKXpxHtC/yWOlteSPHQeAjLbe42N/5yHbAggq QUU7aF07HNL2A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39c-0006ig-Ui; Thu, 26 Jan 2023 15:23:04 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 11/24] rtc: pm8xxx: clean up comments Date: Thu, 26 Jan 2023 15:20:44 +0100 Message-Id: <20230126142057.25715-12-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095394022593302?= X-GMAIL-MSGID: =?utf-8?q?1756095394022593302?= Clean up the driver comments somewhat and remove obsolete, incorrect or redundant ones. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index ea867b20573a..8a94a19e0d14 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -23,13 +23,13 @@ /** * struct pm8xxx_rtc_regs - describe RTC registers per PMIC versions - * @ctrl: base address of control register - * @write: base address of write register - * @read: base address of read register - * @alarm_ctrl: base address of alarm control register - * @alarm_ctrl2: base address of alarm control2 register - * @alarm_rw: base address of alarm read-write register - * @alarm_en: alarm enable mask + * @ctrl: address of control register + * @write: base address of write registers + * @read: base address of read registers + * @alarm_ctrl: address of alarm control register + * @alarm_ctrl2: address of alarm control2 register + * @alarm_rw: base address of alarm read-write registers + * @alarm_en: alarm enable mask */ struct pm8xxx_rtc_regs { unsigned int ctrl; @@ -42,12 +42,12 @@ struct pm8xxx_rtc_regs { }; /** - * struct pm8xxx_rtc - rtc driver internal structure - * @rtc: rtc device for this driver. - * @regmap: regmap used to access RTC registers - * @allow_set_time: indicates whether writing to the RTC is allowed + * struct pm8xxx_rtc - RTC driver internal structure + * @rtc: RTC device + * @regmap: regmap used to access registers + * @allow_set_time: whether the time can be set * @alarm_irq: alarm irq number - * @regs: rtc registers description. + * @regs: register description * @dev: device structure */ struct pm8xxx_rtc { @@ -90,7 +90,7 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) if (rc) return rc; - /* Disable RTC H/w before writing on RTC register */ + /* Disable RTC */ rc = regmap_update_bits(rtc_dd->regmap, regs->ctrl, PM8xxx_RTC_ENABLE, 0); if (rc) return rc; @@ -111,7 +111,7 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) if (rc) return rc; - /* Enable RTC H/w after writing on RTC register */ + /* Enable RTC */ rc = regmap_update_bits(rtc_dd->regmap, regs->ctrl, PM8xxx_RTC_ENABLE, PM8xxx_RTC_ENABLE); if (rc) @@ -242,7 +242,7 @@ static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) if (rc) return rc; - /* Clear Alarm register */ + /* Clear alarm register */ if (!enable) { rc = regmap_bulk_write(rtc_dd->regmap, regs->alarm_rw, value, sizeof(value)); @@ -269,13 +269,13 @@ static irqreturn_t pm8xxx_alarm_trigger(int irq, void *dev_id) rtc_update_irq(rtc_dd->rtc, 1, RTC_IRQF | RTC_AF); - /* Clear the alarm enable bit */ + /* Disable alarm */ rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, 0); if (rc) return IRQ_NONE; - /* Clear RTC alarm register */ + /* Clear alarm status */ rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl2, PM8xxx_RTC_ALARM_CLEAR, 0); if (rc) @@ -332,9 +332,6 @@ static const struct pm8xxx_rtc_regs pmk8350_regs = { .alarm_en = BIT(7), }; -/* - * Hardcoded RTC bases until IORESOURCE_REG mapping is figured out - */ static const struct of_device_id pm8xxx_id_table[] = { { .compatible = "qcom,pm8921-rtc", .data = &pm8921_regs }, { .compatible = "qcom,pm8058-rtc", .data = &pm8058_regs }, @@ -382,7 +379,6 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) device_init_wakeup(&pdev->dev, 1); - /* Register the RTC device */ rtc_dd->rtc = devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(rtc_dd->rtc)) return PTR_ERR(rtc_dd->rtc); @@ -390,7 +386,6 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) rtc_dd->rtc->ops = &pm8xxx_rtc_ops; rtc_dd->rtc->range_max = U32_MAX; - /* Request the alarm IRQ */ rc = devm_request_any_context_irq(&pdev->dev, rtc_dd->alarm_irq, pm8xxx_alarm_trigger, IRQF_TRIGGER_RISING, From patchwork Thu Jan 26 14:20:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48715 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp297257wrn; Thu, 26 Jan 2023 06:25:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXsqIPi7EiEkFRzQKZuFqhSYP6xc7nWtbVePTG4CwnCDd+poVZWQRQXh4clYZSJS55bVQchN X-Received: by 2002:a05:6402:5306:b0:49b:b274:b815 with SMTP id eo6-20020a056402530600b0049bb274b815mr40113411edb.39.1674743133220; Thu, 26 Jan 2023 06:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743133; cv=none; d=google.com; s=arc-20160816; b=Q3Aoy8HdAjDQve3o7jSYfIgJEoYOgzyEa+r31WkCRkae1eYj280RpjLUr4D/iSeE0T pfAXgL2BunHGJagDBe5tIHNYsujYQkWr2ufU8GQL4uTkbPOaDdcJOygm6Qulv6YHoabX NZdMrjbct9SuBudmPwQLGIDWE32IGyRYQYehMi+OrR1JCBEPxltN3+4D+hLS3Tz19x6y yp9Pj5VwEO4lc+nwGAr/U5nNkYijVjNzdNuBuJmlN0+wFKhJaC4RuHKwlf4IQnHCRhRm mjA0UO4oqDtcCUUix3VS2dr+MpN+8hVBVUAdUemL2eZilAz4SUcKUrIrDiY+ZcNHxUO3 HUsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=r82Uy/4GkwmX4T8zh+mXPpVq4PFwdPiMIZOrJao3JEY=; b=BNTgAJ/8i6tVHXhwkAkzVg7Y0yUf5rNzKzDEQqQ0tq2LkbmJCCWydEIjZ3c/LhqzHx IL6yB6JsFiBSAYenqMNhIM+GqRCrmxQI1kZfPgTQqSMlo8Hjaq+F6ti+pHSQaVSp//Yj SIM0RsEkoaKtEoIcDtIKdmIlXxD1Bs7ZjtllVr3e963S170kYY0qMAZkoH7oPfSQ5xVo nddQMH+VZDCCV7jStC1/wA+ATJVkT1B87uaeNl2NGXmNm4wh8uVV5qpTgTQq4dXPsgNR BxofyXyiQUAy+9QLMHa0U7zjebjXut6AhQjOdGDLxvtexXmjlxL7nLHjQd7/c5+nHECO vWLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DyoqI8A8; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 16-20020a170906021000b0086f0864592dsi1644921ejd.321.2023.01.26.06.25.08; Thu, 26 Jan 2023 06:25:33 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=DyoqI8A8; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232088AbjAZOXU (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231869AbjAZOXC (ORCPT ); Thu, 26 Jan 2023 09:23:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EC60113D6; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D4D4861851; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 201BBC4333B; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742978; bh=/YRM5Ic3ZY+jzd9X9EDvX7MvH3WHxEA0VUrC4Satfvw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DyoqI8A87cJGQXnD7+L7dl3WOCOHfnZatJ9NZucT2o+3XlPYuwqEsthsNQzrp5RGw lUQZA+x9rKmxlIMo4rSbtDQQmJiUjnnsisvnkcVHV3deaxxvCBUTvZt1SNgwYhRgZq vrmElovfH8pmYL8B8rQG04WK1XoP/c0bGPehFRuZS8nJV23IT+XerTKk9z47MdE1rI ebGMSxmN+YkGd/XBDTiCbaZPP3p/Z9Vl/xp8wmgBHKy/9wkibsqPskPnh06F1L/A6N AOlll+fkdsLmGhYM+qGMlbhJIGcbwzMc1syf419fQU7R7lRZVBfWqDpSIQJ+oH7L5y kh4O6yUnTW9BQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006ij-1h; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 12/24] rtc: pm8xxx: use u32 for timestamps Date: Thu, 26 Jan 2023 15:20:45 +0100 Message-Id: <20230126142057.25715-13-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095456035790473?= X-GMAIL-MSGID: =?utf-8?q?1756095456035790473?= The PMIC RTC registers are 32-bit so explicitly use u32 rather than unsigned long for timestamps to reflect the hardware. This will also help avoid unintentional range extensions when adding support for managing an external offset. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 8a94a19e0d14..b1ce246c501a 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -74,7 +74,7 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; u8 value[NUM_8_BIT_RTC_REGS]; bool alarm_enabled; - unsigned long secs; + u32 secs; int rc; if (!rtc_dd->allow_set_time) @@ -83,7 +83,7 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) secs = rtc_tm_to_time64(tm); put_unaligned_le32(secs, value); - dev_dbg(dev, "set time: %ptRd %ptRt (%lu)\n", tm, tm, secs); + dev_dbg(dev, "set time: %ptRd %ptRt (%u)\n", tm, tm, secs); rc = regmap_update_bits_check(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, 0, &alarm_enabled); @@ -131,10 +131,10 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) { int rc; u8 value[NUM_8_BIT_RTC_REGS]; - unsigned long secs; unsigned int reg; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; + u32 secs; rc = regmap_bulk_read(rtc_dd->regmap, regs->read, value, sizeof(value)); if (rc) @@ -158,7 +158,7 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) secs = get_unaligned_le32(value); rtc_time64_to_tm(secs, tm); - dev_dbg(dev, "read time: %ptRd %ptRt (%lu)\n", tm, tm, secs); + dev_dbg(dev, "read time: %ptRd %ptRt (%u)\n", tm, tm, secs); return 0; } @@ -168,7 +168,7 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) u8 value[NUM_8_BIT_RTC_REGS]; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; - unsigned long secs; + u32 secs; int rc; secs = rtc_tm_to_time64(&alarm->time); @@ -201,9 +201,9 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) int rc; unsigned int ctrl_reg; u8 value[NUM_8_BIT_RTC_REGS]; - unsigned long secs; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; + u32 secs; rc = regmap_bulk_read(rtc_dd->regmap, regs->alarm_rw, value, sizeof(value)); From patchwork Thu Jan 26 14:20:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48709 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp296632wrn; Thu, 26 Jan 2023 06:24:10 -0800 (PST) X-Google-Smtp-Source: AK7set9zWmYKVHKQg9Oh0jXUgzPLtwn0KbPoRi7k51iz4QoGyGBFiEJu47UdUJF4i3VN2iK/rCN2 X-Received: by 2002:a05:6402:2421:b0:49e:ed9c:215f with SMTP id t33-20020a056402242100b0049eed9c215fmr1309632eda.38.1674743050232; Thu, 26 Jan 2023 06:24:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743050; cv=none; d=google.com; s=arc-20160816; b=y03AxwBPI4gzilairDC8nJbKL3RDNNxY/t6Qxe/qI73qS2hixhtNVlDZUeaC801cA2 FhdYQp4kqoeFYpZuGAhbKp9pmshNH3jR89JMjDC3OnIkvPltTAi/+yriSDql8ppY0qfT JuOvGQ6zKKcAB4zrtbJ8MDBhd/X3vNq8Aa+cmFSK+YgeCIvIuMZxNO1yKObtfZL1RrOg dZ41d4BgCWKLT5+J+FYUNJFrFBbOIsN90OAUBNh//ilRo5S7jJlfP8gvnDFpbmSAHjdJ 84ybt+g1TP8JurT3FuLjw3k67h18pQVqJ7lPOQkgh+UPbZyHDgf5MsZ1vhRHArOpGcn/ 2PZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=C7SVNiMpDG/jd0BTjNxyFPqWmDxlh7Xmmlr1YNH6jEo=; b=Av3J3/oiqp11jHnJ0ZpGZSSc6mudp3aGbts6tGBVOzc5nsJ6W+jonSt8wI7cNRmm41 NDfP+w5wS+r7HX+ZSCEhx1SFfrYGLwvkrC+f/8TgugyBgTprba8yoVNtFzCZhlEiuPET CnSyegBAxRdvRSU4jCxZ3xnl/hy37bZj2AypXlyxU8DH5saJ1jlUyQhgkj0YR8ejwCBn hQ0LH98ENrEze07Tk8bz/cch4pl9c7yADW9yMUBEE4d70oIXgwFa/EKVEncQJ45KZ4wC G/hepiDKCCE2GUr/1Eh7wJ6r10eOTOvjOtc3R5pck6Y4rFmSYM1dkkRPFKzkDt8fZCPA JX3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ejj99tG2; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f8-20020a056402160800b00488c68b1998si1931219edv.103.2023.01.26.06.23.46; Thu, 26 Jan 2023 06:24:10 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=Ejj99tG2; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232116AbjAZOXV (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231873AbjAZOXC (ORCPT ); Thu, 26 Jan 2023 09:23:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ECB9113E4; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D8F3161856; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B1D0C433A1; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742978; bh=yUxC+lcXB5W9v1WZ5zrNhza/r9HK2s/OODdAQcbHFZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ejj99tG2bXtibv0Ng9yQlXE9MJdkQmaWaL0uOnpkCg3SwDVglOIoDA5fejqAPS8RJ EGERQvMw0JYJqQD+Ap/SUbxyKdowiunvIXLcPUsQV1b8xZ+Q1fcPyIbiJgOWLg7UJa KUPDx7iNFyeyyb/owSwhQ4KVXsLYQ5X4P45n5yQucekf11FvNiigJguauSOVNUG+I0 +ObVsbJuAHQghSVxwTgJ1mvTQb/FOqPLemd6RMX4jni30rmEJSLRaOX/rm/HF+7Zr5 0ZQP9z5M2Xn39QEVGurUOcCGl+A/kQlUA7VTwVo/CqCedhlHTPuaTZ5qG0142S4WbK dwIXSEvs4Grrw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006im-4E; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 13/24] rtc: pm8xxx: refactor read_time() Date: Thu, 26 Jan 2023 15:20:46 +0100 Message-Id: <20230126142057.25715-14-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095368472815527?= X-GMAIL-MSGID: =?utf-8?q?1756095368472815527?= In preparation for adding support for setting the time by means of an externally stored offset, refactor read_time() by adding a new helper that can be used to retrieve the raw time as stored in the RTC. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 54 ++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index b1ce246c501a..2f96a178595c 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -59,6 +59,37 @@ struct pm8xxx_rtc { struct device *dev; }; +static int pm8xxx_rtc_read_raw(struct pm8xxx_rtc *rtc_dd, u32 *secs) +{ + const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; + u8 value[NUM_8_BIT_RTC_REGS]; + unsigned int reg; + int rc; + + rc = regmap_bulk_read(rtc_dd->regmap, regs->read, value, sizeof(value)); + if (rc) + return rc; + + /* + * Read the LSB again and check if there has been a carry over. + * If there has, redo the read operation. + */ + rc = regmap_read(rtc_dd->regmap, regs->read, ®); + if (rc < 0) + return rc; + + if (reg < value[0]) { + rc = regmap_bulk_read(rtc_dd->regmap, regs->read, value, + sizeof(value)); + if (rc) + return rc; + } + + *secs = get_unaligned_le32(value); + + return 0; +} + /* * Steps to write the RTC registers. * 1. Disable alarm if enabled. @@ -129,33 +160,14 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) { - int rc; - u8 value[NUM_8_BIT_RTC_REGS]; - unsigned int reg; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); - const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; u32 secs; + int rc; - rc = regmap_bulk_read(rtc_dd->regmap, regs->read, value, sizeof(value)); + rc = pm8xxx_rtc_read_raw(rtc_dd, &secs); if (rc) return rc; - /* - * Read the LSB again and check if there has been a carry over. - * If there is, redo the read operation. - */ - rc = regmap_read(rtc_dd->regmap, regs->read, ®); - if (rc < 0) - return rc; - - if (unlikely(reg < value[0])) { - rc = regmap_bulk_read(rtc_dd->regmap, regs->read, - value, sizeof(value)); - if (rc) - return rc; - } - - secs = get_unaligned_le32(value); rtc_time64_to_tm(secs, tm); dev_dbg(dev, "read time: %ptRd %ptRt (%u)\n", tm, tm, secs); From patchwork Thu Jan 26 14:20:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp297924wrn; Thu, 26 Jan 2023 06:26:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXtFXFn4HrySue9AfsjjKyRtiRuWmPgxpSfrsFCHSzCI2E6g01qRPw0Ta5nqUFPHwnmpuOrV X-Received: by 2002:a05:6402:5412:b0:49d:f4de:1988 with SMTP id ev18-20020a056402541200b0049df4de1988mr40262782edb.42.1674743209136; Thu, 26 Jan 2023 06:26:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743209; cv=none; d=google.com; s=arc-20160816; b=Gl4lv8i/YDcsxR2bpSNGeCvOPhHrnDTLPD95Hzuq4D8vPgHSvRcKpNNrRYJuiBiP6Z zL1vwbAosKkZwtBGGmmG9WwlLSUpVn8lRdvGv4A4fauV9D+NUJjoAuXO38XVBHqCiLbP RJlvUIVo2x28x53e5G7LsQsOuoLnkDIXU+EBh++IP/naoIMQ++OA7GCb8tELz3X6ZcQi A0TSkRgxvHfFF0jrWpPmdQP1fp3KaQ8IGOqxyk94sIzFKu5wZcZ+kDHIm+5AYPd1UND/ PUJB1V+pfLGXQumS3tjI/Oj03P84GoAtj6JDNYSp2ufVSjmoXocvEkvuizdszYno5/MQ 3G+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UOUITaCpXRdx7QBo6ZzBFOdaYjBdsbRCilaIJm6kNn8=; b=JhoFADNwkhmLuAVSalSqif6IIPgy0aK13Y9Dg6bkrq2AJRI0tDYzNva/NdP741rs+/ XxnLM/9RsmYs/5MtRgd1TZnWHSB1qxNO5A9em4/svXmWjDzrGm8tcSf7hv3mie8C7Cme cRITlnPQHEbwHiq+V2PJXAKrfsFonj5iDnITTDuOVvVNKviOqHZSaZ4lGvKquHmnYiyg REk5NX0KX8CBApukb+7SLR43T48b85YnjwBA6m9ni/F0IcvY2+32Ml3grxArywVGj9RU Comim6cGfxYI2h69Rc2tW8p6SsG9MeNnDk5mTRkXHuQ4E3MU3wQro2uMbe6MNVxnmok5 M+CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MgXXlPuY; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i20-20020a50d754000000b004a0a7676130si1958169edj.31.2023.01.26.06.26.25; Thu, 26 Jan 2023 06:26:49 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=MgXXlPuY; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232236AbjAZOX5 (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231985AbjAZOXF (ORCPT ); Thu, 26 Jan 2023 09:23:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A102B113E4; Thu, 26 Jan 2023 06:23:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 001D0B81DF6; Thu, 26 Jan 2023 14:23:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B115C4322E; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742978; bh=ivf8oy7wqRDszm/BUrY97t3/c8yLV7KjrfeB3zeaq0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MgXXlPuYv2IqtdbJcM1Rcx7qf1xF0zIhG6QWg1mFH2mZq7r4DxuIKFRjLg5xmOFRI r2gShAU7c6Du+NGn7P2HFOgg/lnnSX41hCqjMKt0PYDi96y1a6/15gi78ZXz/+3wvr MqjDbCgDFaeQq2UPZ3FTzT5hOlCXResTRl+F8ybwVuRdgixTsMy0n/Y2qaVzgQ7iVo NkxRTV3GGMgiJVkIdY4KB0/UxI+NM5IjUPE/A0xK+OOq98QWWY6cjVWmvCYkhUQ1/e Z3eByYTJ5VZvm7yvpx2wgvTh17Spzj041nFlrMm4edAKA28ey7OpF2IeTbbSakK8I3 DfZc5CSBFS/oQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006ip-6j; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 14/24] rtc: pm8xxx: clean up local declarations Date: Thu, 26 Jan 2023 15:20:47 +0100 Message-Id: <20230126142057.25715-15-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095535527494911?= X-GMAIL-MSGID: =?utf-8?q?1756095535527494911?= Clean up local declarations somewhat by using the reverse xmas style consistently throughout. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 2f96a178595c..922aef0f0241 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -177,9 +177,9 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) { - u8 value[NUM_8_BIT_RTC_REGS]; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; + u8 value[NUM_8_BIT_RTC_REGS]; u32 secs; int rc; @@ -210,12 +210,12 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) { - int rc; - unsigned int ctrl_reg; - u8 value[NUM_8_BIT_RTC_REGS]; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; + u8 value[NUM_8_BIT_RTC_REGS]; + unsigned int ctrl_reg; u32 secs; + int rc; rc = regmap_bulk_read(rtc_dd->regmap, regs->alarm_rw, value, sizeof(value)); @@ -238,11 +238,11 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) static int pm8xxx_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) { - int rc; struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; u8 value[NUM_8_BIT_RTC_REGS] = {0}; unsigned int val; + int rc; if (enable) val = regs->alarm_en; @@ -355,9 +355,9 @@ MODULE_DEVICE_TABLE(of, pm8xxx_id_table); static int pm8xxx_rtc_probe(struct platform_device *pdev) { - int rc; - struct pm8xxx_rtc *rtc_dd; const struct of_device_id *match; + struct pm8xxx_rtc *rtc_dd; + int rc; match = of_match_node(pm8xxx_id_table, pdev->dev.of_node); if (!match) From patchwork Thu Jan 26 14:20:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp298077wrn; Thu, 26 Jan 2023 06:27:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXs95FeA2m3lvrUqlCYaJlYDES6hVDo2N5ZykwidzgAculItzq6kDksxQA18UIqgtsukcJt2 X-Received: by 2002:a17:906:dc44:b0:86d:abca:3f55 with SMTP id yz4-20020a170906dc4400b0086dabca3f55mr41818804ejb.15.1674743226402; Thu, 26 Jan 2023 06:27:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743226; cv=none; d=google.com; s=arc-20160816; b=jo9HWxkJogtr1o5ulvgxWOyyQaXJ9qFBqyUEW1NuXuoB4vkreyNhgyynt+5NrdRUq1 Nf1pYXgEvEp00Aa4z0049Nc1ODaB6KSat08GKPq/PTa8IpbNKAJ/OtbLCig6uZV5RcKZ UtoBczRMHwXfNKdvVocjKTC2UEpAGyKF/LffwV8rpKAGTUjPxK8KyKKEFXzeJOzwuJJi tXQ2PuYJODsdeD306MxoiDN1Fl3onDmVQrvjULq9qaHiustlDzqj1sYN9An1jXVLIy0X yL098IXWS8+nqYz6Hh6Iwilxh9U+nyXhAO+L/Q+bHAhfaoYUF+xiNv6qNf8DOqAV7KIW osJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fcDxyFeNWZW/USdTfm2r6LDZK+y9VZ0AaHx/6d7pXFA=; b=z2bvKVhaRI9B1frL9YaXZrH7OSviux1nZSoV/DmaC2500uXwWWTixQXWMIugT6SSdE sTClYZPLH6AlgmPbP/53BHRawXtRsmxwWFPS8nC/ZmDQEZ9dUnfJr5u+j54DG8Ksp+rq yJJ99npwVQAl3ig2BG3z0QsG6ysnhJMT0RLJ+tFnsfVVpvCAAMHEs8gAi7gAH4C1osfC FF1/C/c0EjU4RceFTiy7r3f/bKVqhKdyAQ9ZsP9zHmgUmdub/Ia9E90KLejzl3U4VZvh mVoInokAsRfu3Zjb+k0pePC16WPotCnaszd/6Gc5VlXAKTw/3FEf37LJtcJD0EpnkCWv G2CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OMnTIpqG; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ms32-20020a170907622000b007d82520def9si1395367ejc.503.2023.01.26.06.26.42; Thu, 26 Jan 2023 06:27:06 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=OMnTIpqG; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232245AbjAZOX7 (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231991AbjAZOXF (ORCPT ); Thu, 26 Jan 2023 09:23:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 470283757B; Thu, 26 Jan 2023 06:23:04 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 08C04B81DF8; Thu, 26 Jan 2023 14:23:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63D5FC4322F; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742978; bh=2SM/Ui25AWvYpcR7rG/b1iY3k51zQ41f392BYri9b24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OMnTIpqGk9MS51mIXmtKCNcxlJaK26xH4GGnA1GIWjxMtOuQmnhywFbzqMZA7V5r9 4IjElCUzoqhXP5eWBpGihE7DyWawK7G+AOVoExtB/D4fYAkaFUEkkt7MzEUKzWGM6E HjOA/tTLJiVdLjKU19LhpP9xFHccNde8LdfyfCEdGmzpk4VuUGuBt+xwENFPlvdg8A 6lqZXgl6l6kYj8kXHVCnufDDHOV26iC6UhK+1uPwy0k2FpBAytyV9SJex8l23BJZlb zw1kf7ODFdKWUVg2/g2pu2cqzLEZdTNixRzQMY86Z7Elkd0oJzGfepOdbgDknO5mK9 b1ls8j3EplOww== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006ir-9H; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 15/24] dt-bindings: rtc: qcom-pm8xxx: add nvmem-cell offset Date: Thu, 26 Jan 2023 15:20:48 +0100 Message-Id: <20230126142057.25715-16-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095553621183215?= X-GMAIL-MSGID: =?utf-8?q?1756095553621183215?= On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account. Add an 'offset' nvmem cell which can be used to store a 32-bit offset from the Unix epoch so that the RTC time can be updated on such platforms. Signed-off-by: Johan Hovold Acked-by: Krzysztof Kozlowski --- .../devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml b/Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml index 21c8ea08ff0a..b95a69cc9ae0 100644 --- a/Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml +++ b/Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml @@ -40,6 +40,16 @@ properties: description: Indicates that the setting of RTC time is allowed by the host CPU. + nvmem-cells: + items: + - description: + four-byte nvmem cell holding a little-endian offset from the Unix + epoch representing the time when the RTC timer was last reset + + nvmem-cell-names: + items: + - const: offset + wakeup-source: true required: @@ -69,6 +79,8 @@ examples: compatible = "qcom,pm8921-rtc"; reg = <0x11d>; interrupts = <0x27 0>; + nvmem-cells = <&rtc_offset>; + nvmem-cell-names = "offset"; }; }; }; From patchwork Thu Jan 26 14:20:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp297276wrn; Thu, 26 Jan 2023 06:25:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXuGca/81h2N/fIs2CA8rayk/cO6cb/T1b4TczBVoXO9y7td7l/tW22M9k2+vEfTn1JCF+QJ X-Received: by 2002:a17:906:b806:b0:84d:430a:5e63 with SMTP id dv6-20020a170906b80600b0084d430a5e63mr36022832ejb.27.1674743135321; Thu, 26 Jan 2023 06:25:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743135; cv=none; d=google.com; s=arc-20160816; b=kVpldQJ8O7fvJu9jgpCQP3PRLNq4jlzqrXxAxU9dMD9IPqzdwDJPA3HWJlPKxB0Aht 3OM98fSJRoBpu3Vvdqk8XTjXIxMD6fYSLdZy9y5k/qZtK/v3AxDLCQx+DVaXQIMeLn47 iOBrDAnmGXPUGQLn9sScMCUoXJgAk8xwn8jE61JL8RGJ5PQkAASowY4+KyCSgpj02xas Hti97eKD8FnxuqnO3c0sPlAG1TdTyb3EXVix2mjO4jyWlOBT1KuaAIoh3LsbKU6twS4G f410DqEKQ+rhvVr1zQvkxDfqADdKxKjTV0A9heNFJJisHfVwo9ThWeJwDct9xkV0PwnF bEkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=63P3VscmATr20oxOZ235Hprw8S9QQZIoihSW7FITL+8=; b=RAHtjxYBgAf1pKKR58MdBlZnJRNSvV6IqSvx+7oeVgeKfTM/1X6cFfi7iu+LR+qXpY gjnjkXjfgdfYeVDErAupvCVxWlb4HP8wplz1dMIMsgxwXi42ihdm/V8XpH8e7Y8oEVAO 4trxQRGQ4etI9WcPiZ2EiwYbs8PaBv7xkjYgJrxBlQtfWa3sI6VYDSq7DfOpJtuLrMMO TpDAmIxbkbOtSnEgdzmsCUiIFdNrrG5v9FQ4QGxUR2KJkvie8r5SEYloRiY0PmqilUU1 vFDSfH38xG3GeunfAS7hy0DrGSzU9LbKYKaIl4VhxAeKqVa0CKGeGbmX7qzt2x0evI08 0ztA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ibCSm02b; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vf17-20020a170907239100b0086fcc2f95c0si1213509ejb.455.2023.01.26.06.25.11; Thu, 26 Jan 2023 06:25:35 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=ibCSm02b; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232213AbjAZOXt (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231876AbjAZOXC (ORCPT ); Thu, 26 Jan 2023 09:23:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CC4C1715A; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 11D9061842; Thu, 26 Jan 2023 14:22:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76C67C43239; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742978; bh=MyPlfqgwLCW9R8daVZNHfkNPmJZl3+mMcd7/6rQjSw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ibCSm02bF9LGX8B5EOn5MyMdY7qbeRz/d2gIpICeFd+4sKa7S993D87f0q8PBT6tr 0feICV4zR3zAxEICP7V3cjjSbKMQpihzI51Ri/AYIx/b7H4tCY1XlVp+H7Z+7dvI3A 6UTX2RVCkyzRNmbVpV8tGNQX+GL7TDLEDDjTlbqKPGx75Wict0r880e3qbKva3vBa4 A4andUNIBnh/QP2r2hpWM3t0GeWjzEXlHKyyoXWvKTZTDWtxDYcE+Up8GTU14CBHV+ 7xm4wWgXyVm7beCJZ/RqhhsGMMQB2Zpm/hjaZ1eES9+3ySgpur0w8r6KxzWJ+gdVSw pmgo15E8rYvcw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006iu-CA; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 16/24] rtc: pm8xxx: add support for nvmem offset Date: Thu, 26 Jan 2023 15:20:49 +0100 Message-Id: <20230126142057.25715-17-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095458030647794?= X-GMAIL-MSGID: =?utf-8?q?1756095458030647794?= On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which the driver can take into account. Add support for storing a 32-bit offset from the Epoch in an nvmem cell so that the RTC time can be set on such platforms. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 134 +++++++++++++++++++++++++++++++++++---- 1 file changed, 123 insertions(+), 11 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 922aef0f0241..09816b9f6282 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -3,6 +3,7 @@ */ #include #include +#include #include #include #include @@ -49,6 +50,8 @@ struct pm8xxx_rtc_regs { * @alarm_irq: alarm irq number * @regs: register description * @dev: device structure + * @nvmem_cell: nvmem cell for offset + * @offset: offset from epoch in seconds */ struct pm8xxx_rtc { struct rtc_device *rtc; @@ -57,8 +60,60 @@ struct pm8xxx_rtc { int alarm_irq; const struct pm8xxx_rtc_regs *regs; struct device *dev; + struct nvmem_cell *nvmem_cell; + u32 offset; }; +static int pm8xxx_rtc_read_nvmem_offset(struct pm8xxx_rtc *rtc_dd) +{ + size_t len; + void *buf; + int rc; + + buf = nvmem_cell_read(rtc_dd->nvmem_cell, &len); + if (IS_ERR(buf)) { + rc = PTR_ERR(buf); + dev_err(rtc_dd->dev, "failed to read nvmem offset: %d\n", rc); + return rc; + } + + if (len != sizeof(u32)) { + dev_err(rtc_dd->dev, "unexpected nvmem cell size %zu\n", len); + kfree(buf); + return -EINVAL; + } + + rtc_dd->offset = get_unaligned_le32(buf); + + kfree(buf); + + return 0; +} + +static int pm8xxx_rtc_write_nvmem_offset(struct pm8xxx_rtc *rtc_dd, u32 offset) +{ + u8 buf[sizeof(u32)]; + int rc; + + put_unaligned_le32(offset, buf); + + rc = nvmem_cell_write(rtc_dd->nvmem_cell, buf, sizeof(buf)); + if (rc < 0) { + dev_err(rtc_dd->dev, "failed to write nvmem offset: %d\n", rc); + return rc; + } + + return 0; +} + +static int pm8xxx_rtc_read_offset(struct pm8xxx_rtc *rtc_dd) +{ + if (!rtc_dd->nvmem_cell) + return 0; + + return pm8xxx_rtc_read_nvmem_offset(rtc_dd); +} + static int pm8xxx_rtc_read_raw(struct pm8xxx_rtc *rtc_dd, u32 *secs) { const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; @@ -90,6 +145,33 @@ static int pm8xxx_rtc_read_raw(struct pm8xxx_rtc *rtc_dd, u32 *secs) return 0; } +static int pm8xxx_rtc_update_offset(struct pm8xxx_rtc *rtc_dd, u32 secs) +{ + u32 raw_secs; + u32 offset; + int rc; + + if (!rtc_dd->nvmem_cell) + return -ENODEV; + + rc = pm8xxx_rtc_read_raw(rtc_dd, &raw_secs); + if (rc) + return rc; + + offset = secs - raw_secs; + + if (offset == rtc_dd->offset) + return 0; + + rc = pm8xxx_rtc_write_nvmem_offset(rtc_dd, offset); + if (rc) + return rc; + + rtc_dd->offset = offset; + + return 0; +} + /* * Steps to write the RTC registers. * 1. Disable alarm if enabled. @@ -99,23 +181,15 @@ static int pm8xxx_rtc_read_raw(struct pm8xxx_rtc *rtc_dd, u32 *secs) * 5. Enable rtc if disabled in step 2. * 6. Enable alarm if disabled in step 1. */ -static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) +static int __pm8xxx_rtc_set_time(struct pm8xxx_rtc *rtc_dd, u32 secs) { - struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; u8 value[NUM_8_BIT_RTC_REGS]; bool alarm_enabled; - u32 secs; int rc; - if (!rtc_dd->allow_set_time) - return -ENODEV; - - secs = rtc_tm_to_time64(tm); put_unaligned_le32(secs, value); - dev_dbg(dev, "set time: %ptRd %ptRt (%u)\n", tm, tm, secs); - rc = regmap_update_bits_check(rtc_dd->regmap, regs->alarm_ctrl, regs->alarm_en, 0, &alarm_enabled); if (rc) @@ -158,6 +232,27 @@ static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) return 0; } +static int pm8xxx_rtc_set_time(struct device *dev, struct rtc_time *tm) +{ + struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); + u32 secs; + int rc; + + secs = rtc_tm_to_time64(tm); + + if (rtc_dd->allow_set_time) + rc = __pm8xxx_rtc_set_time(rtc_dd, secs); + else + rc = pm8xxx_rtc_update_offset(rtc_dd, secs); + + if (rc) + return rc; + + dev_dbg(dev, "set time: %ptRd %ptRt (%u + %u)\n", tm, tm, + secs - rtc_dd->offset, rtc_dd->offset); + return 0; +} + static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct pm8xxx_rtc *rtc_dd = dev_get_drvdata(dev); @@ -168,10 +263,11 @@ static int pm8xxx_rtc_read_time(struct device *dev, struct rtc_time *tm) if (rc) return rc; + secs += rtc_dd->offset; rtc_time64_to_tm(secs, tm); - dev_dbg(dev, "read time: %ptRd %ptRt (%u)\n", tm, tm, secs); - + dev_dbg(dev, "read time: %ptRd %ptRt (%u + %u)\n", tm, tm, + secs - rtc_dd->offset, rtc_dd->offset); return 0; } @@ -184,6 +280,7 @@ static int pm8xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) int rc; secs = rtc_tm_to_time64(&alarm->time); + secs -= rtc_dd->offset; put_unaligned_le32(secs, value); rc = regmap_update_bits(rtc_dd->regmap, regs->alarm_ctrl, @@ -223,6 +320,7 @@ static int pm8xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) return rc; secs = get_unaligned_le32(value); + secs += rtc_dd->offset; rtc_time64_to_tm(secs, &alarm->time); rc = regmap_read(rtc_dd->regmap, regs->alarm_ctrl, &ctrl_reg); @@ -380,9 +478,23 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) rtc_dd->allow_set_time = of_property_read_bool(pdev->dev.of_node, "allow-set-time"); + rtc_dd->nvmem_cell = devm_nvmem_cell_get(&pdev->dev, "offset"); + if (IS_ERR(rtc_dd->nvmem_cell)) { + rc = PTR_ERR(rtc_dd->nvmem_cell); + if (rc != -ENOENT) + return rc; + rtc_dd->nvmem_cell = NULL; + } + rtc_dd->regs = match->data; rtc_dd->dev = &pdev->dev; + if (!rtc_dd->allow_set_time) { + rc = pm8xxx_rtc_read_offset(rtc_dd); + if (rc) + return rc; + } + rc = pm8xxx_rtc_enable(rtc_dd); if (rc) return rc; From patchwork Thu Jan 26 14:20:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48725 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp298078wrn; Thu, 26 Jan 2023 06:27:07 -0800 (PST) X-Google-Smtp-Source: AK7set9CcP/5SCM8V0Y7bnj1tf2XBFWwOZ0i+ig33Z/LSiElXmmnaugXs4aNwUGZ7IMDWWeN/wXP X-Received: by 2002:a05:6402:693:b0:4a0:8f85:6fe3 with SMTP id f19-20020a056402069300b004a08f856fe3mr9216870edy.39.1674743226881; Thu, 26 Jan 2023 06:27:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743226; cv=none; d=google.com; s=arc-20160816; b=BNNcAVgFYuIAMiXgGqYip9UQa9wwacTC2OJ6XaXWmkcp4m7f6nMvnUDiAbnB4ev11C qGhO/Vf4V0MtJbHc6sFPX0GHiR373PwX8OUCNq7pcC8uRLEg8n+dpiKo7c0u9Nua6eFb BiX9GV9fQtobfqyFpkToUlRb1++aRvwR51ktpDH6O9LiLyWmXP/vJeNAk0oHbo+TRmPZ N7lsVRUxe9O/xEuZIPKQH7cJx8FsCp0GbFixuVtoQqbAiO7GDzVPqC6zEP1cyFVzxnHG bxwNJtYrgQyJJI6dBrhjnV6Aar+sNTFXYo4PkzQkQEf6u3UV1NnTkFcnCkZHLeZtRUYn EaIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HJGrOCQwFac1TXVS2aLD5iKaERJyIzqAX3CiLa/Jn1w=; b=BFHj/haMvvUh5Ix/b/ZcWbcQnO534UfV6672z14ou0ypgfh2l5qvSzS41TkKY7fm6w UR3P65HnStZP8CeHbuheuJCqoOsZOS0OGCmIBTxB+Mt83RUfz2I64u56AemcWA6qxfzr 16FTl/0TAmOvYt7qBoMy1NltYUN4woiUagoak0DocwpvR8gnujkcjr1xrHCKAE4yk1mr T89drT3yykv56trV2ZatpAQ7DsM52IxZC1b0I4Eks0ATW9yXRXH6d5sQfSKOAOt1+eob RrK09Ez0q3apKqhvi0bki3OQ9StlA5p7LPUtEgmXL7h1mMvD05fZYmgZMgYiu91GWEW4 dw1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dqZDgQlY; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j9-20020a05640211c900b004a090c40aecsi1985597edw.411.2023.01.26.06.26.42; Thu, 26 Jan 2023 06:27:06 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=dqZDgQlY; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232033AbjAZOYB (ORCPT + 99 others); Thu, 26 Jan 2023 09:24:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231990AbjAZOXF (ORCPT ); Thu, 26 Jan 2023 09:23:05 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47F5A37B47; Thu, 26 Jan 2023 06:23:04 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 31A84B81DFB; Thu, 26 Jan 2023 14:23:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 957B2C4323F; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742978; bh=TZt8tg0f5EGEIjmtonuFfOLla/KhReUiEwgCPwUl7Y8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dqZDgQlYoS0ADYsAw5Kl0tc/vASEnUJdOEncA27mTb7vK50h1WKMrrKDllY3j0XaU 8UaxP2YrZklcHOWS3/G0Hq71+supY2z/20fhny7fAwTmHhY6wn5wBa5NpzjK32zBd4 YQeEVSs6ga/yysJoFRCCfet14xThts1Iq8F37IUAx6xc7ayF6ozTXWWofWrWwmXMEV 5/TcymIWe/XyBqRFrsiuIFJ68iRAk6nSzKGS5SG7jxt+b2nbi/T9sXlTE38QBSBxZJ ZAxtigb0Wi0gqMKQHM11ECa0qd915d9EfLRe/XZ2a7ozCmOSbWnVhKeCmz5LPt5n5x MTi9wkZyHbCfg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006iy-FO; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 17/24] rtc: pm8xxx: add copyright notice Date: Thu, 26 Jan 2023 15:20:50 +0100 Message-Id: <20230126142057.25715-18-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095553460477245?= X-GMAIL-MSGID: =?utf-8?q?1756095553460477245?= Add a copyright notice for Linaro and add myself as a (primary) author of this driver. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 09816b9f6282..25bdd804b4d2 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -1,5 +1,9 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. +/* + * pm8xxx RTC driver + * + * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. + * Copyright (c) 2023, Linaro Limited */ #include #include @@ -551,3 +555,4 @@ MODULE_ALIAS("platform:rtc-pm8xxx"); MODULE_DESCRIPTION("PMIC8xxx RTC driver"); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Anirudh Ghayal "); +MODULE_AUTHOR("Johan Hovold "); From patchwork Thu Jan 26 14:20:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp296736wrn; Thu, 26 Jan 2023 06:24:27 -0800 (PST) X-Google-Smtp-Source: AK7set/jkg+mv74YHKEFFNG1YR5Y8U/M8clueELJePLtKB0CmgNf5Zi1Adn4ycSI9QlJLxoLCm/c X-Received: by 2002:a50:ee95:0:b0:4a0:b70f:95b2 with SMTP id f21-20020a50ee95000000b004a0b70f95b2mr3997267edr.13.1674743067201; Thu, 26 Jan 2023 06:24:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743067; cv=none; d=google.com; s=arc-20160816; b=j93f5NnkxxGpdExhkkR92D9UPrdYDMzlMOkK8VdRNctFkGJkhYv4UN4OTVIEqyS1U4 dn743P3UTxvW9PYx+E4XMPg12EC79IFE5Eefy75HHbod0wQ+oh1plBSZ2YP0RSJr/sVW HPA+BitNiSd0lKRXrjO9IgWsIiIFaGoWXtVtlO8mnuv3xTo/2d/UJ3Dyd5f8q09mh2n/ 7SXLVeMVMMmxMmONB6A9IyjaqBk+bbXYXPtTFWI93K/vtecv7cVA7bXPqnioMsVKGdM8 1YEQkr5xM0BFjrQIkz+2wG60Ub1bJdsXFBBkAS2VncEjT0W5iroECm+Ord9OqDMuiLIc vK+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5iOSugU4J1aatxBtIWlOok20Z3UHw0KrifYoS1+fzyA=; b=JGKOvAGzdbRJtdfh9CG4On5qIRetQJnICWOJU95hNLNlncB1eK0Fl2pJeqB+NyrkU0 +vX5/rxDvqKzxMCnkOwTGBFka1TvVtD34HBElxZiZdiIHHiCi7rNFEs7t7evoPYEQlLL 3b7fTUZbDRt6Kh0WyiaPGDRTdOOYi/Y/OsuSEnuI+umm+hk2/ZH38+4XvCh8xPXUoA5d S1OJGr7el1sXXRkBVc7mLa3VyMpdWg3CgfAiN5ugr7I9Jv478Uy44zrCJAsFFWeLCu38 JQVUAlAvFLyNuHjfyvPoFX+ebP+I6V8rLmeX1qs6k22N46eQZw2Et2xj9czBH+Sj1SvP 2iPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eHPvLL5B; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h30-20020a0564020e9e00b004a0ac03019bsi1716732eda.141.2023.01.26.06.24.03; Thu, 26 Jan 2023 06:24:27 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=eHPvLL5B; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232063AbjAZOXQ (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231856AbjAZOXB (ORCPT ); Thu, 26 Jan 2023 09:23:01 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CF7A17166; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 23D026184D; Thu, 26 Jan 2023 14:22:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8139C43615; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742978; bh=kGIY8BsCOcAUuz4rUJvWx7AsZas3uSRgZ9e8CL6ualY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eHPvLL5BRkmGEBfeV0iCFJ3m0Iy4byK3gJD3+Hddcma5Ep/xVtAEUO/0qwXqvwaZo magytMcxv9mNvnSd6TFYB/fxbtTjvpzjN7hlSsA+jo6yO+LDjYDhlonTkaZfVWI3Dx wpeYT2zFfGcjZOeCcIZbT7vWFYKz4ghVcEcnSPHJhHXKTtSeW7WVpjQkaXwJ53xPhb fwr8m7ENW8IdVTy6XQxMcZFZgC89DcB1mD2k1SIXAVFHajUm0B81w+NjoOxvyIaHcD 1qnfPvntsA3zL2SnMDHS+c0HKZFIGTtSQ6m+WFdVVXE4yLWLUW2H+QGAhXhD++AmOl MHSYrWJ2zBi0A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006j1-Hw; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [RFC 18/24] dt-bindings: rtc: qcom-pm8xxx: add uefi-variable offset Date: Thu, 26 Jan 2023 15:20:51 +0100 Message-Id: <20230126142057.25715-19-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095386558766437?= X-GMAIL-MSGID: =?utf-8?q?1756095386558766437?= On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account. Add a 'qcom,uefi-rtc-info' boolean flag which indicates that the RTC offset is stored in a Qualcomm specific UEFI variable so that the RTC time can be updated on such platforms. The UEFI variable is 882f8c2b-9646-435f-8de5-f208ff80c1bd-RTCInfo and holds a 12-byte structure where the first four bytes is a GPS time offset in little-endian byte order. Signed-off-by: Johan Hovold --- Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml b/Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml index b95a69cc9ae0..774c34c3f8f6 100644 --- a/Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml +++ b/Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml @@ -50,6 +50,12 @@ properties: items: - const: offset + qcom,uefi-rtc-info: + type: boolean + description: + RTC offset is stored as a four-byte GPS time offset in a 12-byte UEFI + variable 882f8c2b-9646-435f-8de5-f208ff80c1bd-RTCInfo + wakeup-source: true required: From patchwork Thu Jan 26 14:20:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48710 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp296712wrn; Thu, 26 Jan 2023 06:24:23 -0800 (PST) X-Google-Smtp-Source: AMrXdXv7fpWi71RiqCYOG7szm347KhwpJifkb6qyZBbOi0J6mIA7TALHKX6i0WHvT35cK/jYpv+v X-Received: by 2002:a17:906:b317:b0:84e:d302:1551 with SMTP id n23-20020a170906b31700b0084ed3021551mr38415782ejz.37.1674743062927; Thu, 26 Jan 2023 06:24:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743062; cv=none; d=google.com; s=arc-20160816; b=bEHiqKXeFRmO4Hg363eVPjfXQebtAoBYN/Qe7463PnKBV1wrAWJ2AFU7BADf43IdxD 2/xLtwEooKqPkWERHepv734ZcVSLrGXDj5BWNtQ6Xg1rD01E4LrYkMEL+cSmak52tTHM XZLjFsaU+70/AYMTMNbu/RUQCKxMYUzccJMDw6rkNWPoUSsOU0Vq20+ys8q0CZBG5tBQ 07PCUgHqptcRW4SNXKr5nOoHyEo/RqI7kd4i3Tqa/sU5Tau5z68oh+nltXlP5Pq47+7w wpUZiJGd3nXMhd/vCQN+GFtkVKL4Rob55eabAogNv3NVCwT8XiLTKYlh0dP6lT+d2++t 6eyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VWtCdj+MGloAIKG1MX6LFtd9LeO1IlMG56D6zOcU2hM=; b=uO5SgPn7P1OJpfTKgp1KV3zghFqPY6bjdQvUPCnkMZv6H9ePTLuyrhNSB77RVAHTHD ozBNyxyMGl1lpP5ax4aJMsHgmPjPn0nxffhE1z1LRqGccPoRfuKztTnd9DIqtktnULuW 29fQyhNT4cxL+wjeQisAJF9hxaoUFuojX4WSVsg4+qbJ/QUnLlE+v5qgaVChRtnYHUrN JyAaEqPsFKfGBTLN4XUp8+vUH7gVT3XjVmf80SX5MJVizn0BbdCTBT12AmBwr8W5+GY9 mxWGbhZQc4YNN/FaZpZjMbTkdYZ7TqcPHM3tTICzwNrsHPCFOOM8WQH4UgmYZFC/vbdR FJ2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QgfzUw6M; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mx12-20020a1709065a0c00b00871f78c75edsi1189047ejc.826.2023.01.26.06.23.58; Thu, 26 Jan 2023 06:24:22 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=QgfzUw6M; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232064AbjAZOX3 (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231899AbjAZOXD (ORCPT ); Thu, 26 Jan 2023 09:23:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D7CC17CF1; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8DA2361853; Thu, 26 Jan 2023 14:22:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6E4EC43616; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742978; bh=ZZphE2HmPTraJC6heuasLA305OKL2tD5mgsLEy+bUwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QgfzUw6MTIQ9TB7L/rKCDX8h4K11VTvdXUKrzG/YdIrKd7aj7epWzmH3N8YtkZM8K yEEKgqRWpMU0dy05/0BjXv+cu2iAnGsKflO2hgt6laCJw4+XFsc1BXGsu0/ldoLTsy GiQmFKmD1ewencAUyJ1/TdguBvSX1awuW59JvAYSux4rFQrUOKLh5qF7tTdV1m1LAx RPFSU9+lPS/oLdB9t/8ipJ19wpYQidLwI2TZVLOI1sFuz4WFbaBzuagEaunocq6T25 aMZL96JlNK3HEVUaXybGRQ8f8ZTrAXxUU1aMXqbczi4AUG3B5NKzKg1wkTIQtCXQEQ Q5T2uOOwlDfaA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006j4-L8; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 19/24] rtc: pm8xxx: add support for uefi offset Date: Thu, 26 Jan 2023 15:20:52 +0100 Message-Id: <20230126142057.25715-20-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095381566911111?= X-GMAIL-MSGID: =?utf-8?q?1756095381566911111?= On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which the driver can take into account. Add support for storing a 32-bit offset from the GPS time epoch in a UEFI variable so that the RTC time can be set on such platforms. The UEFI variable is 882f8c2b-9646-435f-8de5-f208ff80c1bd-RTCInfo and holds a 12-byte structure where the first four bytes is a GPS time offset in little-endian byte order. Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 122 +++++++++++++++++++++++++++++++++++++-- include/linux/rtc.h | 1 + 2 files changed, 119 insertions(+), 4 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 25bdd804b4d2..6c2324baeec6 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -5,6 +5,7 @@ * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. * Copyright (c) 2023, Linaro Limited */ +#include #include #include #include @@ -17,6 +18,7 @@ #include #include +#include #include /* RTC_CTRL register bit fields */ @@ -46,6 +48,11 @@ struct pm8xxx_rtc_regs { unsigned int alarm_en; }; +struct qcom_uefi_rtc_info { + __le32 offset_gps; + u8 reserved[8]; +} __packed; + /** * struct pm8xxx_rtc - RTC driver internal structure * @rtc: RTC device @@ -54,6 +61,7 @@ struct pm8xxx_rtc_regs { * @alarm_irq: alarm irq number * @regs: register description * @dev: device structure + * @rtc_info: qcom uefi rtc-info structure * @nvmem_cell: nvmem cell for offset * @offset: offset from epoch in seconds */ @@ -61,13 +69,101 @@ struct pm8xxx_rtc { struct rtc_device *rtc; struct regmap *regmap; bool allow_set_time; + bool use_uefi; int alarm_irq; const struct pm8xxx_rtc_regs *regs; struct device *dev; + struct qcom_uefi_rtc_info rtc_info; struct nvmem_cell *nvmem_cell; u32 offset; }; +#ifdef CONFIG_EFI + +MODULE_IMPORT_NS(EFIVAR); + +#define QCOM_UEFI_NAME L"RTCInfo" +#define QCOM_UEFI_GUID EFI_GUID(0x882f8c2b, 0x9646, 0x435f, \ + 0x8d, 0xe5, 0xf2, 0x08, 0xff, 0x80, 0xc1, 0xbd) +#define QCOM_UEFI_ATTRS (EFI_VARIABLE_NON_VOLATILE | \ + EFI_VARIABLE_BOOTSERVICE_ACCESS | \ + EFI_VARIABLE_RUNTIME_ACCESS) + +static int pm8xxx_rtc_read_uefi_offset(struct pm8xxx_rtc *rtc_dd) +{ + struct qcom_uefi_rtc_info *rtc_info = &rtc_dd->rtc_info; + unsigned long size = sizeof(*rtc_info); + struct device *dev = rtc_dd->dev; + efi_status_t status; + u32 offset_gps; + int rc; + + rc = efivar_lock(); + if (rc) + return rc; + + status = efivar_get_variable(QCOM_UEFI_NAME, &QCOM_UEFI_GUID, NULL, + &size, rtc_info); + efivar_unlock(); + + if (status != EFI_SUCCESS) { + dev_err(dev, "failed to read UEFI offset: %lu\n", status); + return efi_status_to_err(status); + } + + if (size != sizeof(*rtc_info)) { + dev_err(dev, "unexpected UEFI structure size %lu\n", size); + return -EINVAL; + } + + dev_dbg(dev, "uefi_rtc_info = %*ph\n", (int)size, rtc_info); + + /* Convert from GPS to Unix time offset */ + offset_gps = le32_to_cpu(rtc_info->offset_gps); + rtc_dd->offset = offset_gps + (u32)RTC_TIMESTAMP_BEGIN_GPS; + + return 0; +} + +static int pm8xxx_rtc_write_uefi_offset(struct pm8xxx_rtc *rtc_dd, u32 offset) +{ + struct qcom_uefi_rtc_info *rtc_info = &rtc_dd->rtc_info; + unsigned long size = sizeof(*rtc_info); + struct device *dev = rtc_dd->dev; + efi_status_t status; + u32 offset_gps; + + /* Convert from Unix to GPS time offset */ + offset_gps = offset - (u32)RTC_TIMESTAMP_BEGIN_GPS; + + rtc_info->offset_gps = cpu_to_le32(offset_gps); + + dev_dbg(dev, "efi_rtc_info = %*ph\n", (int)size, rtc_info); + + status = efivar_set_variable(QCOM_UEFI_NAME, &QCOM_UEFI_GUID, + QCOM_UEFI_ATTRS, size, rtc_info); + if (status != EFI_SUCCESS) { + dev_err(dev, "failed to write UEFI offset: %lx\n", status); + return efi_status_to_err(status); + } + + return 0; +} + +#else /* CONFIG_EFI */ + +static int pm8xxx_rtc_read_uefi_offset(struct pm8xxx_rtc *rtc_dd) +{ + return -ENODEV; +} + +static int pm8xxx_rtc_write_uefi_offset(struct pm8xxx_rtc *rtc_dd, u32 offset) +{ + return -ENODEV; +} + +#endif /* CONFIG_EFI */ + static int pm8xxx_rtc_read_nvmem_offset(struct pm8xxx_rtc *rtc_dd) { size_t len; @@ -112,10 +208,13 @@ static int pm8xxx_rtc_write_nvmem_offset(struct pm8xxx_rtc *rtc_dd, u32 offset) static int pm8xxx_rtc_read_offset(struct pm8xxx_rtc *rtc_dd) { - if (!rtc_dd->nvmem_cell) + if (!rtc_dd->nvmem_cell && !rtc_dd->use_uefi) return 0; - return pm8xxx_rtc_read_nvmem_offset(rtc_dd); + if (rtc_dd->nvmem_cell) + return pm8xxx_rtc_read_nvmem_offset(rtc_dd); + else + return pm8xxx_rtc_read_uefi_offset(rtc_dd); } static int pm8xxx_rtc_read_raw(struct pm8xxx_rtc *rtc_dd, u32 *secs) @@ -155,7 +254,7 @@ static int pm8xxx_rtc_update_offset(struct pm8xxx_rtc *rtc_dd, u32 secs) u32 offset; int rc; - if (!rtc_dd->nvmem_cell) + if (!rtc_dd->nvmem_cell && !rtc_dd->use_uefi) return -ENODEV; rc = pm8xxx_rtc_read_raw(rtc_dd, &raw_secs); @@ -167,7 +266,11 @@ static int pm8xxx_rtc_update_offset(struct pm8xxx_rtc *rtc_dd, u32 secs) if (offset == rtc_dd->offset) return 0; - rc = pm8xxx_rtc_write_nvmem_offset(rtc_dd, offset); + if (rtc_dd->nvmem_cell) + rc = pm8xxx_rtc_write_nvmem_offset(rtc_dd, offset); + else + rc = pm8xxx_rtc_write_uefi_offset(rtc_dd, offset); + if (rc) return rc; @@ -488,6 +591,17 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) if (rc != -ENOENT) return rc; rtc_dd->nvmem_cell = NULL; + + /* Use UEFI storage as fallback if available */ + rtc_dd->use_uefi = of_property_read_bool(pdev->dev.of_node, + "qcom,uefi-rtc-info"); + } + + if (rtc_dd->use_uefi && !efivar_is_available()) { + if (IS_ENABLED(CONFIG_EFI)) + return -EPROBE_DEFER; + dev_warn(&pdev->dev, "efivars not available\n"); + rtc_dd->use_uefi = false; } rtc_dd->regs = match->data; diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 1fd9c6a21ebe..1ecee2fe4214 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -169,6 +169,7 @@ struct rtc_device { /* useful timestamps */ #define RTC_TIMESTAMP_BEGIN_0000 -62167219200ULL /* 0000-01-01 00:00:00 */ #define RTC_TIMESTAMP_BEGIN_1900 -2208988800LL /* 1900-01-01 00:00:00 */ +#define RTC_TIMESTAMP_BEGIN_GPS 315964800LL /* 1980-01-06 00:00:00 */ #define RTC_TIMESTAMP_BEGIN_2000 946684800LL /* 2000-01-01 00:00:00 */ #define RTC_TIMESTAMP_END_2063 2966371199LL /* 2063-12-31 23:59:59 */ #define RTC_TIMESTAMP_END_2079 3471292799LL /* 2079-12-31 23:59:59 */ From patchwork Thu Jan 26 14:20:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48727 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp298310wrn; Thu, 26 Jan 2023 06:27:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXvxKKgmF0/J+kejwrlT/fckh4aPBOduO7rVYgeakvHQtA+L9V8i4PIIv5VA0KJTWTRuIzUn X-Received: by 2002:a05:6402:40a:b0:499:1ed2:6456 with SMTP id q10-20020a056402040a00b004991ed26456mr37778682edv.22.1674743261933; Thu, 26 Jan 2023 06:27:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743261; cv=none; d=google.com; s=arc-20160816; b=UnXMJ6Plrn7A+bexKv0zP48cg82IQJS5fu8W2ALF35KkLIy8sfnZBRBMYsw6nvKQKA tmAeZbmWTqsIUhsk/3So+tRCEwpfLFRNNmTJN0NgQaBWunHu4f273n9f5d/aJAK8KXrn hmv9DoHaTRwP4fZh6gsGr3QzasEBeSy0UCkRHCS7WDWCO/wEJmycubpYNuHDTWYskwGl BExqoE7J+0c+jD/RGXCMW+M/19qIcKujLhuW3kOkZijSmBs0/mX6jAePyJTvj50Si/XF mWCWTB92bEts0YG3khnn3ywMdJIJ8hGagpkqNwPWhwnF/USn5dwxkMmwtGh6E7DQ7P2A 70+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ta2GnRIpceh3RMeKWUnCPT54ijI858R0e6dCexk4YbQ=; b=ysnOnLltZB839QCdQanLMU+fokjFw+5odTGCiBloMtqf8+4wheHGESt3YOtKbZxOh8 5wWUtwdSKc51v22kTAdjZIvoz6ReJXlKf7IWgDsTrRJE5uKM14367V1JjVXQakz6tluz 4ulDkK5OCJkUDJWO1k6dHfewEXpvCQ/7QSajUkmGAaCPNxySCOCOokwfbPfQeHhKtqMY jIuwCdpRM03N3D4/ELLFCtNCPDN499ppq4Lt1W3WgPVMvcVfyq6+XmTEaJoiQkq4Q1ix aNhR6pUYGQOS9qRwr5QOoyUg1ZntB7mJbuiIc+Ff+HauqhlmyvOgySiCOzjJoMyiKseX SIog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QvboQJsn; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a056402150700b004a0912d723dsi1932714edw.264.2023.01.26.06.27.18; Thu, 26 Jan 2023 06:27:41 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=QvboQJsn; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232195AbjAZOXo (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231877AbjAZOXC (ORCPT ); Thu, 26 Jan 2023 09:23:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DCDF18171; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8F3B86184B; Thu, 26 Jan 2023 14:22:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDEB5C433A4; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742978; bh=Vi//U5VEBM3SVbBW52EARl3dF8z9tulSGPpETR9FMoo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QvboQJsnw9W5Az8/y6ZX3N1z7MLhys4c75QZLpAKqaPMvSGvvG5Y2JCkFGSu+XV6b A0W4jE/AlWm6UD/BgRBDfx/yXW9SWrtJeByHgbAD8O2IvO7nl0SCdLjhSmozLvK3nH leLoLQ5QLSEEbkwuSk0Mkzalp0uBeXeOJ9fQjRZKzchMQVXbJnzHWVJ456QfJMxyUS wVVbLlQOZJu3TOctULEK9Na4Vu8Fv42cUTrPFcYCLXHe3FyKQdB+UbIJbXiCBl5YkL aB71HqmU6Y7p0uuy3j+pcl3d9GKJRkvJHLfF1KksFCWiQOI6ZMnflC7hCjev4AsiCB whEFZILMbEg0Q== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006j7-ON; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 20/24] arm64: defconfig: enable Qualcomm SDAM nvmem driver Date: Thu, 26 Jan 2023 15:20:53 +0100 Message-Id: <20230126142057.25715-21-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095590381396206?= X-GMAIL-MSGID: =?utf-8?q?1756095590381396206?= The SDAM nvmem driver can be used to access the Shared Direct Access Memory Module registers in some Qualcomm PMICs. These registers can specifically be used to store a time offset on platforms where the PMIC RTC time registers are read-only in order to allow the RTC time to be updated. Signed-off-by: Johan Hovold --- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index a17cbdac1904..b3f714ff4006 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -1308,6 +1308,7 @@ CONFIG_NVMEM_MTK_EFUSE=y CONFIG_NVMEM_QCOM_QFPROM=y CONFIG_NVMEM_ROCKCHIP_EFUSE=y CONFIG_NVMEM_SNVS_LPGPR=y +CONFIG_NVMEM_SPMI_SDAM=m CONFIG_NVMEM_SUNXI_SID=y CONFIG_NVMEM_UNIPHIER_EFUSE=y CONFIG_NVMEM_MESON_EFUSE=m From patchwork Thu Jan 26 14:20:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48711 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp296718wrn; Thu, 26 Jan 2023 06:24:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXvqZMXNgugMyBpHA84wnYlUBuiFlvobxzlwIIjjTesft6ACoLH5ADpPZh1kwKr34KWbmVhX X-Received: by 2002:a05:6402:43c5:b0:499:b5fc:e56f with SMTP id p5-20020a05640243c500b00499b5fce56fmr41938202edc.19.1674743064686; Thu, 26 Jan 2023 06:24:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743064; cv=none; d=google.com; s=arc-20160816; b=fogDgfv+c4L06HCHSBpvoHNcVjfsUYIX8XYXrsYK4cITNr0oO/btgLN2ejHF3oTg4M 6dJVcpHuYdKuL7IM263KZu5ISUlbITyzli4vJxMScyU2AlrjKtptYBbA51kVJem0gpQ0 tY8Lmhaej0P26HAHXtoMGuwhsCBjQCl9hDThHgMfx23m1+NWagIkQHLLsLRaSNX26nq2 12sNFG+93/Sc0ZFDLApoThvMcOxUduit62gkP84AqtzbQwdj4V08i+XvYA7pPQtd59Lm 0h/WCpdLa8deCSfJ9hpWzmQAGXxyagShVuGzae9WXRrFGsXeyeknIaQ+qtsaNnduutmz MXpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TNLaUEhRyGqWcG2gEgw1iXhxDtHgS44UL+TxWEV1s3I=; b=rSz7ULLKfHu943DxOgBJ/19olS9q/zUjay6iFBGJ6D13XPgft2W/wUQnTxQoYJoaz6 Vn7xPibqG6D+QI0tNBtf5R6fskQb8YB7OPgm+9IXjri+dkWxk8OvjssBeJnHCaZqAedy Cz0akzBLrAGjGtHAmj9tEJiijlLfN+YmMMwsPfsDSofy7NUyTdSRVlUNnkXYBl6PF+T5 Z6fLLoJfRJRUZ9OF217+sdu9DsAqcVlI5wAhOPdGyZUNY7GrpAOzqaFq4qHyOYpRfvIj +ST3hZp16+XbY3+ILTHC3zPgbKWOcHndEjaXPAL/hKfw8B2fYfWJtTeALn13LFXrIQG3 sprA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AgIpGWzc; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dn20-20020a05640222f400b004a091a92414si1902830edb.472.2023.01.26.06.24.00; Thu, 26 Jan 2023 06:24:24 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=AgIpGWzc; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232148AbjAZOXd (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231915AbjAZOXD (ORCPT ); Thu, 26 Jan 2023 09:23:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D674323C41; Thu, 26 Jan 2023 06:23:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B76D961841; Thu, 26 Jan 2023 14:23:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24AF6C433EF; Thu, 26 Jan 2023 14:23:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742981; bh=Y6hQ4z8OREr8VZpyQDiq2a1MkhG2QzkUzUjGr8t059g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AgIpGWzcvjRAD8OqapUHhafHGrt/fxZTtm0U42XXVbuddEnFxuybBp8LUuVT7WrMm lFGzWHk6Oz2xuOAQNiGdUSZtyhoRX+ETNoLgdyGtrQ8jiVIhIzLGMT5C7Iu5IZlrSW 9y1JJn345/qjlolLNeTwIvDjUElvvWa0LAQ1Ai3Ix025yM9Ur15zdpXdNX2lt64eMU sjiPnBa/AO6XrKuwjBpz6MuNVCjK/x0KGWxuGl9ZM3CuzCjMHh4IfgwcPiwHDWQ6tv UStzxPo6OgBuu1FWuKHhsTGMPf8HakJJC12r7YIJRPNPa05XNf7RF2J2bUed80rmZe hKl7yLY0fF89A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006jA-Qx; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 21/24] arm64: dts: qcom: sc8280xp-pmics: add pmk8280 rtc Date: Thu, 26 Jan 2023 15:20:54 +0100 Message-Id: <20230126142057.25715-22-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095383850314314?= X-GMAIL-MSGID: =?utf-8?q?1756095383850314314?= The PMK8280 has an RTC which can also be used as a wakeup source. Note that the RTC can not be disabled and updating the time is not permitted either. Instead an offset can be stored in some other machine- specific non-volatile memory which a driver can take into account. Signed-off-by: Johan Hovold --- arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi b/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi index f2c0b71b5d8e..c62262b88810 100644 --- a/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi +++ b/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi @@ -95,6 +95,15 @@ pmk8280_adc_tm: adc-tm@3400 { #thermal-sensor-cells = <1>; status = "disabled"; }; + + pmk8280_rtc: rtc@6100 { + compatible = "qcom,pmk8350-rtc"; + reg = <0x6100>, <0x6200>; + reg-names = "rtc", "alarm"; + interrupts = <0x0 0x62 0x1 IRQ_TYPE_EDGE_RISING>; + wakeup-source; + status = "disabled"; + }; }; pmc8280_1: pmic@1 { From patchwork Thu Jan 26 14:20:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48716 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp297267wrn; Thu, 26 Jan 2023 06:25:34 -0800 (PST) X-Google-Smtp-Source: AK7set/KSrPUe4WvY/mdQBElNfRMg0iqz7XE3CJypqo8hZTEdCtLCT0l9b5xcY+C/pl7A81o2rBl X-Received: by 2002:a17:907:9b88:b0:878:5937:7637 with SMTP id kq8-20020a1709079b8800b0087859377637mr3560997ejc.38.1674743133941; Thu, 26 Jan 2023 06:25:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743133; cv=none; d=google.com; s=arc-20160816; b=o+CUPk8906AKJIT0FezCpU1GPBUJI/XVwLnofrC62SoMQ5Bj4dTgZB7If+y6E1EfY2 8cF6PQ52sqTpRS4JIkrnMivY+aZLQ3xakDCix8oBPogyyKSTC4npSggwsrgXfMseBg84 9nLNB32OHFZE6BKmooCRLFlb5EtSECoiL1zIJCQ/PE7JydLlhvXXzWZY/2kV+htjMGU7 S+iF6UFw5y9i/TzEC9OgbwNbMjZGcl7wLEA54zre+GggolXW1GzCBM3X3GesPC5DQLYk uSehRPBtUgBXNGaSpwes092WAN4hAJhL5xhfHLQ5mlvdmgi7WqZFtqIuzow+YG9WB4DV pImg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2ZtpouYcgDvRPxgAxvaa4qhiCcC00MzcmzUYXGcRPLk=; b=s17NXyb9kMvSZglZIqNdxRupbIw7P4ZI5I7tw9Zyd3+oFDAd6TKY70j17hkuK8BdqI pYTTXV7ZuibvLmpbD7rIz7rez2FJyJQ6ijUu1Bnj0T19m3sCIfHefWgLLczxYu7xZD0u ZxH4DwM3Bdn2naHYQay0ic8hlQt+zlPnfCMRbHXWFumuypkQpuCKqxrVF0Eh0AHBDuZq 7TOdUaYoddjbaigpEeJN/7wNhnW59+H0XODe6rwqj7oGEFKu3n+HP//oEAo4vpX1Tbps g7STL97irVBVixN/aMtjNv2QgWlH+pJKNlGiPnbz9+zLYe7CIx0VQR+lFY3HGKlJak2X /0KA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FV1d9Uno; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g10-20020a1709067c4a00b0084d44edc334si1589432ejp.204.2023.01.26.06.25.10; Thu, 26 Jan 2023 06:25:33 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=FV1d9Uno; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232208AbjAZOXq (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231882AbjAZOXC (ORCPT ); Thu, 26 Jan 2023 09:23:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AC1E1D91B; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A0EFB61877; Thu, 26 Jan 2023 14:22:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F30AEC4339B; Thu, 26 Jan 2023 14:22:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742979; bh=q2Bbjj15dQE3xFdW3ZNa040Zv7U1rr2wKNg7FOHt9Xo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FV1d9Unocn1wapAKWF+DKxSVHJgr3xEEW0vCjObhVaN5P8c2rAMovOJ0/T4zuatC9 9pnGTsUYl5LM8i0gt39olhyDNqUjUyw9fJQBgE85HVuC+Wkrpnk7nhjzKw2W9opoiU BrZy1dolgpdc+9WZ27Gkbb/oDWSSc49J1pM7VrELTEAyKfsw/edNneTOZu8VTW1pek Jt/F+CRKA058MJDz0zdpLVVBBRC52363GSzEXINFe3l0XgvSBr+ggJw0Ig6vGkmst9 id+S6fxlcY7ozBLDWRZug/NrGV17bEz5fpa2jdsC1gJCM1992irOrWuo8F9djUDaIP z2ZO8227AlHRg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006jD-TT; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 22/24] arm64: dts: qcom: sc8280xp-pmics: add pmk8280 sdam nvram Date: Thu, 26 Jan 2023 15:20:55 +0100 Message-Id: <20230126142057.25715-23-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095456321558341?= X-GMAIL-MSGID: =?utf-8?q?1756095456321558341?= Add one of the PMK8280 SDAM blocks which can be used to store an RTC offset. Signed-off-by: Johan Hovold --- arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi b/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi index c62262b88810..7220d5b5ab7b 100644 --- a/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi +++ b/arch/arm64/boot/dts/qcom/sc8280xp-pmics.dtsi @@ -104,6 +104,15 @@ pmk8280_rtc: rtc@6100 { wakeup-source; status = "disabled"; }; + + pmk8280_sdam_6: nvram@8500 { + compatible = "qcom,spmi-sdam"; + reg = <0x8500 0x100>; + #address-cells = <1>; + #size-cells = <1>; + ranges = <0 0x8500 0x100>; + status = "disabled"; + }; }; pmc8280_1: pmic@1 { From patchwork Thu Jan 26 14:20:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp297286wrn; Thu, 26 Jan 2023 06:25:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXsJWqxXVnRV+Ntj2w5AdC4gF4yqas8qcg/JVbwHi5RlBMIvQ5Va9MWaUtAp+K51mxcTdGsO X-Received: by 2002:a17:906:684e:b0:84d:3794:5748 with SMTP id a14-20020a170906684e00b0084d37945748mr33347803ejs.9.1674743136297; Thu, 26 Jan 2023 06:25:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743136; cv=none; d=google.com; s=arc-20160816; b=c2JHuoR4WLU+Sk62KI1J7e4Onufq2jbAgyiIJYPE9v6vU0tU6hCDPkSvRuRAcx9epp Z4vucDa8GMGvS6aYD/bigoV2aA9cmkdibBfAlB/yiLKJp+uhyHVnB17E/aNmTXC/kXsq ZjiUrwb1JlDitvd+dASonESED+hnKR38fBVOmLiiPzl22LHwsGLlvHAsFSiyapcWKyw0 YRqN4Tn8SqE9A3oasJL1xPy0aKjy+s5jA22PWZBuhv3QQw3vV+OPXAzFAIhWATBwfihd nWPrphGYn9mLX+DejcgpEIoYuZRp07Bq7U4id66q9YFhGnCBU5BLsxqSVIIxNA73zqxP zN4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ny75enbYgTs7HU/40L43X11IbbSkNHpPWd3KrAhybNo=; b=VpWiHS2K/r0DLGty7HM+RdpqJ9FKc5WBZ8IQaGn2F+REmVvDaI9/bJ8AJGJxK3lMFR +ktZm1pngKruUIaRk3kuqfj510nuljw+aUOXWGRNwKgPd2V1rxxCGhDoqmpjhPEBTHQ2 YHA4FReBMo33CVeTbS9TaLFxfeVrmVYR+6YPQvKA8+fwW/bgY4z8k9ZaQzeVpVAVFNPV OBb98HnUPY8poQnOsv5yrqTLj2DRxHUtyDlMw5KdMELSBK7UNXIeX8ZhI12p0yBNtwyw e2U9IDKfNAYZDj2pbNS+XQDFzc763K+8r8bHbnWwDZ+rYLzHYOWH2ZE0hrwtY+LMTJzU I7Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZvhIj1VG; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y9-20020a170906518900b008787e4ac0bfsi439431ejk.719.2023.01.26.06.25.12; Thu, 26 Jan 2023 06:25:36 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=ZvhIj1VG; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232224AbjAZOXv (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231509AbjAZOXC (ORCPT ); Thu, 26 Jan 2023 09:23:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D58417171; Thu, 26 Jan 2023 06:23:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5134C61867; Thu, 26 Jan 2023 14:22:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BD28C4361B; Thu, 26 Jan 2023 14:22:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742979; bh=HCGjEGUFY0gKH3ZyA4nO2jGVovR75O5DPlTfU63GDlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZvhIj1VGCEOt9h4Lgx+D4p1ZnjGp22aEyT0sSvkrWuhJZyw3vMdxsbCGsbd+q9iBo 8HaOVgkZBxIc2bxujRq9uGMIkY5VPgxFSaDqmzeipOtC2XVI58HDi6wbs9XY5CSSmw smCdxK/T8ixr+PorT6XynyKKoJ1Pvu/hvn3O8RrOK2XnqRxWFNL1QFHfFb+mFaq7Xt wnynkGVKPvyZEykAG6hs9/8gsJRnBGNOLfIvLtwwPihwLwUAtwgMaCVcb6HxqNpiGr TfBQwugcHSuh7i63umCFVvtKBSVUK4W2ddp5GTGjiIWtNGxAda8/dq3TFvc5+FX0r0 uDTgC7hrfF6/A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39d-0006jF-W4; Thu, 26 Jan 2023 15:23:06 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 23/24] arm64: dts: qcom: sc8280xp-crd: enable rtc Date: Thu, 26 Jan 2023 15:20:56 +0100 Message-Id: <20230126142057.25715-24-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095458928041584?= X-GMAIL-MSGID: =?utf-8?q?1756095458928041584?= The SC8280XP CRD firmware does not implement the UEFI time runtime services so the RTC in the PM8280K PMIC needs to be accessed directly. To complicate things further, the RTC control and time registers are read-only on this platform so an offset must be stored in some other machine-specific non-volatile memory which an RTC driver can take into account when reading or updating the time. The UEFI firmware (and Windows) use a UEFI variable for this: 882f8c2b-9646-435f-8de5-f208ff80c1bd-RTCInfo but the offset can only be accessed via the Qualcomm UEFI Secure Application residing in the TEE as the firmware does not implement the variable runtime services either. Unfortunately setting variables using this interface does not work on the CRD so updating the time would not be possible. Instead, reserve four bytes in one of the PMIC SDAM blocks to hold the RTC offset. Signed-off-by: Johan Hovold --- arch/arm64/boot/dts/qcom/sc8280xp-crd.dts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts b/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts index c780b82e498d..192e076345d2 100644 --- a/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts +++ b/arch/arm64/boot/dts/qcom/sc8280xp-crd.dts @@ -500,6 +500,21 @@ &pmk8280_pon_pwrkey { status = "okay"; }; +&pmk8280_rtc { + nvmem-cells = <&rtc_offset>; + nvmem-cell-names = "offset"; + + status = "okay"; +}; + +&pmk8280_sdam_6 { + status = "okay"; + + rtc_offset: rtc-offset@bc { + reg = <0xbc 0x4>; + }; +}; + &qup0 { status = "okay"; }; From patchwork Thu Jan 26 14:20:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 48712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp296730wrn; Thu, 26 Jan 2023 06:24:26 -0800 (PST) X-Google-Smtp-Source: AK7set/jhta+FNfcSGLp2kBURHVx8lyc95zf9XuyAw9geOP/8oZerNjHHi5tIF/kX3/vYQbxMVZm X-Received: by 2002:a17:906:d14b:b0:878:7448:7019 with SMTP id br11-20020a170906d14b00b0087874487019mr1345139ejb.63.1674743066325; Thu, 26 Jan 2023 06:24:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674743066; cv=none; d=google.com; s=arc-20160816; b=xTjkOXtpr8FEAk86rv8UcEGzFu3oX56hK6FGx7QC3EYpg80eZkkRVTYZr3DCaCnn8D 7/ZYdVzoADmI9dvnEzeKIr6xU0MPWVCN720msXI5HH3J8zHilOqa7WuKrPMuqdM3naOe 7KzPpK9PuW+drxEduSiSoYwe06iKLAw51o2hrEQP/ILDmzgkIVcwLJHIiDJIcBaiHgzo Z0AL1druC5Le5L7zsbmOtJnI986cx81n3INph0kKM88DV90NwVsL/UzkKyT3i2ETjlwU Ax4aye8+LO1UGzxqo2g37wOCeEZJEoFP2fAfZxkteHPlCsJ0+46Q4E1KJMCfOGVQhryM bw7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KTGzhXAVgaOqT9bmc4yuMvqHvvUb3tFh3fOLZqvkXEc=; b=tD5vKOp2CWkIBDjhbe1jvWY/RHtOk9v/lCwizfWD9EwaEjshHpeqjDHWWIOA5gCKoI 9Zhz9ldwTDfI81JD3XgoysHkc3ovVi2tufZowgr4JCSiX5oiHOapGjRqW7LChOz/LBH9 +Srmj3Zq7zoKcibo5+QR6mbv6sG6fK0gSF/PE9h78CK1UF8SSEFxNLDBojqRcH1++iLX W2m5Ljwrq4dQMJcJhRUrIjctxM5h6frsbLKhgtzCWdoDdFX4+eIG0wAyJttfEOExvkMA iNB1TrqZzd7lv1OlhO7mqpbJmTTy+1W6bZLuIA/9nX0g471hhik59HXylOurcDHDi2yG kuzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uoAiN7RL; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id uj20-20020a170907c99400b0086bfaaa9edesi1287152ejc.807.2023.01.26.06.24.02; Thu, 26 Jan 2023 06:24:26 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=uoAiN7RL; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232159AbjAZOXf (ORCPT + 99 others); Thu, 26 Jan 2023 09:23:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231939AbjAZOXD (ORCPT ); Thu, 26 Jan 2023 09:23:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DAFD241ED; Thu, 26 Jan 2023 06:23:02 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2055C61843; Thu, 26 Jan 2023 14:23:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82F47C433A1; Thu, 26 Jan 2023 14:23:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674742981; bh=5UwR9QbyWi/Z/2mgCV5ah8EZM6pifSRECiAKO2qRn28=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uoAiN7RLIltAF2itdi3Ajs7/6S33o92wkpcy+qExHZNJo+NeZy1wAm5c8lDdbmCj/ Y7/do4gY6riMzI6mBqMH8aJB+0YJkh41cyZeWwHMSOPcx8UKe+94GDN8lYf8ivezIT r2LjK+N8Vwj3ko5OVXCN3gXzffaET5/HLEFbqJ6osHexUbhLeDIx9xSYQX5x2AwGb9 GOrRVhWZQIQDcuWCr2FbND7cUkG7AWElZKRBsY+ipbZqu94DFtwIpMLi7d3RQrlqhS J05jHWiqLRMKeyPv8PmleXqtaweyzMgdm3b7hMTlHIAig502LNjiSBg4d5JZYGR8U8 tbGdCvx76bkow== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1pL39e-0006jI-2J; Thu, 26 Jan 2023 15:23:06 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Andy Gross , Konrad Dybcio , Alessandro Zummo , Rob Herring , Krzysztof Kozlowski , Maximilian Luz , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 24/24] arm64: dts: qcom: sc8280xp-x13s: enable rtc Date: Thu, 26 Jan 2023 15:20:57 +0100 Message-Id: <20230126142057.25715-25-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126142057.25715-1-johan+linaro@kernel.org> References: <20230126142057.25715-1-johan+linaro@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756095385779202744?= X-GMAIL-MSGID: =?utf-8?q?1756095385779202744?= The Lenovo X13s firmware does not implement the UEFI time runtime services so the RTC in the PM8280K PMIC needs to be accessed directly. To complicate things further, the RTC control and time registers are read-only on this platform so an offset must be stored in some other machine-specific non-volatile memory which an RTC driver can take into account when reading or updating the time. The UEFI firmware (and Windows) use a UEFI variable for this: 882f8c2b-9646-435f-8de5-f208ff80c1bd-RTCInfo but the offset can only be accessed via the Qualcomm UEFI Secure Application residing in the TEE as the firmware does not implement the variable runtime services either. While it is possible to access this UEFI variable from Linux on the X13s, this requires using a fairly complex and reverse-engineered firmware interface. As the only benefit of doing so is to make sure that the UEFI (Windows) and Linux time never gets out of sync, it seems preferable to use the PMIC scratch registers for storing an offset instead. This also avoids flash wear in case of RTC drift, etc. So instead of using the UEFI RTC offset, reserve four bytes in one of the PMIC SDAM blocks to hold the RTC offset. Signed-off-by: Johan Hovold --- .../dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts index db406f7774de..6e88e0bb6871 100644 --- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts +++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts @@ -683,6 +683,21 @@ &pmk8280_pon_resin { status = "okay"; }; +&pmk8280_rtc { + nvmem-cells = <&rtc_offset>; + nvmem-cell-names = "offset"; + + status = "okay"; +}; + +&pmk8280_sdam_6 { + status = "okay"; + + rtc_offset: rtc-offset@bc { + reg = <0xbc 0x4>; + }; +}; + &pmk8280_vadc { status = "okay";