* [PATCH 0/1] RTC: nuvoton: Modify the setting timing of write ownership
@ 2023-07-18 8:45 Mia Lin
2023-07-18 8:45 ` [PATCH 1/1] " Mia Lin
0 siblings, 1 reply; 2+ messages in thread
From: Mia Lin @ 2023-07-18 8:45 UTC (permalink / raw)
To: avifishman70, tmaimon77, tali.perry1, venture, yuenn,
benjaminfair, a.zummo, alexandre.belloni, KWLIU, JJLIU0, KFLIN,
YHYANG2, mylin1
Cc: openbmc, linux-rtc, linux-kernel, Mia Lin
- Change the write ownership to default.
- Set the TWO bit to gain write ownership for BMC before it updates time.
- Restore the TWO bit after BMC updates the time.
- Set 24-Hour Format.
Mia Lin (1):
RTC: nuvoton: Modify the setting timing of write ownership
drivers/rtc/rtc-nct3018y.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 1/1] RTC: nuvoton: Modify the setting timing of write ownership
2023-07-18 8:45 [PATCH 0/1] RTC: nuvoton: Modify the setting timing of write ownership Mia Lin
@ 2023-07-18 8:45 ` Mia Lin
0 siblings, 0 replies; 2+ messages in thread
From: Mia Lin @ 2023-07-18 8:45 UTC (permalink / raw)
To: avifishman70, tmaimon77, tali.perry1, venture, yuenn,
benjaminfair, a.zummo, alexandre.belloni, KWLIU, JJLIU0, KFLIN,
YHYANG2, mylin1
Cc: openbmc, linux-rtc, linux-kernel, Mia Lin
- Change the write ownership to default.
- Set the TWO bit to gain write ownership for BMC before it updates time.
- Restore the TWO bit after BMC updates the time.
- Set 24-Hour Format.
Signed-off-by: Mia Lin <mimi05633@gmail.com>
---
drivers/rtc/rtc-nct3018y.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-nct3018y.c b/drivers/rtc/rtc-nct3018y.c
index a4e3f924837e..e6b06724cdef 100644
--- a/drivers/rtc/rtc-nct3018y.c
+++ b/drivers/rtc/rtc-nct3018y.c
@@ -178,7 +178,19 @@ static int nct3018y_rtc_set_time(struct device *dev, struct rtc_time *tm)
{
struct i2c_client *client = to_i2c_client(dev);
unsigned char buf[4] = {0};
- int err;
+ int err, flags, restore_flags = 0;
+
+ /* Check and set TWO bit */
+ flags = i2c_smbus_read_byte_data(client, NCT3018Y_REG_CTRL);
+ if (!(flags & NCT3018Y_BIT_TWO)) {
+ restore_flags = 1;
+ flags |= NCT3018Y_BIT_TWO;
+ err = i2c_smbus_write_byte_data(client, NCT3018Y_REG_CTRL, flags);
+ if (err < 0) {
+ dev_dbg(&client->dev, "Unable to write NCT3018Y_REG_CTRL\n");
+ return err;
+ }
+ }
buf[0] = bin2bcd(tm->tm_sec);
err = i2c_smbus_write_byte_data(client, NCT3018Y_REG_SC, buf[0]);
@@ -212,6 +224,16 @@ static int nct3018y_rtc_set_time(struct device *dev, struct rtc_time *tm)
return -EIO;
}
+ /* Restore TWO bit */
+ if (restore_flags) {
+ flags &= ~NCT3018Y_BIT_TWO;
+ err = i2c_smbus_write_byte_data(client, NCT3018Y_REG_CTRL, flags);
+ if (err < 0) {
+ dev_dbg(&client->dev, "Unable to write NCT3018Y_REG_CTRL\n");
+ return err;
+ }
+ }
+
return err;
}
@@ -479,7 +501,7 @@ static int nct3018y_probe(struct i2c_client *client)
dev_dbg(&client->dev, "%s: NCT3018Y_BIT_TWO is set\n", __func__);
}
- flags = NCT3018Y_BIT_TWO;
+ flags = NCT3018Y_BIT_HF;
err = i2c_smbus_write_byte_data(client, NCT3018Y_REG_CTRL, flags);
if (err < 0) {
dev_dbg(&client->dev, "Unable to write NCT3018Y_REG_CTRL\n");
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-18 8:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-18 8:45 [PATCH 0/1] RTC: nuvoton: Modify the setting timing of write ownership Mia Lin
2023-07-18 8:45 ` [PATCH 1/1] " Mia Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).