rtc: pcf8563: HYM8563 support and unreliable-time reporting
cover rtc: pcf8563: HYM8563 support and unreliable-time reporting
The Haoyu HYM8563, found for example on the Radxa ROCK 5B, is a clone of the NXP PCF8563 with an identical timekeeping register layout, but the pcf8563 driver does not match its compatible used in upstream DT.
Boards fitted with it end up without DM_RTC and, as a consequence, without usable EFI GetTime and SetTime runtime services. On top of that, when the chip reports that the time may be unreliable after a supply voltage drop, the driver returns a bare -1, which callers interpret as -EPERM rather than as invalid data.
This series makes the existing driver serve the HYM8563 and lets callers distinguish an unreliable time from a permission problem.
The driver gains the additional compatible string and returns -EINVAL when the voltage-low flag is set, matching the rv3032 driver and the behaviour of the Linux driver for the same chips.
Daniel Golle (2):
rtc: pcf8563: add haoyu,hym8563 compatible
rtc: pcf8563: return -EINVAL when the voltage-low flag is set
drivers/rtc/pcf8563.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
base-commit: ece349ade2973e220f524ce59e59711cc919263f
Signature · 1 line
2.55.0
PATCH 1/2 rtc: pcf8563: add haoyu,hym8563 compatible
The HYM8563 is a PCF8563 clone with an identical timekeeping register layout and is found e.g. on the Radxa ROCK 5B. Match its compatible so DM_RTC (and with it the EFI GetTime/SetTime runtime services) can use the existing driver with upstream DT.
--- drivers/rtc/pcf8563.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/pcf8563.c +1 -0
@@ -213,6 +213,7 @@ static const struct rtc_ops pcf8563_rtc_ops = {static const struct udevice_id pcf8563_rtc_ids[] = { { .compatible ="nxp,pcf8563" }, + { .compatible ="haoyu,hym8563" }, { } };
Signature · 1 line
2.55.0
Re: [PATCH 1/2] rtc: pcf8563: add haoyu,hym8563 compatible
Quoted 6 lines · Daniel Golle
The HYM8563 is a PCF8563 clone with an identical timekeeping register layout and is found e.g. on the Radxa ROCK 5B. Match its compatible so
DM_RTC(and with it the EFI GetTime/SetTime runtime services) can use the existing driver with upstream DT.Signed-off-by Daniel Golle <[email protected]>
I see this compatible upstream, so:
Signature · 1 line
Tom
PATCH 2/2 rtc: pcf8563: return -EINVAL when the voltage-low flag is set
In reply to Daniel GolleReturn a proper error code instead of a bare -1 (-EPERM) when VL indicates the time is not reliable, matching rv3032 and the Linux driver behaviour.
--- drivers/rtc/pcf8563.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/pcf8563.c +2 -1
@@ -16,6 +16,7 @@#include <log.h> #include <rtc.h> #include <i2c.h> +#include <linux/errno.h> #if !CONFIG_IS_ENABLED (DM_RTC )static uchar rtc_read (uchar reg);
@@ -144,7 +145,7 @@ static int pcf8563_rtc_get(struct udevice *dev, struct rtc_time *tmp)if (sec &0x80 ) {puts ("### Warning: RTC Low Voltage - date/time not reliable\n" ); - rel =-1 ; + rel = -EINVAL ; } tmp->tm_sec =bcd2bin (sec &0x7F );
Signature · 1 line
2.55.0
Quoted 11 lines · Daniel Golle
The Haoyu HYM8563, found for example on the Radxa ROCK 5B, is a clone of the NXP PCF8563 with an identical timekeeping register layout, but the pcf8563 driver does not match its compatible used in upstream DT.
Boards fitted with it end up without
DM_RTCand, as a consequence, without usable EFI GetTime and SetTime runtime services. On top of that, when the chip reports that the time may be unreliable after a supply voltage drop, the driver returns a bare -1, which callers interpret as-EPERMrather than as invalid data.[...]
Applied to u-boot/main, thanks!
[1/2] rtc: pcf8563: add haoyu,hym8563 compatible
commit: a9a289a211f7e6b479afc3e5f0c07c56e5d6ff7d
[2/2] rtc: pcf8563: return -EINVAL when the voltage-low flag is set
commit: 9811c57b2e01398c6f8ba29a63d93edd4ffe6482Signature · 1 line
Tom