Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1285311
| From | Juergen Borleis <jbe@pengutronix.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/3] RTC/PCF85063: fix time/date reading (part 1) |
| Date | 2015-12-07 14:50 +0100 |
| Message-ID | <qD4kW-56d-11@gated-at.bofh.it> (permalink) |
| References | <qD4kW-56d-13@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
When reading the seconds register, all time/date registers are frozen
until the year register is read. So, read all time/date registers in one
turn.
Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
---
drivers/rtc/rtc-pcf85063.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index 63334cb..75f2866 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -39,6 +39,38 @@ struct pcf85063 {
int voltage_low; /* indicates if a low_voltage was detected */
};
+static int pcf85063_read_time(struct i2c_client *client, u8 *buf, u16 size)
+{
+ int rc;
+ u8 clk_ctrl = PCF85063_REG_SC;
+ struct i2c_msg msgs[] = {
+ {
+ .addr = client->addr,
+ .len = sizeof(clk_ctrl),
+ .buf = &clk_ctrl,
+ }, {
+ .addr = client->addr,
+ .flags = I2C_M_RD,
+ .len = size,
+ .buf = buf
+ },
+ };
+
+ /*
+ * while reading the time/date registers are blocked and not updated
+ * anymore until the access is finished. To not lose a second
+ * event, the access must be finished within one second. So, read all
+ * time/date registers in one turn.
+ */
+ rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
+ if (rc != ARRAY_SIZE(msgs)) {
+ dev_err(&client->dev, "date/time register read error\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+
/*
* In the routines that deal directly with the pcf85063 hardware, we use
* rtc_time -- month 0-11, hour 0-23, yr = calendar year-epoch.
--
2.6.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH 1/3] RTC/PCF85063: fix time/date reading (part 1) Juergen Borleis <jbe@pengutronix.de> - 2015-12-07 14:50 +0100
csiph-web