Skip to content

Commit 15f57b3

Browse files
Philipp Rosenbergeralexandrebelloni
authored andcommitted
rtc: pcf2127: Run a OTP refresh if not done before
The datasheet of the PCF2127 states, it is recommended to process an OTP refresh once the power is up and the oscillator is operating stable. The OTP refresh takes less than 100 ms to complete. Signed-off-by: Philipp Rosenberger <p.rosenberger@kunbus.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20210118085752.5759-3-p.rosenberger@kunbus.com
1 parent b9ac079 commit 15f57b3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/rtc/rtc-pcf2127.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
#define PCF2127_REG_ALARM_DM 0x0D
5959
#define PCF2127_REG_ALARM_DW 0x0E
6060
#define PCF2127_BIT_ALARM_AE BIT(7)
61+
/* CLKOUT control register */
62+
#define PCF2127_REG_CLKOUT 0x0f
63+
#define PCF2127_BIT_CLKOUT_OTPR BIT(5)
6164
/* Watchdog registers */
6265
#define PCF2127_REG_WD_CTL 0x10
6366
#define PCF2127_BIT_WD_CTL_TF0 BIT(0)
@@ -559,6 +562,7 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
559562
{
560563
struct pcf2127 *pcf2127;
561564
int ret = 0;
565+
unsigned int val;
562566

563567
dev_dbg(dev, "%s\n", __func__);
564568

@@ -615,6 +619,19 @@ static int pcf2127_probe(struct device *dev, struct regmap *regmap,
615619
regmap_clear_bits(pcf2127->regmap, PCF2127_REG_CTRL1,
616620
PCF2127_BIT_CTRL1_POR_OVRD);
617621

622+
ret = regmap_read(pcf2127->regmap, PCF2127_REG_CLKOUT, &val);
623+
if (ret < 0)
624+
return ret;
625+
626+
if (!(val & PCF2127_BIT_CLKOUT_OTPR)) {
627+
ret = regmap_set_bits(pcf2127->regmap, PCF2127_REG_CLKOUT,
628+
PCF2127_BIT_CLKOUT_OTPR);
629+
if (ret < 0)
630+
return ret;
631+
632+
msleep(100);
633+
}
634+
618635
/*
619636
* Watchdog timer enabled and reset pin /RST activated when timed out.
620637
* Select 1Hz clock source for watchdog timer.

0 commit comments

Comments
 (0)