Skip to contentSkip to conversation

i2c: qcom-cci: Add DT property for SCL clock stretching

PATCH In review Cory Keitz 4 participants 8 messages Mar 5 – Mar 11

Subsystems (4)
lore
Share & tools
lore

Cory Keitz

author
#0 lore raw

cover i2c: qcom-cci: Add DT property for SCL clock stretching

The Qualcomm CCI I2C controller has an SCL clock stretch enable bit in the MISC_CTL register. Currently the driver hardcodes this off in per-SoC hw_params tables, with no way to enable it from the device tree on a per-master basis.

Clock stretching is required for GMSL configurations where the deserializer uses it to absorb the latency imposed by forwarding I2C transactions across the serial link. Without it, the CCI master exhibits intermittent transaction failure.

This series adds a "qcom,scl-stretch-enable" boolean DT property to individual CCI i2c-bus sub-nodes. The property ORs with the existing hw_params default so it is purely additive and does not affect masters that do not set it.

Tested on sa8775p using the qcom,sm8250-cci compatible string with two CCI buses connected to one max96724/max96717 GMSL2 pair each. Enabling this property eliminated intermittent NACK errors during serializer and/or deserializer probe.

---
Cory Keitz (2):
dt-bindings: i2c: qcom-cci: Document qcom,scl-stretch-enable property
i2c: qcom-cci: Add DT property for SCL clock stretching

 Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml | 8 ++++++++
 drivers/i2c/busses/i2c-qcom-cci.c                       | 7 ++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

---
base-commit: ecc64d2dc9ff9738d2a896beb68e02c2feaf9a02
change-id: 20260304-cci-scl-stretch-e20060685476

Best regards,

Signature · 1 line
Cory Keitz <[email protected]>
author
#1 lore raw

PATCH 1/2 dt-bindings: i2c: qcom-cci: Document qcom,scl-stretch-enable property

Add the optional boolean property "qcom,scl-stretch-enable" to the CCI i2c-bus sub-nodes. This property enables SCL clock stretching on the corresponding CCI master, which is needed by peripherals such as GMSL deserializers that hold SCL low to absorb forwarding latency.

---
 Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml +8 -0
index 399a09409e07..fea609fa2f05 100644
@@ -78,6 +78,14 @@ patternProperties:
       clock-frequency:
         default: 100000
 
+      qcom,scl-stretch-enable:
+        type: boolean
+        description:
+          Enable SCL clock stretching on this CCI master. When set, the
+          CCI hardware will assert the SCL stretch enable bit in the
+          MISC_CTL register, allowing peripherals to hold SCL low to
+          throttle the bus.
+
 required:
   - compatible
   - clock-names
Signature · 1 line
2.47.3
#2 lore raw

Re: [PATCH 1/2] dt-bindings: i2c: qcom-cci: Document qcom,scl-stretch-enable property

Quoted 17 lines · On 05/03/2026 15:40, Cory Keitz via B4 Relay wrote:

From: Cory Keitz <[email protected]>

Add the optional boolean property "qcom,scl-stretch-enable" to the CCI i2c-bus sub-nodes. This property enables SCL clock stretching on the corresponding CCI master, which is needed by peripherals such as GMSL deserializers that hold SCL low to absorb forwarding latency.

---
 Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml | 8 ++++++++
 1 file changed, 8 insertions(+)
Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml +0 -0
index 399a09409e07..fea609fa2f05 100644

Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml patternProperties: · line 81

Quoted 4 lines
Documentation/devicetree/bindings/i2c/qcom,i2c-cci.yaml +1 -0
@@ -78,6 +78,14 @@ patternProperties:
       clock-frequency:
         default: 100000
 
+      qcom,scl-stretch-enable:

I don't understand why only Qualcomm needs per-controller property and no others need to static configuration. Maybe this is just already solved?

And I actually found this:
https://lore.kernel.org/all/[email protected]/

so this is all done.

Best regards,
Krzysztof

author
#3 lore raw

Re: [PATCH 1/2] dt-bindings: i2c: qcom-cci: Document qcom,scl-stretch-enable property

Quoted 7 lines · Krzysztof Kozlowski

I don't understand why only Qualcomm needs per-controller property and no others need to static configuration. Maybe this is just already solved?

And I actually found this:
https://lore.kernel.org/all/[email protected]/

so this is all done.

Thanks, I hadn't seen this. The two properties there aren't quite the same but the point about it being a general property is well taken. I plan to follow Loic's suggestion and hardcode instead of using a DT property.

author
#4 lore raw

PATCH 2/2 i2c: qcom-cci: Add DT property for SCL clock stretching

In reply to Cory Keitz

The CCI hardware supports an SCL clock stretch enable bit in the MISC_CTL register, but the driver hardcodes it off for most SoC variants. This makes the bus driver unstable for configurations which rely on clock stretching. Notably, GMSL uses clock stretching to absorb the latency of transaction forwarding across the link.

Add a per-master "qcom,scl-stretch-enable" boolean DT property that ORs with the existing hw_params default, allowing clock stretching to be enabled on individual CCI masters without affecting others.

---
 drivers/i2c/busses/i2c-qcom-cci.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-qcom-cci.c +6 -1
index 884055df1560..022c10b310a0 100644
@@ -111,6 +111,7 @@ struct cci_master {
 	struct i2c_adapter adap;
 	u16 master;
 	u8 mode;
+	bool scl_stretch_en;
 	int status;
 	struct completion irq_complete;
 	struct cci *cci;
@@ -284,7 +285,8 @@ static int cci_init(struct cci *cci)
 		val = hw->tbuf;
 		writel(val, cci->base + CCI_I2C_Mm_SDA_CTL_2(i));
 
-		val = hw->scl_stretch_en << 8 | hw->trdhld << 4 | hw->tsp;
+		val = (hw->scl_stretch_en | cci->master[i].scl_stretch_en) << 8 |
+			hw->trdhld << 4 | hw->tsp;
 		writel(val, cci->base + CCI_I2C_Mm_MISC_CTL(i));
 	}
 
@@ -572,6 +574,9 @@ static int cci_probe(struct platform_device *pdev)
 				master->mode = I2C_MODE_FAST_PLUS;
 		}
 
+		master->scl_stretch_en =
+			of_property_read_bool(child, "qcom,scl-stretch-enable");
+
 		init_completion(&master->irq_complete);
 	}
 
Signature · 1 line
2.47.3
maintainer
#5 lore raw
In reply to Cory Keitz

Hi Cory,

Quoted 16 lines · On Thu, Mar 5, 2026 at 3:40 PM Cory Keitz via B4 Relay…

The Qualcomm CCI I2C controller has an SCL clock stretch enable bit in the MISC_CTL register. Currently the driver hardcodes this off in per-SoC hw_params tables, with no way to enable it from the device tree on a per-master basis.

Clock stretching is required for GMSL configurations where the deserializer uses it to absorb the latency imposed by forwarding I2C transactions across the serial link. Without it, the CCI master exhibits intermittent transaction failure.

This series adds a "qcom,scl-stretch-enable" boolean DT property to individual CCI i2c-bus sub-nodes. The property ORs with the existing hw_params default so it is purely additive and does not affect masters that do not set it.

Quoted 4 lines

Tested on sa8775p using the qcom,sm8250-cci compatible string with two CCI buses connected to one max96724/max96717 GMSL2 pair each. Enabling this property eliminated intermittent NACK errors during serializer and/or deserializer probe.

I'm not convinced this kind of hardware behaviour belongs in devicetree. As far as I understand, clock stretching is part of the I2C specification, and slaves are allowed to use it whenever they need additional time. Masters are therefore expected to tolerate stretching. Given that, why not enable it unconditionally in the driver? Is there any downside to doing so?

Regards,
Loic

author
#6 lore raw
Quoted 6 lines · Loic Poulain

I'm not convinced this kind of hardware behaviour belongs in devicetree. As far as I understand, clock stretching is part of the I2C specification, and slaves are allowed to use it whenever they need additional time. Masters are therefore expected to tolerate stretching. Given that, why not enable it unconditionally in the driver? Is there any downside to doing so?

Fair point. I wasn't sure of implications across the platforms, so my preference was to make the change opt-in to preserve behavior for existing systems. This is probably an overly-cautious approach though. I'm happy to submit a v2 that forces it on, and remove the new DT binding.

Cory

#7 lore raw
In reply to Loic Poulain
Quoted 25 lines · Loic Poulain

Hi Cory,

Quoted 16 lines · On Thu, Mar 5, 2026 at 3:40 PM Cory Keitz via B4 Relay…

The Qualcomm CCI I2C controller has an SCL clock stretch enable bit in the MISC_CTL register. Currently the driver hardcodes this off in per-SoC hw_params tables, with no way to enable it from the device tree on a per-master basis.

Clock stretching is required for GMSL configurations where the deserializer uses it to absorb the latency imposed by forwarding I2C transactions across the serial link. Without it, the CCI master exhibits intermittent transaction failure.

This series adds a "qcom,scl-stretch-enable" boolean DT property to individual CCI i2c-bus sub-nodes. The property ORs with the existing hw_params default so it is purely additive and does not affect masters that do not set it.

Quoted 4 lines

Tested on sa8775p using the qcom,sm8250-cci compatible string with two CCI buses connected to one max96724/max96717 GMSL2 pair each. Enabling this property eliminated intermittent NACK errors during serializer and/or deserializer probe.

Quoted 6 lines

I'm not convinced this kind of hardware behaviour belongs in devicetree. As far as I understand, clock stretching is part of the I2C specification, and slaves are allowed to use it whenever they need additional time. Masters are therefore expected to tolerate stretching. Given that, why not enable it unconditionally in the driver? Is there any downside to doing so?

+Mukesh may be able to help

Konrad