All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc: pcf85063: Always clear EXT_TEST from set_time
@ 2021-10-15 11:12 Phil Elwell
  2021-10-15 19:12 ` Alexandre Belloni
  0 siblings, 1 reply; 2+ messages in thread
From: Phil Elwell @ 2021-10-15 11:12 UTC (permalink / raw)
  To: Alessandro Zummo, Alexandre Belloni, linux-rtc; +Cc: Phil Elwell

Power-on reset after the insertion of a battery does not always complete
successfully, leading to corrupted register content. The EXT_TEST bit
will stop the clock from running, but currently the driver will never
recover.

Safely handle the erroneous state by clearing EXT_TEST as part of the
usual set_time method.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 drivers/rtc/rtc-pcf85063.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/rtc/rtc-pcf85063.c b/drivers/rtc/rtc-pcf85063.c
index 14da4ab30104..ea75b71a1f16 100644
--- a/drivers/rtc/rtc-pcf85063.c
+++ b/drivers/rtc/rtc-pcf85063.c
@@ -34,6 +34,7 @@
 #define PCF85063_REG_CTRL1		0x00 /* status */
 #define PCF85063_REG_CTRL1_CAP_SEL	BIT(0)
 #define PCF85063_REG_CTRL1_STOP		BIT(5)
+#define PCF85063_REG_CTRL1_EXT_TEST	BIT(7)
 
 #define PCF85063_REG_CTRL2		0x01
 #define PCF85063_CTRL2_AF		BIT(6)
@@ -117,6 +118,7 @@ static int pcf85063_rtc_set_time(struct device *dev, struct rtc_time *tm)
 	 * reset state until all time/date registers are written
 	 */
 	rc = regmap_update_bits(pcf85063->regmap, PCF85063_REG_CTRL1,
+				PCF85063_REG_CTRL1_EXT_TEST |
 				PCF85063_REG_CTRL1_STOP,
 				PCF85063_REG_CTRL1_STOP);
 	if (rc)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] rtc: pcf85063: Always clear EXT_TEST from set_time
  2021-10-15 11:12 [PATCH] rtc: pcf85063: Always clear EXT_TEST from set_time Phil Elwell
@ 2021-10-15 19:12 ` Alexandre Belloni
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Belloni @ 2021-10-15 19:12 UTC (permalink / raw)
  To: Alessandro Zummo, Phil Elwell, linux-rtc; +Cc: Alexandre Belloni

On Fri, 15 Oct 2021 12:12:08 +0100, Phil Elwell wrote:
> Power-on reset after the insertion of a battery does not always complete
> successfully, leading to corrupted register content. The EXT_TEST bit
> will stop the clock from running, but currently the driver will never
> recover.
> 
> Safely handle the erroneous state by clearing EXT_TEST as part of the
> usual set_time method.
> 
> [...]

Applied, thanks!

[1/1] rtc: pcf85063: Always clear EXT_TEST from set_time
      commit: 9f08c9ed580a287de6546044e28f15bb183d00ff

Best regards,
-- 
Alexandre Belloni <alexandre.belloni@bootlin.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-10-15 19:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 11:12 [PATCH] rtc: pcf85063: Always clear EXT_TEST from set_time Phil Elwell
2021-10-15 19:12 ` Alexandre Belloni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.