[PATCH] rtc: m41t80: Clear oscillator failure bit on probe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The oscillator failure bit of the flags register defaults to 1 when the
m41t80 RTC device is powered up. If we don't clear it as the manual says
we should then the bit remains set permanently and since commit
05a7f27a889f ("rtc: m41t80: handle oscillator failure bit") we spam the
kernel console with an error message on every attempt to read the RTC,
for example:

  Welcome to Buildroot
  mips64r6-n32-le-hf-soak login: [   15.534459] rtc-m41t80 0-0068:
  Oscillator failure, data is invalid.
  [   16.526308] rtc-m41t80 0-0068: Oscillator failure, data is invalid.
  [   19.534342] rtc-m41t80 0-0068: Oscillator failure, data is invalid.
  [   20.526327] rtc-m41t80 0-0068: Oscillator failure, data is invalid.

Fix this by clearing the OF flag during probe, as the m41t80 manual
says we ought to.

Signed-off-by: Paul Burton <paul.burton@xxxxxxxxxx>
Fixes: 05a7f27a889f ("rtc: m41t80: handle oscillator failure bit")
Cc: Alessandro Zummo <a.zummo@xxxxxxxxxxxx>
Cc: Alexandre Belloni <alexandre.belloni@xxxxxxxxxxxxxxxxxx>
Cc: Mylène Josserand <mylene.josserand@xxxxxxxxxxxxxxxxxx>
Cc: rtc-linux@xxxxxxxxxxxxxxxx
Cc: <stable@xxxxxxxxxxxxxxx> # v4.7+

---

 drivers/rtc/rtc-m41t80.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 58698d21c2c3..33be6e4694f6 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -813,6 +813,17 @@ static int m41t80_probe(struct i2c_client *client,
 
 	m41t80_data->rtc = rtc;
 
+	/* Clear the OF (Oscillator failure) bit, which is 1 on power up */
+	rc = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS);
+	if (rc < 0) {
+		dev_warn(&client->dev, "unable to read flags");
+	} else if (rc & M41T80_FLAGS_OF) {
+		rc &= ~M41T80_FLAGS_OF;
+		rc = i2c_smbus_write_byte_data(client, M41T80_REG_FLAGS, rc);
+		if (rc)
+			dev_warn(&client->dev, "unable to clear OF flag");
+	}
+
 	/* Make sure HT (Halt Update) bit is cleared */
 	rc = i2c_smbus_read_byte_data(client, M41T80_REG_ALARM_HOUR);
 
-- 
2.12.1




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]