Hello,
I'm currently testing the PCF2131 RTC with I2C connection, on a Variscite devkit powered by i.MX8M Plus with Yocto Kirkstone (kernel 5.15.71).
The RTC works fine, but I have some strange behavior with the timestamp functions.
This is what I've done to make it work:
- Updated the driver in the kernel to support the PCF2131 (support added from kernel 6.6 >)
- Add the RTC definition in the device tree
- Boot up the board and checked the RTC was correctly recognized
By default, as the datasheet states, the battery switch over is not active and timestamps save only the first triggered event (and not overwrites itself when triggered again).
I'm interested in:
- Having the battery switch-over active
- Saving the event in TS4 when RTC switch over (control bit BTSE in register control 4)
- Timestamp (TS) overwriting themself when triggered
To do so I made the following changes:
function pcf2127_enable_ts in rtc-pcf2127.c
Set TSM (Timestamp mode) to 0.
/* Enable timestamp function. */
ret = regmap_update_bits(pcf2127->regmap,
pcf2127->cfg->ts[ts_id].reg_base,
PCF2127_BIT_TS_CTRL_TSOFF,
0);
ret = regmap_update_bits(pcf2127->regmap,
pcf2127->cfg->ts[ts_id].reg_base,
PCF2127_BIT_TS_CTRL_TSM,
0);

function pcf2127_probe in rtc-pcf2127.c
Enabled switch-over and battery low detection and
set BTSE to 1 and BF to 0 to have the timestamp4 update when switch-over happen.
Reference: page 17 and 43 of the datasheet to find bit map and default values.
// Set default behavour of RTC
// Activate switchover and low battery
ret = regmap_update_bits(pcf2127->regmap,
PCF2127_REG_CTRL3,
PCF2127_BIT_CTRL3_BTSE,
1);
ret = regmap_update_bits(pcf2127->regmap,
PCF2127_REG_CTRL3,
PCF2127_BIT_CTRL3_BF |
PCF2127_BIT_CTRL3_PWR0 |
PCF2127_BIT_CTRL3_PWR1 |
PCF2127_BIT_CTRL3_PWR2,
0);


Everything seems to work fine, the RTC time is correct and is maintained when going with the battery. Timestamps correctly overwrite itself when triggered.
The problem are the following:
- When the system is rebooted (so when RTC does the switchover to battery), all the timestamp register reset and become empty.
- Some random other time they are not empty after reboot, but filled with the same value with recent date and time.
- When doing the switch-over TS4 is not updated
Thank you in advande for any help,
Best regards