RTC
RTC设备驱动是一个标准的字符设备驱动。
1 rtc 驱动配置
以主配置 x1600e_halley6_nand_factory_defconfig 为例
kernel的配置为:
或者通过如下命令:
build$ grep -nr "kernel" configs/x1600e_halley6_nand_factory_defconfig
6:APP_kernel_dir=../kernel/kernel-x2000
7:APP_kernel_config=x1600_halley6_module_base_linux_sfc_nand_defconfig
可知kernel的配置为: x1600_halley6_module_base_linux_sfc_nand_defconfig
可知当前的kernel 编译路径为:kernel/kernel-x2000
1.1 选中 kernel 相关配置
先使用主配置 x1600e_halley6_nand_factory_defconfig 整体编译以后,再执行如下操作。
执行如下命令,进入kernel的配置界面
kernel/kernel-x2000$ make menuconfig
Ingenic device-drivers Configurations → [RTC] drivers
<*> INGENIC RTC
[*] Ingenic RTC suspend test
(60) Ingenic RTC suspend alarm time Unit of second (NEW)
<*> INGENIC RTC V1
保存配置退出,执行如下操作,让配置 x1600_halley6_module_base_linux_sfc_nand_defconfig生效。
kernel/kernel-x2000$ cp .config arch/mips/configs/x1600_halley6_module_base_linux_sfc_nand_defconfig -arf
1.2 kernel设备树相关配置
执行如下命令,进入kernel的配置界面
make menuconfig 进入配置菜单
kernel/kernel-x2000$ make menuconfig
或者通过如下命令:
kernel/kernel-x2000$ grep -nr ".dts" arch/mips/configs/x1600_halley6_module_base_linux_sfc_nand_defconfig
70:CONFIG_DT_X1600_MODULE_BASE_DTS_FILE="x1600_halley6_module_base.dts"
搜索 x1600_halley6_module_base.dts 文件路径。
kernel/kernel-x2000$ find ./ -name "x1600_halley6_module_base.dts"
./arch/mips/boot/dts/ingenic/x1600_halley6_module_base.dts
可知文件路径:kernel/kernel-x2000$ ls arch/mips/boot/dts/ingenic/x1600_halley6_module_base.dts
打开文件 x1600_halley6_module_base.dts
可知用到的文件为:x1600.dtsi ,确定文件路径如下:
kernel/kernel-x2000$ find ./ -name "x1600.dtsi"
./arch/mips/boot/dts/ingenic/x1600.dtsi
[2]+ Done gedit arch/mips/boot/dts/ingenic/x1600_halley6_module_base.dts
rtc: rtc@0x10003000 {
compatible = "ingenic,rtc-x1600";
reg = <0x10003000 0x4c>;
interrupt-parent = <&core_intc>;
interrupts = <IRQ_RTC>;
system-power-controller;
power-on-press-ms = <1000>;
status = "ok";
};
2 rtc 测试
编译进入内核,进行休眠唤醒一段时间
echo mem > sys/power/state (休眠60秒后自动唤醒-(测试点为定时和计时准确以及唤醒功能))
# echo mem > /sys/power/state
[ 3501.220119] PM: Syncing filesystems ... done.
[ 3501.223391] Freezing user space processes ... (elapsed 0.001 seconds) done.
[ 3501.225050] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[ 3501.226652] x2000 suspend begin!
[ 3501.226870] Suspending console(s) (use no_console_suspend to debug)
[ 3501.227854] <<-GTP-DEBUG->> [2626]Suspend by i2c pm.
[ 3501.227881] bcmsdh_sdmmc_suspend Enter
[ 3501.227891] bcmsdh_sdmmc_suspend Enter
[ 3501.229235] -------suspend count = 0
[ 3501.229283] PM: suspend of devices complete after 1.733 msecs
[ 3501.229651] PM: late suspend of devices complete after 0.360 msecs
[ 3501.230112] PM: noirq suspend of devices complete after 0.451 msecs
[ 3501.230116] Disabling non-boot CPUs ...
[ 3501.250013] adc_read_channel_value:adc get value timeout!
[ 3501.280041] SMP: CPU1 is offline
[ 3501.280185] SMP[1] is disabled
[ 3501.280508] x2000 pm enter!!
[ 3501.280508] soc pm sleep
[ 3501.280508] tcsm addr = b2400000 80013d90 size = 64
[ 3501.280508] tcsm addr = b2400040 80013de0 size = 4096
[ 3501.280508] tcsm addr = b2401040 8001416c size = 3072
[ 3501.280508] LCR: ff001f01
[ 3501.280508] OPCR: 40f0150c
[ 3501.280508] gate0 = 0x47f817dd
[ 3501.280508] gate1 = 0x337eff5f
[ 3501.280508] warning : bit[1] in clk gate0 is enabled
[ 3501.280508] warning : bit[5] in clk gate0 is enabled
[ 3501.280508] warning : bit[11] in clk gate0 is enabled
[ 3501.280508] warning : bit[13] in clk gate0 is enabled
[ 3501.280508] warning : bit[14] in clk gate0 is enabled
[ 3501.280508] warning : bit[15] in clk gate0 is enabled
[ 3501.280508] warning : bit[16] in clk gate0 is enabled
[ 3501.280508] warning : bit[17] in clk gate0 is enabled
[ 3501.280508] warning : bit[18] in clk gate0 is enabled
[ 3501.280508] warning : bit[27] in clk gate0 is enabled
[ 3501.280508] warning : bit[28] in clk gate0 is enabled
[ 3501.280508] warning : bit[29] in clk gate0 is enabled
[ 3501.280508] warning : bit[31] in clk gate0 is enabled
[ 3501.280508] warning : bit[5] in clk gate1 is enabled
[ 3501.280508] warning : bit[7] in clk gate1 is enabled
[ 3501.280508] warning : bit[16] in clk gate1 is enabled
[ 3501.280508] warning : bit[23] in clk gate1 is enabled
[ 3501.280508] warning : bit[26] in clk gate1 is enabled
[ 3501.280508] warning : bit[27] in clk gate1 is enabled
[ 3501.280508] warning : bit[30] in clk gate1 is enabled
[ 3501.280508] warning : bit[31] in clk gate1 is enabled
[ 3501.280508] post wakeup!
[ 3501.280554] Enabling non-boot CPUs ...
[ 3501.280618] [SMP] Booting CPU1 ...
[ 3501.280632] Primary instruction cache 32kB, VIPT, 8-way, linesize 32 bytes.
[ 3501.280636] Primary data cache 32kB, 8-way, VIPT, no aliases, linesize 32 bytes
[ 3501.280639] =======found ...... ingenic sc cache ops ...!, found: 1
[ 3501.280639]
[ 3501.280642] Unified secondary cache 512kB 16-way, linesize 64 bytes.
[ 3501.280685] #### now starting init for cpu : 1
[ 3501.280690] percpu irq inited.
[ 3501.280694] percpu cpu_num:1 timerevent init
[ 3501.280706] clockevents_config_and_register success.
[ 3501.280711] CPU1 revision is: 00132000 (Ingenic XBurst@II.V2)
[ 3501.280713] FPU revision is: 00f32000
[ 3501.280715] MSA revision is: 00002000
[ 3501.280855] [SMP] slave cpu1 start up finished.
[ 3501.280857] CPU1 is up
[ 3501.281221] PM: noirq resume of devices complete after 0.354 msecs
[ 3501.282372] PM: early resume of devices complete after 0.268 msecs
[ 3501.282853] create CDT index: 0 ~ 22, index number:23.
[ 3501.289844] bcmsdh_sdmmc_resume Enter
[ 3501.289847] bcmsdh_sdmmc_resume Enter
[ 3501.289853] sdio_reset_comm():
[ 3501.298977] mmc0: Error resetting SDIO communications (-145)
[ 3501.299007] <<-GTP-DEBUG->> [2638]Resume by i2c pm.
[ 3501.301349] PM: resume of devices complete after 18.967 msecs
[ 3501.321678] x2000 pm end!
[ 3501.321855] Restarting tasks ... done.
#
#