public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 0/3] i2c: i2c-cdns: Driver fixes
@ 2022-03-01  8:16 Michal Simek
  2022-03-01  8:16 ` [PATCH 1/3] i2c: i2c-cdns: Start read transaction after write to transfer_size reg Michal Simek
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Michal Simek @ 2022-03-01  8:16 UTC (permalink / raw)
  To: u-boot, git; +Cc: Heiko Schocher, Michal Simek

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(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] i2c: i2c-cdns: Start read transaction after write to transfer_size reg
  2022-03-01  8:16 [PATCH 0/3] i2c: i2c-cdns: Driver fixes Michal Simek
@ 2022-03-01  8:16 ` Michal Simek
  2022-03-01  8:16 ` [PATCH 2/3] i2c: i2c-cdns: Fix write transaction state Michal Simek
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2022-03-01  8:16 UTC (permalink / raw)
  To: u-boot, git
  Cc: Sai Pavan Boddu, Ashok Reddy Soma, Heiko Schocher, Michal Simek

From: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>

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.

Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
Reviewed-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/i2c/i2c-cdns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-cdns.c b/drivers/i2c/i2c-cdns.c
index a650dd69b89f..5736afb45191 100644
--- a/drivers/i2c/i2c-cdns.c
+++ b/drivers/i2c/i2c-cdns.c
@@ -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, &regs->address);
 			if (recv_count > CDNS_I2C_TRANSFER_SIZE) {
 				writel(CDNS_I2C_TRANSFER_SIZE,
 				       &regs->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, &regs->transfer_size);
 				curr_recv_count = recv_count;
 			}
+			writel(addr, &regs->address);
 		}
 	}
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] i2c: i2c-cdns: Fix write transaction state
  2022-03-01  8:16 [PATCH 0/3] i2c: i2c-cdns: Driver fixes Michal Simek
  2022-03-01  8:16 ` [PATCH 1/3] i2c: i2c-cdns: Start read transaction after write to transfer_size reg Michal Simek
@ 2022-03-01  8:16 ` Michal Simek
  2022-03-01  8:16 ` [PATCH 3/3] i2c: i2c-cdns: Prevent early termination of write Michal Simek
  2022-03-09 11:36 ` [PATCH 0/3] i2c: i2c-cdns: Driver fixes Michal Simek
  3 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2022-03-01  8:16 UTC (permalink / raw)
  To: u-boot, git; +Cc: Sai Pavan Boddu, Ashok Reddy Soma, Heiko Schocher

From: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>

Start write transfer after loading data to FIFO.

Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
Reviewed-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/i2c/i2c-cdns.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/i2c/i2c-cdns.c b/drivers/i2c/i2c-cdns.c
index 5736afb45191..07d53be11f12 100644
--- a/drivers/i2c/i2c-cdns.c
+++ b/drivers/i2c/i2c-cdns.c
@@ -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(&regs->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++), &regs->data);
+		/* Trigger write only after loading data */
+		if (start) {
+			writel(addr, &regs->address);
+			start = 0;
+		}
 		if (len && readl(&regs->transfer_size) == CDNS_I2C_FIFO_DEPTH) {
 			ret = cdns_i2c_wait(regs, CDNS_I2C_INTERRUPT_COMP |
 					    CDNS_I2C_INTERRUPT_ARBLOST);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] i2c: i2c-cdns: Prevent early termination of write
  2022-03-01  8:16 [PATCH 0/3] i2c: i2c-cdns: Driver fixes Michal Simek
  2022-03-01  8:16 ` [PATCH 1/3] i2c: i2c-cdns: Start read transaction after write to transfer_size reg Michal Simek
  2022-03-01  8:16 ` [PATCH 2/3] i2c: i2c-cdns: Fix write transaction state Michal Simek
@ 2022-03-01  8:16 ` Michal Simek
  2022-03-09 11:36 ` [PATCH 0/3] i2c: i2c-cdns: Driver fixes Michal Simek
  3 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2022-03-01  8:16 UTC (permalink / raw)
  To: u-boot, git; +Cc: Sai Pavan Boddu, Ashok Reddy Soma, Heiko Schocher

From: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>

During sequential loading of data, hold the bus to prevent controller
from sending stop signal in case no data is available in fifo.

Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
Reviewed-by: Ashok Reddy Soma <ashok.reddy.soma@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 drivers/i2c/i2c-cdns.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/i2c-cdns.c b/drivers/i2c/i2c-cdns.c
index 07d53be11f12..0da9f6f35a9f 100644
--- a/drivers/i2c/i2c-cdns.c
+++ b/drivers/i2c/i2c-cdns.c
@@ -257,16 +257,18 @@ static int cdns_i2c_write_data(struct i2c_cdns_bus *i2c_bus, u32 addr, u8 *data,
 	setbits_le32(&regs->control, CDNS_I2C_CONTROL_CLR_FIFO);
 	clrbits_le32(&regs->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(&regs->control, CDNS_I2C_CONTROL_HOLD);
 
 	/* Clear the interrupts in status register */
 	writel(CDNS_I2C_INTERRUPTS_MASK, &regs->interrupt_status);
 
-	writel(addr, &regs->address);
+	/* In case of Probe (i.e no data), start the transfer */
+	if (!len)
+		writel(addr, &regs->address);
 
 	while (len-- && !is_arbitration_lost(regs)) {
 		writel(*(cur_data++), &regs->data);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] i2c: i2c-cdns: Driver fixes
  2022-03-01  8:16 [PATCH 0/3] i2c: i2c-cdns: Driver fixes Michal Simek
                   ` (2 preceding siblings ...)
  2022-03-01  8:16 ` [PATCH 3/3] i2c: i2c-cdns: Prevent early termination of write Michal Simek
@ 2022-03-09 11:36 ` Michal Simek
  3 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2022-03-09 11:36 UTC (permalink / raw)
  To: U-Boot, git; +Cc: Heiko Schocher

út 1. 3. 2022 v 9:16 odesílatel Michal Simek <michal.simek@xilinx.com> napsal:
>
> 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(-)
>
> --
> 2.35.1
>

applied.
M

-- 
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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-09 11:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-01  8:16 [PATCH 0/3] i2c: i2c-cdns: Driver fixes Michal Simek
2022-03-01  8:16 ` [PATCH 1/3] i2c: i2c-cdns: Start read transaction after write to transfer_size reg Michal Simek
2022-03-01  8:16 ` [PATCH 2/3] i2c: i2c-cdns: Fix write transaction state Michal Simek
2022-03-01  8:16 ` [PATCH 3/3] i2c: i2c-cdns: Prevent early termination of write Michal Simek
2022-03-09 11:36 ` [PATCH 0/3] i2c: i2c-cdns: Driver fixes Michal Simek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox