情况说明:
v3s RTC使用备用电池时,时间只保存,不走,每次开始时候还是原先关机的时间。
个人感觉是使用备用电池时候外部32K晶振没使用。
下面贴代码,
dts里面:
ext_osc32k: ext_osc32k_clk {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <32768>;
clock-accuracy = <50000>;
clock-output-names = "ext-osc32k";
};
rtc: rtc@01f00000 {
compatible = "allwinner,sun6i-a31-rtc";
reg = <0x01f00000 0x54>;
interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
<GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
clock-output-names = "osc32k";
clocks = <&ext_osc32k>;
#clock-cells = <1>;
};
部分启动日志:
[ 0.698307] ohci-platform: OHCI generic platform driver
[ 0.703768] udc-core: couldn't find an available UDC - added [g_cdc] to list of pending drivers
[ 0.712986] sun6i-rtc 1c20400.rtc: rtc core: registered rtc-sun6i as rtc0
[ 0.719819] sun6i-rtc 1c20400.rtc: RTC enabled
[ 0.724802] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[ 0.733057] usbcore: registered new interface driver usbhid
[ 0.738665] usbhid: USB HID core driver
[ 0.742837] NET: Registered protocol family 17
[ 0.750274] sun6i-rtc 1c20400.rtc: setting system clock to 2018-01-11 18:46:45 UTC (1515696405)
[ 0.759251] vcc3v0: disabling
[ 0.762225] vcc3v3: disabling
[ 0.765187] vcc5v0: disabling
[ 0.800383] random: crng init done
查看rtc驱动代码里,也是有使能外部晶振的。
在driver/rtc-sun6i.c文件里:
部分代码:
/* Switch to the external, more precise, oscillator */
writel(SUN6I_LOSC_CTRL_KEY | SUN6I_LOSC_CTRL_EXT_OSC,
rtc->base + SUN6I_LOSC_CTRL);
/* Yes, I know, this is ugly. */
sun6i_rtc = rtc;
/* Deal with old DTs */
if (!of_get_property(node, "clocks", NULL))
return;
电路图不知道怎么贴,就简单说明下好了 :
接32k晶振,VCC_RTC引脚接备用3.3V电源 正常使用时候接电源芯片的3.3v。
备用电源掉电时候只接VCC_RTC引脚,不知道这个有没关系。
以下由 @哇酷小二 2020-07-21 添加:
----------------------------------------------
问题已解决, 关于v3s关机后,使用后备电池时钟不跑的解决方法:
https://whycan.cn/t_4909.html