linx3.0.101下面DS1307 RTC驱动调试过程

本文探讨了DS1307实时时钟(RTC)在Linux环境下的驱动配置问题,包括如何通过i2c_bus进行正确设置,并对比了DS1307与SNVS RTC的不同注册方式及其带来的影响。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

snvs_rtcsnvs_rtc.0: setting system clock to 1970-01-01 06:51:46 UTC (24706)

Freescale SNVSReal Time Clock (RTC_DRV_SNVS),这个选项去掉。

drivers/rtc/hctosys.c:unable to open rtc device (rtc0)

root@imx6solo /$find . -name rtc

./sys/class/rtc

把RTC_DRV_SNVS加回来:

snvs_rtcsnvs_rtc.0: setting system clock to 1970-01-02 03:14:40 UTC (98080)

这样就有/dev/rtc了。

DS1307是i2c_rtc_driver的框架:

static int __initds1307_init(void)

{

       return i2c_add_driver(&ds1307_driver);

}

而snvs是platform_rtc_driver的架构:

static int __initsnvs_rtc_init(void)

{

       returnplatform_driver_register(&snvs_rtc_driver);

}

linux下访问i2c设备:int fd= = open("/dev/i2c-0",O_RDWR);

i2c-core: driver [isl29023] using legacyresume method

Init RTC-DS1307device success!

i2c /dev entries driver

DS1307作为RTC设备,只向i2cbus注册的话,busybox就无法操作它,这就很不方便。最好是同时也向platform进行注册。

root@imx6solo /$find . -name rtc

./sys/class/rtc

root@imx6solo /$ls /sys/class/rtc/         //空目录

root@imx6solo /$

增加SVNS内部RTC后:

root@imx6solo ~$ls /sys/class/rtc/rtc0/

date           max_user_freq  since_epoch   uevent        

device         name           subsystem      wakealarm     

hctosys        power          time         

看来应该是i2c_device_probe()要在open设备时才会来调用,跟platform设备不同。不过,改为platform_driver_register方式注册也不行!

我怀疑应该是注册rtc设备不成功吧,下面这一句:

       ds1307->rtc =rtc_device_register(client->name, &client->dev,

                            &ds13xx_rtc_ops,THIS_MODULE);

一进这个func,我就增加了打印输出:printk("ds1307_probeis called!\n");

但居然没有打印,说明这个probe没有被调用。

从i2c的打印来看:

i2c-core: driver [isl29023] using legacysuspend method

i2c-core: driver [isl29023] using legacyresume method

Init RTC-DS1307device success!

i2c /dev entries driver

Linux videocapture interface: v2.00

mag3110 2-000e:check mag3110 chip ID

mag3110 2-000e:read chip ID 0xfffffffb is not equal to 0xc4!

mag3110: probe of2-000e failed with error -22

i2c-core: driver [mag3110] using legacysuspend method

i2c-core: driver [mag3110] using legacy resumemethod

i2c-core: driver [mma8450] using legacysuspend method

i2c-core: driver [mma8450] using legacy resumemethod

add mma8450 i2c driver。没有add rtc-ds1307i2c driver?是否说明register不成功?但是ret=i2c_add_driver(&ds1307_driver);这个返回值是0,应该是成功的。

在board-mx6q_sabresd.c中,

static struct i2c_board_info mxc_i2c1_board_info[] __initdata = {中增加

       {

I2C_BOARD_INFO("rtc-ds1307", 0x68),  // 11010000-->0110,1000=0x68(7bit i2c slave addr)  },

imx6solo居然有四条i2c-bus,ds1307挂在第二条i2c-1上面。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

草根大哥

进军大神程序员路上,谢谢支持!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值