rtc: ab-eoz9: fix the undervoltage handling
cover rtc: ab-eoz9: fix the undervoltage handling
The AB EOZ9 can report if there are undervoltage conditions encountered while the RTC is maintaining the date and time. This is useful when a device is stored for a long amount of time without being used, to know how reliable the reported date and time are at reboot.
Patch 1 reworks the user report of undervoltages by checking the lowest threshold first.
Patch 2 makes so that we don't fail the temperature readout, as when the system is currently running, the RTC battery should be at a nominal voltage. Temperature-related undervoltage reports are about what happened while the system was down, and not about the current state of the power supply.
Maxime Chevallier (2):
rtc: ab-eoz9: check the lowest voltage threshold first
rtc: ab-eoz9: don't fail temperature reads on undervoltage
notification
drivers/rtc/rtc-ab-eoz9.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
Signature · 1 line
2.47.0
PATCH 1/2 rtc: ab-eoz9: check the lowest voltage threshold first
When checking the internal status flags for time validity, 2 different voltage thresholds are verified :
VLOW1 is at 2.1V and indicates that temperature monitoring isn't possible at that voltage. This stops any temperature compensation and can cause time deviations
VLOW2 is at 1.3V, below that voltage no timekeeping is possible.
In both cases, we consider the reported time to be unreliable and print a warning.
The current code checks for VLOW1 undervoltage first, but as it is higher than VLOW2 it will always trigger before the VLOW2 threshold is hit.
Make sure we first check the VLOW2 condition when checking time validity.
--- drivers/rtc/rtc-ab-eoz9.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/rtc/rtc-ab-eoz9.c +4 -4
@@ -116,15 +116,15 @@ static int abeoz9_check_validity(struct device *dev)return -EINVAL ; } -if (val &ABEOZ9_REG_CTRL_STATUS_V1F ) { +if (val &ABEOZ9_REG_CTRL_STATUS_V2F ) {dev_warn (dev, -"voltage drops below VLOW1 threshold, date is invalid\n" ); +"voltage drops below VLOW2 threshold, date is invalid\n" );return -EINVAL ; } -if ((val &ABEOZ9_REG_CTRL_STATUS_V2F )) { +if ((val &ABEOZ9_REG_CTRL_STATUS_V1F )) {dev_warn (dev, -"voltage drops below VLOW2 threshold, date is invalid\n" ); +"voltage drops below VLOW1 threshold, date is invalid\n" );return -EINVAL ; }
Signature · 1 line
2.47.0
PATCH 2/2 rtc: ab-eoz9: don't fail temperature reads on undervoltage notification
In reply to Maxime ChevallierThe undervoltage flags reported by the RTC are useful to know if the time and date are reliable after a reboot. Although the threshold VLOW1 indicates that the thermometer has been shutdown and time compensation is off, it doesn't mean that the temperature readout is currently impossible.
As the system is running, the RTC voltage is now fully established and we can read the temperature.
--- drivers/rtc/rtc-ab-eoz9.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/rtc/rtc-ab-eoz9.c +0 -7
@@ -396,13 +396,6 @@ static int abeoz9z3_temp_read(struct device *dev,if (ret <0 )return ret; -if ((val &ABEOZ9_REG_CTRL_STATUS_V1F ) || - (val &ABEOZ9_REG_CTRL_STATUS_V2F )) { -dev_err (dev, -"thermometer might be disabled due to low voltage\n" ); -return -EINVAL ; - } -switch (attr) {case hwmon_temp_input: ret =regmap_read (regmap,ABEOZ9_REG_REG_TEMP , &val);
Signature · 1 line
2.47.0
Re: (subset) [PATCH 2/2] rtc: ab-eoz9: don't fail temperature reads on undervoltage notification
Quoted 10 lines · Maxime Chevallier
The undervoltage flags reported by the RTC are useful to know if the time and date are reliable after a reboot. Although the threshold VLOW1 indicates that the thermometer has been shutdown and time compensation is off, it doesn't mean that the temperature readout is currently impossible.
As the system is running, the RTC voltage is now fully established and we can read the temperature.
[...]
Applied, thanks!
[2/2] rtc: ab-eoz9: don't fail temperature reads on undervoltage notification
https://git.kernel.org/abelloni/c/e0779a0dcf41
Best regards,
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com