i2c: i2c-cdns: Driver fixes
cover i2c: i2c-cdns: Driver fixes
Hi,
these 3 patches came from checking functionality on QEMU in connection to SOM program.
Thanks,
Michal
Sai Pavan Boddu (3):
i2c: i2c-cdns: Start read transaction after write to transfer_size reg
i2c: i2c-cdns: Fix write transaction state
i2c: i2c-cdns: Prevent early termination of write
drivers/i2c/i2c-cdns.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
Signature · 1 line
2.35.1
PATCH 2/3 i2c: i2c-cdns: Fix write transaction state
From: Sai Pavan Boddu <[email protected]>
Start write transfer after loading data to FIFO.
---
drivers/i2c/i2c-cdns.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/i2c/i2c-cdns.c +6 -0
@@ -251,6 +251,7 @@ static int cdns_i2c_write_data(struct i2c_cdns_bus *i2c_bus, u32 addr, u8 *data,u8 *cur_data = data;struct cdns_i2c_regs *regs = i2c_bus->regs;u32 ret; +bool start =1 ;/* Set the controller in Master transmit mode and clear FIFO */ setbits_le32 (®s->control,CDNS_I2C_CONTROL_CLR_FIFO );
@@ -269,6 +270,11 @@ static int cdns_i2c_write_data(struct i2c_cdns_bus *i2c_bus, u32 addr, u8 *data,while (len-- && !is_arbitration_lost (regs)) {writel (*(cur_data++), ®s->data); +/* Trigger write only after loading data */ +if (start) { +writel (addr, ®s->address); + start =0 ; + }if (len &&readl (®s->transfer_size) ==CDNS_I2C_FIFO_DEPTH ) { ret =cdns_i2c_wait (regs,CDNS_I2C_INTERRUPT_COMP |CDNS_I2C_INTERRUPT_ARBLOST );
Signature · 1 line
2.35.1
PATCH 1/3 i2c: i2c-cdns: Start read transaction after write to transfer_size reg
In reply to Michal SimekFrom: Sai Pavan Boddu <[email protected]>
Avoid a race condition where read transaction is started keeping expected bytes as 0. Which sometimes would result in sending STOP signal as no data is expected. Observed on QEMU platform.
---
drivers/i2c/i2c-cdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-cdns.c +1 -1
@@ -375,7 +375,6 @@ static int cdns_i2c_read_data(struct i2c_cdns_bus *i2c_bus, u32 addr, u8 *data, curr_recv_count = recv_count; } }else if (recv_count && !hold_quirk && !curr_recv_count) { -writel (addr, ®s->address);if (recv_count >CDNS_I2C_TRANSFER_SIZE ) {writel (CDNS_I2C_TRANSFER_SIZE , ®s->transfer_size);
@@ -384,6 +383,7 @@ static int cdns_i2c_read_data(struct i2c_cdns_bus *i2c_bus, u32 addr, u8 *data,writel (recv_count, ®s->transfer_size); curr_recv_count = recv_count; } +writel (addr, ®s->address); } }
Signature · 1 line
2.35.1
PATCH 3/3 i2c: i2c-cdns: Prevent early termination of write
In reply to Michal SimekFrom: Sai Pavan Boddu <[email protected]>
During sequential loading of data, hold the bus to prevent controller from sending stop signal in case no data is available in fifo.
---
drivers/i2c/i2c-cdns.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/i2c/i2c-cdns.c +6 -4
@@ -257,16 +257,18 @@ static int cdns_i2c_write_data(struct i2c_cdns_bus *i2c_bus, u32 addr, u8 *data,setbits_le32 (®s->control,CDNS_I2C_CONTROL_CLR_FIFO );clrbits_le32 (®s->control,CDNS_I2C_CONTROL_RW ); -/* Check message size against FIFO depth, and set hold bus bit -* if it is greater than FIFO depth +/* +* For sequential data load hold the bus. */ -if (len >CDNS_I2C_FIFO_DEPTH ) +if (len >1 )setbits_le32 (®s->control,CDNS_I2C_CONTROL_HOLD );/* Clear the interrupts in status register */ writel (CDNS_I2C_INTERRUPTS_MASK , ®s->interrupt_status); -writel (addr, ®s->address); +/* In case of Probe (i.e no data), start the transfer */ +if (!len) +writel (addr, ®s->address);while (len-- && !is_arbitration_lost (regs)) {writel (*(cur_data++), ®s->data);
Signature · 1 line
2.35.1
Michal Simek
Appliedút 1. 3. 2022 v 9:16 odesílatel Michal Simek <[email protected]> napsal:
Quoted 15 lines
Hi,
these 3 patches came from checking functionality on QEMU in connection to SOM program.
Thanks,
MichalSai Pavan Boddu (3):
i2c: i2c-cdns: Start read transaction after write totransfer_sizereg
i2c: i2c-cdns: Fix write transaction state
i2c: i2c-cdns: Prevent early termination of write
Quoted 6 lines
drivers/i2c/i2c-cdns.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)--
2.35.1
applied.
M
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs