【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.创 ...
随机推荐
- centos7 安装步骤
这里选择64位 32位没有找到网卡... 注:这里是网络类型分配,网络类型分配分为三种,Bridge,NAT和Host-Only,大概区别是 1 BRIDGE 桥接:相当于主机和虚拟机连接到同一个h ...
- POJ 1182 食物链 【带权并查集】
<题目链接> 题目大意: 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形.A吃B, B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我 ...
- 基于Vue.js的uni-app前端框架结合.net core开发跨平台project
一.由来 最近由于业务需要要开发一套公益的APP项目,因此结合所给出的需求最终采用uni-app这种跨平台前端框架以及.netcore快速搭建我们的项目,并且能做到一套代码跨多个平台. 当然在前期技术 ...
- TXT 与 DataTable 互转
//********************************************************************************************* publ ...
- android 按钮特效 波纹 Android button effects ripple
android 按钮特效 波纹 Android button effects ripple 作者:韩梦飞沙 Author:han_meng_fei_sha 邮箱:313134555@qq.com E- ...
- [BZOJ4541][HNOI2016]矿区(平面图转对偶图)
https://www.cnblogs.com/ljh2000-jump/p/6423399.html #include<cmath> #include<vector> #in ...
- Windows 文件名的书写规范
下面是不能用于文件名的: / \ : * " < > | windows系统下文件名长度为: 255个英文字符(DOS下8.3格式),包括文件名和扩展名在内,或者是255/2=1 ...
- 第一次打开app
//判断是不是第一次启动应用 if (![[NSUserDefaults standardUserDefaults] boolForKey:@"everLaunched"]) { ...
- python 元组和字典中元素作为函数调用参数传递
模式1. def test1(*args): test3(*args) def test2(**kargs): test3(**kargs) def test3(a, b): print(a,b) ...
- windows 下重置 mysql 的 root 密码
今天发现 WordPress 连接不上数据库,登录 window server 服务器查看,所有服务均运行正常. 使用 root 账号登录 mysql 数据库,结果提示密码不匹配.我突然意识到,服务器 ...
