Has anyone got da9063 RTC working from linux?

Hello All!

I see da9063 RTC is firing nIRQ just once.

[    2.841628] da9063-rtc da9063-rtc: registered as rtc0
[    2.847116] da9063-rtc da9063-rtc: setting system clock to 2021-10-25T14:28:35 UTC (1635172115)
and later hwclock called once from init scripts...
...
cat /proc/interrupts
...
 63:          1          0          0          0  sifive-gpio   1  da9063-irq
 65:          0          0          0          1  da9063-irq   1  ALARM

The EVENT_A register is clear

i2cget -f -y 0 0x58 0x06
0x00

If i issue hwclock again i get timeout despite EVENT_A register holds E_ALARM bit and all other events are cleared:

+ i2cget -f -y 0 0x58 0x06
0x02
+ i2cget -f -y 0 0x58 0x07
0x00
+ i2cget -f -y 0 0x58 0x08
0x00
+ i2cget -f -y 0 0x58 0x09
0x00

However nIRQ hasn’t been fired. Moreover the MASK seems to be set correctly :

i2cget -f -y 0 0x58 0x0A
0x1d

It turns out to be a bug in SiFive PLIC irqchip driver, see for detail:
https://patchwork.kernel.org/project/linux-riscv/patch/20211024013303.3499461-4-guoren@kernel.org/

I think Guo Ren will provide a quickfix.

For the impatient :

I can claim that the da9063 RTC is fully operational.

Setting RTC clock to wakeup shutdowned system:

sh -c "echo `date '+%s' -d '+ 1 minutes'` > /sys/class/rtc/rtc0/wakealarm"
shutdown

This will do a full “reset”, actually it’s shutdown + wakeup later.

@Maquefel Do you have plans to submit changes to drivers/rtc/rtc-da9063.c upstream?

Hello David!

I’ve already submitted this particular patch:

https://lkml.org/lkml/2021/11/1/800

Not sure everything is correct and waiting for feedback.

I see there is no reply (unless I missed something) for 2 weeks now. You might want to wait a week and ping the patch. Kernel merge window is now closed thus people should start replying.

I assume this is separate work from your OpenSBI patches to support reset on FU740?

Side note: we should really rename sifive_fu740sifive_unmatched, like we did in U-Boot. This rest is not FU740 specific, it’s platform specific and that’s Unmatched.

Yes surprisingly long response time, i always thought that this particular subsystem is not overwhelmed so much. I’ll ping them before the end of the week, may be earlier.

Yes indeed, the method proposed in OpenSBI patches is different - i am currently experimenting with TICK ALARM, with no recent progress, i get weird results with board being powered off and then preventing the onKEY power it back again (turns off shortly after key pressed), until cable plugged/unplugged (the BATTERY is missing).

That’s not a problem, i ll keep it in mind and introduce patch together with I2C minor reworks, in case you don’t have time for this.

@davidlt , as Adam Thomson pointed out we don’t need the sysfs entry - we can simply set alarm via:

rtcwake -m no -s 60

It comes from util-linux package so it’s hard to miss it.