linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] USB: dwc3: get extcon device by OF graph bindings
       [not found] <CGME20180515121250eucas1p115e0ee3cefb47faacbd4e4583b11f6e8@eucas1p1.samsung.com>
@ 2018-05-15 12:12 ` Andrzej Hajda
       [not found]   ` <CGME20180515121251eucas1p290dce20660eb0008f6eeff30fc42443e@eucas1p2.samsung.com>
       [not found]   ` <CGME20180515121251eucas1p160dd3dcff49f0dad845ed6be98f33bbe@eucas1p1.samsung.com>
  0 siblings, 2 replies; 8+ messages in thread
From: Andrzej Hajda @ 2018-05-15 12:12 UTC (permalink / raw)
  To: open list:DESIGNWARE USB3 DRD IP DRIVER
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Felipe Balbi, Greg Kroah-Hartman, Inki Dae, Rob Herring,
	Mark Rutland, Krzysztof Kozlowski, Chanwoo Choi,
	Laurent Pinchart, linux-kernel, linux-samsung-soc

Hi,

This small patchset tries to address issue with broken DT extcon property
in case of USB controller - DWC3. It exposes similar problem as in proposed
USB connector bindings[1] - extcon device is required by devices not always
connected directly to extcon device. Here we have:
DWC3 -> USB-PHY -> MUIC -> USB-connector
                               ^
MHL-bridge---------------------^

More details and proposition of generic solution in first patch 

v2:
- rebased on latest linux-next,
- since recently dwc3 fallbacks to ID detection using internal OTG block if
  extcon property is not present, added code allowing to fallback to OTG
  block also in case of graph is not present

[1]: https://marc.info/?i=20180131134435.12216-1-a.hajda%40samsung.com

Regards
Andrzej


Andrzej Hajda (2):
  USB: dwc3: get extcon device by OF graph bindings
  arm64: dts: exynos: add OF graph between USB-PHY and MUIC

 .../dts/exynos/exynos5433-tm2-common.dtsi     | 19 ++++++++++-
 drivers/usb/dwc3/drd.c                        | 34 +++++++++++++++----
 2 files changed, 46 insertions(+), 7 deletions(-)

-- 
2.17.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] USB: dwc3: get extcon device by OF graph bindings
       [not found]   ` <CGME20180515121251eucas1p290dce20660eb0008f6eeff30fc42443e@eucas1p2.samsung.com>
@ 2018-05-15 12:12     ` Andrzej Hajda
  0 siblings, 0 replies; 8+ messages in thread
From: Andrzej Hajda @ 2018-05-15 12:12 UTC (permalink / raw)
  To: open list:DESIGNWARE USB3 DRD IP DRIVER
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Felipe Balbi, Greg Kroah-Hartman, Inki Dae, Rob Herring,
	Mark Rutland, Krzysztof Kozlowski, Chanwoo Choi,
	Laurent Pinchart, linux-kernel, linux-samsung-soc

extcon device is used to detect host/device connection. Since extcon
OF property is deprecated, alternative method should be added.
This method uses OF graph bindings to locate extcon.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/usb/dwc3/drd.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
index 1d8c557e97e0..270682486f82 100644
--- a/drivers/usb/dwc3/drd.c
+++ b/drivers/usb/dwc3/drd.c
@@ -8,6 +8,7 @@
  */
 
 #include <linux/extcon.h>
+#include <linux/of_graph.h>
 #include <linux/platform_device.h>
 
 #include "debug.h"
@@ -439,17 +440,38 @@ static int dwc3_drd_notifier(struct notifier_block *nb,
 	return NOTIFY_DONE;
 }
 
+struct extcon_dev *dwc3_get_extcon(struct dwc3 *dwc)
+{
+	struct device *dev = dwc->dev;
+	struct device_node *np_phy, *np_conn;
+	struct extcon_dev *edev;
+
+	if (of_property_read_bool(dev->of_node, "extcon"))
+		return extcon_get_edev_by_phandle(dwc->dev, 0);
+
+	np_phy = of_parse_phandle(dev->of_node, "phys", 0);
+	np_conn = of_graph_get_remote_node(np_phy, -1, -1);
+
+	if (np_conn)
+		edev = extcon_find_edev_by_node(np_conn);
+	else
+		edev = NULL;
+
+	of_node_put(np_conn);
+	of_node_put(np_phy);
+
+	return edev;
+}
+
 int dwc3_drd_init(struct dwc3 *dwc)
 {
 	int ret, irq;
 
-	if (dwc->dev->of_node &&
-	    of_property_read_bool(dwc->dev->of_node, "extcon")) {
-		dwc->edev = extcon_get_edev_by_phandle(dwc->dev, 0);
-
-		if (IS_ERR(dwc->edev))
-			return PTR_ERR(dwc->edev);
+	dwc->edev = dwc3_get_extcon(dwc);
+	if (IS_ERR(dwc->edev))
+		return PTR_ERR(dwc->edev);
 
+	if (dwc->edev) {
 		dwc->edev_nb.notifier_call = dwc3_drd_notifier;
 		ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,
 					       &dwc->edev_nb);
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] arm64: dts: exynos: add OF graph between USB-PHY and MUIC
       [not found]   ` <CGME20180515121251eucas1p160dd3dcff49f0dad845ed6be98f33bbe@eucas1p1.samsung.com>
@ 2018-05-15 12:12     ` Andrzej Hajda
  2018-05-15 12:19       ` Krzysztof Kozlowski
  2018-06-20 18:28       ` Krzysztof Kozlowski
  0 siblings, 2 replies; 8+ messages in thread
From: Andrzej Hajda @ 2018-05-15 12:12 UTC (permalink / raw)
  To: open list:DESIGNWARE USB3 DRD IP DRIVER
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Felipe Balbi, Greg Kroah-Hartman, Inki Dae, Rob Herring,
	Mark Rutland, Krzysztof Kozlowski, Chanwoo Choi,
	Laurent Pinchart, linux-kernel, linux-samsung-soc

OF graph describes USB data lanes between USB-PHY and respective MUIC.
Since graph is present and DWC driver can use it to get extcon, obsolete
extcon property can be removed.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 .../dts/exynos/exynos5433-tm2-common.dtsi     | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi b/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
index 03453b822093..042e5894a138 100644
--- a/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
+++ b/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
@@ -868,6 +868,18 @@
 					};
 				};
 			};
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port@0 {
+					reg = <0>;
+					muic_to_usb: endpoint {
+						remote-endpoint = <&usb_to_muic>;
+					};
+				};
+			};
 		};
 
 		regulators {
@@ -1287,12 +1299,17 @@
 
 &usbdrd_dwc3 {
 	dr_mode = "otg";
-	extcon = <&muic>;
 };
 
 &usbdrd30_phy {
 	vbus-supply = <&safeout1_reg>;
 	status = "okay";
+
+	port {
+		usb_to_muic: endpoint {
+			remote-endpoint = <&muic_to_usb>;
+		};
+	};
 };
 
 &xxti {
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] arm64: dts: exynos: add OF graph between USB-PHY and MUIC
  2018-05-15 12:12     ` [PATCH v2 2/2] arm64: dts: exynos: add OF graph between USB-PHY and MUIC Andrzej Hajda
@ 2018-05-15 12:19       ` Krzysztof Kozlowski
  2018-05-16  5:56         ` Felipe Balbi
  2018-06-20 18:28       ` Krzysztof Kozlowski
  1 sibling, 1 reply; 8+ messages in thread
From: Krzysztof Kozlowski @ 2018-05-15 12:19 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: open list:DESIGNWARE USB3 DRD IP DRIVER,
	Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Felipe Balbi, Greg Kroah-Hartman, Inki Dae, Rob Herring,
	Mark Rutland, Chanwoo Choi, Laurent Pinchart, linux-kernel,
	linux-samsung-soc

On Tue, May 15, 2018 at 2:12 PM, Andrzej Hajda <a.hajda@samsung.com> wrote:
> OF graph describes USB data lanes between USB-PHY and respective MUIC.
> Since graph is present and DWC driver can use it to get extcon, obsolete
> extcon property can be removed.
>
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  .../dts/exynos/exynos5433-tm2-common.dtsi     | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)

As we discussed for v1 - since this was not split into two, I'll apply
it once first patch hits mainline.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] arm64: dts: exynos: add OF graph between USB-PHY and MUIC
  2018-05-15 12:19       ` Krzysztof Kozlowski
@ 2018-05-16  5:56         ` Felipe Balbi
  0 siblings, 0 replies; 8+ messages in thread
From: Felipe Balbi @ 2018-05-16  5:56 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Andrzej Hajda
  Cc: open list:DESIGNWARE USB3 DRD IP DRIVER,
	Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Greg Kroah-Hartman, Inki Dae, Rob Herring, Mark Rutland,
	Chanwoo Choi, Laurent Pinchart, linux-kernel, linux-samsung-soc

[-- Attachment #1: Type: text/plain, Size: 680 bytes --]

Krzysztof Kozlowski <krzk@kernel.org> writes:

> On Tue, May 15, 2018 at 2:12 PM, Andrzej Hajda <a.hajda@samsung.com> wrote:
>> OF graph describes USB data lanes between USB-PHY and respective MUIC.
>> Since graph is present and DWC driver can use it to get extcon, obsolete
>> extcon property can be removed.
>>
>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
>> ---
>>  .../dts/exynos/exynos5433-tm2-common.dtsi     | 19 ++++++++++++++++++-
>>  1 file changed, 18 insertions(+), 1 deletion(-)
>
> As we discussed for v1 - since this was not split into two, I'll apply
> it once first patch hits mainline.

I just took patch 1 to my tree, fyi

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] arm64: dts: exynos: add OF graph between USB-PHY and MUIC
  2018-05-15 12:12     ` [PATCH v2 2/2] arm64: dts: exynos: add OF graph between USB-PHY and MUIC Andrzej Hajda
  2018-05-15 12:19       ` Krzysztof Kozlowski
@ 2018-06-20 18:28       ` Krzysztof Kozlowski
  2018-06-22 10:39         ` Andrzej Hajda
  1 sibling, 1 reply; 8+ messages in thread
From: Krzysztof Kozlowski @ 2018-06-20 18:28 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: open list:DESIGNWARE USB3 DRD IP DRIVER,
	Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Felipe Balbi, Greg Kroah-Hartman, Inki Dae, Rob Herring,
	Mark Rutland, Chanwoo Choi, Laurent Pinchart, linux-kernel,
	linux-samsung-soc

On Tue, May 15, 2018 at 02:12:39PM +0200, Andrzej Hajda wrote:
> OF graph describes USB data lanes between USB-PHY and respective MUIC.
> Since graph is present and DWC driver can use it to get extcon, obsolete
> extcon property can be removed.
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> ---
>  .../dts/exynos/exynos5433-tm2-common.dtsi     | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)

dtc W=1 now complains with:
===
Warning (graph_child_address):
/soc/hsi2c@14d90000/max77843@66/max77843-muic/ports: graph node has single child node 'port@0', #address-cells/#size-cells are not necessary
===

Do you plan to add more ports soon?

Best regards,
Krzysztof

> diff --git a/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi b/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
> index 03453b822093..042e5894a138 100644
> --- a/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
> +++ b/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
> @@ -868,6 +868,18 @@
>  					};
>  				};
>  			};
> +
> +			ports {
> +				#address-cells = <1>;
> +				#size-cells = <0>;
> +
> +				port@0 {
> +					reg = <0>;
> +					muic_to_usb: endpoint {
> +						remote-endpoint = <&usb_to_muic>;
> +					};
> +				};
> +			};
>  		};
>  
>  		regulators {
> @@ -1287,12 +1299,17 @@
>  
>  &usbdrd_dwc3 {
>  	dr_mode = "otg";
> -	extcon = <&muic>;
>  };
>  
>  &usbdrd30_phy {
>  	vbus-supply = <&safeout1_reg>;
>  	status = "okay";
> +
> +	port {
> +		usb_to_muic: endpoint {
> +			remote-endpoint = <&muic_to_usb>;
> +		};
> +	};
>  };
>  
>  &xxti {
> -- 
> 2.17.0
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] arm64: dts: exynos: add OF graph between USB-PHY and MUIC
  2018-06-20 18:28       ` Krzysztof Kozlowski
@ 2018-06-22 10:39         ` Andrzej Hajda
  2018-06-22 10:56           ` Krzysztof Kozlowski
  0 siblings, 1 reply; 8+ messages in thread
From: Andrzej Hajda @ 2018-06-22 10:39 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: open list:DESIGNWARE USB3 DRD IP DRIVER,
	Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Felipe Balbi, Greg Kroah-Hartman, Inki Dae, Rob Herring,
	Mark Rutland, Chanwoo Choi, Laurent Pinchart, linux-kernel,
	linux-samsung-soc

On 20.06.2018 20:28, Krzysztof Kozlowski wrote:
> On Tue, May 15, 2018 at 02:12:39PM +0200, Andrzej Hajda wrote:
>> OF graph describes USB data lanes between USB-PHY and respective MUIC.
>> Since graph is present and DWC driver can use it to get extcon, obsolete
>> extcon property can be removed.
>>
>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
>> ---
>>  .../dts/exynos/exynos5433-tm2-common.dtsi     | 19 ++++++++++++++++++-
>>  1 file changed, 18 insertions(+), 1 deletion(-)
> dtc W=1 now complains with:
> ===
> Warning (graph_child_address):
> /soc/hsi2c@14d90000/max77843@66/max77843-muic/ports: graph node has single child node 'port@0', #address-cells/#size-cells are not necessary
> ===
>
> Do you plan to add more ports soon?

There could be a link between UART and MUIC, it could be beneficial for
the platform - there is no point to feed UART with data when UART output
is muxed-out by MUIC.
So I plan to investigate it but this is not on my short list :)
Alternatively one can create graphs without using it atm.

Regards
Andrzej

>
> Best regards,
> Krzysztof
>
>> diff --git a/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi b/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
>> index 03453b822093..042e5894a138 100644
>> --- a/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
>> +++ b/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi
>> @@ -868,6 +868,18 @@
>>  					};
>>  				};
>>  			};
>> +
>> +			ports {
>> +				#address-cells = <1>;
>> +				#size-cells = <0>;
>> +
>> +				port@0 {
>> +					reg = <0>;
>> +					muic_to_usb: endpoint {
>> +						remote-endpoint = <&usb_to_muic>;
>> +					};
>> +				};
>> +			};
>>  		};
>>  
>>  		regulators {
>> @@ -1287,12 +1299,17 @@
>>  
>>  &usbdrd_dwc3 {
>>  	dr_mode = "otg";
>> -	extcon = <&muic>;
>>  };
>>  
>>  &usbdrd30_phy {
>>  	vbus-supply = <&safeout1_reg>;
>>  	status = "okay";
>> +
>> +	port {
>> +		usb_to_muic: endpoint {
>> +			remote-endpoint = <&muic_to_usb>;
>> +		};
>> +	};
>>  };
>>  
>>  &xxti {
>> -- 
>> 2.17.0
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] arm64: dts: exynos: add OF graph between USB-PHY and MUIC
  2018-06-22 10:39         ` Andrzej Hajda
@ 2018-06-22 10:56           ` Krzysztof Kozlowski
  0 siblings, 0 replies; 8+ messages in thread
From: Krzysztof Kozlowski @ 2018-06-22 10:56 UTC (permalink / raw)
  To: Andrzej Hajda
  Cc: open list:DESIGNWARE USB3 DRD IP DRIVER,
	Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS,
	Felipe Balbi, Greg Kroah-Hartman, Inki Dae, Rob Herring,
	Mark Rutland, Chanwoo Choi, Laurent Pinchart, linux-kernel,
	linux-samsung-soc

On 22 June 2018 at 12:39, Andrzej Hajda <a.hajda@samsung.com> wrote:
> On 20.06.2018 20:28, Krzysztof Kozlowski wrote:
>> On Tue, May 15, 2018 at 02:12:39PM +0200, Andrzej Hajda wrote:
>>> OF graph describes USB data lanes between USB-PHY and respective MUIC.
>>> Since graph is present and DWC driver can use it to get extcon, obsolete
>>> extcon property can be removed.
>>>
>>> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
>>> ---
>>>  .../dts/exynos/exynos5433-tm2-common.dtsi     | 19 ++++++++++++++++++-
>>>  1 file changed, 18 insertions(+), 1 deletion(-)
>> dtc W=1 now complains with:
>> ===
>> Warning (graph_child_address):
>> /soc/hsi2c@14d90000/max77843@66/max77843-muic/ports: graph node has single child node 'port@0', #address-cells/#size-cells are not necessary
>> ===
>>
>> Do you plan to add more ports soon?
>
> There could be a link between UART and MUIC, it could be beneficial for
> the platform - there is no point to feed UART with data when UART output
> is muxed-out by MUIC.
> So I plan to investigate it but this is not on my short list :)
> Alternatively one can create graphs without using it atm.

In that case could you remove here the address/size-cells to fix the
warning? I see that code uses -1 in of_graph_get_remote_node() so it
should not depend on the reg number.

Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-06-22 10:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20180515121250eucas1p115e0ee3cefb47faacbd4e4583b11f6e8@eucas1p1.samsung.com>
2018-05-15 12:12 ` [PATCH v2 0/2] USB: dwc3: get extcon device by OF graph bindings Andrzej Hajda
     [not found]   ` <CGME20180515121251eucas1p290dce20660eb0008f6eeff30fc42443e@eucas1p2.samsung.com>
2018-05-15 12:12     ` [PATCH v2 1/2] " Andrzej Hajda
     [not found]   ` <CGME20180515121251eucas1p160dd3dcff49f0dad845ed6be98f33bbe@eucas1p1.samsung.com>
2018-05-15 12:12     ` [PATCH v2 2/2] arm64: dts: exynos: add OF graph between USB-PHY and MUIC Andrzej Hajda
2018-05-15 12:19       ` Krzysztof Kozlowski
2018-05-16  5:56         ` Felipe Balbi
2018-06-20 18:28       ` Krzysztof Kozlowski
2018-06-22 10:39         ` Andrzej Hajda
2018-06-22 10:56           ` Krzysztof Kozlowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).