解决方案|外部RTC s35390a调试(hwclock: select() to /dev/rtc1 to wait for clock tick timed out)

【解决方案|外部RTC s35390a调试(hwclock: select() to /dev/rtc1 to wait for clock tick timed out)】在Kernel 5.2.11中配置好RTC的DeviceTree之后,RTC工作正常

&pio { i2c1_pins: i2c1-pins { pins = "PB18", "PB19"; function = "i2c1"; }; }; &i2c1 { status = "okay"; pinctrl-0 = <&i2c1_pins>; pinctrl-names = "default"; s35390a: s35390a@30 { compatible = "sii,s35390a"; reg = <0x30>; }; };

但是当用hwclock查看和调试RTC的时候,发现hwclock总是失败
# hwclock -r -Dhwclock: select() to /dev/rtc1 to wait for clock tick timed out

从提示来看,应该是hwclock会去设置alarm,但是一直没有等到alarm的中断,所以hwclock超时失败
5.2.11版本的Kernel只使能了s35390a的INT2,所以可以将s35390a的INT2引脚接入CPU的中断引脚,保证alarm中断可用
不过由于硬件的限制,不能改电路了,故而有一个折中的办法,即将RTC添加uie_unsupported标志,则hwclock就不会去等待alarm了
diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c index 8c37acb4a007..726751bc0a4a --- a/drivers/rtc/rtc-s35390a.c +++ b/drivers/rtc/rtc-s35390a.c @@ -498,6 +498,8 @@ static int s35390a_probe(struct i2c_client *client, goto exit_dummy; } +s35390a->rtc->uie_unsupported = 1; + if (status1 & S35390A_FLAG_INT2) rtc_update_irq(s35390a->rtc, 1, RTC_AF);

    推荐阅读