i2c: tegra: Add SMBus block read function
PATCH RESEND 1/1 i2c: tegra: Add SMBus block read function
Emulate SMBus block read using ContinueXfer to read the length byte
--- drivers/i2c/busses/i2c-tegra.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-tegra.c +16 -2
@@ -1233,6 +1233,11 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,return err; i2c_dev->msg_buf = msg->buf; + +/* The condition true implies smbus block read and len is already read */ +if (msg->flags &I2C_M_RECV_LEN && end_state !=MSG_END_CONTINUE ) + i2c_dev->msg_buf = msg->buf +1 ; + i2c_dev->msg_buf_remaining = msg->len; i2c_dev->msg_err =I2C_ERR_NONE ; i2c_dev->msg_read = !!(msg->flags &I2C_M_RD );
@@ -1389,6 +1394,15 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],else end_type =MSG_END_REPEAT_START ; } +/* If M_RECV_LEN use ContinueXfer to read the first byte */ +if (msgs[i].flags &I2C_M_RECV_LEN ) { + ret =tegra_i2c_xfer_msg (i2c_dev, &msgs[i],MSG_END_CONTINUE ); +if (ret) +break ; +/* Set the read byte as msg len */ + msgs[i].len = msgs[i].buf[0 ]; +dev_dbg (i2c_dev->dev,"reading %d bytes\n" , msgs[i].len); + } ret =tegra_i2c_xfer_msg (i2c_dev, &msgs[i], end_type);if (ret)break ;
@@ -1416,10 +1430,10 @@ static u32 tegra_i2c_func(struct i2c_adapter *adap) {struct tegra_i2c_dev *i2c_dev =i2c_get_adapdata (adap);u32 ret =I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK ) | -I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ; +I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ;if (i2c_dev->hw->has_continue_xfer_support) - ret |=I2C_FUNC_NOSTART ; + ret |=I2C_FUNC_NOSTART |I2C_FUNC_SMBUS_READ_BLOCK_DATA ;return ret; }
Signature · 1 line
2.17.1
Dmitry Osipenko
reviewer10.02.2022 18:36, Akhil R пишет:
Quoted 42 lines
Emulate SMBus block read using ContinueXfer to read the length byte
Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-tegra.c +14
-0@@ -1233,6 +1233,11 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,return err; i2c_dev->msg_buf = msg->buf; + +/* The condition true implies smbus block read and len is already read */ +if (msg->flags &I2C_M_RECV_LEN && end_state !=MSG_END_CONTINUE ) + i2c_dev->msg_buf = msg->buf +1 ; + i2c_dev->msg_buf_remaining = msg->len; i2c_dev->msg_err =I2C_ERR_NONE ; i2c_dev->msg_read = !!(msg->flags &I2C_M_RD );@@ -1389,6 +1394,15 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],else end_type =MSG_END_REPEAT_START ; } +/* If M_RECV_LEN use ContinueXfer to read the first byte */ +if (msgs[i].flags &I2C_M_RECV_LEN ) { + ret =tegra_i2c_xfer_msg (i2c_dev, &msgs[i],MSG_END_CONTINUE ); +if (ret) +break ; +/* Set the read byte as msg len */ + msgs[i].len = msgs[i].buf[0 ]; +dev_dbg (i2c_dev->dev,"reading %d bytes\n" , msgs[i].len); + } ret =tegra_i2c_xfer_msg (i2c_dev, &msgs[i], end_type);if (ret)break ;@@ -1416,10 +1430,10 @@ static u32 tegra_i2c_func(struct i2c_adapter *adap) {struct tegra_i2c_dev *i2c_dev =i2c_get_adapdata (adap);
drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter *adap) · line 1439
Quoted 10 lines
drivers/i2c/busses/i2c-tegra.c +2
-2u32 ret =I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL & ~I2C_FUNC_SMBUS_QUICK ) | -I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ; +I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ;if (i2c_dev->hw->has_continue_xfer_support) - ret |=I2C_FUNC_NOSTART ; + ret |=I2C_FUNC_NOSTART |I2C_FUNC_SMBUS_READ_BLOCK_DATA ;return ret; }
Please describe how this was tested.
Quoted 53 lines
10.02.2022 18:36, Akhil R пишет:
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer_msg(struct tegra_i2c_dev
Quoted 12 lines
Emulate SMBus block read using ContinueXfer to read the length byte
Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-tegra.c +0
-0@@ -1233,6 +1233,11 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev
*i2c_dev,drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +3
-0return err; i2c_dev->msg_buf = msg->buf; + +/* The condition true implies smbus block read and len is already read */ + if (msg->flags & I2C_M_RECV_LEN && end_state !=
MSG_END_CONTINUE)drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer(struct i2c_adapter *adap,
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +2
-0+ i2c_dev->msg_buf = msg->buf +1 ; + i2c_dev->msg_buf_remaining = msg->len; i2c_dev->msg_err =I2C_ERR_NONE ; i2c_dev->msg_read = !!(msg->flags &I2C_M_RD );@@ -1389,6 +1394,15 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap,struct
i2c_msgmsgs[],drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +3
-0else end_type =MSG_END_REPEAT_START ; } +/* If M_RECV_LEN use ContinueXfer to read the first byte */ +if (msgs[i].flags &I2C_M_RECV_LEN ) { + ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i],
MSG_END_CONTINUE);drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter
Quoted 10 lines
drivers/i2c/busses/i2c-tegra.c +6
-0+if (ret) +break ; +/* Set the read byte as msg len */ + msgs[i].len = msgs[i].buf[0 ]; +dev_dbg (i2c_dev->dev,"reading %d bytes\n" , msgs[i].len); + } ret =tegra_i2c_xfer_msg (i2c_dev, &msgs[i], end_type);if (ret)break ;@@ -1416,10 +1430,10 @@ static u32 tegra_i2c_func(struct i2c_adapter*adap)
drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter *adap)
Quoted 3 lines
drivers/i2c/busses/i2c-tegra.c +0
-0{struct tegra_i2c_dev *i2c_dev =i2c_get_adapdata (adap); u32 ret = I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL &~I2C_FUNC_SMBUS_QUICK) |
Quoted 3 lines
drivers/i2c/busses/i2c-tegra.c +1
-1-I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ; +I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ;
Quoted 8 lines
drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter *adap) · line 1439
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +1
-1if (i2c_dev->hw->has_continue_xfer_support) - ret |=I2C_FUNC_NOSTART ; + ret |=I2C_FUNC_NOSTART |I2C_FUNC_SMBUS_READ_BLOCK_DATA ;return ret; }Please describe how this was tested.
This is tested using an I2C EEPROM to emulate SMBus block read in which we read the first byte as the length of bytes to read. This is an expected feature for NVIDIA Grace chipset where there will be an actual SMBus device.
Thanks,
Akhil
Dmitry Osipenko
reviewer11.02.2022 12:11, Akhil R пишет:
Quoted 57 lines
Quoted 57 lines
10.02.2022 18:36, Akhil R пишет:
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer_msg(struct tegra_i2c_dev
Quoted 12 lines
Emulate SMBus block read using ContinueXfer to read the length byte
Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-tegra.c +0
-0@@ -1233,6 +1233,11 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev
*i2c_dev,drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +3
-0return err; i2c_dev->msg_buf = msg->buf; + +/* The condition true implies smbus block read and len is already read */ + if (msg->flags & I2C_M_RECV_LEN && end_state !=
MSG_END_CONTINUE)drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer(struct i2c_adapter *adap,
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +2
-0+ i2c_dev->msg_buf = msg->buf +1 ; + i2c_dev->msg_buf_remaining = msg->len; i2c_dev->msg_err =I2C_ERR_NONE ; i2c_dev->msg_read = !!(msg->flags &I2C_M_RD );@@ -1389,6 +1394,15 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap,struct
i2c_msgmsgs[],drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +3
-0else end_type =MSG_END_REPEAT_START ; } +/* If M_RECV_LEN use ContinueXfer to read the first byte */ +if (msgs[i].flags &I2C_M_RECV_LEN ) { + ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i],
MSG_END_CONTINUE);drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter
Quoted 10 lines
drivers/i2c/busses/i2c-tegra.c +6
-0+if (ret) +break ; +/* Set the read byte as msg len */ + msgs[i].len = msgs[i].buf[0 ]; +dev_dbg (i2c_dev->dev,"reading %d bytes\n" , msgs[i].len); + } ret =tegra_i2c_xfer_msg (i2c_dev, &msgs[i], end_type);if (ret)break ;@@ -1416,10 +1430,10 @@ static u32 tegra_i2c_func(struct i2c_adapter*adap)
drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter *adap)
Quoted 3 lines
drivers/i2c/busses/i2c-tegra.c +0
-0{struct tegra_i2c_dev *i2c_dev =i2c_get_adapdata (adap); u32 ret = I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL &~I2C_FUNC_SMBUS_QUICK) |
Quoted 7 lines
drivers/i2c/busses/i2c-tegra.c +2
-2-I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ; +I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ;if (i2c_dev->hw->has_continue_xfer_support) - ret |=I2C_FUNC_NOSTART ; + ret |=I2C_FUNC_NOSTART |I2C_FUNC_SMBUS_READ_BLOCK_DATA ;
Quoted 7 lines
Quoted 4 lines
drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter *adap) · line 1439
Quoted 2 lines
drivers/i2c/busses/i2c-tegra.c +0
-0return ret; }Please describe how this was tested.
This is tested using an I2C EEPROM to emulate SMBus block read in which we read the first byte as the length of bytes to read. This is an expected feature for NVIDIA Grace chipset where there will be an actual SMBus device.
We have several Tegra30+ tablets that have EC on SMBus. Svyatoslav tried your I2C patch + [1] on Asus TF201 and reported that it breaks EC. Any idea why it doesn't work?
[1]
https://github.com/grate-driver/linux/commit/aa8d71f5a960ef40503e5448c622d62d1c53a2c0
Dmitry Osipenko
reviewer12.02.2022 19:15, Dmitry Osipenko пишет:
Quoted 66 lines
11.02.2022 12:11, Akhil R пишет:
Quoted 57 lines
Quoted 57 lines
10.02.2022 18:36, Akhil R пишет:
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer_msg(struct tegra_i2c_dev
Quoted 12 lines
Emulate SMBus block read using ContinueXfer to read the length byte
Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-tegra.c +0
-0@@ -1233,6 +1233,11 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev
*i2c_dev,drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +3
-0return err; i2c_dev->msg_buf = msg->buf; + +/* The condition true implies smbus block read and len is already read */ + if (msg->flags & I2C_M_RECV_LEN && end_state !=
MSG_END_CONTINUE)drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer(struct i2c_adapter *adap,
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +2
-0+ i2c_dev->msg_buf = msg->buf +1 ; + i2c_dev->msg_buf_remaining = msg->len; i2c_dev->msg_err =I2C_ERR_NONE ; i2c_dev->msg_read = !!(msg->flags &I2C_M_RD );@@ -1389,6 +1394,15 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap,struct
i2c_msgmsgs[],drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +3
-0else end_type =MSG_END_REPEAT_START ; } +/* If M_RECV_LEN use ContinueXfer to read the first byte */ +if (msgs[i].flags &I2C_M_RECV_LEN ) { + ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i],
MSG_END_CONTINUE);drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter
Quoted 10 lines
drivers/i2c/busses/i2c-tegra.c +6
-0+if (ret) +break ; +/* Set the read byte as msg len */ + msgs[i].len = msgs[i].buf[0 ]; +dev_dbg (i2c_dev->dev,"reading %d bytes\n" , msgs[i].len); + } ret =tegra_i2c_xfer_msg (i2c_dev, &msgs[i], end_type);if (ret)break ;@@ -1416,10 +1430,10 @@ static u32 tegra_i2c_func(struct i2c_adapter*adap)
drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter *adap)
Quoted 3 lines
drivers/i2c/busses/i2c-tegra.c +0
-0{struct tegra_i2c_dev *i2c_dev =i2c_get_adapdata (adap); u32 ret = I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL &~I2C_FUNC_SMBUS_QUICK) |
Quoted 7 lines
drivers/i2c/busses/i2c-tegra.c +2
-2-I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ; +I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ;if (i2c_dev->hw->has_continue_xfer_support) - ret |=I2C_FUNC_NOSTART ; + ret |=I2C_FUNC_NOSTART |I2C_FUNC_SMBUS_READ_BLOCK_DATA ;Quoted 7 lines
Quoted 4 lines
drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter *adap) · line 1439
Quoted 2 lines
drivers/i2c/busses/i2c-tegra.c +0
-0return ret; }Please describe how this was tested.
This is tested using an I2C EEPROM to emulate SMBus block read in which we read the first byte as the length of bytes to read. This is an expected feature for NVIDIA Grace chipset where there will be an actual SMBus device.
Quoted 6 lines
We have several Tegra30+ tablets that have EC on SMBus. Svyatoslav tried your I2C patch + [1] on Asus TF201 and reported that it breaks EC. Any idea why it doesn't work?
[1]
https://github.com/grate-driver/linux/commit/aa8d71f5a960ef40503e5448c622d62d1c53a2c0
Ah, I see now that I2C_FUNC_SMBUS_WRITE_BLOCK_DATA not supported, we should check again without the write then.
Dmitry Osipenko
reviewer12.02.2022 19:20, Dmitry Osipenko пишет:
Quoted 71 lines
12.02.2022 19:15, Dmitry Osipenko пишет:
Quoted 70 lines
11.02.2022 12:11, Akhil R пишет:
Quoted 57 lines
Quoted 57 lines
10.02.2022 18:36, Akhil R пишет:
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer_msg(struct tegra_i2c_dev
Quoted 12 lines
Emulate SMBus block read using ContinueXfer to read the length byte
Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/i2c/busses/i2c-tegra.c +0
-0@@ -1233,6 +1233,11 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev
*i2c_dev,drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +3
-0return err; i2c_dev->msg_buf = msg->buf; + +/* The condition true implies smbus block read and len is already read */ + if (msg->flags & I2C_M_RECV_LEN && end_state !=
MSG_END_CONTINUE)drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer(struct i2c_adapter *adap,
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +2
-0+ i2c_dev->msg_buf = msg->buf +1 ; + i2c_dev->msg_buf_remaining = msg->len; i2c_dev->msg_err =I2C_ERR_NONE ; i2c_dev->msg_read = !!(msg->flags &I2C_M_RD );@@ -1389,6 +1394,15 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap,struct
i2c_msgmsgs[],drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +3
-0else end_type =MSG_END_REPEAT_START ; } +/* If M_RECV_LEN use ContinueXfer to read the first byte */ +if (msgs[i].flags &I2C_M_RECV_LEN ) { + ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i],
MSG_END_CONTINUE);drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter
Quoted 10 lines
drivers/i2c/busses/i2c-tegra.c +6
-0+if (ret) +break ; +/* Set the read byte as msg len */ + msgs[i].len = msgs[i].buf[0 ]; +dev_dbg (i2c_dev->dev,"reading %d bytes\n" , msgs[i].len); + } ret =tegra_i2c_xfer_msg (i2c_dev, &msgs[i], end_type);if (ret)break ;@@ -1416,10 +1430,10 @@ static u32 tegra_i2c_func(struct i2c_adapter*adap)
drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter *adap)
Quoted 3 lines
drivers/i2c/busses/i2c-tegra.c +0
-0{struct tegra_i2c_dev *i2c_dev =i2c_get_adapdata (adap); u32 ret = I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL &~I2C_FUNC_SMBUS_QUICK) |
Quoted 7 lines
drivers/i2c/busses/i2c-tegra.c +2
-2-I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ; +I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ;if (i2c_dev->hw->has_continue_xfer_support) - ret |=I2C_FUNC_NOSTART ; + ret |=I2C_FUNC_NOSTART |I2C_FUNC_SMBUS_READ_BLOCK_DATA ;Quoted 7 lines
Quoted 4 lines
drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter *adap) · line 1439
Quoted 2 lines
drivers/i2c/busses/i2c-tegra.c +0
-0return ret; }Please describe how this was tested.
This is tested using an I2C EEPROM to emulate SMBus block read in which we read the first byte as the length of bytes to read. This is an expected feature for NVIDIA Grace chipset where there will be an actual SMBus device.
We have several Tegra30+ tablets that have EC on SMBus. Svyatoslav tried your I2C patch + [1] on Asus TF201 and reported that it breaks EC. Any idea why it doesn't work?
Quoted 5 lines
Quoted 2 lines
[1]
https://github.com/grate-driver/linux/commit/aa8d71f5a960ef40503e5448c622d62d1c53a2c0Ah, I see now that
I2C_FUNC_SMBUS_WRITE_BLOCK_DATAnot supported, we should check again without the write then.
We also missed that i2c_smbus_read_i2c_block_data() populates the first byte of the read data with the transfer size. So i2c_smbus_read_block_data() actually works properly.
It's unclear to me what's the point of emulating I2C_FUNC_SMBUS_READ_BLOCK_DATA within the driver if you could use i2c_smbus_read_i2c_block_data().
Quoted 85 lines
12.02.2022 19:20, Dmitry Osipenko пишет:
Quoted 10 lines
12.02.2022 19:15, Dmitry Osipenko пишет:
Quoted 9 lines
11.02.2022 12:11, Akhil R пишет:
Quoted 8 lines
Quoted 8 lines
10.02.2022 18:36, Akhil R пишет:
Quoted 7 lines
Emulate SMBus block read using ContinueXfer to read the length byte
Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer_msg(struct
Quoted 5 lines
drivers/i2c/busses/i2c-tegra.c +0
-0@@ -1233,6 +1233,11 @@ static int tegra_i2c_xfer_msg(struct
tegra_i2c_devQuoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
*i2c_dev,Quoted 5 lines
drivers/i2c/busses/i2c-tegra.c +2
-0return err; i2c_dev->msg_buf = msg->buf; + +/* The condition true implies smbus block read and len is already read */
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer_msg(struct · line 1238
Quoted 1 line
drivers/i2c/busses/i2c-tegra.c +1
-0+ if (msg->flags & I2C_M_RECV_LEN && end_state !=
MSG_END_CONTINUE)drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer(struct i2c_adapter
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +2
-0+ i2c_dev->msg_buf = msg->buf +1 ; + i2c_dev->msg_buf_remaining = msg->len; i2c_dev->msg_err =I2C_ERR_NONE ; i2c_dev->msg_read = !!(msg->flags &I2C_M_RD );@@ -1389,6 +1394,15 @@ static int tegra_i2c_xfer(struct i2c_adapter*adap,
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
struct
i2c_msgmsgs[],drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +3
-0else end_type =MSG_END_REPEAT_START ; } +/* If M_RECV_LEN use ContinueXfer to read the first byte */ +if (msgs[i].flags &I2C_M_RECV_LEN ) { + ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i],
MSG_END_CONTINUE);drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter
Quoted 10 lines
drivers/i2c/busses/i2c-tegra.c +6
-0+if (ret) +break ; +/* Set the read byte as msg len */ + msgs[i].len = msgs[i].buf[0 ]; +dev_dbg (i2c_dev->dev,"reading %d bytes\n" , msgs[i].len); + } ret =tegra_i2c_xfer_msg (i2c_dev, &msgs[i], end_type);if (ret)break ;@@ -1416,10 +1430,10 @@ static u32 tegra_i2c_func(struct i2c_adapter*adap)
Quoted 3 lines
drivers/i2c/busses/i2c-tegra.c +0
-0{struct tegra_i2c_dev *i2c_dev =i2c_get_adapdata (adap); u32 ret = I2C_FUNC_I2C | (I2C_FUNC_SMBUS_EMUL &Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
~I2C_FUNC_SMBUS_QUICK) |
Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c +2
-2-I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ; +I2C_FUNC_10BIT_ADDR |I2C_FUNC_PROTOCOL_MANGLING ;if (i2c_dev->hw->has_continue_xfer_support) - ret |=I2C_FUNC_NOSTART ; + ret |= I2C_FUNC_NOSTART |
I2C_FUNC_SMBUS_READ_BLOCK_DATA;Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
drivers/i2c/busses/i2c-tegra.c static u32 tegra_i2c_func(struct i2c_adapter *adap) · line 1439
Quoted 3 lines
drivers/i2c/busses/i2c-tegra.c +0
-0return ret; }Please describe how this was tested.
This is tested using an I2C EEPROM to emulate SMBus block read in which we read the first byte as the length of bytes to read. This is an expected feature for NVIDIA Grace chipset where there will be an actual SMBus
device.
Quoted 7 lines
Quoted 7 lines
We have several Tegra30+ tablets that have EC on SMBus. Svyatoslav tried your I2C patch + [1] on Asus TF201 and reported that it breaks EC. Any idea why it doesn't work?
driver/linux/commit/aa8d71f5a960ef40503e5448c622d62d1c53a2c0
Quoted 2 lines
Ah, I see now that
I2C_FUNC_SMBUS_WRITE_BLOCK_DATAnot supported,we
Quoted 1 line
should check again without the write then.
Quoted 7 lines
We also missed that
i2c_smbus_read_i2c_block_data()populates the first byte of the read data with the transfer size. Soi2c_smbus_read_block_data()actually works properly.It's unclear to me what's the point of emulating
I2C_FUNC_SMBUS_READ_BLOCK_DATAwithin the driver if you could usei2c_smbus_read_i2c_block_data().
We are looking to support I2C_M_RECV_LEN where the length is read from the first byte of data. I see that i2c_smbus_read_i2c_block_data() requires the length to be passed from the client driver.
BTW, I2C_FUNC_SMBUS_WRITE_BLOCK_DATA is also expected to be supported. It is included in I2C_FUNC_SMBUS_EMUL. I suppose, it doesn't require any additional change in the driver. The client driver should populate the first byte as the length of data to be transferred.
Thanks,
Akhil
Dmitry Osipenko
reviewer14.02.2022 07:49, Akhil R пишет:
Quoted 11 lines
Quoted 3 lines
It's unclear to me what's the point of emulating
I2C_FUNC_SMBUS_READ_BLOCK_DATAwithin the driver if you could usei2c_smbus_read_i2c_block_data().We are looking to support
I2C_M_RECV_LENwhere the length is read from the first byte of data. I see thati2c_smbus_read_i2c_block_data()requires the length to be passed from the client driver.BTW,
I2C_FUNC_SMBUS_WRITE_BLOCK_DATAis also expected to be supported. It is included inI2C_FUNC_SMBUS_EMUL. I suppose, it doesn't require any additional change in the driver. The client driver should populate the first byte as the length of data to be transferred.
Please support both read and write.
Quoted 8 lines
14.02.2022 07:49, Akhil R пишет:
Quoted 7 lines
Quoted 3 lines
It's unclear to me what's the point of emulating
I2C_FUNC_SMBUS_READ_BLOCK_DATAwithin the driver if you could usei2c_smbus_read_i2c_block_data().We are looking to support
I2C_M_RECV_LENwhere the length is read from the first byte of data. I see thati2c_smbus_read_i2c_block_data()requires the length to be passed from the client driver.
Quoted 7 lines
Quoted 1 line
BTW,
I2C_FUNC_SMBUS_WRITE_BLOCK_DATAis also expected to besupported.
Quoted 3 lines
It is included in
I2C_FUNC_SMBUS_EMUL. I suppose, it doesn't require any additional change in the driver. The client driver should populate the first byte as the length of data to be transferred.Please support both read and write.
Both read and write are supported. Write doesn't require any additional change in the driver as far as I understand.
It is actually the same that I mentioned before. Or am I missing something here?
Thanks,
Akhil
Dmitry Osipenko
reviewer16.02.2022 06:54, Akhil R пишет:
Quoted 14 lines
Quoted 14 lines
14.02.2022 07:49, Akhil R пишет:
Quoted 8 lines
Quoted 3 lines
It's unclear to me what's the point of emulating
I2C_FUNC_SMBUS_READ_BLOCK_DATAwithin the driver if you could usei2c_smbus_read_i2c_block_data().We are looking to support
I2C_M_RECV_LENwhere the length is read from the first byte of data. I see thati2c_smbus_read_i2c_block_data()requires the length to be passed from the client driver.BTW,
I2C_FUNC_SMBUS_WRITE_BLOCK_DATAis also expected to besupported.
Quoted 3 lines
It is included in
I2C_FUNC_SMBUS_EMUL. I suppose, it doesn't require any additional change in the driver. The client driver should populate the first byte as the length of data to be transferred.
Quoted 5 lines
Quoted 1 line
Please support both read and write.
Both read and write are supported. Write doesn't require any additional change in the driver as far as I understand.
It is actually the same that I mentioned before. Or am I missing something here?
I missed that I2C_FUNC_SMBUS_EMUL includes I2C_FUNC_SMBUS_WRITE_BLOCK_DATA.
10.02.2022 18:36, Akhil R пишет:
Quoted 6 lines
Emulate SMBus block read using ContinueXfer to read the length byte
Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
Quoted 6 lines · Akhil R
Emulate SMBus block read using ContinueXfer to read the length byte
Signed-off-by Akhil R <[email protected]>--- drivers/i2c/busses/i2c-tegra.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
Wolfram Sang
AppliedQuoted 3 lines · Akhil R
Emulate SMBus block read using ContinueXfer to read the length byte
Signed-off-by Akhil R <[email protected]>
Applied to for-next, thanks!