我的问题是, RTC硬件时钟,断电后重启时间没有保存,如何解决。
热启动时钟是保存的,冷启动没保存。
初始化程序, 是内核源码,没改动,如下:
static void am335x_rtc_init(int evm_id, int profile)
{
void __iomem *base;
struct clk *clk;
struct omap_hwmod *oh;
struct platform_device *pdev;
char *dev_name = "am33xx-rtc";
clk = clk_get(NULL, "rtc_fck");
if (IS_ERR(clk)) {
pr_err("rtc : Failed to get RTC clock\n");
return;
}
if (clk_enable(clk)) {
pr_err("rtc: Clock Enable Failed\n");
return;
}
base = ioremap(AM33XX_RTC_BASE, SZ_4K);
if (WARN_ON(!base))
return;
/* Unlock the rtc's registers */
writel(0x83e70b13, base + 0x6c);
writel(0x95a4f1e0, base + 0x70);
/*
* Enable the 32K OSc
* TODO: Need a better way to handle this
* Since we want the clock to be running before mmc init
* we need to do it before the rtc probe happens
*/
writel(0x48, base + 0x54);
iounmap(base);
switch (evm_id) {
case BEAGLE_BONE_A3:
case BEAGLE_BONE_OLD:
am335x_rtc_info.pm_off = true;
break;
default:
break;
}
clk_disable(clk);
clk_put(clk);
if (omap_rev() == AM335X_REV_ES2_0)
am335x_rtc_info.wakeup_capable = 1;
oh = omap_hwmod_lookup("rtc");
if (!oh) {
pr_err("could not look up %s\n", "rtc");
return;
}
pdev = omap_device_build(dev_name, -1, oh, &am335x_rtc_info,
sizeof(struct omap_rtc_pdata), NULL, 0, 0);
WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
dev_name, oh->name);
}