Skip to contentSkip to conversation

i2c: designware: device tree bindings for i2c speed mode

PATCH In review [email protected] 3 participants 6 messages Aug 19, 2014 – Aug 20, 2014

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

PATCH 1/2 i2c: designware: device tree bindings for i2c speed mode

From: Alan Tull <[email protected]>

Add "speed-mode" Device Tree property to select between standard and fast i2c mode. Previously, driver was hardwired as fast mode. Default to fast mode if property is not present.

---
 .../devicetree/bindings/i2c/i2c-designware.txt     |    3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/i2c/i2c-designware.txt +3 -0
index 5199b0c..0e4cd21 100644
@@ -9,6 +9,8 @@ Required properties :
 Recommended properties :
 
  - clock-frequency : desired I2C bus clock frequency in Hz.
+ - speed-mode      : 0 = standard (0 - 100Kb/s)
+                   : 1 = fast (<= 400Kb/s) <== default
 
 Optional properties :
  - i2c-sda-hold-time-ns : should contain the SDA hold time in nanoseconds.
@@ -29,6 +31,7 @@ Example :
 		reg = <0xf0000 0x1000>;
 		interrupts = <11>;
 		clock-frequency = <400000>;
+		speed-mode = <0>;
 	};
 
 	i2c@1120000 {
Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH 2/2 i2c: designware: add speed mode device tree setting

From: Alan Tull <[email protected]>

Add "speed-mode" Device Tree property to select between standard and fast i2c mode. Previously, driver was hardwired as fast mode. Default to fast mode if property is not present.

---
 drivers/i2c/busses/i2c-designware-platdrv.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-designware-platdrv.c +7 -2
index bc87733..3fdc775 100644
@@ -122,7 +122,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
 	struct dw_i2c_dev *dev;
 	struct i2c_adapter *adap;
 	struct resource *mem;
-	int irq, r;
+	int irq, r, speed_prop, ret, speed = DW_IC_CON_SPEED_FAST;
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
@@ -167,6 +167,11 @@ static int dw_i2c_probe(struct platform_device *pdev)
 		of_property_read_u32(pdev->dev.of_node,
 				     "i2c-scl-falling-time-ns",
 				     &dev->scl_falling_time);
+
+		ret = of_property_read_u32(pdev->dev.of_node,
+					   "speed-mode", &speed_prop);
+		if (!ret && (speed_prop == 0))
+			speed = DW_IC_CON_SPEED_STD;
 	}
 
 	dev->functionality =
@@ -177,7 +182,7 @@ static int dw_i2c_probe(struct platform_device *pdev)
 		I2C_FUNC_SMBUS_WORD_DATA |
 		I2C_FUNC_SMBUS_I2C_BLOCK;
 	dev->master_cfg =  DW_IC_CON_MASTER | DW_IC_CON_SLAVE_DISABLE |
-		DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST;
+		DW_IC_CON_RESTART_EN | speed;
 
 	/* Try first if we can configure the device from ACPI */
 	r = dw_i2c_acpi_configure(pdev);
Signature · 1 line
1.7.9.5
#2 lore raw
In reply to [email protected]
Quoted 6 lines · On Tue, Aug 19, 2014 at 01:34:35PM -0500…

From: Alan Tull <[email protected]>

Add "speed-mode" Device Tree property to select between standard and fast i2c mode. Previously, driver was hardwired as fast mode. Default to fast mode if property is not present.

NACK. This should be deduced from the clock-frequency setting...

Quoted 11 lines
---
 .../devicetree/bindings/i2c/i2c-designware.txt     |    3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/i2c/i2c-designware.txt +0 -0
index 5199b0c..0e4cd21 100644

Documentation/devicetree/bindings/i2c/i2c-designware.txt Required properties : · line 11

Quoted 3 lines
Documentation/devicetree/bindings/i2c/i2c-designware.txt +0 -0
@@ -9,6 +9,8 @@ Required properties :
 Recommended properties :
 
  - clock-frequency : desired I2C bus clock frequency in Hz.

... which is described here, but surprisingly not supported in the driver yet :(

Check i2c-riic for an example.

Quoted 16 lines
Documentation/devicetree/bindings/i2c/i2c-designware.txt +3 -0
+ - speed-mode      : 0 = standard (0 - 100Kb/s)
+                   : 1 = fast (<= 400Kb/s) <== default
 
 Optional properties :
  - i2c-sda-hold-time-ns : should contain the SDA hold time in nanoseconds.
@@ -29,6 +31,7 @@ Example :
 		reg = <0xf0000 0x1000>;
 		interrupts = <11>;
 		clock-frequency = <400000>;
+		speed-mode = <0>;
 	};
 
 	i2c@1120000 {
Signature · 1 line
1.7.9.5
author
#3 lore raw
Quoted 9 lines · Wolfram Sang
Quoted 6 lines · On Tue, Aug 19, 2014 at 01:34:35PM -0500…

From: Alan Tull <[email protected]>

Add "speed-mode" Device Tree property to select between standard and fast i2c mode. Previously, driver was hardwired as fast mode. Default to fast mode if property is not present.

NACK. This should be deduced from the clock-frequency setting...

I just sent out a new patch that looks at the clock-frequency setting.

Alan

#4 lore raw
In reply to [email protected]
Quoted 17 lines · On Tue, Aug 19, 2014 at 07:34:35PM +0100, [email protected] wrote:

From: Alan Tull <[email protected]>

Add "speed-mode" Device Tree property to select between standard and fast i2c mode. Previously, driver was hardwired as fast mode. Default to fast mode if property is not present.

---
 .../devicetree/bindings/i2c/i2c-designware.txt     |    3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/i2c/i2c-designware.txt +0 -0
index 5199b0c..0e4cd21 100644

Documentation/devicetree/bindings/i2c/i2c-designware.txt Required properties : · line 13

Quoted 5 lines
Documentation/devicetree/bindings/i2c/i2c-designware.txt +2 -0
@@ -9,6 +9,8 @@ Required properties :
 Recommended properties :
 
  - clock-frequency : desired I2C bus clock frequency in Hz.
+ - speed-mode      : 0 = standard (0 - 100Kb/s)
+                   : 1 = fast (<= 400Kb/s) <== default

This is a bit opaque.

Is this a limit on the max bit-rate the device should operate at?

Why not just have an optional boolean property to limit to standard speed?

Thanks,
Mark.

Quoted 19 lines
Documentation/devicetree/bindings/i2c/i2c-designware.txt +1 -0
 Optional properties :
  - i2c-sda-hold-time-ns : should contain the SDA hold time in nanoseconds.
@@ -29,6 +31,7 @@ Example :
 		reg = <0xf0000 0x1000>;
 		interrupts = <11>;
 		clock-frequency = <400000>;
+		speed-mode = <0>;
 	};
 
 	i2c@1120000 {
Signature · 6 lines
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
Quoted 26 lines · Mark Rutland
Quoted 17 lines · On Tue, Aug 19, 2014 at 07:34:35PM +0100…

From: Alan Tull <[email protected]>

Add "speed-mode" Device Tree property to select between standard and fast i2c mode. Previously, driver was hardwired as fast mode. Default to fast mode if property is not present.

---
 .../devicetree/bindings/i2c/i2c-designware.txt     |    3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/i2c/i2c-designware.txt +0 -0
index 5199b0c..0e4cd21 100644

Documentation/devicetree/bindings/i2c/i2c-designware.txt Required properties : · line 13

Quoted 5 lines
Documentation/devicetree/bindings/i2c/i2c-designware.txt +2 -0
@@ -9,6 +9,8 @@ Required properties :
 Recommended properties :
 
  - clock-frequency : desired I2C bus clock frequency in Hz.
+ - speed-mode      : 0 = standard (0 - 100Kb/s)
+                   : 1 = fast (<= 400Kb/s) <== default

This is a bit opaque.

Quoted 4 lines

Is this a limit on the max bit-rate the device should operate at?

Why not just have an optional boolean property to limit to standard speed?

I see there's a new patch doing this based on clock-frequency, so feel free to ignore this.

Mark.