public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] rtc: nct3018y: add support for control register initialization
@ 2026-04-09  7:21 David Wang
  2026-04-09  7:21 ` [PATCH 1/2] dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property David Wang
  2026-04-09  7:21 ` [PATCH 2/2] rtc: nct3018y: add optional control register initialization David Wang
  0 siblings, 2 replies; 6+ messages in thread
From: David Wang @ 2026-04-09  7:21 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh, krzk+dt, conor+dt
  Cc: andrew, avi.fishman, tmaimon77, tali.perry1, venture, yuenn,
	benjaminfair, ctcchien, mimi05633, openbmc, linux-rtc, devicetree,
	linux-kernel, davidwang, David Wang

This series adds support for an optional Device Tree property
"nuvoton,ctrl-reg-val" to initialize the RTC control register (0x0A).

This provides flexibility for different platforms (especially in
server environments) to configure behaviors such as 24h mode and
write ownership without driver source modifications.

David Wang (2):
  dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property
  rtc: nct3018y: add optional control register initialization

 .../devicetree/bindings/rtc/nuvoton,nct3018y.yaml        | 5 +++++
 drivers/rtc/rtc-nct3018y.c                               | 9 +++++++++
 2 files changed, 14 insertions(+)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property
  2026-04-09  7:21 [PATCH 0/2] rtc: nct3018y: add support for control register initialization David Wang
@ 2026-04-09  7:21 ` David Wang
  2026-04-09  7:23   ` Krzysztof Kozlowski
  2026-04-09  7:21 ` [PATCH 2/2] rtc: nct3018y: add optional control register initialization David Wang
  1 sibling, 1 reply; 6+ messages in thread
From: David Wang @ 2026-04-09  7:21 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh, krzk+dt, conor+dt
  Cc: andrew, avi.fishman, tmaimon77, tali.perry1, venture, yuenn,
	benjaminfair, ctcchien, mimi05633, openbmc, linux-rtc, devicetree,
	linux-kernel, davidwang, David Wang

Add "nuvoton,ctrl-reg-val" vendor property to allow optional
initialization of the RTC control register (0x0A).

This allows platform-specific configurations like 24h mode and
write ownership to be defined via Device Tree.

Signed-off-by: David Wang <tomato1220@gmail.com>
---
 Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml b/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
index 4f9b5604acd9..0984dfb77170 100644
--- a/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
+++ b/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
@@ -24,6 +24,10 @@ properties:
 
   reset-source: true
 
+  nuvoton,ctrl-reg-val:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: Initial value for the control register (0x0A).
+
 required:
   - compatible
   - reg
@@ -39,6 +43,7 @@ examples:
         rtc@6f {
             compatible = "nuvoton,nct3018y";
             reg = <0x6f>;
+            nuvoton,ctrl-reg-val = <0x21>;
         };
     };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] rtc: nct3018y: add optional control register initialization
  2026-04-09  7:21 [PATCH 0/2] rtc: nct3018y: add support for control register initialization David Wang
  2026-04-09  7:21 ` [PATCH 1/2] dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property David Wang
@ 2026-04-09  7:21 ` David Wang
  1 sibling, 0 replies; 6+ messages in thread
From: David Wang @ 2026-04-09  7:21 UTC (permalink / raw)
  To: a.zummo, alexandre.belloni, robh, krzk+dt, conor+dt
  Cc: andrew, avi.fishman, tmaimon77, tali.perry1, venture, yuenn,
	benjaminfair, ctcchien, mimi05633, openbmc, linux-rtc, devicetree,
	linux-kernel, davidwang, David Wang

Support the "nuvoton,ctrl-reg-val" Device Tree property to initialize
the RTC control register (0x0A) during the probe phase.

This provides flexibility for different platforms to override default
hardware settings.

Signed-off-by: David Wang <tomato1220@gmail.com>
---
 drivers/rtc/rtc-nct3018y.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/rtc/rtc-nct3018y.c b/drivers/rtc/rtc-nct3018y.c
index cd4b1db902e9..4bc47b4ac935 100644
--- a/drivers/rtc/rtc-nct3018y.c
+++ b/drivers/rtc/rtc-nct3018y.c
@@ -534,6 +534,15 @@ static int nct3018y_probe(struct i2c_client *client)
 		}
 	}
 
+	if (!of_property_read_u32(client->dev.of_node, "nuvoton,ctrl-reg-val", &flags)) {
+
+		err = i2c_smbus_write_byte_data(client, NCT3018Y_REG_CTRL, (u8)flags);
+		if (err < 0) {
+			dev_dbg(&client->dev, "Unable to write NCT3018Y_REG_CTRL.\n");
+			return err;
+		}
+	}
+
 	flags = 0;
 	err = i2c_smbus_write_byte_data(client, NCT3018Y_REG_ST, flags);
 	if (err < 0) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property
  2026-04-09  7:21 ` [PATCH 1/2] dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property David Wang
@ 2026-04-09  7:23   ` Krzysztof Kozlowski
  2026-04-09  7:44     ` David Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2026-04-09  7:23 UTC (permalink / raw)
  To: David Wang, a.zummo, alexandre.belloni, robh, krzk+dt, conor+dt
  Cc: andrew, avi.fishman, tmaimon77, tali.perry1, venture, yuenn,
	benjaminfair, ctcchien, mimi05633, openbmc, linux-rtc, devicetree,
	linux-kernel, davidwang

On 09/04/2026 09:21, David Wang wrote:
> Add "nuvoton,ctrl-reg-val" vendor property to allow optional
> initialization of the RTC control register (0x0A).
> 
> This allows platform-specific configurations like 24h mode and
> write ownership to be defined via Device Tree.
> 
> Signed-off-by: David Wang <tomato1220@gmail.com>
> ---
>  Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml b/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
> index 4f9b5604acd9..0984dfb77170 100644
> --- a/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
> +++ b/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
> @@ -24,6 +24,10 @@ properties:
>  
>    reset-source: true
>  
> +  nuvoton,ctrl-reg-val:
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    description: Initial value for the control register (0x0A).

24h mode is not a property of a board. I don't know what "write
ownership" is.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property
  2026-04-09  7:23   ` Krzysztof Kozlowski
@ 2026-04-09  7:44     ` David Wang
  2026-04-09 13:30       ` Alexandre Belloni
  0 siblings, 1 reply; 6+ messages in thread
From: David Wang @ 2026-04-09  7:44 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: a.zummo, alexandre.belloni, robh, krzk+dt, conor+dt, andrew,
	avi.fishman, tmaimon77, tali.perry1, venture, yuenn, benjaminfair,
	ctcchien, mimi05633, openbmc, linux-rtc, devicetree, linux-kernel,
	davidwang

On Apr 9, 2026, at 15:23, Krzysztof Kozlowski wrote:
>
> On 09/04/2026 09:21, David Wang wrote:
> > Add "nuvoton,ctrl-reg-val" vendor property to allow optional
> > initialization of the RTC control register (0x0A).
> >
> > This allows platform-specific configurations like 24h mode and
> > write ownership to be defined via Device Tree.
> >
> > Signed-off-by: David Wang <tomato1220@gmail.com>
> > ---
> >  Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml b/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
> > index 4f9b5604acd9..0984dfb77170 100644
> > --- a/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
> > +++ b/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
> > @@ -24,6 +24,10 @@ properties:
> >
> >    reset-source: true
> >
> > +  nuvoton,ctrl-reg-val:
> > +    $ref: /schemas/types.yaml#/definitions/uint32
> > +    description: Initial value for the control register (0x0A).
>
> 24h mode is not a property of a board. I don't know what "write
> ownership" is.
>
> Best regards,
> Krzysztof

Hi Krzysztof,

Thanks for your feedback. Let me clarify these two points based on the
NCT3018Y datasheet:
1. Regarding "write ownership": The NCT3018Y features two I2C
interfaces (Primary and Secondary). The TWO (Time Write Ownership) bit
in the control register determines which interface has the authority
to write to the RTC. We need to ensure the interface connected to our
SoC is granted this ownership during probe—especially for factory-new
chips—to ensure the RTC is writable.
2. Regarding "24h mode": This bit determines the internal data format
in which time is stored within the RTC hardware. Setting this ensures
the hardware's internal storage layout matches the driver's
expectation from the start.

Best regards,
David Wang

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property
  2026-04-09  7:44     ` David Wang
@ 2026-04-09 13:30       ` Alexandre Belloni
  0 siblings, 0 replies; 6+ messages in thread
From: Alexandre Belloni @ 2026-04-09 13:30 UTC (permalink / raw)
  To: David Wang
  Cc: Krzysztof Kozlowski, a.zummo, robh, krzk+dt, conor+dt, andrew,
	avi.fishman, tmaimon77, tali.perry1, venture, yuenn, benjaminfair,
	ctcchien, mimi05633, openbmc, linux-rtc, devicetree, linux-kernel,
	davidwang

On 09/04/2026 15:44:43+0800, David Wang wrote:
> On Apr 9, 2026, at 15:23, Krzysztof Kozlowski wrote:
> >
> > On 09/04/2026 09:21, David Wang wrote:
> > > Add "nuvoton,ctrl-reg-val" vendor property to allow optional
> > > initialization of the RTC control register (0x0A).
> > >
> > > This allows platform-specific configurations like 24h mode and
> > > write ownership to be defined via Device Tree.
> > >
> > > Signed-off-by: David Wang <tomato1220@gmail.com>
> > > ---
> > >  Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml | 5 +++++
> > >  1 file changed, 5 insertions(+)
> > >
> > > diff --git a/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml b/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
> > > index 4f9b5604acd9..0984dfb77170 100644
> > > --- a/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
> > > +++ b/Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml
> > > @@ -24,6 +24,10 @@ properties:
> > >
> > >    reset-source: true
> > >
> > > +  nuvoton,ctrl-reg-val:
> > > +    $ref: /schemas/types.yaml#/definitions/uint32
> > > +    description: Initial value for the control register (0x0A).
> >
> > 24h mode is not a property of a board. I don't know what "write
> > ownership" is.
> >
> > Best regards,
> > Krzysztof
> 
> Hi Krzysztof,
> 
> Thanks for your feedback. Let me clarify these two points based on the
> NCT3018Y datasheet:
> 1. Regarding "write ownership": The NCT3018Y features two I2C
> interfaces (Primary and Secondary). The TWO (Time Write Ownership) bit
> in the control register determines which interface has the authority
> to write to the RTC. We need to ensure the interface connected to our
> SoC is granted this ownership during probe—especially for factory-new
> chips—to ensure the RTC is writable.

You need a write-access property. For NXP, we settled with
nxp,write-access.



> 2. Regarding "24h mode": This bit determines the internal data format
> in which time is stored within the RTC hardware. Setting this ensures
> the hardware's internal storage layout matches the driver's
> expectation from the start.

The driver needs to always write 24h mode but can support reading both.



-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-09 13:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-09  7:21 [PATCH 0/2] rtc: nct3018y: add support for control register initialization David Wang
2026-04-09  7:21 ` [PATCH 1/2] dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property David Wang
2026-04-09  7:23   ` Krzysztof Kozlowski
2026-04-09  7:44     ` David Wang
2026-04-09 13:30       ` Alexandre Belloni
2026-04-09  7:21 ` [PATCH 2/2] rtc: nct3018y: add optional control register initialization David Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox