rockchip: i2c: don't sent stop bit after each message
PATCH 1/1 rockchip: i2c: don't sent stop bit after each message
That's not correct and it breaks SMBUS-style reads and and writes for some chips (e.g. SYR82X/SYR83X).
Stop bit should be sent only after the last message.
--- drivers/i2c/rk_i2c.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/i2c/rk_i2c.c +3 -2
@@ -253,7 +253,6 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len, } i2c_exit: -rk_i2c_send_stop_bit (i2c);rk_i2c_disable (i2c);return err;
@@ -332,7 +331,6 @@ static int rk_i2c_write(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len, } i2c_exit: -rk_i2c_send_stop_bit (i2c);rk_i2c_disable (i2c);return err;
@@ -360,6 +358,9 @@ static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, } } +rk_i2c_send_stop_bit (i2c); +rk_i2c_disable (i2c); +return 0 ; }
Signature · 1 line
2.24.0
PATCH 1/1 rockchip: i2c: don't sent stop bit after each message
Hi Vasily,
drivers/i2c/rk_i2c.c static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, · line 362
Quoted 2 lines · Vasily Khoruzhick
drivers/i2c/rk_i2c.c +2
-0+rk_i2c_send_stop_bit (i2c); +rk_i2c_disable (i2c);
I think it is better to also stop i2c if i2c xfer failed, how do you feel about it?
@@ -356,11 +356,16 @@ static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
}
if (ret) {
debug("i2c_write: error sending\n");
- return -EREMOTEIO;
+ ret = -EREMOTEIO;
+ goto exit;
}
}
- return 0;
+exit:
+ rk_i2c_send_stop_bit(i2c);
+ rk_i2c_disable(i2c);
+
+ return ret;
}
PATCH 1/1 rockchip: i2c: don't sent stop bit after each message
Quoted 9 lines · David.Wu
Hi Vasily,
drivers/i2c/rk_i2c.c static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, · line 362
Quoted 2 lines · Vasily Khoruzhick
drivers/i2c/rk_i2c.c +2
-0+rk_i2c_send_stop_bit (i2c); +rk_i2c_disable (i2c);I think it is better to also stop i2c if i2c xfer failed, how do you feel about it?
I'm not sure if it's a good idea to continue communication if we've got a failure and sending a stop bit is continuing communication.
But I'm not an expert in i2c and I don't have any strong opinion on that, so I can send v2 with change you proposed.
Quoted 21 lines
(quoted diff) +7
-2@@ -356,11 +356,16 @@ static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, } if (ret) { debug("i2c_write: error sending\n"); - return -EREMOTEIO; + ret = -EREMOTEIO; + goto exit; } } - return 0; +exit: + rk_i2c_send_stop_bit(i2c); + rk_i2c_disable(i2c); + + return ret; }
PATCH 1/1 rockchip: i2c: don't sent stop bit after each message【请注意,邮件由[email protected]代发】 message
In reply to Vasily KhoruzhickQuoted 6 lines · Vasily Khoruzhick
That's not correct and it breaks SMBUS-style reads and and writes for some chips (e.g. SYR82X/SYR83X).
Stop bit should be sent only after the last message.
Signed-off-by Vasily Khoruzhick <[email protected]>
Thanks,
- Kever
Quoted 34 lines
--- drivers/i2c/rk_i2c.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/i2c/rk_i2c.c +3
-2@@ -253,7 +253,6 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len, } i2c_exit: -rk_i2c_send_stop_bit (i2c);rk_i2c_disable (i2c);return err;@@ -332,7 +331,6 @@ static int rk_i2c_write(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len, } i2c_exit: -rk_i2c_send_stop_bit (i2c);rk_i2c_disable (i2c);return err;@@ -360,6 +358,9 @@ static int rockchip_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, } } +rk_i2c_send_stop_bit (i2c); +rk_i2c_disable (i2c); +return 0 ; }