+ -
当前位置:首页 → 问答吧 → rs5c372 unable to open rtc

rs5c372 unable to open rtc

时间:2010-07-21

来源:互联网

使用kernel自带的rtc驱动,/drivers/rtc/rtc-rs5c372驱动,无法打开设备

在menuconfig菜单中已经配置了I2C设备和RTC时钟设备,但是启动信息中显示无法打开rtc0,也没有看到rtc的注册信息,但是可以看到驱动已经注册,
跟踪后发现,
static struct i2c_driver rs5c372_driver = {
        .driver                = {
                .name        = "rtc-rs5c372",
        },
        .id                        = I2C_DRIVERID_RS5C372,
        .probe                = rs5c372_probe,
        .remove                = rs5c372_remove,

};

rs5c372的初始化调用i2c_add_driver(&rs5c372_driver);
该函数在i2c.h中定义:
static inline int i2c_add_driver(struct i2c_driver *driver)
{
        return i2c_register_driver(THIS_MODULE, driver);
}

i2c_register_driver在i2c-core.c中实现:

int i2c_register_driver(struct module *owner, struct i2c_driver *driver)
{
        int res;

        /* new style driver methods can't mix with legacy ones */
        if (is_newstyle_driver(driver)) {

                if (driver->attach_adapter || driver->detach_adapter
                                || driver->detach_client) {
                        printk(KERN_WARNING
                                        "i2c-core: driver [%s] is confused\n",
                                        driver->driver.name);
                        return -EINVAL;
                }
        }

        /* add the driver to the list of i2c drivers in the driver core */
        driver->driver.owner = owner;
        driver->driver.bus = &i2c_bus_type;

        /* for new style drivers, when registration returns the driver core
         * will have called probe() for all matching-but-unbound devices.
         */
        res = driver_register(&driver->driver);
        printk("chow: res=%d\n", res);
        if (res)
                return res;

        mutex_lock(&core_lists);

        list_add_tail(&driver->list,&drivers);
        pr_debug("i2c-core: driver [%s] registered\n", driver->driver.name);


       
        printk("chow:i2c-core: driver [%s] registered\n", driver->driver.name);
       
        /* legacy drivers scan i2c busses directly */
        if (driver->attach_adapter) {
                struct i2c_adapter *adapter;

                list_for_each_entry(adapter, &adapters, list) {
                printk("Chow: reg:adapter %s\n", driver->driver.name);
                        driver->attach_adapter(adapter);//
                }
        } else {

  //红色部分是自己加的测试代码,rs5c372的driver结构体只定义了probe,所以attach_adapter为0,在rs5c372初始化时,跳到else处,而else没有任何动作,直接返回
  导致rs5c372根本没有执行probe函数,也就无法正常加载,不知道我的理解对不对,应该怎样理解,并解决该问题,这是I2C设备是怎么注册probe的?谢谢               
                              struct i2c_client *client;
                printk("chow: drive [%s] no attach_adapter\n", driver->driver.name);

                if (driver->probe) {
                        printk("chow: driver [%s] use probe\n", driver->driver.name);
                        //list_for_each_entry(client, &adapters, list) {
                                //driver->probe(client);
                        //}
                }               
        }

        mutex_unlock(&core_lists);
        return 0;
}
应该怎样解决,具体的启动信息如下:
#

**********************************************
*                LPC-2478-STK                *
*    www.olimex.com/dev/lpc-2478stk.html     *
**********************************************
..
..


U-Boot 1.3.2 (Jul 17 2010 - 20:30:09)

CPU:   LPC2478 (ARM7tdmi-s from NXP)
       running at 57.6 MHz (12 MHz crystal)
DRAM:  16 MB
Flash:  8.5 MB
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Hit any key to stop autoboot:  0
lpc-2478-stk # cp.b 80040000 A0008000 200000;go a0008000
## Starting application at 0xA0008000 ...
ûLinux version 2.6.24.2-uc0 ([email protected]) (gcc version 3.4.4) #197 Wed Jul 21 00:17:30 CST 2010
CPU: NXP-LPC2468 [24680000] revision 0 (ARMvundefined/unknown), cr=a01697e0
Machine: Olimex LPC-2478-STK
Warning: bad configuration page, trying to continue
Built 1 zonelists in Zone order, mobility grouping off.  Total pages: 4064
Kernel command line: noinitrd root=/dev/mtdblock2 rootfstype=jffs2 rw console=ttyS0,115200 mem=16M
PID hash table entries: 64 (order: 6, 256 bytes)
LPC22XX Clocking Fin=12000000Hz Fcco=288000000Hz M=11 N=0
Fcclk=57600000 PCLKSEL=55515555 11555455
Console: colour dummy device 80x30
Dentry cache hash table entries: 2048 (order: 1, 8192 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Memory: 16MB = 16MB total
Memory: 14720KB available (1268K code, 160K data, 80K init)
NetWinder Floating Point Emulator V0.97 (double precision)
JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
fuse init (API version 7.9)
Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing disabled
chow : Driver 'serial8250' is register
serial8250.0: ttyS0 at MMIO 0xe000c000 (irq = 6) is a 16550A
console [ttyS0] enabled
serial8250.0: ttyS1 at MMIO 0xe0010000 (irq = 7) is a 16550A
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: module loaded
Number of erase regions: 2
Primary Vendor Command Set: 0002 (AMD/Fujitsu Standard)
Primary Algorithm Table at 0040
Alternative Vendor Command Set: 0000 (None)
No Alternate Algorithm Table
Vcc Minimum:  2.7 V
Vcc Maximum:  3.6 V
No Vpp line
Typical byte/word write timeout: 128 µs
Maximum byte/word write timeout: 1024 µs
Typical full buffer write timeout: 128 µs
Maximum full buffer write timeout: 4096 µs
Typical block erase timeout: 1024 ms
Maximum block erase timeout: 16384 ms
Chip erase not supported
Device size: 0x400000 bytes (4 MiB)
Flash Device Interface description: 0x0002
  - supports x8 and x16 via BYTE# with asynchronous interface
Max. bytes in buffer write: 0x20
Number of Erase Block Regions: 2
  Erase Region #0: BlockSize 0x2000 bytes, 8 blocks
  Erase Region #1: BlockSize 0x10000 bytes, 63 blocks
NXP lpc24xx1: Found 1 x16 devices at 0x0 in 16-bit bank
Amd/Fujitsu Extended Query Table at 0x0040
number of CFI chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
cmdlinepart partition parsing not available
Number of erase regions: 2
Primary Vendor Command Set: 0002 (AMD/Fujitsu Standard)
Primary Algorithm Table at 0040
Alternative Vendor Command Set: 0000 (None)
No Alternate Algorithm Table
Vcc Minimum:  2.7 V
Vcc Maximum:  3.6 V
No Vpp line
Typical byte/word write timeout: 128 µs
Maximum byte/word write timeout: 1024 µs
Typical full buffer write timeout: 128 µs
Maximum full buffer write timeout: 4096 µs
Typical block erase timeout: 1024 ms
Maximum block erase timeout: 16384 ms
Chip erase not supported
Device size: 0x400000 bytes (4 MiB)
Flash Device Interface description: 0x0002
  - supports x8 and x16 via BYTE# with asynchronous interface
Max. bytes in buffer write: 0x20
Number of Erase Block Regions: 2
  Erase Region #0: BlockSize 0x2000 bytes, 8 blocks
  Erase Region #1: BlockSize 0x10000 bytes, 63 blocks
NXP lpc24xx2: Found 1 x16 devices at 0x0 in 16-bit bank
Amd/Fujitsu Extended Query Table at 0x0040
number of CFI chips: 1
cfi_cmdset_0002: Disabling erase-suspend-program due to code brokenness.
cmdlinepart partition parsing not available
Creating 3 MTD partitions on "NXP lpc24xx1":
0x00000000-0x00040000 : "uboot"
ftl_cs: FTL header not found.
0x00040000-0x001c0000 : "Kernel"
ftl_cs: FTL header not found.
0x001c0000-0x00400000 : "jffs2"
ftl_cs: FTL header not found.
Creating 3 MTD partitions on "NXP lpc24xx2":
0x00000000-0x00380000 : "user"
ftl_cs: FTL header not found.
0x00380000-0x003c0000 : "firecord"
ftl_cs: FTL header not found.
0x003c0000-0x00400000 : "applycation"
ftl_cs: FTL header not found.
block2mtd: version $Revision: 1.30 $
Chow:rs5c372_init
chow : Driver 'rtc-rs5c372' is register
chow: res=0
chow:i2c-core: driver [rtc-rs5c372] registered
chow: drive [rtc-rs5c372] no attach_adapter
chow: driver [rtc-rs5c372] use probe
chow : Driver 'dev_driver' is register
chow: res=0
chow:i2c-core: driver [dev_driver] registered
chow : Driver 'lpc22xx-i2c' is register
lpc22xx_i2c_probe base=e005c000 irq=19
Division by zero in kernel.
Function entered at [<a0020500>] from [<a0020d3c>]
Function entered at [<a0020d24>] from [<a00cbaa8>]
Function entered at [<a011e6b4>] from [<a0019004>]
r5:a015dba4 r4:a0311800
Function entered at [<a0018efc>] from [<a01037f0>]
r7:a015dc2c r6:00000000 r5:a0169768 r4:a015dba4
Function entered at [<a01037d0>] from [<a01018a8>]
Function entered at [<a010175c>] from [<a0101aec>]
Function entered at [<a0101a08>] from [<a0100a94>]
r5:a01b9ef0 r4:00000000
Function entered at [<a0100a3c>] from [<a0101b10>]
r7:a01685b0 r6:a0169770 r5:a0169768 r4:00000000
Function entered at [<a0101af0>] from [<a0100f88>]
Function entered at [<a0100f08>] from [<a0101f7c>]
Function entered at [<a0101f20>] from [<a0103904>]
r4:00000000
Function entered at [<a0103898>] from [<a00190c0>]
Function entered at [<a00190ac>] from [<a0008ba4>]
Function entered at [<a0008b00>] from [<a0031c9c>]
=== lpc22xx_pca_init
chow: name=lpc22xx-i2c adapter
chow: adapter=0
chow: adapter=-1609439968
Chow: i2c probe
Chow:rtc_class_open: rtc_class=1
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
VFS: Mounted root (jffs2 filesystem).
init started:  BusyBox v1.00 (2010.06.01-15:23+0000) multi-call binary
init started:  BusyBox v1.00 (2010.06.01-15:23+0000) multi-call binary
Starting pid 18, console : '/etc/rc'
Welcome to
          ____ _  _
         /  __| ||_|                 
    _   _| |  | | _ ____  _   _  _  _
   | | | | |  | || |  _ \| | | |\ \/ /
   | |_| | |__| || | | | | |_| |/    \
   |  ___\____|_||_|_| |_|\____|\_/\_/
   | |
   |_|

For further information check:
http://www.uclinux.org/
http://www.olimex.com/dev/
Starting pid 29, console : '/bin/sh'


BusyBox v1.00 (2010.06.01-16:26+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.

#

作者: joey_chow   发布时间: 2010-07-21

内核启动后,在proc/devies下也有rtc设备,不知道是不是使用不当
# cat proc/devices
Character devices:
  1 mem
  4 /dev/vc/0
  4 tty
  4 ttyS
  5 /dev/tty
  5 /dev/console
  7 vcs
10 misc
13 input
29 fb
90 mtd
254 rtc

Block devices:
  1 ramdisk
  7 loop
31 mtdblock
44 ftl

作者: joey_chow   发布时间: 2010-07-21