Message ID | 20230811054220.99562-4-francis_yuu@stu.pku.edu.cn |
---|---|
State | New |
Headers | show |
Series | [v2,1/4] hw/i2c/aspeed: Fix I2CD_POOL_CTRL register bit field defination | expand |
On 8/11/23 07:42, Hang Yu wrote: > Added support for the BUFFER ORGANIZATION option in reg I2CC_POOL_CTRL, BUFFER ORGANIZATION could be lower case > when set to 1,The buffer is split into two parts: Lower 16 bytes for Tx > and higher 16 bytes for Rx. > > Signed-off-by: Hang Yu <francis_yuu@stu.pku.edu.cn> > --- > hw/i2c/aspeed_i2c.c | 7 ++++++- > include/hw/i2c/aspeed_i2c.h | 1 + > 2 files changed, 7 insertions(+), 1 deletion(-) > > diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c > index 44905d7899..26fefb8f9e 100644 > --- a/hw/i2c/aspeed_i2c.c > +++ b/hw/i2c/aspeed_i2c.c > @@ -296,7 +296,12 @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) > RX_SIZE) + 1; > > if (SHARED_ARRAY_FIELD_EX32(bus->regs, reg_cmd, RX_BUFF_EN)) { > - uint8_t *pool_base = aic->bus_pool_base(bus); > + uint8_t *pool_base; > + if (ARRAY_FIELD_EX32(bus->regs, I2CC_POOL_CTRL, BUF_ORGANIZATION)) { > + pool_base = aic->bus_pool_base(bus) + 16; > + } else { > + pool_base = aic->bus_pool_base(bus); > + } or simply add : if (ARRAY_FIELD_EX32(bus->regs, I2CC_POOL_CTRL, BUF_ORGANIZATION)) { pool_base += 16; } > > for (i = 0; i < pool_rx_count; i++) { > pool_base[i] = i2c_recv(bus->bus); > diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h > index 2e1e15aaf0..88b144a599 100644 > --- a/include/hw/i2c/aspeed_i2c.h > +++ b/include/hw/i2c/aspeed_i2c.h > @@ -162,6 +162,7 @@ REG32(I2CC_MS_TXRX_BYTE_BUF, 0x08) > /* 15:0 shared with I2CD_BYTE_BUF[15:0] */ > REG32(I2CC_POOL_CTRL, 0x0c) > /* 31:0 shared with I2CD_POOL_CTRL[31:0] */ > + FIELD(I2CC_POOL_CTRL, BUF_ORGANIZATION, 0, 1) /* AST2600 */ > REG32(I2CM_INTR_CTRL, 0x10) > REG32(I2CM_INTR_STS, 0x14) > FIELD(I2CM_INTR_STS, PKT_STATE, 28, 4)
diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c index 44905d7899..26fefb8f9e 100644 --- a/hw/i2c/aspeed_i2c.c +++ b/hw/i2c/aspeed_i2c.c @@ -296,7 +296,12 @@ static void aspeed_i2c_bus_recv(AspeedI2CBus *bus) RX_SIZE) + 1; if (SHARED_ARRAY_FIELD_EX32(bus->regs, reg_cmd, RX_BUFF_EN)) { - uint8_t *pool_base = aic->bus_pool_base(bus); + uint8_t *pool_base; + if (ARRAY_FIELD_EX32(bus->regs, I2CC_POOL_CTRL, BUF_ORGANIZATION)) { + pool_base = aic->bus_pool_base(bus) + 16; + } else { + pool_base = aic->bus_pool_base(bus); + } for (i = 0; i < pool_rx_count; i++) { pool_base[i] = i2c_recv(bus->bus); diff --git a/include/hw/i2c/aspeed_i2c.h b/include/hw/i2c/aspeed_i2c.h index 2e1e15aaf0..88b144a599 100644 --- a/include/hw/i2c/aspeed_i2c.h +++ b/include/hw/i2c/aspeed_i2c.h @@ -162,6 +162,7 @@ REG32(I2CC_MS_TXRX_BYTE_BUF, 0x08) /* 15:0 shared with I2CD_BYTE_BUF[15:0] */ REG32(I2CC_POOL_CTRL, 0x0c) /* 31:0 shared with I2CD_POOL_CTRL[31:0] */ + FIELD(I2CC_POOL_CTRL, BUF_ORGANIZATION, 0, 1) /* AST2600 */ REG32(I2CM_INTR_CTRL, 0x10) REG32(I2CM_INTR_STS, 0x14) FIELD(I2CM_INTR_STS, PKT_STATE, 28, 4)
Added support for the BUFFER ORGANIZATION option in reg I2CC_POOL_CTRL, when set to 1,The buffer is split into two parts: Lower 16 bytes for Tx and higher 16 bytes for Rx. Signed-off-by: Hang Yu <francis_yuu@stu.pku.edu.cn> --- hw/i2c/aspeed_i2c.c | 7 ++++++- include/hw/i2c/aspeed_i2c.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)