From: Mia Lin <mimi05633@gmail.com>
To: avifishman70@gmail.com, tmaimon77@gmail.com,
tali.perry1@gmail.com, venture@google.com, yuenn@google.com,
benjaminfair@google.com, a.zummo@towertech.it,
alexandre.belloni@bootlin.com, KWLIU@nuvoton.com,
JJLIU0@nuvoton.com, KFLIN@nuvoton.com, YHYANG2@nuvoton.com,
mylin1@nuvoton.com
Cc: openbmc@lists.ozlabs.org, linux-rtc@vger.kernel.org,
linux-kernel@vger.kernel.org, Mia Lin <mimi05633@gmail.com>
Subject: [PATCH 1/1] RTC: nuvoton: Modify the setting timing of write ownership
Date: Tue, 18 Jul 2023 16:45:35 +0800 [thread overview]
Message-ID: <20230718084535.11081-2-mimi05633@gmail.com> (raw)
In-Reply-To: <20230718084535.11081-1-mimi05633@gmail.com>
- 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
prev parent reply other threads:[~2023-07-18 8:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230718084535.11081-2-mimi05633@gmail.com \
--to=mimi05633@gmail.com \
--cc=JJLIU0@nuvoton.com \
--cc=KFLIN@nuvoton.com \
--cc=KWLIU@nuvoton.com \
--cc=YHYANG2@nuvoton.com \
--cc=a.zummo@towertech.it \
--cc=alexandre.belloni@bootlin.com \
--cc=avifishman70@gmail.com \
--cc=benjaminfair@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=mylin1@nuvoton.com \
--cc=openbmc@lists.ozlabs.org \
--cc=tali.perry1@gmail.com \
--cc=tmaimon77@gmail.com \
--cc=venture@google.com \
--cc=yuenn@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox