1 From c3cfd27eb16d2fc12cfa77e6cd5f9eb352403c16 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Fri, 15 Oct 2021 11:45:36 +0100
4 Subject: [PATCH] rtc: pcf85063: Always clear EXT_TEST from set_time
6 Power-on reset after the insertion of a battery does not always complete
7 successfully, leading to corrupted register content. The EXT_TEST bit
8 will stop the clock from running, but currently the driver will never
11 Safely handle the erroneous state by clearing EXT_TEST as part of the
12 usual set_time method.
14 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
16 drivers/rtc/rtc-pcf85063.c | 2 ++
17 1 file changed, 2 insertions(+)
19 --- a/drivers/rtc/rtc-pcf85063.c
20 +++ b/drivers/rtc/rtc-pcf85063.c
22 #define PCF85063_REG_CTRL1 0x00 /* status */
23 #define PCF85063_REG_CTRL1_CAP_SEL BIT(0)
24 #define PCF85063_REG_CTRL1_STOP BIT(5)
25 +#define PCF85063_REG_CTRL1_EXT_TEST BIT(7)
27 #define PCF85063_REG_CTRL2 0x01
28 #define PCF85063_CTRL2_AF BIT(6)
29 @@ -117,6 +118,7 @@ static int pcf85063_rtc_set_time(struct
30 * reset state until all time/date registers are written
32 rc = regmap_update_bits(pcf85063->regmap, PCF85063_REG_CTRL1,
33 + PCF85063_REG_CTRL1_EXT_TEST |
34 PCF85063_REG_CTRL1_STOP,
35 PCF85063_REG_CTRL1_STOP);