标签:
1. 概述
rtc(real time clock) 给linux系统提供时间,设备在断电的情况下,rtc芯片因为有电池的存在,可以继续工作。
驱动:
drivers/rtc/ 驱动目录
drivers/rtc/class.c 注册了一个类RTC,然后向驱动程序提供了注册/注销接口
drivers/rtc/interface.c 主要提供了用户程序与RTC驱动的接口函数
drivers/rtc/rtc-dev.c 定义了基本的设备文件操作函数,比如:open,read,ioctl
drivers/rtc/rtc-sysfs.c 与sysfs有关
drivers/rtc/rtc-proc.c 与proc有关
drivers/rtc/rtc-lib.c 库文件, 系统默认启动的时间1970就在这里
drivers/rtc/qpnp-rtc.c 高通RTC驱动实现
drivers/rtc/rtc-xxx.c 通常以该命名方式, 其它芯片的RTC驱动
pm8916_rtc: qcom,pm8916_rtc {
spmi-dev-container;
compatible = "qcom,qpnp-rtc";
#address-cells = <1>;
#size-cells = <1>;
qcom,qpnp-rtc-write = <0>;
qcom,qpnp-rtc-alarm-pwrup = <0>;
qcom,pm8916_rtc_rw@6000 {
reg = <0x6000 0x100>;
};
qcom,pm8916_rtc_alarm@6100 {
reg = <0x6100 0x100>;
interrupts = <0x0 0x61 0x1>;
};
};
根据设备树内容的规则,这里可看出该平台rtc名称, 寄存器,中断等。
文件操作使用:
/*
* For these RTC methods the device parameter is the physical device
* on whatever bus holds the hardware (I2C, Platform, SPI, etc), which
* was passed to rtc_device_register(). Its driver_data normally holds
* device state, including the rtc_device pointer for the RTC.
*
* Most of these methods are called with rtc_device.ops_lock held,
* through the rtc_*(struct rtc_device *, ...) calls.
*
* The (current) exceptions are mostly