是这样的,我经过ioremap将I2C操作相关的寄存器映射,然后通过writeb等写入寄存器,然后使用reab等读出寄存器,但是读出数值为0。代码如下:
78 data = readl(devp->GPD1CON);
79 printk(KERN_INFO "GPM4CON = %x\n",data);
80 writeb(0x90,I2CSTA0); //stop i2c, not generate x
81 writeb(0xef,I2CCON0); //set rx mode, enable tx interrupt,
82 writeb(0xf1,I2CLC0); //set SCL
83 writeb((devp->slave_addr<<1)|0x01,I2CDS0); //write slave address
84 tmp[0] = readb(I2CSTA0);
85 tmp[1] = readb(I2CCON0);
86 tmp[2] = readb(I2CLC0);
87 tmp[3] = readb(I2CDS0);
88 printk(KERN_INFO "I2CSTA0 = %x, I2CCON0 = %x, I2CLC0 = %x, I2CDS0 = %x\n",tmp[0],tmp[1],tmp[2],tmp[3]);
第一个printk输出GPIO寄存器信息,能够正确输出,第二个printk输出I2C寄存器信息,输出全部都是0