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

David Wang <[email protected]>
Newsgroups org.ozlabs.lists.openbmc,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel,org.kernel.vger.linux-rtc
Message-ID <65d40ded5afd87d0dbdcf98652a97e4ad244505c.1775717959.git.tomato1220@gmail.com>
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 <[email protected]>
---
 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.