Message ID | 20230201143431.863784-1-frieder@fris.de |
---|---|
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 s9csp318060wrn; Wed, 1 Feb 2023 06:46:02 -0800 (PST) X-Google-Smtp-Source: AK7set+yqKnjKzZxHzQ7ZlCUqMd1vq6X9rfRFrcXdyeuUhWBDc04GyexVzDC/atvzsNuIVU2ZA/X X-Received: by 2002:a17:903:2302:b0:196:6162:1a76 with SMTP id d2-20020a170903230200b0019661621a76mr4066243plh.0.1675262762039; Wed, 01 Feb 2023 06:46:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675262762; cv=none; d=google.com; s=arc-20160816; b=khLmrfCWcn/fKvE+d/V5eJiTHU+TiRhe9AIstzCmakdiBRk2UN+4hS3CtQgNo331x9 EQ6tGhj2PmnEdnDCQlYgPbSy0Nibd98mQbe8KRu4Z/5IjGAW9Z5pDtJJFbBBjpe6smrX ia1egxx0USS5FolTaRSdlwnUapCAB6yCbzAwGvdG0cvU/q+BHvezSmGsERAUXBJI1fkf dQv/PQ37fjEeJTvGEdT7KpEoc5umVBT7Jy4CphtblufpD/8qZEyosP1ABekycmlN5SfP xNBvHFWEu7JEYDgxOS58+ZmW9hOUOCXrv+4CNCK2PsnmFywT51msuzaXavj0gBQtZUvj cK+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 :message-id:date:subject:cc:to:from:dkim-signature; bh=jpzkr24nHKJp5IYEK48VP/WYJnaAAqAY3mtPMKQ4JTk=; b=zNLFdrIScypin4x6rbAw/EsY437uyKXnNP3i0S9FrDTGE4ayKmAWZ+pANSGDMf9Kyj PfuwZk6vUI1lr5e4RNLtgJRHFcfWC22ffLaBZHDvs1cHZLV4+yA1nISPwEQwCao6fmpe CT9P+P+xieUooLnU2PEhp/wFhGOUD5hun/uAL06BlON+USceAftzg4Uh9cPdY7ZVcOcY Bqy/x/UMqDjuGtYNLyYICHGw2Rp0UKTaNaUdscDcOSGxeyH24QF8O4UY/+0+e+pfE/pT /87V6RU/IGmF6g40/d/xR74wLyZ2g8rxZInsHARryp8KMUfCMzHv42b8YyBeyNksxSw5 gb0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fris.de header.s=dkim header.b=EyhNDpIm; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fris.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 21-20020a170902c15500b001963669c7d4si19055522plj.532.2023.02.01.06.45.49; Wed, 01 Feb 2023 06:46:02 -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=@fris.de header.s=dkim header.b=EyhNDpIm; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fris.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232675AbjBAOnf (ORCPT <rfc822;duw91626@gmail.com> + 99 others); Wed, 1 Feb 2023 09:43:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232536AbjBAOnM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 1 Feb 2023 09:43:12 -0500 Received: from mail.fris.de (mail.fris.de [IPv6:2a01:4f8:c2c:390b::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D6052E82E; Wed, 1 Feb 2023 06:43:03 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 75799BFC6C; Wed, 1 Feb 2023 15:34:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fris.de; s=dkim; t=1675262091; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding; bh=jpzkr24nHKJp5IYEK48VP/WYJnaAAqAY3mtPMKQ4JTk=; b=EyhNDpImLtYrLnSp9RszhmfZjgngLI5STcz8zOdrh17GinHCp5YJE3zgtszbPSiQnpAnae xNdr4zrlZ0mKxAUaBUSqQJuGlTP2/pCqfbrB5/hovHvR+PojO5PttjnGFIcnjJ31qp23nr KdZlZTyJbhqvHE24LaQGzhdy4qYwLM4nxNYHAe/PUIY61wf7idcvDamcz4jI6virl51pHY jpdHe8kKUEDGJjPiRr0KhLIL4GZhloH23lwsCEaQ1ykSVM7YcpFDTIMNYXmkKDs1IVwsqR A9x7BKDpE/1rj0AeNSB3yW+hOWuKYYiBQdV0CGzRcpIomE9IBP6lCZc8K2iNeA== From: Frieder Schrempf <frieder@fris.de> To: Alexandre Belloni <alexandre.belloni@bootlin.com>, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org Cc: Frieder Schrempf <frieder.schrempf@kontron.de>, Alessandro Zummo <a.zummo@towertech.it>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, Rob Herring <robh+dt@kernel.org>, Sascha Hauer <s.hauer@pengutronix.de>, Shawn Guo <shawnguo@kernel.org> Subject: [PATCH 0/7] Enable backup switch mode on RTCs via devicetree Date: Wed, 1 Feb 2023 15:34:22 +0100 Message-Id: <20230201143431.863784-1-frieder@fris.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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?1756640326157508999?= X-GMAIL-MSGID: =?utf-8?q?1756640326157508999?= |
Series |
Enable backup switch mode on RTCs via devicetree
|
|
Message
Frieder Schrempf
Feb. 1, 2023, 2:34 p.m. UTC
From: Frieder Schrempf <frieder.schrempf@kontron.de>
Some RTC devices like the RV3028 have BSM disabled as factory default.
This makes the RTC quite useless if it is expected to preserve the
time on hardware that has a battery-buffered supply for the RTC.
Let boards that have a buffered supply for the RTC force the BSM to the
desired value via devicetree by setting the 'backup-switch-mode' property.
That way the RTC on the boards work as one would expect them to do without
any per-board intervention through userspace tools to enable BSM.
Frieder Schrempf (7):
dt-bindings: rtc: Move RV3028 to separate binding file
dt-bindings: rtc: Add backup-switch-mode property
dt-bindings: rtc: microcrystal,rv3032: Add backup-switch-mode property
rtc: Move BSM defines to separate header for DT usage
rtc: class: Support setting backup switch mode from devicetree
arm64: dts: imx8mm-kontron: Remove useless trickle-diode-disable from
RTC node
arm64: dts: imx8mm-kontron: Enable backup switch mode for RTC on OSM-S
module
.../bindings/rtc/microcrystal,rv3028.yaml | 60 +++++++++++++++++++
.../devicetree/bindings/rtc/rtc.yaml | 7 +++
.../devicetree/bindings/rtc/trivial-rtc.yaml | 2 -
.../dts/freescale/imx8mm-kontron-osm-s.dtsi | 3 +-
drivers/rtc/class.c | 14 +++++
include/dt-bindings/rtc/rtc.h | 11 ++++
include/uapi/linux/rtc.h | 6 +-
7 files changed, 95 insertions(+), 8 deletions(-)
create mode 100644 Documentation/devicetree/bindings/rtc/microcrystal,rv3028.yaml
create mode 100644 include/dt-bindings/rtc/rtc.h
Comments
Hello, You can't do that, this breaks an important use case and it is the reason why I didn't use device tree in the beginning. What is wrong with setting BSM from userspace? You will anyway have to set the time and date from userspace for it to be saved. On 01/02/2023 15:34:22+0100, Frieder Schrempf wrote: > From: Frieder Schrempf <frieder.schrempf@kontron.de> > > Some RTC devices like the RV3028 have BSM disabled as factory default. > This makes the RTC quite useless if it is expected to preserve the > time on hardware that has a battery-buffered supply for the RTC. > > Let boards that have a buffered supply for the RTC force the BSM to the > desired value via devicetree by setting the 'backup-switch-mode' property. > > That way the RTC on the boards work as one would expect them to do without > any per-board intervention through userspace tools to enable BSM. > > Frieder Schrempf (7): > dt-bindings: rtc: Move RV3028 to separate binding file > dt-bindings: rtc: Add backup-switch-mode property > dt-bindings: rtc: microcrystal,rv3032: Add backup-switch-mode property > rtc: Move BSM defines to separate header for DT usage > rtc: class: Support setting backup switch mode from devicetree > arm64: dts: imx8mm-kontron: Remove useless trickle-diode-disable from > RTC node > arm64: dts: imx8mm-kontron: Enable backup switch mode for RTC on OSM-S > module > > .../bindings/rtc/microcrystal,rv3028.yaml | 60 +++++++++++++++++++ > .../devicetree/bindings/rtc/rtc.yaml | 7 +++ > .../devicetree/bindings/rtc/trivial-rtc.yaml | 2 - > .../dts/freescale/imx8mm-kontron-osm-s.dtsi | 3 +- > drivers/rtc/class.c | 14 +++++ > include/dt-bindings/rtc/rtc.h | 11 ++++ > include/uapi/linux/rtc.h | 6 +- > 7 files changed, 95 insertions(+), 8 deletions(-) > create mode 100644 Documentation/devicetree/bindings/rtc/microcrystal,rv3028.yaml > create mode 100644 include/dt-bindings/rtc/rtc.h > > -- > 2.39.1
On 01.02.23 17:15, Alexandre Belloni wrote: > Hello, > > You can't do that, this breaks an important use case and it is the > reason why I didn't use device tree in the beginning. What is wrong with > setting BSM from userspace? You will anyway have to set the time and > date from userspace for it to be saved. Ok, I was already afraid there is something I missed. Can you give a short explanation of what use case this would break? There is nothing wrong with setting BSM from userspace. It's just the fact that users expect BSM to be enabled in any case as there is a battery on the board. It is much more effort to ensure that production, user, etc. are aware of an extra step required than to let the kernel deal with it behind the scenes.
Hi Alexandre, On 01.02.23 17:26, Frieder Schrempf wrote: > On 01.02.23 17:15, Alexandre Belloni wrote: >> Hello, >> >> You can't do that, this breaks an important use case and it is the >> reason why I didn't use device tree in the beginning. What is wrong with >> setting BSM from userspace? You will anyway have to set the time and >> date from userspace for it to be saved. > > Ok, I was already afraid there is something I missed. Can you give a > short explanation of what use case this would break? > > There is nothing wrong with setting BSM from userspace. It's just the > fact that users expect BSM to be enabled in any case as there is a > battery on the board. It is much more effort to ensure that production, > user, etc. are aware of an extra step required than to let the kernel > deal with it behind the scenes. Would you mind elaborating on your argument that this would break stuff? I currently don't see how an additional optional devicetree property would break anything. Thanks Frieder
On 13.02.23 10:18, Frieder Schrempf wrote: > Hi Alexandre, > > On 01.02.23 17:26, Frieder Schrempf wrote: >> On 01.02.23 17:15, Alexandre Belloni wrote: >>> Hello, >>> >>> You can't do that, this breaks an important use case and it is the >>> reason why I didn't use device tree in the beginning. What is wrong with >>> setting BSM from userspace? You will anyway have to set the time and >>> date from userspace for it to be saved. >> >> Ok, I was already afraid there is something I missed. Can you give a >> short explanation of what use case this would break? >> >> There is nothing wrong with setting BSM from userspace. It's just the >> fact that users expect BSM to be enabled in any case as there is a >> battery on the board. It is much more effort to ensure that production, >> user, etc. are aware of an extra step required than to let the kernel >> deal with it behind the scenes. > > Would you mind elaborating on your argument that this would break stuff? > I currently don't see how an additional optional devicetree property > would break anything. Ping!?
Hi Alexandre, On 06.03.23 14:27, Frieder Schrempf wrote: > On 13.02.23 10:18, Frieder Schrempf wrote: >> Hi Alexandre, >> >> On 01.02.23 17:26, Frieder Schrempf wrote: >>> On 01.02.23 17:15, Alexandre Belloni wrote: >>>> Hello, >>>> >>>> You can't do that, this breaks an important use case and it is the >>>> reason why I didn't use device tree in the beginning. What is wrong with >>>> setting BSM from userspace? You will anyway have to set the time and >>>> date from userspace for it to be saved. >>> >>> Ok, I was already afraid there is something I missed. Can you give a >>> short explanation of what use case this would break? >>> >>> There is nothing wrong with setting BSM from userspace. It's just the >>> fact that users expect BSM to be enabled in any case as there is a >>> battery on the board. It is much more effort to ensure that production, >>> user, etc. are aware of an extra step required than to let the kernel >>> deal with it behind the scenes. >> >> Would you mind elaborating on your argument that this would break stuff? >> I currently don't see how an additional optional devicetree property >> would break anything. > > Ping!? It seems like you decided to ignore me for whatever reasons there are. I'm sure we can sort it out in some way if you would respond, please. Thanks Frieder
Hello, On 22/03/2023 14:14:50+0100, Frieder Schrempf wrote: > On 06.03.23 14:27, Frieder Schrempf wrote: > > On 13.02.23 10:18, Frieder Schrempf wrote: > >> Hi Alexandre, > >> > >> On 01.02.23 17:26, Frieder Schrempf wrote: > >>> On 01.02.23 17:15, Alexandre Belloni wrote: > >>>> Hello, > >>>> > >>>> You can't do that, this breaks an important use case and it is the > >>>> reason why I didn't use device tree in the beginning. What is wrong with > >>>> setting BSM from userspace? You will anyway have to set the time and > >>>> date from userspace for it to be saved. > >>> > >>> Ok, I was already afraid there is something I missed. Can you give a > >>> short explanation of what use case this would break? > >>> > >>> There is nothing wrong with setting BSM from userspace. It's just the > >>> fact that users expect BSM to be enabled in any case as there is a > >>> battery on the board. It is much more effort to ensure that production, > >>> user, etc. are aware of an extra step required than to let the kernel > >>> deal with it behind the scenes. > >> > >> Would you mind elaborating on your argument that this would break stuff? > >> I currently don't see how an additional optional devicetree property > >> would break anything. > > > > Ping!? > > It seems like you decided to ignore me for whatever reasons there are. > I'm sure we can sort it out in some way if you would respond, please. I do what I can with the time I have. There are 2 issues: - the first one is that this is encoding device configuration in the device tree which is forbidden. BSM is not really hardware related. The worse that could happen is that the backup voltage is not present and so the RTC will never switch to the backup source. - the second one is why I got to a userspace solution. There are RTC where it is crucial to be able to change BSM dynamically. Those RTCs have a standby mode: they will only draw current from the backup source once they have seen VDD once. This is useful when you install a battery in a product and this products stays on the shelf for a while before being used. However, if your production line needs to powerup the device to flash it or perform tests, the RTC will get out of standby mode and you need a way to get it back to standby. This is possible with the current interface, I'm not going to have a second interface. Regards,
On 22.03.23 23:19, Alexandre Belloni wrote: > Hello, > > On 22/03/2023 14:14:50+0100, Frieder Schrempf wrote: >> On 06.03.23 14:27, Frieder Schrempf wrote: >>> On 13.02.23 10:18, Frieder Schrempf wrote: >>>> Hi Alexandre, >>>> >>>> On 01.02.23 17:26, Frieder Schrempf wrote: >>>>> On 01.02.23 17:15, Alexandre Belloni wrote: >>>>>> Hello, >>>>>> >>>>>> You can't do that, this breaks an important use case and it is the >>>>>> reason why I didn't use device tree in the beginning. What is wrong with >>>>>> setting BSM from userspace? You will anyway have to set the time and >>>>>> date from userspace for it to be saved. >>>>> >>>>> Ok, I was already afraid there is something I missed. Can you give a >>>>> short explanation of what use case this would break? >>>>> >>>>> There is nothing wrong with setting BSM from userspace. It's just the >>>>> fact that users expect BSM to be enabled in any case as there is a >>>>> battery on the board. It is much more effort to ensure that production, >>>>> user, etc. are aware of an extra step required than to let the kernel >>>>> deal with it behind the scenes. >>>> >>>> Would you mind elaborating on your argument that this would break stuff? >>>> I currently don't see how an additional optional devicetree property >>>> would break anything. >>> >>> Ping!? >> >> It seems like you decided to ignore me for whatever reasons there are. >> I'm sure we can sort it out in some way if you would respond, please. > > I do what I can with the time I have. Thanks for taking the time! I know that maintainers are usually chronically overloaded. Still I got a bit worried after ~7 weeks that I wont get a reply at all. > > There are 2 issues: > - the first one is that this is encoding device configuration in the > device tree which is forbidden. BSM is not really hardware related. > The worse that could happen is that the backup voltage is not present > and so the RTC will never switch to the backup source. This is an argument that I was expecting to hear in the first place. I think this is kind of a grey area as the BSM feature is definitely related to the hardware implementation of the V_DD and V_BACKUP supply voltages, but at the same time it also might reflect device configuration. > > - the second one is why I got to a userspace solution. There are RTC > where it is crucial to be able to change BSM dynamically. Those RTCs > have a standby mode: they will only draw current from the backup source > once they have seen VDD once. This is useful when you install a battery > in a product and this products stays on the shelf for a while before > being used. However, if your production line needs to powerup the device > to flash it or perform tests, the RTC will get out of standby mode and > you need a way to get it back to standby. This is possible with the > current interface, I'm not going to have a second interface. Thanks for pointing that out. The userspace solution is definitely useful and necessary and I would never argue against it. What I'm proposing is not really a second interface but a way to set the default mode at boot time. If you really think this is too much, then I will need to scratch this approach.