diff options
author | Tom Rini <trini@konsulko.com> | 2021-12-20 08:51:53 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-12-20 08:51:53 -0500 |
commit | 1cd75ceae563f87aba9f16a83544c228b811bc97 (patch) | |
tree | 9c1968823a6680550160b4c074a4b3612283e283 | |
parent | d3213c26b56e564207515f1e28e663718e015dc3 (diff) | |
parent | ccea46c05b08b34ef829d460e50e2ce9bc17cdc7 (diff) | |
download | u-boot-1cd75ceae563f87aba9f16a83544c228b811bc97.zip u-boot-1cd75ceae563f87aba9f16a83544c228b811bc97.tar.gz u-boot-1cd75ceae563f87aba9f16a83544c228b811bc97.tar.bz2 |
Merge tag '20211220-fixes-for-2022.01' of https://source.denx.de/u-boot/custodians/u-boot-i2c
i2c changes for 20211220-fixes-for-2022.01
- mvtwsi: Swab the register address if its size is > 1
-rw-r--r-- | drivers/i2c/mvtwsi.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c index 236bfb8..ff21e3c 100644 --- a/drivers/i2c/mvtwsi.c +++ b/drivers/i2c/mvtwsi.c @@ -860,6 +860,9 @@ static int mvtwsi_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs) { struct mvtwsi_i2c_dev *dev = dev_get_priv(bus); struct i2c_msg *dmsg, *omsg, dummy; + u8 *addr_buf_ptr; + u8 addr_buf[4]; + int i; memset(&dummy, 0, sizeof(struct i2c_msg)); @@ -873,12 +876,17 @@ static int mvtwsi_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs) omsg = nmsgs == 1 ? &dummy : msg; dmsg = nmsgs == 1 ? msg : msg + 1; + /* We need to swap the register address if its size is > 1 */ + addr_buf_ptr = &addr_buf[0]; + for (i = omsg->len; i > 0; i--) + *addr_buf_ptr++ = omsg->buf[i - 1]; + if (dmsg->flags & I2C_M_RD) - return __twsi_i2c_read(dev->base, dmsg->addr, omsg->buf, + return __twsi_i2c_read(dev->base, dmsg->addr, addr_buf, omsg->len, dmsg->buf, dmsg->len, dev->tick); else - return __twsi_i2c_write(dev->base, dmsg->addr, omsg->buf, + return __twsi_i2c_write(dev->base, dmsg->addr, addr_buf, omsg->len, dmsg->buf, dmsg->len, dev->tick); } |