Skip to contentSkip to conversation

dt-bindings: add bindings for USB physical connector

RFC PATCH Superseded Andrzej Hajda 3 participants 13 messages Feb 15, 2018 – Feb 20, 2018 1 message not in the archive

Subsystems (7)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20180215103925eucas1p1f2278a69a7d81b6ba1ae3583d11e1997@eucas1p1.samsung.com

#1 lore raw

v2 cover dt-bindings: add bindings for USB physical connector

Hi,

Thanks for reviews of previous iterations.

This patchset introduces USB physical connector bindings, together with working example.

v2: I have addressed comments by Rob and Laurent, thanks
v3: Separate binding for Samsung 11-pin connector, added full-blown USB-C example.

Changes are also described in patches.

Regards
Andrzej

Andrzej Hajda (5):
dt-bindings: add bindings for USB physical connector
dt-bindings: add bindings for Samsung micro-USB 11-pin connector
arm64: dts: exynos: add micro-USB connector node to TM2 platforms
arm64: dts: exynos: add OF graph between MHL and USB connector
extcon: add possibility to get extcon device by OF node

Maciej Purski (1):
drm/bridge/sii8620: use micro-USB cable detection logic to detect MHL

 .../connector/samsung,usb-connector-11pin.txt      | 51 ++++++++++++
 .../bindings/connector/usb-connector.txt           | 74 +++++++++++++++++
 .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 38 ++++++++-
 drivers/extcon/extcon.c                            | 44 +++++++---
 drivers/gpu/drm/bridge/sil-sii8620.c               | 97 +++++++++++++++++++++-
 include/linux/extcon.h                             |  6 ++
 6 files changed, 294 insertions(+), 16 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/connector/samsung,usb-connector-11pin.txt
 create mode 100644 Documentation/devicetree/bindings/connector/usb-connector.txt
Signature · 1 line
2.16.1
#2 lore raw

RFC PATCH v2 1/6 dt-bindings: add bindings for USB physical connector

These bindings allow to describe most known standard USB connectors and it should be possible to extend it if necessary.
USB connectors, beside USB can be used to route other protocols, for example UART, Audio, MHL. In such case every device passing data through the connector should have appropriate graph bindings.

---
v3:
- removed MHL port (samsung connector will have separate bindings),
- added 2nd example for USB-C,
- improved formatting
v2:
- moved connector type(A,B,C) to compatible string (Rob),
- renamed size property to type (Rob),
- changed type description to be less confusing (Laurent),
- removed vendor specific compatibles (implied by graph port number),
- added requirement of connector being a child of IC (Rob),
- removed max-mode (subtly suggested by Rob, it should be detected anyway by USB Controller in runtime, downside is that device is not able to report its real capabilities, maybe better would be to make it optional(?)),
- assigned port numbers to data buses (Rob).

Regards
Andrzej

dt-bindings: add bindings for USB physical connector v3

---
 .../bindings/connector/usb-connector.txt           | 74 ++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/connector/usb-connector.txt
Documentation/devicetree/bindings/connector/usb-connector.txt new file +74 -0
new file mode 100644
index 000000000000..1efda92639da
@@ -0,0 +1,74 @@
+USB Connector
+=============
+
+USB connector node represents physical USB connector. It should be
+a child of USB interface controller.
+
+Required properties:
+- compatible: describes type of the connector, must be one of:
+    "usb-a-connector",
+    "usb-b-connector",
+    "usb-c-connector".
+
+Optional properties:
+- label: symbolic name for the connector,
+- type: size of the connector, should be specified in case of USB-A, USB-B
+  non-standard (large) connector sizes: "mini", "micro".
+
+Required nodes:
+- any data bus to the connector should be modeled using the OF graph bindings
+  specified in bindings/graph.txt, unless the bus is between parent node and
+  the connector. Since single connector can have multpile data buses every bus
+  has assigned OF graph port number as follows:
+    0: High Speed (HS), present in all connectors,
+    1: Super Speed (SS), present in SS capable connectors,
+    2: Sideband use (SBU), present in USB-C.
+
+Examples
+--------
+
+1. Micro-USB connector with HS lines routed via controller (MUIC):
+
+muic-max77843 at 66 {
+	...
+	usb_con: connector {
+		compatible = "usb-b-connector";
+		label = "micro-USB";
+		type = "micro";
+	};
+};
+
+2. USB-C connector attached to CC controller (s2mm005), HS lines routed
+to companion PMIC (max77865), SS lines to USB3 PHY and SBU to DisplayPort:
+
+ccic: s2mm005 at 33 {
+	...
+	usb_con: connector {
+		compatible = "usb-c-connector";
+		label = "USB-C";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port at 0 {
+				reg = <0>;
+				usb_con_hs: endpoint {
+					remote-endpoint = <&max77865_usbc_hs>;
+				};
+			};
+			port at 1 {
+				reg = <1>;
+				usb_con_ss: endpoint {
+					remote-endpoint = <&usbdrd_phy_ss>;
+				};
+			};
+			port at 2 {
+				reg = <2>;
+				usb_con_sbu: endpoint {
+					remote-endpoint = <&dp_aux>;
+				};
+			};
+		};
+	};
+};
Signature · 1 line
2.16.1
maintainer
#3 lore raw
Quoted 46 lines · Andrzej Hajda

These bindings allow to describe most known standard USB connectors and it should be possible to extend it if necessary.
USB connectors, beside USB can be used to route other protocols, for example UART, Audio, MHL. In such case every device passing data through the connector should have appropriate graph bindings.

---
v3:
- removed MHL port (samsung connector will have separate bindings),
- added 2nd example for USB-C,
- improved formatting
v2:
- moved connector type(A,B,C) to compatible string (Rob),
- renamed size property to type (Rob),
- changed type description to be less confusing (Laurent),
- removed vendor specific compatibles (implied by graph port number),
- added requirement of connector being a child of IC (Rob),
- removed max-mode (subtly suggested by Rob, it should be detected anyway by USB Controller in runtime, downside is that device is not able to report its real capabilities, maybe better would be to make it optional(?)),
- assigned port numbers to data buses (Rob).

Regards
Andrzej

dt-bindings: add bindings for USB physical connector v3

---
 .../bindings/connector/usb-connector.txt           | 74 ++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/connector/usb-connector.txt
Documentation/devicetree/bindings/connector/usb-connector.txt new file +6 -0
new file mode 100644
index 000000000000..1efda92639da
@@ -0,0 +1,74 @@
+USB Connector
+=============
+
+USB connector node represents physical USB connector. It should be
+a child of USB interface controller.
+

Documentation/devicetree/bindings/connector/usb-connector.txt line 16

Quoted 10 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +10 -0
+Required properties:
+- compatible: describes type of the connector, must be one of:
+    "usb-a-connector",
+    "usb-b-connector",
+    "usb-c-connector".
+
+Optional properties:
+- label: symbolic name for the connector,
+- type: size of the connector, should be specified in case of USB-A, USB-B
+  non-standard (large) connector sizes: "mini", "micro".

The smaller connectors are standard too. Perhaps "non-fullsize connector sizes".

We're missing a micro-AB connector, but I think those are actually pretty rare. Most phones are micro-B connectors, but do both host and device.

Documentation/devicetree/bindings/connector/usb-connector.txt line 24

Quoted 8 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +8 -0
+
+Required nodes:
+- any data bus to the connector should be modeled using the OF graph bindings
+  specified in bindings/graph.txt, unless the bus is between parent node and
+  the connector. Since single connector can have multpile data buses every bus
+  has assigned OF graph port number as follows:
+    0: High Speed (HS), present in all connectors,
+    1: Super Speed (SS), present in SS capable connectors,

This should also say endpoint 0 is USB-SS, endpoint 1 (and higher?) is Alternate Mode. And show in the example.

Quoted 8 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +8 -0
+    2: Sideband use (SBU), present in USB-C.
+
+Examples
+--------
+
+1. Micro-USB connector with HS lines routed via controller (MUIC):
+
+muic-max77843 at 66 {

Documentation/devicetree/bindings/connector/usb-connector.txt line 42

Quoted 10 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +10 -0
+	...
+	usb_con: connector {
+		compatible = "usb-b-connector";
+		label = "micro-USB";
+		type = "micro";
+	};
+};
+
+2. USB-C connector attached to CC controller (s2mm005), HS lines routed
+to companion PMIC (max77865), SS lines to USB3 PHY and SBU to DisplayPort:

Having SBU to DP but no DP video path connection is wrong.

Quoted 35 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +32 -0
+
+ccic: s2mm005 at 33 {
+	...
+	usb_con: connector {
+		compatible = "usb-c-connector";
+		label = "USB-C";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port at 0 {
+				reg = <0>;
+				usb_con_hs: endpoint {
+					remote-endpoint = <&max77865_usbc_hs>;
+				};
+			};
+			port at 1 {
+				reg = <1>;
+				usb_con_ss: endpoint {
+					remote-endpoint = <&usbdrd_phy_ss>;
+				};
+			};
+			port at 2 {
+				reg = <2>;
+				usb_con_sbu: endpoint {
+					remote-endpoint = <&dp_aux>;
+				};
+			};
+		};
+	};
+};
Signature · 1 line
2.16.1
#4 lore raw
Quoted 51 lines · Rob Herring
Quoted 50 lines · Andrzej Hajda

These bindings allow to describe most known standard USB connectors and it should be possible to extend it if necessary.
USB connectors, beside USB can be used to route other protocols, for example UART, Audio, MHL. In such case every device passing data through the connector should have appropriate graph bindings.

---
v3:
- removed MHL port (samsung connector will have separate bindings),
- added 2nd example for USB-C,
- improved formatting
v2:
- moved connector type(A,B,C) to compatible string (Rob),
- renamed size property to type (Rob),
- changed type description to be less confusing (Laurent),
- removed vendor specific compatibles (implied by graph port number),
- added requirement of connector being a child of IC (Rob),
- removed max-mode (subtly suggested by Rob, it should be detected anyway by USB Controller in runtime, downside is that device is not able to report its real capabilities, maybe better would be to make it optional(?)),
- assigned port numbers to data buses (Rob).

Regards
Andrzej

dt-bindings: add bindings for USB physical connector v3

---
 .../bindings/connector/usb-connector.txt           | 74 ++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/connector/usb-connector.txt
Documentation/devicetree/bindings/connector/usb-connector.txt new file +10 -0
new file mode 100644
index 000000000000..1efda92639da
@@ -0,0 +1,74 @@
+USB Connector
+=============
+
+USB connector node represents physical USB connector. It should be
+a child of USB interface controller.
+
+Required properties:
+- compatible: describes type of the connector, must be one of:
+    "usb-a-connector",
+    "usb-b-connector",
Quoted 8 lines

Documentation/devicetree/bindings/connector/usb-connector.txt line 16

Quoted 6 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +6 -0
+    "usb-c-connector".
+
+Optional properties:
+- label: symbolic name for the connector,
+- type: size of the connector, should be specified in case of USB-A, USB-B
+  non-standard (large) connector sizes: "mini", "micro".

The smaller connectors are standard too. Perhaps "non-fullsize connector sizes".

The word "standard" is used in specs, but your description looks better, maybe even shorter version would work: "non-fullsize connectors:".

Quoted 5 lines

We're missing a micro-AB connector, but I think those are actually pretty rare. Most phones are micro-B connectors, but do both host and device.

Quoted 10 lines

Documentation/devicetree/bindings/connector/usb-connector.txt line 24

Quoted 8 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +8 -0
+
+Required nodes:
+- any data bus to the connector should be modeled using the OF graph bindings
+  specified in bindings/graph.txt, unless the bus is between parent node and
+  the connector. Since single connector can have multpile data buses every bus
+  has assigned OF graph port number as follows:
+    0: High Speed (HS), present in all connectors,
+    1: Super Speed (SS), present in SS capable connectors,

This should also say endpoint 0 is USB-SS, endpoint 1 (and higher?) is Alternate Mode. And show in the example.

What if there is SS mux before, which muxes USB-SS and DP lines. In my case the mux is located in USB-PHY (it is 2nd example below). In such case there is only one graph connection to SS port and this connection will handle both USB-SS and AltMode traffic. Anyway from USB-C connector's point of view, there is no distinction which lines are USB-SS, which are AltMode. In fact platform decides in real time about muxing of SS and AltMode signals, as it depends on cable/plug orientations. Maybe instead of mapping endpoint numbers to SS/AltMode, we should map them to SS1/SS2 lines if necessary(???).

To be sure of your intentions. Do you want to model simple SS muxes as a part of USB-C connector?

Quoted 11 lines
Quoted 11 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +11 -0
+    2: Sideband use (SBU), present in USB-C.
+
+Examples
+--------
+
+1. Micro-USB connector with HS lines routed via controller (MUIC):
+
+muic-max77843@66 {
+	...
+	usb_con: connector {
+		compatible = "usb-b-connector";
Quoted 8 lines

Documentation/devicetree/bindings/connector/usb-connector.txt line 42

Quoted 7 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +7 -0
+		label = "micro-USB";
+		type = "micro";
+	};
+};
+
+2. USB-C connector attached to CC controller (s2mm005), HS lines routed
+to companion PMIC (max77865), SS lines to USB3 PHY and SBU to DisplayPort:

Having SBU to DP but no DP video path connection is wrong.

But it is real hardware :)
As I said earlier, DP video lines are connected to mux in USB3-PHY. I can add this explanation to the description to make it clear.

Regards
Andrzej

Quoted 38 lines
Quoted 36 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +32 -0
+
+ccic: s2mm005@33 {
+	...
+	usb_con: connector {
+		compatible = "usb-c-connector";
+		label = "USB-C";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port@0 {
+				reg = <0>;
+				usb_con_hs: endpoint {
+					remote-endpoint = <&max77865_usbc_hs>;
+				};
+			};
+			port@1 {
+				reg = <1>;
+				usb_con_ss: endpoint {
+					remote-endpoint = <&usbdrd_phy_ss>;
+				};
+			};
+			port@2 {
+				reg = <2>;
+				usb_con_sbu: endpoint {
+					remote-endpoint = <&dp_aux>;
+				};
+			};
+		};
+	};
+};
Signature · 1 line
2.16.1
maintainer
#5 lore raw
Quoted 61 lines · Andrzej Hajda
Quoted 51 lines · Rob Herring
Quoted 50 lines · Andrzej Hajda

These bindings allow to describe most known standard USB connectors and it should be possible to extend it if necessary.
USB connectors, beside USB can be used to route other protocols, for example UART, Audio, MHL. In such case every device passing data through the connector should have appropriate graph bindings.

---
v3:
- removed MHL port (samsung connector will have separate bindings),
- added 2nd example for USB-C,
- improved formatting
v2:
- moved connector type(A,B,C) to compatible string (Rob),
- renamed size property to type (Rob),
- changed type description to be less confusing (Laurent),
- removed vendor specific compatibles (implied by graph port number),
- added requirement of connector being a child of IC (Rob),
- removed max-mode (subtly suggested by Rob, it should be detected anyway by USB Controller in runtime, downside is that device is not able to report its real capabilities, maybe better would be to make it optional(?)),
- assigned port numbers to data buses (Rob).

Regards
Andrzej

dt-bindings: add bindings for USB physical connector v3

---
 .../bindings/connector/usb-connector.txt           | 74 ++++++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/connector/usb-connector.txt
Documentation/devicetree/bindings/connector/usb-connector.txt new file +10 -0
new file mode 100644
index 000000000000..1efda92639da
@@ -0,0 +1,74 @@
+USB Connector
+=============
+
+USB connector node represents physical USB connector. It should be
+a child of USB interface controller.
+
+Required properties:
+- compatible: describes type of the connector, must be one of:
+    "usb-a-connector",
+    "usb-b-connector",
Quoted 8 lines

Documentation/devicetree/bindings/connector/usb-connector.txt line 16

Quoted 6 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +6 -0
+    "usb-c-connector".
+
+Optional properties:
+- label: symbolic name for the connector,
+- type: size of the connector, should be specified in case of USB-A, USB-B
+  non-standard (large) connector sizes: "mini", "micro".

The smaller connectors are standard too. Perhaps "non-fullsize connector sizes".

Quoted 2 lines

The word "standard" is used in specs, but your description looks better, maybe even shorter version would work: "non-fullsize connectors:".

Sure.

Quoted 15 lines
Quoted 4 lines

We're missing a micro-AB connector, but I think those are actually pretty rare. Most phones are micro-B connectors, but do both host and device.

Quoted 10 lines

Documentation/devicetree/bindings/connector/usb-connector.txt line 24

Quoted 8 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +8 -0
+
+Required nodes:
+- any data bus to the connector should be modeled using the OF graph bindings
+  specified in bindings/graph.txt, unless the bus is between parent node and
+  the connector. Since single connector can have multpile data buses every bus
+  has assigned OF graph port number as follows:
+    0: High Speed (HS), present in all connectors,
+    1: Super Speed (SS), present in SS capable connectors,

This should also say endpoint 0 is USB-SS, endpoint 1 (and higher?) is Alternate Mode. And show in the example.

Quoted 4 lines

What if there is SS mux before, which muxes USB-SS and DP lines. In my case the mux is located in USB-PHY (it is 2nd example below). In such case there is only one graph connection to SS port and this connection will handle both USB-SS and AltMode traffic.

Ah yes, good point.

Quoted 8 lines

Anyway from USB-C connector's point of view, there is no distinction which lines are USB-SS, which are AltMode. In fact platform decides in real time about muxing of SS and AltMode signals, as it depends on cable/plug orientations. Maybe instead of mapping endpoint numbers to SS/AltMode, we should map them to SS1/SS2 lines if necessary(???).

To be sure of your intentions. Do you want to model simple SS muxes as a part of USB-C connector?

That was, but you are right. That should be part of whatever device does the muxing.

Given you need a uC just to manage the USB-C connector, I'd guess there isn't any simple case like just a GPIO to control a mux.

Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +11 -0
+    2: Sideband use (SBU), present in USB-C.
+
+Examples
+--------
+
+1. Micro-USB connector with HS lines routed via controller (MUIC):
+
+muic-max77843 at 66 {
+    ...
+    usb_con: connector {
+            compatible = "usb-b-connector";
Quoted 8 lines

Documentation/devicetree/bindings/connector/usb-connector.txt line 42

Quoted 7 lines
Documentation/devicetree/bindings/connector/usb-connector.txt new file +7 -0
+            label = "micro-USB";
+            type = "micro";
+    };
+};
+
+2. USB-C connector attached to CC controller (s2mm005), HS lines routed
+to companion PMIC (max77865), SS lines to USB3 PHY and SBU to DisplayPort:

Having SBU to DP but no DP video path connection is wrong.

Quoted 3 lines

But it is real hardware :)
As I said earlier, DP video lines are connected to mux in USB3-PHY. I can add this explanation to the description to make it clear.

Okay.

Rob

#6 lore raw

RFC PATCH v2 2/6 dt-bindings: add bindings for Samsung micro-USB 11-pin connector

In reply to Andrzej Hajda

Samsung micro-USB 11-pin connector beside standard micro-USB pins, has pins dedicated to route MHL traffic.

---
 .../connector/samsung,usb-connector-11pin.txt      | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/connector/samsung,usb-connector-11pin.txt
Documentation/devicetree/bindings/connector/samsung,usb-connector-11pin.txt new file +51 -0
new file mode 100644
index 000000000000..c8ef1ad6732f
@@ -0,0 +1,51 @@
+Samsung micro-USB 11-pin connector
+==================================
+
+Samsung micro-USB 11-pin connector is an extension of micro-USB connector.
+It is present in multiple Samsung mobile devices.
+It has additional pins to route MHL traffic simultanously with USB.
+
+The bindings are superset of usb-connector bindings for micro-USB connector[1].
+
+Required properties:
+- compatible: must be: "samsung,usb-connector-11pin", "usb-b-connector",
+- type: must be "micro".
+
+Optional properties:
+- label: symbolic name for the connector.
+
+Required nodes:
+- any data bus to the connector should be modeled using the OF graph bindings
+  specified in bindings/graph.txt, unless the bus is between parent node and
+  the connector. Since single connector can have multpile data buses every bus
+  has assigned OF graph port number as follows:
+    0: High Speed (HS),
+    3: Mobile High-Definition Link (MHL), specific to 11-pin Samsung micro-USB.
+
+[1]: bindings/connector/usb-connector.txt
+
+Example
+-------
+
+Micro-USB connector with HS lines routed via controller (MUIC) and :
+
+muic-max77843 at 66 {
+	...
+	usb_con: connector {
+		compatible = "samsung,usb-connector-11pin", "usb-b-connector";
+		label = "micro-USB";
+		type = "micro";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port at 3 {
+				reg = <3>;
+				usb_con_mhl: endpoint {
+					remote-endpoint = <&sii8620_mhl>;
+				};
+			};
+		};
+	};
+};
Signature · 1 line
2.16.1
maintainer Reviewed-by on v2 2/6
#7 lore raw

Re: [RFC PATCH v2 2/6] dt-bindings: add bindings for Samsung micro-USB 11-pin connector

Quoted 20 lines · Andrzej Hajda

Samsung micro-USB 11-pin connector beside standard micro-USB pins, has pins dedicated to route MHL traffic.

---
 .../connector/samsung,usb-connector-11pin.txt      | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/connector/samsung,usb-connector-11pin.txt
Documentation/devicetree/bindings/connector/samsung,usb-connector-11pin.txt new file +5 -0
new file mode 100644
index 000000000000..c8ef1ad6732f
@@ -0,0 +1,51 @@
+Samsung micro-USB 11-pin connector
+==================================
+
+Samsung micro-USB 11-pin connector is an extension of micro-USB connector.
+It is present in multiple Samsung mobile devices.

Documentation/devicetree/bindings/connector/samsung,usb-connector-11pin.txt line 15

Quoted 10 lines
Documentation/devicetree/bindings/connector/samsung,usb-connector-11pin.txt new file +10 -0
+It has additional pins to route MHL traffic simultanously with USB.
+
+The bindings are superset of usb-connector bindings for micro-USB connector[1].
+
+Required properties:
+- compatible: must be: "samsung,usb-connector-11pin", "usb-b-connector",
+- type: must be "micro".
+
+Optional properties:
+- label: symbolic name for the connector.

This is already defined in [1] so you don't need it here.

Otherwise,

Quoted 39 lines
Documentation/devicetree/bindings/connector/samsung,usb-connector-11pin.txt new file +36 -0
+
+Required nodes:
+- any data bus to the connector should be modeled using the OF graph bindings
+  specified in bindings/graph.txt, unless the bus is between parent node and
+  the connector. Since single connector can have multpile data buses every bus
+  has assigned OF graph port number as follows:
+    0: High Speed (HS),
+    3: Mobile High-Definition Link (MHL), specific to 11-pin Samsung micro-USB.
+
+[1]: bindings/connector/usb-connector.txt
+
+Example
+-------
+
+Micro-USB connector with HS lines routed via controller (MUIC) and :
+
+muic-max77843 at 66 {
+	...
+	usb_con: connector {
+		compatible = "samsung,usb-connector-11pin", "usb-b-connector";
+		label = "micro-USB";
+		type = "micro";
+
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port at 3 {
+				reg = <3>;
+				usb_con_mhl: endpoint {
+					remote-endpoint = <&sii8620_mhl>;
+				};
+			};
+		};
+	};
+};
Signature · 1 line
2.16.1
#8 lore raw

RFC PATCH v2 3/6 arm64: dts: exynos: add micro-USB connector node to TM2 platforms

In reply to Andrzej Hajda

Since USB connector bindings are available we can describe it on TM2(e).

---
 arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi +7 -0
index a1e93d91a3ed..7e49fadee412 100644
@@ -798,6 +798,13 @@
 
 		muic: max77843-muic {
 			compatible = "maxim,max77843-muic";
+
+			musb_con: musb_connector {
+				compatible = "samsung,usb-connector-11pin",
+					     "usb-b-connector";
+				label = "micro-USB";
+				type = "micro";
+			};
 		};
 
 		regulators {
Signature · 1 line
2.16.1
#9 lore raw

RFC PATCH v2 4/6 arm64: dts: exynos: add OF graph between MHL and USB connector

In reply to Andrzej Hajda

OF graph describes MHL data lanes between MHL and respective USB connector.

---
 .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 31 +++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi +28 -3
index 7e49fadee412..ef758f7337e9 100644
@@ -779,9 +779,22 @@
 		clocks = <&pmu_system_controller 0>;
 		clock-names = "xtal";
 
-		port {
-			mhl_to_hdmi: endpoint {
-				remote-endpoint = <&hdmi_to_mhl>;
+		ports {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			port at 0 {
+				reg = <0>;
+				mhl_to_hdmi: endpoint {
+					remote-endpoint = <&hdmi_to_mhl>;
+				};
+			};
+
+			port at 1 {
+				reg = <1>;
+				mhl_to_musb_con: endpoint {
+					remote-endpoint = <&musb_con_to_mhl>;
+				};
 			};
 		};
 	};
@@ -804,6 +817,18 @@
 					     "usb-b-connector";
 				label = "micro-USB";
 				type = "micro";
+
+				ports {
+					#address-cells = <1>;
+					#size-cells = <0>;
+
+					port at 3 {
+						musb_con_to_mhl: endpoint {
+							remote-endpoint = <&mhl_to_musb_con>;
+						};
+					};
+				};
+			};
 			};
 		};
 
Signature · 1 line
2.16.1
#10 lore raw

Re: [RFC PATCH v2 4/6] arm64: dts: exynos: add OF graph between MHL and USB connector

Quoted 39 lines · Andrzej Hajda

OF graph describes MHL data lanes between MHL and respective USB connector.

---
 .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 31 +++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi +16 -3
index 7e49fadee412..ef758f7337e9 100644
@@ -779,9 +779,22 @@
                clocks = <&pmu_system_controller 0>;
                clock-names = "xtal";
 
-               port {
-                       mhl_to_hdmi: endpoint {
-                               remote-endpoint = <&hdmi_to_mhl>;
+               ports {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+
+                       port at 0 {
+                               reg = <0>;
+                               mhl_to_hdmi: endpoint {
+                                       remote-endpoint = <&hdmi_to_mhl>;
+                               };
+                       };
+
+                       port at 1 {
+                               reg = <1>;
+                               mhl_to_musb_con: endpoint {
+                                       remote-endpoint = <&musb_con_to_mhl>;
+                               };
                        };
                };
        };

arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi line 825

Quoted 9 lines
arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi +6 -0
@@ -804,6 +817,18 @@
                                             "usb-b-connector";
                                label = "micro-USB";
                                type = "micro";
+
+                               ports {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       port at 3 {

I think you might need here "reg = <3>". Doesn't it produce a warning now?

BR,
Krzysztof

Quoted 12 lines
arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi +6 -1
+                                               musb_con_to_mhl: endpoint {
+                                                       remote-endpoint = <&mhl_to_musb_con>;
+                                               };
+                                       };
+                               };
+                       };
                        };
                };
 
--

2.16.1

#11 lore raw

Re: [RFC PATCH v2 4/6] arm64: dts: exynos: add OF graph between MHL and USB connector

Quoted 42 lines · Krzysztof Kozlowski
Quoted 41 lines · Andrzej Hajda

OF graph describes MHL data lanes between MHL and respective USB connector.

---
 .../boot/dts/exynos/exynos5433-tm2-common.dtsi     | 31 +++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi +16 -3
index 7e49fadee412..ef758f7337e9 100644
@@ -779,9 +779,22 @@
                clocks = <&pmu_system_controller 0>;
                clock-names = "xtal";
 
-               port {
-                       mhl_to_hdmi: endpoint {
-                               remote-endpoint = <&hdmi_to_mhl>;
+               ports {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+
+                       port@0 {
+                               reg = <0>;
+                               mhl_to_hdmi: endpoint {
+                                       remote-endpoint = <&hdmi_to_mhl>;
+                               };
+                       };
+
+                       port@1 {
+                               reg = <1>;
+                               mhl_to_musb_con: endpoint {
+                                       remote-endpoint = <&musb_con_to_mhl>;
+                               };
                        };
                };
        };
@@ -804,6 +817,18 @@
                                             "usb-b-connector";
                                label = "micro-USB";
Quoted 8 lines

arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi

Quoted 7 lines
arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi +6 -0
                                type = "micro";
+
+                               ports {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       port@3 {

I think you might need here "reg = <3>". Doesn't it produce a warning now?

You are right, I will fix it. Warning is produced only if compiled with W=1.

Regards
Andrzej

Quoted 13 lines

BR,
Krzysztof

Quoted 9 lines
arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi +6 -0
+                                               musb_con_to_mhl: endpoint {
+                                                       remote-endpoint = <&mhl_to_musb_con>;
+                                               };
+                                       };
+                               };
+                       };
                        };
                };
 
Quoted 10 lines
Quoted 3 lines

--
2.16.1

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

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

#12 lore raw

RFC PATCH v2 5/6 extcon: add possibility to get extcon device by OF node

In reply to Andrzej Hajda

Since extcon property is not allowed in DT, extcon subsystem requires another way to get extcon device. Lets try the simplest approach - get edev by of_node.

---
v2: changed label to follow local convention (Chanwoo)

---
 drivers/extcon/extcon.c | 44 ++++++++++++++++++++++++++++++++++----------
 include/linux/extcon.h  |  6 ++++++
 2 files changed, 40 insertions(+), 10 deletions(-)
drivers/extcon/extcon.c +34 -10
index cb38c2747684..c4972c4cb3bd 100644
@@ -1336,6 +1336,28 @@ void extcon_dev_unregister(struct extcon_dev *edev)
 EXPORT_SYMBOL_GPL(extcon_dev_unregister);
 
 #ifdef CONFIG_OF
+
+/*
+ * extcon_get_edev_by_of_node - Get the extcon device from devicetree.
+ * @node	: OF node identyfying edev
+ *
+ * Return the pointer of extcon device if success or ERR_PTR(err) if fail.
+ */
+struct extcon_dev *extcon_get_edev_by_of_node(struct device_node *node)
+{
+	struct extcon_dev *edev;
+
+	mutex_lock(&extcon_dev_list_lock);
+	list_for_each_entry(edev, &extcon_dev_list, entry)
+		if (edev->dev.parent && edev->dev.parent->of_node == node)
+			goto out;
+	edev = ERR_PTR(-EPROBE_DEFER);
+out:
+	mutex_unlock(&extcon_dev_list_lock);
+
+	return edev;
+}
+
 /*
  * extcon_get_edev_by_phandle - Get the extcon device from devicetree.
  * @dev		: the instance to the given device
@@ -1363,25 +1385,27 @@ struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
 		return ERR_PTR(-ENODEV);
 	}
 
-	mutex_lock(&extcon_dev_list_lock);
-	list_for_each_entry(edev, &extcon_dev_list, entry) {
-		if (edev->dev.parent && edev->dev.parent->of_node == node) {
-			mutex_unlock(&extcon_dev_list_lock);
-			of_node_put(node);
-			return edev;
-		}
-	}
-	mutex_unlock(&extcon_dev_list_lock);
+	edev = extcon_get_edev_by_of_node(node);
 	of_node_put(node);
 
-	return ERR_PTR(-EPROBE_DEFER);
+	return edev;
 }
+
 #else
+
+struct extcon_dev *extcon_get_edev_by_of_node(struct device_node *node)
+{
+	return ERR_PTR(-ENOSYS);
+}
+
 struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev, int index)
 {
 	return ERR_PTR(-ENOSYS);
 }
+
 #endif /* CONFIG_OF */
+
+EXPORT_SYMBOL_GPL(extcon_get_edev_by_of_node);
 EXPORT_SYMBOL_GPL(extcon_get_edev_by_phandle);
 
 /**
include/linux/extcon.h +6 -0
index 6d94e82c8ad9..b47e0c7f01fe 100644
@@ -230,6 +230,7 @@ extern void devm_extcon_unregister_notifier_all(struct device *dev,
  * Following APIs get the extcon_dev from devicetree or by through extcon name.
  */
 extern struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name);
+extern struct extcon_dev *extcon_get_edev_by_of_node(struct device_node *node);
 extern struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
 						     int index);
 
@@ -283,6 +284,11 @@ static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name)
 	return ERR_PTR(-ENODEV);
 }
 
+static inline struct extcon_dev *extcon_get_edev_by_of_node(struct device_node *node)
+{
+	return ERR_PTR(-ENODEV);
+}
+
 static inline struct extcon_dev *extcon_get_edev_by_phandle(struct device *dev,
 				int index)
 {
Signature · 1 line
2.16.1
#13 lore raw

RFC PATCH v2 6/6 drm/bridge/sii8620: use micro-USB cable detection logic to detect MHL

In reply to Andrzej Hajda

From: Maciej Purski <[email protected]>

Currently MHL chip must be turned on permanently to detect MHL cable. It duplicates micro-USB controller's (MUIC) functionality and consumes unnecessary power. Lets use extcon attached to MUIC to enable MHL chip only if it detects MHL cable.

---
This is rework of the patch by Maciej with following changes:
- use micro-USB port bindings to get extcon, instead of extcon property,
- fixed remove sequence,
- fixed extcon get state logic.

Code finding extcon node is hacky IMO, I guess ultimately it should be done via some framework (maybe even extcon), or at least via helper, I hope it can stay as is until the proper solution will be merged.

---
 drivers/gpu/drm/bridge/sil-sii8620.c | 97 ++++++++++++++++++++++++++++++++++--
 1 file changed, 94 insertions(+), 3 deletions(-)
drivers/gpu/drm/bridge/sil-sii8620.c +94 -3
index 9e785b8e0ea2..565cc352ca81 100644
@@ -17,6 +17,7 @@
 
 #include <linux/clk.h>
 #include <linux/delay.h>
+#include <linux/extcon.h>
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
@@ -25,6 +26,7 @@
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/of_graph.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
 
@@ -81,6 +83,10 @@ struct sii8620 {
 	struct edid *edid;
 	unsigned int gen2_write_burst:1;
 	enum sii8620_mt_state mt_state;
+	struct extcon_dev *extcon;
+	struct notifier_block extcon_nb;
+	struct work_struct extcon_wq;
+	int cable_state;
 	struct list_head mt_queue;
 	struct {
 		int r_size;
@@ -2175,6 +2181,77 @@ static void sii8620_init_rcp_input_dev(struct sii8620 *ctx)
 	ctx->rc_dev = rc_dev;
 }
 
+static void sii8620_cable_out(struct sii8620 *ctx)
+{
+	disable_irq(to_i2c_client(ctx->dev)->irq);
+	sii8620_hw_off(ctx);
+}
+
+static void sii8620_extcon_work(struct work_struct *work)
+{
+	struct sii8620 *ctx =
+		container_of(work, struct sii8620, extcon_wq);
+	int state = extcon_get_state(ctx->extcon, EXTCON_DISP_MHL);
+
+	if (state == ctx->cable_state)
+		return;
+
+	ctx->cable_state = state;
+
+	if (state > 0)
+		sii8620_cable_in(ctx);
+	else
+		sii8620_cable_out(ctx);
+}
+
+static int sii8620_extcon_notifier(struct notifier_block *self,
+			unsigned long event, void *ptr)
+{
+	struct sii8620 *ctx =
+		container_of(self, struct sii8620, extcon_nb);
+
+	schedule_work(&ctx->extcon_wq);
+
+	return NOTIFY_DONE;
+}
+
+static int sii8620_extcon_init(struct sii8620 *ctx)
+{
+	struct extcon_dev *edev;
+	struct device_node *musb, *muic;
+	int ret;
+
+	/* get micro-USB connector node */
+	musb = of_graph_get_remote_node(ctx->dev->of_node, 1, -1);
+	/* next get micro-USB Interface Controller node */
+	muic = of_get_next_parent(musb);
+
+	if (!muic) {
+		dev_info(ctx->dev, "no extcon found, switching to 'always on' mode\n");
+		return 0;
+	}
+
+	edev = extcon_get_edev_by_of_node(muic);
+	of_node_put(muic);
+	if (IS_ERR(edev)) {
+		if (PTR_ERR(edev) == -EPROBE_DEFER)
+			return -EPROBE_DEFER;
+		dev_err(ctx->dev, "Invalid or missing extcon\n");
+		return PTR_ERR(edev);
+	}
+
+	ctx->extcon = edev;
+	ctx->extcon_nb.notifier_call = sii8620_extcon_notifier;
+	INIT_WORK(&ctx->extcon_wq, sii8620_extcon_work);
+	ret = extcon_register_notifier(edev, EXTCON_DISP_MHL, &ctx->extcon_nb);
+	if (ret) {
+		dev_err(ctx->dev, "failed to register notifier for MHL\n");
+		return ret;
+	}
+
+	return 0;
+}
+
 static inline struct sii8620 *bridge_to_sii8620(struct drm_bridge *bridge)
 {
 	return container_of(bridge, struct sii8620, bridge);
@@ -2307,13 +2384,20 @@ static int sii8620_probe(struct i2c_client *client,
 	if (ret)
 		return ret;
 
+	ret = sii8620_extcon_init(ctx);
+	if (ret < 0) {
+		dev_err(ctx->dev, "failed to initialize EXTCON\n");
+		return ret;
+	}
+
 	i2c_set_clientdata(client, ctx);
 
 	ctx->bridge.funcs = &sii8620_bridge_funcs;
 	ctx->bridge.of_node = dev->of_node;
 	drm_bridge_add(&ctx->bridge);
 
-	sii8620_cable_in(ctx);
+	if (!ctx->extcon)
+		sii8620_cable_in(ctx);
 
 	return 0;
 }
@@ -2322,8 +2406,15 @@ static int sii8620_remove(struct i2c_client *client)
 {
 	struct sii8620 *ctx = i2c_get_clientdata(client);
 
-	disable_irq(to_i2c_client(ctx->dev)->irq);
-	sii8620_hw_off(ctx);
+	if (ctx->extcon) {
+		extcon_unregister_notifier(ctx->extcon, EXTCON_DISP_MHL,
+					   &ctx->extcon_nb);
+		flush_work(&ctx->extcon_wq);
+		if (ctx->cable_state > 0)
+			sii8620_cable_out(ctx);
+	} else {
+		sii8620_cable_out(ctx);
+	}
 	drm_bridge_remove(&ctx->bridge);
 
 	return 0;
Signature · 1 line
2.16.1