Skip to contentSkip to conversation

i2c: designware: Enable SAR in slave mode for Multiple SAR controllers

RFC PATCH Superseded Umesh Kumar 4 participants 14 messages Aug 4 – Nov 7

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 i2c: designware: Enable SAR in slave mode for Multiple SAR controllers

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) only acknowledge traffic to the primary slave address (IC_SAR) when IC_ENABLE[19] (SAR_EN) is set. The slave enable path writes only IC_ENABLE[0], so on such controllers the target never ACKs its address and a remote master cannot reach it.

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

---
RFC note:

On our multi-SAR CN20K the slave only ACKs with IC_ENABLE[19] set. Existing single-SAR users work without it, and the bit is reserved there, so I've written it unconditionally. Would you prefer this gated behind a per-device capability flag instead? The CN20K PCI device enablement (which would set such a flag) can follow as a separate series.

 drivers/i2c/busses/i2c-designware-common.c | 9 ++++++++-
 drivers/i2c/busses/i2c-designware-core.h   | 6 ++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-common.c +8 -1
index 4dc57fd56170..b6f3d71cf268 100644
@@ -374,7 +374,14 @@ static void i2c_dw_configure_mode(struct dw_i2c_dev *dev, int mode)
 		regmap_write(dev->map, DW_IC_CON, dev->slave_cfg);
 		regmap_write(dev->map, DW_IC_SAR, dev->slave->addr);
 		regmap_write(dev->map, DW_IC_INTR_MASK, DW_IC_INTR_SLAVE_MASK);
-		__i2c_dw_enable(dev);
+		/*
+		 * Controllers synthesised with the Multiple SAR feature only
+		 * acknowledge traffic to IC_SAR when SAR_EN is set; a plain
+		 * enable is not enough. The bit is reserved (ignored) on
+		 * single-SAR controllers.
+		 */
+		regmap_write(dev->map, DW_IC_ENABLE,
+			     DW_IC_ENABLE_ENABLE | DW_IC_ENABLE_SAR_EN);
 		break;
 	default:
 		WARN(1, "Invalid mode %d\n", mode);
drivers/i2c/busses/i2c-designware-core.h +6 -0
index 9d8d104cc391..35eaf2d7404f 100644
@@ -125,6 +125,12 @@
 
 #define DW_IC_ENABLE_ENABLE			BIT(0)
 #define DW_IC_ENABLE_ABORT			BIT(1)
+/*
+ * On controllers synthesised with the Multiple SAR feature (e.g. Marvell
+ * CN20K), the primary slave address register (IC_SAR) only acknowledges bus
+ * traffic when this bit is set. It is reserved on single-SAR controllers.
+ */
+#define DW_IC_ENABLE_SAR_EN			BIT(19)
 
 #define DW_IC_STATUS_ACTIVITY			BIT(0)
 #define DW_IC_STATUS_TFE			BIT(2)
Signature · 1 line
2.43.0
maintainer Acked-by on v1 1/1
#1 lore raw

Hi,

Quoted 14 lines · Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) only acknowledge traffic to the primary slave address (IC_SAR) when IC_ENABLE[19] (SAR_EN) is set. The slave enable path writes only IC_ENABLE[0], so on such controllers the target never ACKs its address and a remote master cannot reach it.

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

---
RFC note:

Quoted 6 lines

On our multi-SAR CN20K the slave only ACKs with IC_ENABLE[19] set. Existing single-SAR users work without it, and the bit is reserved there, so I've written it unconditionally. Would you prefer this gated behind a per-device capability flag instead? The CN20K PCI device enablement (which would set such a flag) can follow as a separate series.

No I think what you do here is fine,

#2 lore raw

PATCH v2 1/1 i2c: designware: Enable SAR in slave mode for Multiple SAR controllers

In reply to Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) only acknowledge traffic to the primary slave address (IC_SAR) when IC_ENABLE[19] (SAR_EN) is set. The slave enable path writes only IC_ENABLE[0], so on such controllers the target never ACKs its address and a remote master cannot reach it.

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

---
Changes in v2:
- No functional change; dropped the RFC tag.
- Added Mika's Acked-by.

 drivers/i2c/busses/i2c-designware-common.c | 9 ++++++++-
 drivers/i2c/busses/i2c-designware-core.h   | 6 ++++++
 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-common.c +8 -1
index 4dc57fd56170..b6f3d71cf268 100644
@@ -374,7 +374,14 @@ static void i2c_dw_configure_mode(struct dw_i2c_dev *dev, int mode)
 		regmap_write(dev->map, DW_IC_CON, dev->slave_cfg);
 		regmap_write(dev->map, DW_IC_SAR, dev->slave->addr);
 		regmap_write(dev->map, DW_IC_INTR_MASK, DW_IC_INTR_SLAVE_MASK);
-		__i2c_dw_enable(dev);
+		/*
+		 * Controllers synthesised with the Multiple SAR feature only
+		 * acknowledge traffic to IC_SAR when SAR_EN is set; a plain
+		 * enable is not enough. The bit is reserved (ignored) on
+		 * single-SAR controllers.
+		 */
+		regmap_write(dev->map, DW_IC_ENABLE,
+			     DW_IC_ENABLE_ENABLE | DW_IC_ENABLE_SAR_EN);
 		break;
 	default:
 		WARN(1, "Invalid mode %d\n", mode);
drivers/i2c/busses/i2c-designware-core.h +6 -0
index 9d8d104cc391..35eaf2d7404f 100644
@@ -125,6 +125,12 @@
 
 #define DW_IC_ENABLE_ENABLE			BIT(0)
 #define DW_IC_ENABLE_ABORT			BIT(1)
+/*
+ * On controllers synthesised with the Multiple SAR feature (e.g. Marvell
+ * CN20K), the primary slave address register (IC_SAR) only acknowledges bus
+ * traffic when this bit is set. It is reserved on single-SAR controllers.
+ */
+#define DW_IC_ENABLE_SAR_EN			BIT(19)
 
 #define DW_IC_STATUS_ACTIVITY			BIT(0)
 #define DW_IC_STATUS_TFE			BIT(2)
Signature · 1 line
2.43.0
#3 lore raw
Quoted 9 lines · Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) only acknowledge traffic to the primary slave address (IC_SAR) when IC_ENABLE[19] (SAR_EN) is set. The slave enable path writes only IC_ENABLE[0], so on such controllers the target never ACKs its address and a remote master cannot reach it.

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

In the commit message and in the code comment below, can we refer to Synopsys DataBook for I²C where this bit is described? Or is it Marvell custom bit?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

Hi Andy ,

It's not a Marvell-custom bit — it's the Synopsys DW_apb_i2c IC_ENABLE.SAR_EN field (bit 19), part of the Multiple SAR feature described in the DataBook. I'll add the DataBook reference to both the commit message and the code comment in v3.

Regards ,
Umesh Kumar

From: Andy Shevchenko <[email protected]>
Sent: Wednesday, August 12, 2026 12:46 PM
To: Umesh Kumar <[email protected]>
Cc: Mika Westerberg <[email protected]>; Andi Shyti <[email protected]>; Bharat Bhushan <[email protected]>; [email protected]; [email protected]
Subject: [EXTERNAL] Re: [PATCH v2] i2c: designware: Enable SAR in slave mode for Multiple SAR controllers

On Wed, Aug 12, 2026 at 09: 10: 17AM +0530, Umesh Kumar wrote: > DesignWare controllers synthesised with the Multiple SAR feature (e. g. > Marvell CN20K) only acknowledge traffic to the primary slave address > (IC_SAR) when IC_ENABLE[19] ZjQcmQRYFpfptBannerStart
Prioritize security for external emails:
Confirm sender and content safety before clicking links or opening attachments
  https://us-phishalarm-ewt.proofpoint.com/EWT/v1/CRVmXkqW!tO3Tvje-Kz8VPqSfGZOxYl-uMGrg7-9lypliHTNEbNmWK_PXdbfXl-N_bBprf9om_uJP2owocFewSpgRPQ$  ‌

ZjQcmQRYFpfptBannerEnd

Quoted 9 lines · Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) only acknowledge traffic to the primary slave address (IC_SAR) when IC_ENABLE[19] (SAR_EN) is set. The slave enable path writes only IC_ENABLE[0], so on such controllers the target never ACKs its address and a remote master cannot reach it.

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

In the commit message and in the code comment below, can we refer to Synopsys DataBook for I²C where this bit is described? Or is it Marvell custom bit?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

PATCH v3 1/1 i2c: designware: Enable SAR in slave mode for Multiple SAR controllers

In reply to Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) gate the primary slave address behind IC_ENABLE.SAR_EN (bit 19). Per the Synopsys DW_apb_i2c DataBook (Multiple SAR feature), when this bit is set the core acknowledges the address matching IC_SAR; otherwise the address is NACKed. The slave enable path writes only IC_ENABLE.ENABLE (bit 0), so on such controllers the target never ACKs its address and a remote master cannot reach it.

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

---
 drivers/i2c/busses/i2c-designware-common.c | 10 +++++++++-
 drivers/i2c/busses/i2c-designware-core.h   |  8 ++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-common.c +9 -1
index 4dc57fd56170..8ed0b588d67b 100644
@@ -374,7 +374,15 @@ static void i2c_dw_configure_mode(struct dw_i2c_dev *dev, int mode)
 		regmap_write(dev->map, DW_IC_CON, dev->slave_cfg);
 		regmap_write(dev->map, DW_IC_SAR, dev->slave->addr);
 		regmap_write(dev->map, DW_IC_INTR_MASK, DW_IC_INTR_SLAVE_MASK);
-		__i2c_dw_enable(dev);
+		/*
+		 * Per the Synopsys DW_apb_i2c DataBook (Multiple SAR feature),
+		 * controllers synthesised with multiple SARs only acknowledge
+		 * traffic to IC_SAR when IC_ENABLE.SAR_EN is set; a plain enable
+		 * is not enough. The bit is reserved (ignored) on single-SAR
+		 * controllers.
+		 */
+		regmap_write(dev->map, DW_IC_ENABLE,
+			     DW_IC_ENABLE_ENABLE | DW_IC_ENABLE_SAR_EN);
 		break;
 	default:
 		WARN(1, "Invalid mode %d\n", mode);
drivers/i2c/busses/i2c-designware-core.h +8 -0
index 9d8d104cc391..b237d093c562 100644
@@ -125,6 +125,14 @@
 
 #define DW_IC_ENABLE_ENABLE			BIT(0)
 #define DW_IC_ENABLE_ABORT			BIT(1)
+/*
+ * IC_ENABLE.SAR_EN, per the Synopsys DW_apb_i2c DataBook (Multiple SAR
+ * feature): on controllers synthesised with multiple SARs (e.g. Marvell
+ * CN20K) the primary slave address (IC_SAR) is only acknowledged when this
+ * bit is set. Must be programmed while IC_ENABLE.ENABLE is 0. Reserved on
+ * single-SAR controllers.
+ */
+#define DW_IC_ENABLE_SAR_EN			BIT(19)
 
 #define DW_IC_STATUS_ACTIVITY			BIT(0)
 #define DW_IC_STATUS_TFE			BIT(2)
Signature · 1 line
2.43.0
reviewer Reviewed-by on v3 1/1
#6 lore raw
Quoted 3 lines · Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) gate the primary slave address behind IC_ENABLE.SAR_EN (bit 19). Per the Synopsys DW_apb_i2c DataBook (Multiple SAR feature),

Also provide a version of the DataBook. Something like v2.20c (hypothetical example).

Quoted 5 lines

when this bit is set the core acknowledges the address matching IC_SAR; otherwise the address is NACKed. The slave enable path writes only IC_ENABLE.ENABLE (bit 0), so on such controllers the target never ACKs its address and a remote master cannot reach it.

Quoted 7 lines

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

---

This is a v3 and no changelog here... What's going on?

Assuming this will be provided

...

drivers/i2c/busses/i2c-designware-common.c static void i2c_dw_configure_mode(struct dw_i2c_dev *dev, int mode) · line 378

Quoted 2 lines
drivers/i2c/busses/i2c-designware-common.c +2 -0
+		/*
+		 * Per the Synopsys DW_apb_i2c DataBook (Multiple SAR feature),

Ditto (mind the version).

Quoted 5 lines
drivers/i2c/busses/i2c-designware-common.c +5 -0
+		 * controllers synthesised with multiple SARs only acknowledge
+		 * traffic to IC_SAR when IC_ENABLE.SAR_EN is set; a plain enable
+		 * is not enough. The bit is reserved (ignored) on single-SAR
+		 * controllers.
+		 */

...

Quoted 7 lines

+/*
+ * IC_ENABLE.SAR_EN, per the Synopsys DW_apb_i2c DataBook (Multiple SAR
+ * feature): on controllers synthesised with multiple SARs (e.g. Marvell
+ * CN20K) the primary slave address (IC_SAR) is only acknowledged when this
+ * bit is set. Must be programmed while IC_ENABLE.ENABLE is 0. Reserved on
+ * single-SAR controllers.
+ */

Not sure if we need a dup comment as it's also in the code. Perhaps leave only in the C code where it makes more sense?

Quoted 1 line

+#define DW_IC_ENABLE_SAR_EN BIT(19)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

PATCH v4 1/1 i2c: designware: Enable SAR in slave mode for Multiple SAR controllers

In reply to Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) gate the primary slave address behind IC_ENABLE.SAR_EN (bit 19). Per the Synopsys DW_apb_i2c DataBook v2.03a (Multiple SAR feature),when this bit is set the core acknowledges the address matching IC_SAR;otherwise the address is NACKed. The slave enable path writes only IC_ENABLE.ENABLE (bit 0), so on such controllers the target never ACKs its address and a remote master cannot reach it.

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

---

Changes in v4:
- Added DataBook version (v2.03a) to commit message and code comment.
- Removed duplicate comment from core.h; kept only in the .c file.

 drivers/i2c/busses/i2c-designware-common.c | 10 +++++++++-
 drivers/i2c/busses/i2c-designware-core.h   |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-common.c +9 -1
index 4dc57fd56170..880b9a74b3ff 100644
@@ -374,7 +374,15 @@ static void i2c_dw_configure_mode(struct dw_i2c_dev *dev, int mode)
 		regmap_write(dev->map, DW_IC_CON, dev->slave_cfg);
 		regmap_write(dev->map, DW_IC_SAR, dev->slave->addr);
 		regmap_write(dev->map, DW_IC_INTR_MASK, DW_IC_INTR_SLAVE_MASK);
-		__i2c_dw_enable(dev);
+		/*
+		 * Per the Synopsys DW_apb_i2c DataBook v2.03a (Multiple SAR
+		 * feature), controllers synthesised with multiple SARs only
+		 * acknowledge traffic to IC_SAR when IC_ENABLE.SAR_EN is set;
+		 * a plain enable is not enough. The bit is reserved (ignored) on
+		 * single-SAR controllers.
+		 */
+		regmap_write(dev->map, DW_IC_ENABLE,
+			     DW_IC_ENABLE_ENABLE | DW_IC_ENABLE_SAR_EN);
 		break;
 	default:
 		WARN(1, "Invalid mode %d\n", mode);
drivers/i2c/busses/i2c-designware-core.h +1 -0
index 9d8d104cc391..1390c8862a68 100644
@@ -125,6 +125,7 @@
 
 #define DW_IC_ENABLE_ENABLE			BIT(0)
 #define DW_IC_ENABLE_ABORT			BIT(1)
+#define DW_IC_ENABLE_SAR_EN			BIT(19)
 
 #define DW_IC_STATUS_ACTIVITY			BIT(0)
 #define DW_IC_STATUS_TFE			BIT(2)
Signature · 1 line
2.43.0
reviewer Reviewed-by on v4 1/1
#8 lore raw
Quoted 4 lines · Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) gate the primary slave address behind IC_ENABLE.SAR_EN (bit 19). Per the Synopsys DW_apb_i2c DataBook v2.03a (Multiple SAR feature),when this bit is set the core acknowledges the address matching

Missing space after ).

Quoted 1 line

IC_SAR;otherwise the address is NACKed. The slave enable path writes only

Same here for ;.

Quoted 6 lines

IC_ENABLE.ENABLE (bit 0), so on such controllers the target never ACKs its address and a remote master cannot reach it.

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

PATCH v5 1/1 i2c: designware: Enable SAR in slave mode for Multiple SAR controllers

In reply to Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) gate the primary slave address behind IC_ENABLE.SAR_EN (bit 19). Per the Synopsys DW_apb_i2c DataBook v2.03a (Multiple SAR feature), when this bit is set the core acknowledges the address matching IC_SAR; otherwise the address is NACKed. The slave enable path writes only IC_ENABLE.ENABLE (bit 0), so on such controllers the target never ACKs its address and a remote master cannot reach it.

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

---

Changes in v5:
- Fixed missing spaces in commit message (Andy Shevchenko).
Changes in v4:
- Added DataBook version (v2.03a) to commit message and code comment.
- Removed duplicate comment from core.h; kept only in the .c file.
- Added changelog.
Changes in v3:
- Referenced the Synopsys DW_apb_i2c DataBook (Andy Shevchenko).
Changes in v2:
- Dropped RFC tag; added Mika's Acked-by.
v1 (RFC): https://lore.kernel.org/linux-i2c/[email protected]/

 drivers/i2c/busses/i2c-designware-common.c | 10 +++++++++-
 drivers/i2c/busses/i2c-designware-core.h   |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-common.c +9 -1
index 4dc57fd56170..880b9a74b3ff 100644
@@ -374,7 +374,15 @@ static void i2c_dw_configure_mode(struct dw_i2c_dev *dev, int mode)
 		regmap_write(dev->map, DW_IC_CON, dev->slave_cfg);
 		regmap_write(dev->map, DW_IC_SAR, dev->slave->addr);
 		regmap_write(dev->map, DW_IC_INTR_MASK, DW_IC_INTR_SLAVE_MASK);
-		__i2c_dw_enable(dev);
+		/*
+		 * Per the Synopsys DW_apb_i2c DataBook v2.03a (Multiple SAR
+		 * feature), controllers synthesised with multiple SARs only
+		 * acknowledge traffic to IC_SAR when IC_ENABLE.SAR_EN is set;
+		 * a plain enable is not enough. The bit is reserved (ignored) on
+		 * single-SAR controllers.
+		 */
+		regmap_write(dev->map, DW_IC_ENABLE,
+			     DW_IC_ENABLE_ENABLE | DW_IC_ENABLE_SAR_EN);
 		break;
 	default:
 		WARN(1, "Invalid mode %d\n", mode);
drivers/i2c/busses/i2c-designware-core.h +1 -0
index 9d8d104cc391..1390c8862a68 100644
@@ -125,6 +125,7 @@
 
 #define DW_IC_ENABLE_ENABLE			BIT(0)
 #define DW_IC_ENABLE_ABORT			BIT(1)
+#define DW_IC_ENABLE_SAR_EN			BIT(19)
 
 #define DW_IC_STATUS_ACTIVITY			BIT(0)
 #define DW_IC_STATUS_TFE			BIT(2)
Signature · 1 line
2.43.0
#10 lore raw
Quoted 11 lines · Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) gate the primary slave address behind IC_ENABLE.SAR_EN (bit 19). Per the Synopsys DW_apb_i2c DataBook v2.03a (Multiple SAR feature), when this bit is set the core acknowledges the address matching IC_SAR; otherwise the address is NACKed. The slave enable path writes only IC_ENABLE.ENABLE (bit 0), so on such controllers the target never ACKs its address and a remote master cannot reach it.

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

I gave my tag and it is absent here. What's going on?
Do you think the fix is not only that and requires a new round of review?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#11 lore raw

Hi Andy ,

Apologies for the oversight — no functional changes were made since your Reviewed-by. I inadvertently dropped the tag during commit amend. Resending as v6 with your Reviewed-by included.

Regards ,
Umesh Kumar

From: Andy Shevchenko <[email protected]>
Sent: Monday, August 17, 2026 10:04 PM
To: Umesh Kumar <[email protected]>
Cc: Andi Shyti <[email protected]>; Mika Westerberg <[email protected]>; Bharat Bhushan <[email protected]>; [email protected]; [email protected]
Subject: [EXTERNAL] Re: [PATCH v5] i2c: designware: Enable SAR in slave mode for Multiple SAR controllers

On Mon, Aug 17, 2026 at 09: 51: 41PM +0530, Umesh Kumar wrote: > DesignWare controllers synthesised with the Multiple SAR feature (e. g. > Marvell CN20K) gate the primary slave address behind IC_ENABLE. SAR_EN > (bit 19). Per the Synopsys ZjQcmQRYFpfptBannerStart
Prioritize security for external emails:
Confirm sender and content safety before clicking links or opening attachments
  https://us-phishalarm-ewt.proofpoint.com/EWT/v1/CRVmXkqW!tO3TvhD0whzUOE920RVUQ_XJPV3L26S-lEMnq92RJA9M7hx481kZx8jKjFzdQ9FYO_HrR3ywL34PqSFqWA$  ‌

ZjQcmQRYFpfptBannerEnd

Quoted 11 lines · Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) gate the primary slave address behind IC_ENABLE.SAR_EN (bit 19). Per the Synopsys DW_apb_i2c DataBook v2.03a (Multiple SAR feature), when this bit is set the core acknowledges the address matching IC_SAR; otherwise the address is NACKed. The slave enable path writes only IC_ENABLE.ENABLE (bit 0), so on such controllers the target never ACKs its address and a remote master cannot reach it.

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

I gave my tag and it is absent here. What's going on?
Do you think the fix is not only that and requires a new round of review?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#12 lore raw

PATCH v6 1/1 i2c: designware: Enable SAR in slave mode for Multiple SAR controllers

In reply to Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) gate the primary slave address behind IC_ENABLE.SAR_EN (bit 19). Per the Synopsys DW_apb_i2c DataBook v2.03a (Multiple SAR feature), when this bit is set the core acknowledges the address matching IC_SAR; otherwise the address is NACKed. The slave enable path writes only IC_ENABLE.ENABLE (bit 0), so on such controllers the target never ACKs its address and a remote master cannot reach it.

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

---
Changes in v6:
- Added Andy's Reviewed-by (missed in v5).

Changes in v5:
- Fixed missing spaces in commit message.

Changes in v4:
- Added DataBook version (v2.03a); removed duplicate comment from core.h.

Changes in v3:
- Referenced the Synopsys DW_apb_i2c DataBook (Andy Shevchenko).

Changes in v2:
- Dropped RFC tag; added Mika's Acked-by.

v1 (RFC): https://lore.kernel.org/linux-i2c/[email protected]/

 drivers/i2c/busses/i2c-designware-common.c | 10 +++++++++-
 drivers/i2c/busses/i2c-designware-core.h   |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-common.c +9 -1
index 4dc57fd56170..880b9a74b3ff 100644
@@ -374,7 +374,15 @@ static void i2c_dw_configure_mode(struct dw_i2c_dev *dev, int mode)
 		regmap_write(dev->map, DW_IC_CON, dev->slave_cfg);
 		regmap_write(dev->map, DW_IC_SAR, dev->slave->addr);
 		regmap_write(dev->map, DW_IC_INTR_MASK, DW_IC_INTR_SLAVE_MASK);
-		__i2c_dw_enable(dev);
+		/*
+		 * Per the Synopsys DW_apb_i2c DataBook v2.03a (Multiple SAR
+		 * feature), controllers synthesised with multiple SARs only
+		 * acknowledge traffic to IC_SAR when IC_ENABLE.SAR_EN is set;
+		 * a plain enable is not enough. The bit is reserved (ignored) on
+		 * single-SAR controllers.
+		 */
+		regmap_write(dev->map, DW_IC_ENABLE,
+			     DW_IC_ENABLE_ENABLE | DW_IC_ENABLE_SAR_EN);
 		break;
 	default:
 		WARN(1, "Invalid mode %d\n", mode);
drivers/i2c/busses/i2c-designware-core.h +1 -0
index 9d8d104cc391..1390c8862a68 100644
@@ -125,6 +125,7 @@
 
 #define DW_IC_ENABLE_ENABLE			BIT(0)
 #define DW_IC_ENABLE_ABORT			BIT(1)
+#define DW_IC_ENABLE_SAR_EN			BIT(19)
 
 #define DW_IC_STATUS_ACTIVITY			BIT(0)
 #define DW_IC_STATUS_TFE			BIT(2)
Signature · 1 line
2.43.0
Reviewed-by on v6 1/1
#13 lore raw
Quoted 8 lines · Umesh Kumar

DesignWare controllers synthesised with the Multiple SAR feature (e.g. Marvell CN20K) gate the primary slave address behind IC_ENABLE.SAR_EN (bit 19). Per the Synopsys DW_apb_i2c DataBook v2.03a (Multiple SAR feature), when this bit is set the core acknowledges the address matching IC_SAR; otherwise the address is NACKed. The slave enable path writes only IC_ENABLE.ENABLE (bit 0), so on such controllers the target never ACKs its address and a remote master cannot reach it.

Quoted 7 lines

Set SAR_EN together with ENABLE when entering slave mode. The bit is reserved (and ignored) on single-SAR controllers, so existing users are unaffected.

Rebased to top-of-tree and applied to for-andi.