免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2122 | 回复: 1
打印 上一主题 下一主题

2440的iic驱动疑惑 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-03-06 18:09 |只看该作者 |倒序浏览
各位大神,最近在看iic驱动,里头有个不明白的地方,求教:
  1. static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
  2.                                       struct i2c_msg *msg)
  3. {
  4.         unsigned int addr = (msg->addr & 0x7f) << 1;
  5.         unsigned long stat;
  6.         unsigned long iiccon;

  7.         stat = 0;
  8.         stat |=  S3C2410_IICSTAT_TXRXEN;

  9.         if (msg->flags & I2C_M_RD) {
  10.                 stat |= S3C2410_IICSTAT_MASTER_RX;
  11.                 addr |= 1;
  12.         } else
  13.                 stat |= S3C2410_IICSTAT_MASTER_TX;

  14.         if (msg->flags & I2C_M_REV_DIR_ADDR)
  15.                 addr ^= 1;

  16.         /* todo - check for wether ack wanted or not */
  17.         s3c24xx_i2c_enable_ack(i2c);

  18.         [backcolor=Red]iiccon = readl(i2c->regs + S3C2410_IICCON);[/backcolor]
  19.         writel(stat, i2c->regs + S3C2410_IICSTAT);

  20.         dev_dbg(i2c->dev, "START: %08lx to IICSTAT, %02x to DS\n", stat, addr);
  21.         writeb(addr, i2c->regs + S3C2410_IICDS);

  22.         /* delay here to ensure the data byte has gotten onto the bus
  23.          * before the transaction is started */

  24.         ndelay(i2c->tx_setup);

  25.         dev_dbg(i2c->dev, "iiccon, %08lx\n", iiccon);
  26.         [backcolor=Red]writel(iiccon, i2c->regs + S3C2410_IICCON);[/backcolor]

  27.         stat |= S3C2410_IICSTAT_START;
  28.         writel(stat, i2c->regs + S3C2410_IICSTAT);
  29. }
复制代码
这是个启动消息传输的函数,里头标红的两个地方,不是很明白,为什么需要先把iiccon寄存器的值读出来,然后再写进去了,也没见做任何处理。

到底是为了什么?求指教。。。。。

论坛徽章:
0
2 [报告]
发表于 2016-03-06 18:11 |只看该作者
也就是代码的第23和35行的位置
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP