modify i2c for read bug by kfx
authorcym <709866821@qq.com>
Thu, 5 Aug 2010 08:02:55 +0000 (16:02 +0800)
committercym <709866821@qq.com>
Thu, 5 Aug 2010 08:16:39 +0000 (16:16 +0800)
drivers/i2c/busses/i2c-rk2818.c

index cf79536d3494709b5f83e761e9fc6c5ba73723d5..46bbb80556c0f182bef423a0ee35c90d279a6a4f 100755 (executable)
@@ -318,7 +318,10 @@ static int rk2818_send_address(struct rk2818_i2c_data *i2c,
                        return ret;
                }
        }
-       writel(I2C_LCMR_START, i2c->regs + I2C_LCMR);
+       if (msg->flags & I2C_M_RD)
+               writel(I2C_LCMR_START|I2C_LCMR_RESUME, i2c->regs + I2C_LCMR);
+       else
+               writel(I2C_LCMR_START, i2c->regs + I2C_LCMR);
        /*
        if(msg->flags & I2C_M_TEN)
        {
@@ -327,7 +330,7 @@ static int rk2818_send_address(struct rk2818_i2c_data *i2c,
                {
                        return ret;
                }
-               addr_2nd = msg->addr & 0xff;
+               addr_2nd = msg->addr & 0xff;if (msg->flags & I2C_M_RD)
                writel(addr_2nd, i2c->regs + I2C_MTXR);
                writel(I2C_LCMR_RESUME, i2c->regs + I2C_LCMR);
                if (msg->flags & I2C_M_RD)
@@ -426,6 +429,8 @@ static int rk2818_xfer_msg(struct i2c_adapter *adap,
                conr = readl(i2c->regs + I2C_CONR);
                conr |= I2C_CONR_NAK;
                writel(conr, i2c->regs + I2C_CONR);
+               if(!stop)
+                       return 0;
                if(msg->flags & I2C_M_TEN)
                        writel(I2C_LCMR_START|I2C_LCMR_RESUME , i2c->regs + I2C_LCMR);
                else