Message ID | 20230126142057.25715-19-johan+linaro@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;lekhanya01809@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <johan+linaro@kernel.org>) id 1pL39d-0006j1-Hw; Thu, 26 Jan 2023 15:23:05 +0100 From: Johan Hovold <johan+linaro@kernel.org> To: Alexandre Belloni <alexandre.belloni@bootlin.com>, Bjorn Andersson <andersson@kernel.org> Cc: Andy Gross <agross@kernel.org>, Konrad Dybcio <konrad.dybcio@linaro.org>, Alessandro Zummo <a.zummo@towertech.it>, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Maximilian Luz <luzmaximilian@gmail.com>, linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold <johan+linaro@kernel.org> 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 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> 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?= |
Series |
rtc: pm8xxx: add support for setting time using nvmem
|
|
Commit Message
Johan Hovold
Jan. 26, 2023, 2:20 p.m. UTC
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 <johan+linaro@kernel.org>
---
Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On Thu, Jan 26, 2023 at 03:20:51PM +0100, Johan Hovold wrote: > 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. Can't you just try to read the UEFI variable and use it if that succeeds? I don't like this in DT because what if lots of devices start storing lots of things in vendor specific UEFI variables. It doesn't scale. Rob
[ +CC: Ard ] On Mon, Jan 30, 2023 at 12:49:44PM -0600, Rob Herring wrote: > On Thu, Jan 26, 2023 at 03:20:51PM +0100, Johan Hovold wrote: > > 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. > > Can't you just try to read the UEFI variable and use it if that > succeeds? Generally, yes. The problem here is that this UEFI variable is not used on all devices using these PMICs and I need a way to determine whether to wait for the UEFI variables to become available or not (e.g. when efivars support is built as module, yes, that's a thing now...). > I don't like this in DT because what if lots of devices start storing > lots of things in vendor specific UEFI variables. It doesn't scale. I hope we won't see that even if we already have some devices for x86 platforms storing MAC addresses and such in UEFI variables. They currently access the UEFI firmware directly (i.e. not using the efivars abstraction) and simply assume UEFI is always there. With the Google SMI efivars implementation or the new Qualcomm SMC-based one, we need a way to determine whether to wait for efivars to become registered. For drivers where efivars is always needed we can just probe defer, but in this case we should not wait unless the DT indicates that the RTC offset is stored in UEFI on this particular machine. Just as the nvmem-cell property indicates that the offset is stored in some abstract nvmem, it seems reasonable to describe the offset being stored in UEFI when that is the case (even if it is indeed generally possible to probe for the latter). An alternative might be to describe the efivars fw dependency in DT too (e.g. for device links), but I believe you have already expressed some concerns over that: https://lore.kernel.org/lkml/20230130210530.GA3339716-robh@kernel.org/ Johan
On Wed, 1 Feb 2023 at 17:09, Johan Hovold <johan@kernel.org> wrote: > > [ +CC: Ard ] > > On Mon, Jan 30, 2023 at 12:49:44PM -0600, Rob Herring wrote: > > On Thu, Jan 26, 2023 at 03:20:51PM +0100, Johan Hovold wrote: > > > 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. > > > > Can't you just try to read the UEFI variable and use it if that > > succeeds? > > Generally, yes. The problem here is that this UEFI variable is not used > on all devices using these PMICs and I need a way to determine whether > to wait for the UEFI variables to become available or not (e.g. when > efivars support is built as module, yes, that's a thing now...). > Could we read this variable at boot and pass it to the kernel in a different way? That way, we only have to defer the ability to set the RTC, right? > > I don't like this in DT because what if lots of devices start storing > > lots of things in vendor specific UEFI variables. It doesn't scale. > > I hope we won't see that even if we already have some devices for x86 > platforms storing MAC addresses and such in UEFI variables. They > currently access the UEFI firmware directly (i.e. not using the efivars > abstraction) and simply assume UEFI is always there. > > With the Google SMI efivars implementation or the new Qualcomm SMC-based > one, we need a way to determine whether to wait for efivars to become > registered. For drivers where efivars is always needed we can just probe > defer, but in this case we should not wait unless the DT indicates that > the RTC offset is stored in UEFI on this particular machine. > > Just as the nvmem-cell property indicates that the offset is stored in > some abstract nvmem, it seems reasonable to describe the offset being > stored in UEFI when that is the case (even if it is indeed generally > possible to probe for the latter). > > An alternative might be to describe the efivars fw dependency in DT too > (e.g. for device links), but I believe you have already expressed some > concerns over that: > > https://lore.kernel.org/lkml/20230130210530.GA3339716-robh@kernel.org/ > > Johan
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: