vim arch/arm/boot/dts/exynos4.dtsi
rtc: rtc@10070000 {
compatible = "samsung,s3c6410-rtc";
reg = <0x10070000 0x100>;
interrupt-parent = <&pmu_system_controller>;
interrupts = ,
;
clocks = <&clock CLK_RTC>;
clock-names = "rtc";
status = "disabled";
};
vim arch/arm/boot/dts/exynos4412-tiny4412.dts
&rtc {
status = "okay";
};
Device Drivers >
Real Time Clock->
<*> Samsung S3C series SoC RTC
然而启动日志里面看到
[ 1.574221] s3c-rtc 10070000.rtc: failed to find rtc source clock
[ 1.578937] s3c-rtc: probe of 10070000.rtc failed with error -2
[ 1.966342] hctosys: unable to open rtc device (rtc0)
drivers/rtc/rtc-s3c.c:550: "failed to find rtc source clock\n");
static int s3c_rtc_probe(struct platform_device *pdev)
{
...
if (info->data->needs_src_clk) {
info->rtc_src_clk = devm_clk_get(&pdev->dev, "rtc_src");
if (IS_ERR(info->rtc_src_clk)) {
ret = PTR_ERR(info->rtc_src_clk);
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev,
"failed to find rtc source clock\n");
else
dev_dbg(&pdev->dev,
"probe deferred due to missing rtc src clk\n");
goto err_src_clk;
}
ret = clk_prepare_enable(info->rtc_src_clk);
if (ret)
goto err_src_clk;
}
...
}
其中info->data是:
static struct s3c_rtc_data const s3c6410_rtc_data = {
.max_user_freq = 32768,
.needs_src_clk = true, // 采用外部32.768K的晶振,不需要从MCLK得到额外时钟
.irq_handler = s3c6410_rtc_irq,
.set_freq = s3c6410_rtc_setfreq,
.enable_tick = s3c6410_rtc_enable_tick,
.save_tick_cnt = s3c6410_rtc_save_tick_cnt,
.restore_tick_cnt = s3c6410_rtc_restore_tick_cnt,
.enable = s3c24xx_rtc_enable,
.disable = s3c6410_rtc_disable,
};
static const struct of_device_id s3c_rtc_dt_match[] = {
...
{
.compatible = "samsung,s3c2443-rtc",
.data = &s3c2443_rtc_data,
}, {
.compatible = "samsung,s3c6410-rtc",
.data = &s3c6410_rtc_data,
},
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, s3c_rtc_dt_match);
static struct platform_driver s3c_rtc_driver = {
.probe = s3c_rtc_probe,
.remove = s3c_rtc_remove,
.driver = {
.name = "s3c-rtc",
.pm = &s3c_rtc_pm_ops,
.of_match_table = of_match_ptr(s3c_rtc_dt_match),
},
};
最后
启动日志
[ 1.574044] s3c-rtc 10070000.rtc: rtc disabled, re-enabling
[ 1.578363] s3c-rtc 10070000.rtc: warning: invalid RTC value so initializing it
[ 1.585656] rtc rtc0: invalid alarm value: 1900-1-1 0:0:0
[ 1.591240] s3c-rtc 10070000.rtc: rtc core: registered s3c as rtc0
[ 1.971626] s3c-rtc 10070000.rtc: setting system clock to 2000-01-01 00:00:00 UTC (946684800)
[root@tiny4412 ]# ls /dev/rtc0
/dev/rtc0
[root@tiny4412 ]#
[root@tiny4412 ]# date -s "2019-11-11 20:33:30"
Mon Nov 11 20:33:30 UTC 2019
[root@tiny4412 ]# hwclock
Sat Jan 1 00:02:45 2000 0.000000 seconds
[root@tiny4412 ]# hwclock -w
[root@tiny4412 ]#
[root@tiny4412 ]# hwclock
Mon Nov 11 20:33:43 2019 0.000000 seconds