probe中我们最关心的就是这个--1107--实现的接口了, i2c-core最终就是通过algo->xfer将设备驱动的数据发送出去的, 是一个硬件相关的函数
787 static const struct i2c_algorithm s3c24xx_i2c_algorithm = {
788
.master_xfer
= s3c24xx_i2c_xfer,
789
.functionality
= s3c24xx_i2c_func,
790 };
748 static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,struct i2c_msg *msgs, int num)
750 {
751
struct s3c24xx_i2c *i2c = (
struct s3c24xx_i2c *)adap->algo_data;
758
for (retry =
0; retry < adap->retries; retry++) {
760
ret = s3c24xx_i2c_doxfer(i2c, msgs, num);
770
udelay(
100);
771
}
776 }
s3c24xx_i2c_xfer()
--760-->循环调用发送函数, 函数的实现如下, 可以看到其中对寄存器的读写, 设备驱动中的发送的请求, 就是通过这些readl(), writel()来实现的.
--770-->时序要求!
256 static void s3c24xx_i2c_message_start(struct s3c24xx_i2c *i2c,
257
struct i2c_msg *msg)
258 {
275
/* todo - check for whether ack wanted or not */
276
s3c24xx_i2c_enable_ack(i2c);
277
278
iiccon = readl(i2c->regs + S3C2410_IICCON);
279
writel(stat, i2c->regs + S3C2410_IICSTAT);
280
281
dev_dbg(i2c->dev,
"START: %08lx to IICSTAT, %02x to DS\n", stat, addr);
282
writeb(addr, i2c->regs + S3C2410_IICDS);
287
ndelay(i2c->tx_setup);
288
290
writel(iiccon, i2c->regs + S3C2410_IICCON);
291
292
stat |= S3C2410_IICSTAT_START;
293
writel(stat, i2c->regs + S3C2410_IICSTAT);
294
295
if (i2c->quirks & QUIRK_POLL) {
296
while ((i2c->msg_num !=
0) && is_ack(i2c)) {
297
i2c_s3c_irq_nextbyte(i2c, stat);
298
stat = readl(i2c->regs + S3C2410_IICSTAT);
299
300
if (stat & S3C2410_IICSTAT_ARBITR)
301
dev_err(i2c->dev,
"deal with arbitration loss\n");
302
}
303
}
304 }