mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-20 22:21:41 +00:00
rockchip: i2c: fix >32 byte reads
The hw can read up to 32 bytes at a time. If we need more than one chunk, we have to enter the plain RX mode. Signed-off-by: Wadim Egorov <w.egorov@phytec.de> Acked-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
This commit is contained in:
parent
313bbcf0ea
commit
5deaa53028
1 changed files with 16 additions and 3 deletions
|
@ -164,6 +164,7 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len,
|
||||||
uint rxdata;
|
uint rxdata;
|
||||||
uint i, j;
|
uint i, j;
|
||||||
int err;
|
int err;
|
||||||
|
bool snd_chunk = false;
|
||||||
|
|
||||||
debug("rk_i2c_read: chip = %d, reg = %d, r_len = %d, b_len = %d\n",
|
debug("rk_i2c_read: chip = %d, reg = %d, r_len = %d, b_len = %d\n",
|
||||||
chip, reg, r_len, b_len);
|
chip, reg, r_len, b_len);
|
||||||
|
@ -184,15 +185,26 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len,
|
||||||
|
|
||||||
while (bytes_remain_len) {
|
while (bytes_remain_len) {
|
||||||
if (bytes_remain_len > RK_I2C_FIFO_SIZE) {
|
if (bytes_remain_len > RK_I2C_FIFO_SIZE) {
|
||||||
con = I2C_CON_EN | I2C_CON_MOD(I2C_MODE_TRX);
|
con = I2C_CON_EN;
|
||||||
bytes_xferred = 32;
|
bytes_xferred = 32;
|
||||||
} else {
|
} else {
|
||||||
con = I2C_CON_EN | I2C_CON_MOD(I2C_MODE_TRX) |
|
/*
|
||||||
I2C_CON_LASTACK;
|
* The hw can read up to 32 bytes at a time. If we need
|
||||||
|
* more than one chunk, send an ACK after the last byte.
|
||||||
|
*/
|
||||||
|
con = I2C_CON_EN | I2C_CON_LASTACK;
|
||||||
bytes_xferred = bytes_remain_len;
|
bytes_xferred = bytes_remain_len;
|
||||||
}
|
}
|
||||||
words_xferred = DIV_ROUND_UP(bytes_xferred, 4);
|
words_xferred = DIV_ROUND_UP(bytes_xferred, 4);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* make sure we are in plain RX mode if we read a second chunk
|
||||||
|
*/
|
||||||
|
if (snd_chunk)
|
||||||
|
con |= I2C_CON_MOD(I2C_MODE_RX);
|
||||||
|
else
|
||||||
|
con |= I2C_CON_MOD(I2C_MODE_TRX);
|
||||||
|
|
||||||
writel(con, ®s->con);
|
writel(con, ®s->con);
|
||||||
writel(bytes_xferred, ®s->mrxcnt);
|
writel(bytes_xferred, ®s->mrxcnt);
|
||||||
writel(I2C_MBRFIEN | I2C_NAKRCVIEN, ®s->ien);
|
writel(I2C_MBRFIEN | I2C_NAKRCVIEN, ®s->ien);
|
||||||
|
@ -227,6 +239,7 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len,
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes_remain_len -= bytes_xferred;
|
bytes_remain_len -= bytes_xferred;
|
||||||
|
snd_chunk = true;
|
||||||
debug("I2C Read bytes_remain_len %d\n", bytes_remain_len);
|
debug("I2C Read bytes_remain_len %d\n", bytes_remain_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue