【Linux高级驱动】rtc驱动开发
【1.分层思想】
1.1 rtc-dev.c //设备接口层,功能:给用户提供接口
1.2 rtc-s3c.c //功能:操作硬件
)
【为了能够读取到rtc的时间】
【一/添加驱动(driver/rtc)】
1.修改driver/rtc/目录下的Kconfig
vi linux-2.6.35.5/driver/rtc/Kconfig
tristate "Samsung S3C series SoC RTC"
depends on ARCH_S3C2410 || ARCH_S3C64XX || ARCH_S5PC100(添加的东西)
help
RTC (Realtime Clock) driver for the clock inbuilt into the
Samsung S3C24XX series of SoCs. This can provide periodic
interrupt rates from 1Hz to 64Hz for user programs, and
wakeup from Alarm.
The driver currently supports the common features on all the
S3C24XX range, such as the S3C2410, S3C2412, S3C2413, S3C2440
and S3C2442.
This driver can also be build as a module. If so, the module
will be called rtc-s3c.
2.配置内核
make menuconfig
<*> Real Time Clock ---> //class.c rtc-dev.c
<*> Samsung S3C series SoC RTCs //需要修改driver/rtc/Kconfig
3.资源添加
vi arch/arm/mach-s5pc100/Kconfig
bool "SMDKC100"
select CPU_S5PC100
select S3C_DEV_FB
select S3C_DEV_I2C1
select S3C_DEV_HSMMC
select S3C_DEV_HSMMC1
select S3C_DEV_HSMMC2
select S5PC100_SETUP_FB_24BPP
select S5PC100_SETUP_I2C1
select S5PC100_SETUP_SDHCI
select S3C_DEV_LED
select S3C_DEV_RTC //添加的代码
vi arch/arm/mach-s5pc100/mach-smdkc100.c
&s3c_device_i2c0,
&s3c_device_i2c1,
&s3c_device_fb,
&s3c_device_hsmmc0,
&s3c_device_hsmmc1,
&s3c_device_hsmmc2,
&smdkc100_lcd_powerdev,
&s5pc100_device_iis0,
&s5pc100_device_ac97,
#ifdef CONFIG_DM9000
&s5pc100_device_dm9000,
#endif
&fsled_device,
&s3c_device_rtc,
};
4.修改linux-2.6.35.5/arch/arm/mach-s5pc100/includ/mach/map.h
vi linux-2.6.35.5/arch/arm/mach-s5pc100/includ/mach/map.h
在其中添加
5.重新编译内核
测试:
1.编写测试程序,见rtc_test.c
2.运行测试程序
./rtc_test
Current RTC date/time is 0-0-2000, 00:00:00.
说明时间没有成功读取到.猜测:没有成功初始化硬件,导致不能成功读取到时间
<解决办法>
使能rtc模块的时钟,在rtc-s3c.c文件的probe函数中,在使能RTC之前添加如下代码
rtc_clk=clk_get(&pdev->dev, "rtc");
clk_enable(rtc_clk);
2.现象:一直读出来的数据位0,也设置不进去,
原因:硬件问题.
【代码跟踪】
open
rtc-s3c.c s3c_rtc_open
request_irq(s3c_rtc_alarmno, s3c_rtc_alarmirq,
IRQF_DISABLED, "s3c2410-rtc alarm", rtc_dev);
request_irq(s3c_rtc_tickno, s3c_rtc_tickirq,
IRQF_DISABLED, "s3c2410-rtc tick", rtc_dev);
RTC_SET_TIME
) {
dev_err(dev, ), base + S3C2410_RTCMON);
writeb(bin2bcd(year), base + S3C2410_RTCYEAR);
RTC_RD_TIME
;
rtc_tm;
【linux设备驱动之rtc驱动开发】
【Linux高级驱动】rtc驱动开发的更多相关文章
- Linux高级字符设备驱动
转载:http://www.linuxidc.com/Linux/2012-05/60469p4.htm 1.什么是Poll方法,功能是什么? 2.Select系统调用(功能) Select ...
- linux 高级字符设备驱动 ioctl操作介绍 例程分析实现【转】
转自:http://my.oschina.net/u/274829/blog/285014 1,ioctl介绍 ioctl控制设备读写数据以及关闭等. 用户空间函数原型:int ioctl(int f ...
- Linux高级字符设备驱动 poll方法(select多路监控原理与实现)
1.什么是Poll方法,功能是什么? 2.Select系统调用(功能) Select系统调用用于多路监控,当没有一个文件满足要求时,select将阻塞调用进程. int selec ...
- 【视频】 Linux高级程序设计01.2开发平台及Linux环境限制
[课程笔记] Linux环境限制 遵循规范,使用现有资源,明确系统限制,增量开发. (1)规范问题 编码的规范,让程序更易读.Linux编码规范. “见着如意”:变量,函数命名等能够让人看到名称就知道 ...
- 【视频】Linux高级程序设计01.1开发工具及gcc gdb
[课程笔记] Linux 下编辑调试工具,gcc,gdb. 把高级语言编译成二进制可执行代码的工具. 需要经历四个步骤: (1) 预处理:去掉注释,进行宏替换(#define相关),头文件(#incl ...
- 【Linux开发】如何查看Linux kernel的内置模块驱动列表和进程ID
[Linux开发]如何查看Linux kernel的内置模块驱动列表和进程ID 标签:[Linux开发] 命令: cat /lib/modules/$(uname -r)/modules.builti ...
- linux RTC 驱动模型分析【转】
转自:http://blog.csdn.net/yaozhenguo2006/article/details/6824970 RTC(real time clock)实时时钟,主要作用是给Linux系 ...
- Linux RTC驱动模型分析之rtc-sysfs.c【转】
转自:https://blog.csdn.net/longwang155069/article/details/52353408 版权声明:本文为博主原创文章,未经博主允许不得转载. https:// ...
- 【Linux高级驱动】linux设备驱动模型之平台设备驱动机制
[1:引言: linux字符设备驱动的基本编程流程] 1.实现模块加载函数 a.申请主设备号 register_chrdev(major,name,file_operations); b.创 ...
随机推荐
- VSCode tasks.json中的各种替换变量的意思 ${workspaceFolder} ${file} ${fileBasename} ${fileDirname}等
When authoring tasks configurations, it is often useful to have a set of predefined common variables ...
- 002.Heartbeat部署及httpd高可用
一 前期准备 1.1 依赖准备 编译安装需要依赖的包,如gcc等: yum -y install gcc gcc-c++ make glibc kernel-devel kernel-headers ...
- VS Code编辑器插件整理及配置设定
语言包: Chinese -- VS Code的汉化包 格式化+代码补全: ESLint -- Integrates ESLint Vetur -- A vue tooling Prettier -- ...
- C#全能数据库操作类及调用示例
C#全能数据库操作类及调用示例 using System; using System.Data; using System.Data.Common; using System.Configuratio ...
- fastJson解析复杂的json字符串,经测试已经成功解析
要解析的json数据格式为: HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { ResponseStatus: { }, ...
- react-native基础教程(1)
转载链接:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/react-native-foundation-course/ React ...
- UVa 127 - "Accordian" Patience POJ 1214 链表题解
UVa和POJ都有这道题. 不同的是UVa要求区分单复数,而POJ不要求. 使用STL做会比較简单,这里纯粹使用指针做了,很麻烦的指针操作,一不小心就错. 调试起来还是很费力的 本题理解起来也是挺费力 ...
- 使用Maven自动部署Java Web项目到Tomcat问题小记
导读 首先说说自己为啥要用maven管理项目,一个直接的原因是:我在自己电脑上开发web项目,每次部署到服务器上时都要经历如下步骤: 首先在Eclipse里将项目打包成war包 将服务器上原来的项目文 ...
- Meclipse alt+/ 没有提示
- 独热编码和dummy编码的作用
参考这篇文章: https://www.cnblogs.com/lianyingteng/p/7792693.html 总结:我们使用one-hot编码时,通常我们的模型不加bias项 或者 加上bi ...
