Skip to contentSkip to conversation

omap24xx_i2c: Enable Repeated Start functionality

PATCH Superseded Aniket Limaye 2 participants 11 messages Mar 10, 2025 – Apr 22, 2025 I2C

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover omap24xx_i2c: Enable Repeated Start functionality

This series implements Repeated Start functionality for the DM_I2C xfer API (omap_i2c_xfer())

First, split out the actual implementation for each individual i2c msg transfer into a new function __omap24_i2c_xfer_msg() and use this to implement omap_i2c_xfer().

Then, add support for the Repeated Start condition in omap_i2c_xfer() through the CONFIG_I2C_REPEATED_START option.

Also add this config to Kconfig and enable it for ARCH_K3 platforms by default.

Test logs (On AM68-SK with DEBUG enabled):
https://gist.github.com/aniket-l/e6d78d52c172ebb475552929b71736a9

Boot logs on k3:
https://gist.github.com/aniket-l/110ee4f950ef05027a12bafa96431936

---
v2:
- Add another patch to remove unused CONFIG_I2C_REPEATED_START
- use new CONFIG_SYS_I2C_OMAP24XX_REPEATED_START
- Return right error codes and update debug prints to be driver specific
- patch formatting updates
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

Aniket Limaye (4):
i2c: omap24xx_i2c: Remove unused CONFIG_I2C_REPEATED_START
i2c: omap24xx_i2c: Use new function __omap24_i2c_xfer_msg()
i2c: omap24xx_i2c: support CONFIG for repeated start in DM_I2C xfer
drivers: i2c: Kconfig: Add CONFIG_SYS_I2C_OMAP24XX_REPEATED_START

 drivers/i2c/Kconfig        |   9 ++
 drivers/i2c/omap24xx_i2c.c | 165 ++++++++++++++++++++++++++++++-------
 2 files changed, 144 insertions(+), 30 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

PATCH v2 1/4 i2c: omap24xx_i2c: Remove unused CONFIG_I2C_REPEATED_START

Remove unused piece of code under CONFIG_I2C_REPEATED_START which does not have any Kconfig entry at all.

---
 drivers/i2c/omap24xx_i2c.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/i2c/omap24xx_i2c.c +1 -9
index ebe472e20cd..1fd5f5cc224 100644
@@ -538,9 +538,7 @@ pr_exit:
 /*
  * i2c_read: Function now uses a single I2C read transaction with bulk transfer
  *           of the requested number of bytes (note that the 'i2c md' command
- *           limits this to 16 bytes anyway). If CONFIG_I2C_REPEATED_START is
- *           defined in the board config header, this transaction shall be with
- *           Repeated Start (Sr) between the address and data phases; otherwise
+ *           limits this to 16 bytes anyway).
  *           Stop-Start (P-S) shall be used (some I2C chips do require a P-S).
  *           The address (reg offset) may be 0, 1 or 2 bytes long.
  *           Function now reads correctly from chips that return more than one
@@ -608,16 +606,10 @@ static int __omap24_i2c_read(void __iomem *i2c_base, int ip_rev, int waitdelay,
 
 	if (alen) {
 		/* Must write reg offset first */
-#ifdef CONFIG_I2C_REPEATED_START
-		/* No stop bit, use Repeated Start (Sr) */
-		omap_i2c_write_reg(i2c_base, ip_rev, I2C_CON_EN | I2C_CON_MST |
-				   I2C_CON_STT | I2C_CON_TRX, OMAP_I2C_CON_REG);
-#else
 		/* Stop - Start (P-S) */
 		omap_i2c_write_reg(i2c_base, ip_rev, I2C_CON_EN | I2C_CON_MST |
 				   I2C_CON_STT | I2C_CON_STP | I2C_CON_TRX,
 				   OMAP_I2C_CON_REG);
-#endif
 		/* Send register offset */
 		while (1) {
 			status = wait_for_event(i2c_base, ip_rev, waitdelay);
Signature · 1 line
2.48.1
Reviewed-by on v2 1/4
#2 lore raw

Re: [PATCH v2 1/4] i2c: omap24xx_i2c: Remove unused CONFIG_I2C_REPEATED_START

Hello Aniket,

Quoted 7 lines · Aniket Limaye

Remove unused piece of code under CONFIG_I2C_REPEATED_START which does not have any Kconfig entry at all.

---
  drivers/i2c/omap24xx_i2c.c | 10 +---------
  1 file changed, 1 insertion(+), 9 deletions(-)

Thanks!

bye,
Heiko

Signature · 4 lines
-- 
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#3 lore raw

PATCH v2 2/4 i2c: omap24xx_i2c: Use new function __omap24_i2c_xfer_msg()

In reply to Aniket Limaye

Remove __omap24_i2c_read/write() usage from omap_i2c_xfer() in favour of the more flexible __omap24_i2c_xfer_msg().
Consequently, these are also no longer needed when DM_I2C is enabled.

New function __omap24_i2c_xfer_msg() will take care of individual read OR write transfers with a target device. It goes through below sequence:
- Program the provided Target Chip address (OMAP_I2C_SA_REG)
- Program the provided Data len (OMAP_I2C_CNT_REG)
- Program the provided Control register flags (OMAP_I2C_CON_REG)
- Read from or Write to the provided Data buffer (OMAP_I2C_DATA_REG)

For a detailed programming guide, refer to the TRM[0] (12.1.3.4 I2C Programming Guide).

This patch by itself should be a transparent change. However this is needed for implementing a proper Repeated Start (Sr) functionality for i2c_msgs.

Previous implementation for omap_i2c_xfer called __omap24_i2c_read/write functions, with hardcoded addr=0 and alen=0 for each i2c_msg. Each of these calls would program the registers always with a Stop bit set, not allowing for a repeated start between i2c_msgs in the same xfer().

[0]: https://www.ti.com/lit/zip/spruj28 (TRM)

---

v2:
- Use proper error codes in __omap24_i2c_xfer_msg()
- Use proper error prints to indicate omap24xx i2c driver
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

---
 drivers/i2c/omap24xx_i2c.c | 143 +++++++++++++++++++++++++++++++------
 1 file changed, 123 insertions(+), 20 deletions(-)
drivers/i2c/omap24xx_i2c.c +123 -20
index 1fd5f5cc224..7c5d786e8e9 100644
@@ -535,6 +535,107 @@ pr_exit:
 	return res;
 }
 
+static int __omap24_i2c_xfer_msg(void __iomem *i2c_base, int ip_rev, int waitdelay,
+				 uchar chip, uchar *buffer, int len, u16 i2c_con_reg)
+{
+	int i;
+	u16 status;
+	int i2c_error = 0;
+	int timeout = I2C_TIMEOUT;
+
+	if (len < 0) {
+		printf("%s: data len < 0\n", __func__);
+		return -EINVAL;
+	}
+
+	if (!buffer) {
+		printf("%s: NULL pointer passed\n", __func__);
+		return -EINVAL;
+	}
+
+	if (!(i2c_con_reg & I2C_CON_EN)) {
+		printf("%s: I2C_CON_EN not set\n", __func__);
+		return -EINVAL;
+	}
+
+	/* Set slave address */
+	omap_i2c_write_reg(i2c_base, ip_rev, chip, OMAP_I2C_SA_REG);
+	/* Read/Write len bytes data */
+	omap_i2c_write_reg(i2c_base, ip_rev, len, OMAP_I2C_CNT_REG);
+	/* Configure the I2C_CON register */
+	omap_i2c_write_reg(i2c_base, ip_rev, i2c_con_reg, OMAP_I2C_CON_REG);
+
+	/* read/write data bytewise */
+	for (i = 0; i < len; i++) {
+		status = wait_for_event(i2c_base, ip_rev, waitdelay);
+		/* Ignore I2C_STAT_RRDY in transmitter mode */
+		if (i2c_con_reg & I2C_CON_TRX)
+			status &= ~I2C_STAT_RRDY;
+		else
+			status &= ~I2C_STAT_XRDY;
+
+		/* Try to identify bus that is not padconf'd for I2C */
+		if (status == I2C_STAT_XRDY) {
+			i2c_error = -EREMOTEIO;
+			printf("%s: pads on bus probably not configured (status=0x%x)\n",
+			       __func__, status);
+			goto xfer_exit;
+		}
+		if (status == 0 || (status & I2C_STAT_NACK)) {
+			i2c_error = -EREMOTEIO;
+			printf("%s: error waiting for ACK (status=0x%x)\n",
+			       __func__, status);
+			goto xfer_exit;
+		}
+		if (status & I2C_STAT_XRDY) {
+			/* Transmit data */
+			omap_i2c_write_reg(i2c_base, ip_rev,
+					   buffer[i], OMAP_I2C_DATA_REG);
+			omap_i2c_write_reg(i2c_base, ip_rev,
+					   I2C_STAT_XRDY, OMAP_I2C_STAT_REG);
+		}
+		if (status & I2C_STAT_RRDY) {
+			/* Receive data */
+			*buffer++ = omap_i2c_read_reg(i2c_base, ip_rev,
+							OMAP_I2C_DATA_REG);
+			omap_i2c_write_reg(i2c_base, ip_rev,
+					   I2C_STAT_RRDY, OMAP_I2C_STAT_REG);
+		}
+	}
+
+	/*
+	 * poll ARDY bit for making sure that last byte really has been
+	 * transferred on the bus.
+	 */
+	do {
+		status = wait_for_event(i2c_base, ip_rev, waitdelay);
+	} while (!(status & I2C_STAT_ARDY) && timeout--);
+	if (timeout <= 0) {
+		printf("%s: timed out on last byte!\n", __func__);
+		i2c_error = -EREMOTEIO;
+		goto xfer_exit;
+	} else {
+		omap_i2c_write_reg(i2c_base, ip_rev, I2C_STAT_ARDY, OMAP_I2C_STAT_REG);
+	}
+
+	/* If Stop bit set, flush FIFO. */
+	if (i2c_con_reg & I2C_CON_STP)
+		goto xfer_exit;
+
+	return 0;
+
+xfer_exit:
+	flush_fifo(i2c_base, ip_rev);
+	omap_i2c_write_reg(i2c_base, ip_rev, 0xFFFF, OMAP_I2C_STAT_REG);
+	return i2c_error;
+}
+
+#if !CONFIG_IS_ENABLED(DM_I2C)
+/*
+ * The legacy I2C functions. These need to get removed once
+ * all users of this driver are converted to DM.
+ */
+
 /*
  * i2c_read: Function now uses a single I2C read transaction with bulk transfer
  *           of the requested number of bytes (note that the 'i2c md' command
@@ -828,11 +929,6 @@ wr_exit:
 	return i2c_error;
 }
 
-#if !CONFIG_IS_ENABLED(DM_I2C)
-/*
- * The legacy I2C functions. These need to get removed once
- * all users of this driver are converted to DM.
- */
 static void __iomem *omap24_get_base(struct i2c_adapter *adap)
 {
 	switch (adap->hwadapnr) {
@@ -967,24 +1063,31 @@ static int omap_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs)
 {
 	struct omap_i2c *priv = dev_get_priv(bus);
 	int ret;
+	u16 i2c_con_reg = 0;
 
-	debug("i2c_xfer: %d messages\n", nmsgs);
+	debug("%s: %d messages\n", __func__, nmsgs);
 	for (; nmsgs > 0; nmsgs--, msg++) {
-		debug("i2c_xfer: chip=0x%x, len=0x%x\n", msg->addr, msg->len);
-		if (msg->flags & I2C_M_RD) {
-			ret = __omap24_i2c_read(priv->regs, priv->ip_rev,
-						priv->waitdelay,
-						msg->addr, 0, 0, msg->buf,
-						msg->len);
-		} else {
-			ret = __omap24_i2c_write(priv->regs, priv->ip_rev,
-						 priv->waitdelay,
-						 msg->addr, 0, 0, msg->buf,
-						 msg->len);
-		}
-		if (ret) {
-			debug("i2c_write: error sending\n");
+		/* Wait until bus not busy */
+		if (wait_for_bb(priv->regs, priv->ip_rev, priv->waitdelay))
 			return -EREMOTEIO;
+
+		/* Set Controller mode with Start and Stop bit */
+		i2c_con_reg = I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_STP;
+		/* Set Transmitter/Receiver mode if it is a write/read msg */
+		if (msg->flags & I2C_M_RD)
+			i2c_con_reg &= ~I2C_CON_TRX;
+		else
+			i2c_con_reg |= I2C_CON_TRX;
+
+		debug("%s: chip=0x%x, len=0x%x, i2c_con_reg=0x%x\n",
+		      __func__, msg->addr, msg->len, i2c_con_reg);
+
+		ret = __omap24_i2c_xfer_msg(priv->regs, priv->ip_rev, priv->waitdelay,
+					    msg->addr, msg->buf, msg->len,
+					    i2c_con_reg);
+		if (ret) {
+			printf("%s: errored out at msg %d: %d\n", __func__, i, ret);
+			return ret;
 		}
 	}
 
Signature · 1 line
2.48.1
Reviewed-by on v2 2/4
#4 lore raw

Re: [PATCH v2 2/4] i2c: omap24xx_i2c: Use new function __omap24_i2c_xfer_msg()

Hello Aniket,

Quoted 28 lines · Aniket Limaye

Remove __omap24_i2c_read/write() usage from omap_i2c_xfer() in favour of the more flexible __omap24_i2c_xfer_msg().
Consequently, these are also no longer needed when DM_I2C is enabled.

New function __omap24_i2c_xfer_msg() will take care of individual read OR write transfers with a target device. It goes through below sequence:
- Program the provided Target Chip address (OMAP_I2C_SA_REG)
- Program the provided Data len (OMAP_I2C_CNT_REG)
- Program the provided Control register flags (OMAP_I2C_CON_REG)
- Read from or Write to the provided Data buffer (OMAP_I2C_DATA_REG)

For a detailed programming guide, refer to the TRM[0] (12.1.3.4 I2C Programming Guide).

This patch by itself should be a transparent change. However this is needed for implementing a proper Repeated Start (Sr) functionality for i2c_msgs.

Previous implementation for omap_i2c_xfer called __omap24_i2c_read/write functions, with hardcoded addr=0 and alen=0 for each i2c_msg. Each of these calls would program the registers always with a Stop bit set, not allowing for a repeated start between i2c_msgs in the same xfer().

[0]: https://www.ti.com/lit/zip/spruj28 (TRM)

---

Quoted 8 lines

v2:
- Use proper error codes in __omap24_i2c_xfer_msg()
- Use proper error prints to indicate omap24xx i2c driver
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

---
  drivers/i2c/omap24xx_i2c.c | 143 +++++++++++++++++++++++++++++++------
  1 file changed, 123 insertions(+), 20 deletions(-)

Thanks!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#5 lore raw

Re: [PATCH v2 2/4] i2c: omap24xx_i2c: Use new function __omap24_i2c_xfer_msg()

In reply to Aniket Limaye

Hello Aniket,

Quoted 28 lines · Aniket Limaye

Remove __omap24_i2c_read/write() usage from omap_i2c_xfer() in favour of the more flexible __omap24_i2c_xfer_msg().
Consequently, these are also no longer needed when DM_I2C is enabled.

New function __omap24_i2c_xfer_msg() will take care of individual read OR write transfers with a target device. It goes through below sequence:
- Program the provided Target Chip address (OMAP_I2C_SA_REG)
- Program the provided Data len (OMAP_I2C_CNT_REG)
- Program the provided Control register flags (OMAP_I2C_CON_REG)
- Read from or Write to the provided Data buffer (OMAP_I2C_DATA_REG)

For a detailed programming guide, refer to the TRM[0] (12.1.3.4 I2C Programming Guide).

This patch by itself should be a transparent change. However this is needed for implementing a proper Repeated Start (Sr) functionality for i2c_msgs.

Previous implementation for omap_i2c_xfer called __omap24_i2c_read/write functions, with hardcoded addr=0 and alen=0 for each i2c_msg. Each of these calls would program the registers always with a Stop bit set, not allowing for a repeated start between i2c_msgs in the same xfer().

[0]: https://www.ti.com/lit/zip/spruj28 (TRM)

---

Quoted 8 lines

v2:
- Use proper error codes in __omap24_i2c_xfer_msg()
- Use proper error prints to indicate omap24xx i2c driver
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

---
  drivers/i2c/omap24xx_i2c.c | 143 +++++++++++++++++++++++++++++++------
  1 file changed, 123 insertions(+), 20 deletions(-)

This patch drops failures in CI, for example:

https://dev.azure.com/hs0298/hs/_build/results?buildId=174&view=logs&j=8d774156-03aa-5a8d-58c3-e707e7e6b7b9&t=9810a296-c5d9-5d86-70ea-69525d43e83a&l=661

https://dev.azure.com/hs0298/hs/_build/results?buildId=174&view=logs&j=b0438df5-671b-55ba-8fc5-1746d486c477&t=d9c340c5-b4ec-5d48-b218-d3f9f8f479f8&l=700

in clear text it is:
"""
+drivers/i2c/omap24xx_i2c.c:538:12: error: '__omap24_i2c_xfer_msg' defined but not used [-Werror=unused-function] """

Could you please send a fix?

Thanks in advance!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#6 lore raw

Re: [PATCH v2 2/4] i2c: omap24xx_i2c: Use new function __omap24_i2c_xfer_msg()

Quoted 45 lines · Heiko Schocher

Hello Aniket,

Quoted 34 lines · Aniket Limaye

Remove __omap24_i2c_read/write() usage from omap_i2c_xfer() in favour of the more flexible __omap24_i2c_xfer_msg().
Consequently, these are also no longer needed when DM_I2C is enabled.

New function __omap24_i2c_xfer_msg() will take care of individual read OR write transfers with a target device. It goes through below sequence:
- Program the provided Target Chip address (OMAP_I2C_SA_REG)
- Program the provided Data len (OMAP_I2C_CNT_REG)
- Program the provided Control register flags (OMAP_I2C_CON_REG)
- Read from or Write to the provided Data buffer (OMAP_I2C_DATA_REG)

For a detailed programming guide, refer to the TRM[0] (12.1.3.4 I2C Programming Guide).

This patch by itself should be a transparent change. However this is needed for implementing a proper Repeated Start (Sr) functionality for i2c_msgs.

Previous implementation for omap_i2c_xfer called __omap24_i2c_read/write functions, with hardcoded addr=0 and alen=0 for each i2c_msg. Each of these calls would program the registers always with a Stop bit set, not allowing for a repeated start between i2c_msgs in the same xfer().

[0]: https://www.ti.com/lit/zip/spruj28 (TRM)

---

v2:
- Use proper error codes in __omap24_i2c_xfer_msg()
- Use proper error prints to indicate omap24xx i2c driver
- Link to v1:
https://lore.kernel.org/u-boot/[email protected]/

Quoted 3 lines

---
  drivers/i2c/omap24xx_i2c.c | 143 +++++++++++++++++++++++++++++++------

  1 file changed, 123 insertions(+), 20 deletions(-)

This patch drops failures in CI, for example:

https://dev.azure.com/hs0298/hs/_build/results?buildId=174&view=logs&j=8d774156-03aa-5a8d-58c3-e707e7e6b7b9&t=9810a296-c5d9-5d86-70ea-69525d43e83a&l=661

Quoted 8 lines

https://dev.azure.com/hs0298/hs/_build/results?buildId=174&view=logs&j=b0438df5-671b-55ba-8fc5-1746d486c477&t=d9c340c5-b4ec-5d48-b218-d3f9f8f479f8&l=700

in clear text it is:
"""
+drivers/i2c/omap24xx_i2c.c:538:12: error: '__omap24_i2c_xfer_msg' defined but not used [-Werror=unused-function]
"" >
Could you please send a fix?

Ahh, thanks for catching this.
Sent a v3:
https://lore.kernel.org/u-boot/[email protected]/

Regards,
Aniket

Quoted 5 lines

Thanks in advance!

bye,
Heiko

#7 lore raw

PATCH v2 3/4 i2c: omap24xx_i2c: support CONFIG for repeated start in DM_I2C xfer

In reply to Aniket Limaye

Repeated Start Condition (Sr) can be used to transfer multiple i2c msgs without sending a Stop condition (P). So far, the driver default was to always send a Stop condition after every i2c msg.

Add support for a config option (CONFIG_SYS_I2C_OMAP24XX_REPEATED_START) to disable sending the Stop condition by default. If this config is enabled, Stop condition will be sent only if explicitly requested in the msg flags OR if it is the last msg in the transfer.

Consequently, handle the Repeated Start condition (Sr) in the next msg by not calling the wait_for_bb() check since it will simply timeout in the absence of a stop condition (BB will be 1 until Stop is programmed)

---

v2:
- fixup code formatting and comment blocks
- CONFIG_I2C_REPEATED_START -> CONFIG_SYS_I2C_OMAP24XX_REPEATED_START
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

---
 drivers/i2c/omap24xx_i2c.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/i2c/omap24xx_i2c.c +16 -6
index 7c5d786e8e9..ad739b123e5 100644
@@ -1066,18 +1066,28 @@ static int omap_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs)
 	u16 i2c_con_reg = 0;
 
 	debug("%s: %d messages\n", __func__, nmsgs);
-	for (; nmsgs > 0; nmsgs--, msg++) {
-		/* Wait until bus not busy */
-		if (wait_for_bb(priv->regs, priv->ip_rev, priv->waitdelay))
-			return -EREMOTEIO;
+	for (int i = 0; i < nmsgs; i++, msg++) {
+		/*
+		 * If previous msg sent a Stop or if this is the first msg
+		 * Wait until bus not busy
+		 */
+		if ((i2c_con_reg & I2C_CON_STP) || (i == 0))
+			if (wait_for_bb(priv->regs, priv->ip_rev, priv->waitdelay))
+				return -EREMOTEIO;
 
-		/* Set Controller mode with Start and Stop bit */
-		i2c_con_reg = I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_STP;
+		/* Set Controller mode with Start bit */
+		i2c_con_reg = I2C_CON_EN | I2C_CON_MST | I2C_CON_STT;
 		/* Set Transmitter/Receiver mode if it is a write/read msg */
 		if (msg->flags & I2C_M_RD)
 			i2c_con_reg &= ~I2C_CON_TRX;
 		else
 			i2c_con_reg |= I2C_CON_TRX;
+		/* Send Stop condition (P) by default */
+		if (!IS_ENABLED(CONFIG_SYS_I2C_OMAP24XX_REPEATED_START))
+			i2c_con_reg |= I2C_CON_STP;
+		/* Send Stop if explicitly requested or if this is the last msg */
+		if ((msg->flags & I2C_M_STOP) || (i == nmsgs - 1))
+			i2c_con_reg |= I2C_CON_STP;
 
 		debug("%s: chip=0x%x, len=0x%x, i2c_con_reg=0x%x\n",
 		      __func__, msg->addr, msg->len, i2c_con_reg);
Signature · 1 line
2.48.1
Reviewed-by on v2 3/4
#8 lore raw

Re: [PATCH v2 3/4] i2c: omap24xx_i2c: support CONFIG for repeated start in DM_I2C xfer

Hello Aniket,

Quoted 16 lines · Aniket Limaye

Repeated Start Condition (Sr) can be used to transfer multiple i2c msgs without sending a Stop condition (P). So far, the driver default was to always send a Stop condition after every i2c msg.

Add support for a config option (CONFIG_SYS_I2C_OMAP24XX_REPEATED_START) to disable sending the Stop condition by default. If this config is enabled, Stop condition will be sent only if explicitly requested in the msg flags OR if it is the last msg in the transfer.

Consequently, handle the Repeated Start condition (Sr) in the next msg by not calling the wait_for_bb() check since it will simply timeout in the absence of a stop condition (BB will be 1 until Stop is programmed)

---

Quoted 8 lines

v2:
- fixup code formatting and comment blocks
- CONFIG_I2C_REPEATED_START -> CONFIG_SYS_I2C_OMAP24XX_REPEATED_START
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

---
  drivers/i2c/omap24xx_i2c.c | 22 ++++++++++++++++------
  1 file changed, 16 insertions(+), 6 deletions(-)

Thanks!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]
#9 lore raw

PATCH v2 4/4 drivers: i2c: Kconfig: Add CONFIG_SYS_I2C_OMAP24XX_REPEATED_START

In reply to Aniket Limaye

Add a Kconfig option to disable sending Stop conditions between multiple i2c_msgs within a single xfer. Enable this config by default for ARCH_K3 platforms.

---

v2:
- CONFIG_I2C_REPEATED_START -> CONFIG_SYS_I2C_OMAP24XX_REPEATED_START
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

---
 drivers/i2c/Kconfig | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/i2c/Kconfig +9 -0
index cdae6825736..41bac5db5a5 100644
@@ -503,6 +503,15 @@ config SYS_I2C_OMAP24XX
 	help
 	  Add support for the OMAP2+ I2C driver.
 
+config SYS_I2C_OMAP24XX_REPEATED_START
+	bool "Enable I2C repeated start"
+	depends on SYS_I2C_OMAP24XX
+	default y if ARCH_K3
+	help
+	  Enable support for repeated start. Updates driver defaults to not
+	  send a Stop condition and issue Repeated Start (Sr) for subsequent
+	  i2c msgs.
+
 config SYS_I2C_RCAR_I2C
 	bool "Renesas R-Car I2C driver"
 	depends on (RCAR_GEN2 || RCAR_64) && DM_I2C
Signature · 1 line
2.48.1
Reviewed-by on v2 4/4
#10 lore raw

Re: [PATCH v2 4/4] drivers: i2c: Kconfig: Add CONFIG_SYS_I2C_OMAP24XX_REPEATED_START

Hello Aniket,

Quoted 7 lines · Aniket Limaye

Add a Kconfig option to disable sending Stop conditions between multiple i2c_msgs within a single xfer. Enable this config by default for ARCH_K3 platforms.

---

Quoted 7 lines

v2:
- CONFIG_I2C_REPEATED_START -> CONFIG_SYS_I2C_OMAP24XX_REPEATED_START
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

---
  drivers/i2c/Kconfig | 9 +++++++++
  1 file changed, 9 insertions(+)

Thanks!

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: [email protected]