aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaemin Yoo <jmin.yoo@samsung.com>2013-03-26 00:29:56 -0400
committerWolfram Sang <wsa@the-dreams.de>2013-04-09 05:23:05 -0400
commit85747311ecb6167c989093c64a13807366fdd3a9 (patch)
treef0fdf82d8c9173441bfce04a5b7dfcf491ce908d
parent51d95709dddf7fdf6769a547de37a9c98edf8df9 (diff)
i2c: s3c2410: Add SMBus emulation for block read
SMBus read and write are supported by the emulation layer of i2c framework if the controller doesn't have SMBus features. I2C_M_RECV_LEN flag is used to let i2c drivers know rx length is not yet determined but will be read to the first byte in rx buffer. s3c2410 doesn't handle this flag. So only one byte is read from slave. There fore following two features are added to the driver code. 1. skip rx length check if I2C_M_RECV_LEN is set and the length is 1. 2. add actual bytes to the rx length after reading first bytes if I2C_M_RECV_LEN. I2C_M_RECV_LEN is only set for SMBus command. So this code does not affect legacy codes which only use i2c command for s3c2410. Signed-off-by: Jaemin Yoo <jmin.yoo@samsung.com> Tested-by: Prasanna Kumar <prasanna.ps@samsung.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 0a81f1f4aee1..6e8ee92ab553 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -346,6 +346,12 @@ static inline int is_lastmsg(struct s3c24xx_i2c *i2c)
346 346
347static inline int is_msglast(struct s3c24xx_i2c *i2c) 347static inline int is_msglast(struct s3c24xx_i2c *i2c)
348{ 348{
349 /* msg->len is always 1 for the first byte of smbus block read.
350 * Actual length will be read from slave. More bytes will be
351 * read according to the length then. */
352 if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1)
353 return 0;
354
349 return i2c->msg_ptr == i2c->msg->len-1; 355 return i2c->msg_ptr == i2c->msg->len-1;
350} 356}
351 357
@@ -485,6 +491,9 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, unsigned long iicstat)
485 byte = readb(i2c->regs + S3C2410_IICDS); 491 byte = readb(i2c->regs + S3C2410_IICDS);
486 i2c->msg->buf[i2c->msg_ptr++] = byte; 492 i2c->msg->buf[i2c->msg_ptr++] = byte;
487 493
494 /* Add actual length to read for smbus block read */
495 if (i2c->msg->flags & I2C_M_RECV_LEN && i2c->msg->len == 1)
496 i2c->msg->len += byte;
488 prepare_read: 497 prepare_read:
489 if (is_msglast(i2c)) { 498 if (is_msglast(i2c)) {
490 /* last byte of buffer */ 499 /* last byte of buffer */