Skip to contentSkip to conversation

rtc: nct3018y: add support for control register initialization

PATCH In review David Wang 3 participants 6 messages Apr 9

Subsystems (3)
lore
Share & tools
lore

David Wang

author
#0 lore raw

cover rtc: nct3018y: add support for control register initialization

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(+)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/2 dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property

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.

---
 Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml +5 -0
index 4f9b5604acd9..0984dfb77170 100644
@@ -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>;
         };
     };
 
Signature · 1 line
2.34.1
author
#5 lore raw

PATCH 2/2 rtc: nct3018y: add optional control register initialization

In reply to 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.

---
 drivers/rtc/rtc-nct3018y.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/rtc/rtc-nct3018y.c +9 -0
index cd4b1db902e9..4bc47b4ac935 100644
@@ -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) {
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 1/2] dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property

In reply to David Wang
Quoted 16 lines · 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.

---
 Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml +0 -0
index 4f9b5604acd9..0984dfb77170 100644

Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml properties: · line 29

Quoted 6 lines
Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml +3 -0
@@ -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

author
#3 lore raw

Re: [PATCH 1/2] dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property

Quoted 28 lines · Krzysztof Kozlowski
Quoted 16 lines · 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.

---
 Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml +0 -0
index 4f9b5604acd9..0984dfb77170 100644

Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml properties: · line 29

Quoted 6 lines
Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml +3 -0
@@ -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.

Quoted 2 lines

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

#4 lore raw

Re: [PATCH 1/2] dt-bindings: rtc: nct3018y: add nuvoton,ctrl-reg-val property

Quoted 34 lines · David Wang
Quoted 28 lines · Krzysztof Kozlowski
Quoted 16 lines · 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.

---
 Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml +0 -0
index 4f9b5604acd9..0984dfb77170 100644

Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml properties: · line 29

Quoted 6 lines
Documentation/devicetree/bindings/rtc/nuvoton,nct3018y.yaml +3 -0
@@ -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.

Quoted 2 lines

Best regards,
Krzysztof

Hi Krzysztof,

Quoted 8 lines

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.

Quoted 4 lines

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.

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