linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call
@ 2016-12-15  7:53 Manish Narani
  2017-01-02  6:30 ` Manish Narani
  0 siblings, 1 reply; 9+ messages in thread
From: Manish Narani @ 2016-12-15  7:53 UTC (permalink / raw)
  To: mathias.nyman, gregkh, linux-usb, linux-kernel
  Cc: anuragku, punnaia, anirudh, mnarani

This patch will add support for OTG host initialization. This will
help OTG drivers to populate their host subsystem.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
---
 drivers/usb/host/xhci-plat.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ddfab30..aa08bdd 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -19,6 +19,7 @@
 #include <linux/usb/phy.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/usb/otg.h>
 
 #include "xhci.h"
 #include "xhci-plat.h"
@@ -144,6 +145,37 @@ static const struct of_device_id usb_xhci_of_match[] = {
 MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
 #endif
 
+static int usb_otg_set_host(struct device *dev, struct usb_hcd *hcd, bool yes)
+{
+	int ret = 0;
+
+	hcd->usb_phy = usb_get_phy(USB_PHY_TYPE_USB3);
+	if (!IS_ERR_OR_NULL(hcd->usb_phy) && hcd->usb_phy->otg) {
+		dev_dbg(dev, "%s otg support available\n", __func__);
+		if (yes) {
+			if (otg_set_host(hcd->usb_phy->otg, &hcd->self)) {
+				dev_err(dev, "%s otg_set_host failed\n",
+						__func__);
+				usb_put_phy(hcd->usb_phy);
+				goto disable_phy;
+			}
+		} else {
+			ret = otg_set_host(hcd->usb_phy->otg, NULL);
+			usb_put_phy(hcd->usb_phy);
+			goto disable_phy;
+		}
+
+	} else
+		goto disable_phy;
+
+	return 0;
+
+disable_phy:
+	hcd->usb_phy = NULL;
+
+	return ret;
+}
+
 static int xhci_plat_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *match;
@@ -255,6 +287,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	if (ret)
 		goto dealloc_usb2_hcd;
 
+	ret = usb_otg_set_host(&pdev->dev, hcd, 1);
+	if (ret)
+		goto dealloc_usb2_hcd;
+
+
 	return 0;
 
 
@@ -283,6 +320,8 @@ static int xhci_plat_remove(struct platform_device *dev)
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
 	struct clk *clk = xhci->clk;
 
+	usb_otg_set_host(&dev->dev, hcd, 0);
+
 	usb_remove_hcd(xhci->shared_hcd);
 	usb_phy_shutdown(hcd->usb_phy);
 
-- 
2.1.1

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

* RE: [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call
  2016-12-15  7:53 [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call Manish Narani
@ 2017-01-02  6:30 ` Manish Narani
  2017-01-02  9:22   ` gregkh
  0 siblings, 1 reply; 9+ messages in thread
From: Manish Narani @ 2017-01-02  6:30 UTC (permalink / raw)
  To: Manish Narani, mathias.nyman, gregkh, linux-usb, linux-kernel
  Cc: Anurag Kumar Vulisha, Punnaiah Choudary Kalluri, Anirudha Sarangi

Ping !!

-----Original Message-----
From: Manish Narani [mailto:manish.narani@xilinx.com]
Sent: Thursday, December 15, 2016 1:24 PM
To: mathias.nyman@intel.com; gregkh@linuxfoundation.org; linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org
Cc: Anurag Kumar Vulisha <anuragku@xilinx.com>; Punnaiah Choudary Kalluri <punnaia@xilinx.com>; Anirudha Sarangi <anirudh@xilinx.com>; Manish Narani <MNARANI@xilinx.com>
Subject: [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call

This patch will add support for OTG host initialization. This will help OTG drivers to populate their host subsystem.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
---
 drivers/usb/host/xhci-plat.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index ddfab30..aa08bdd 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -19,6 +19,7 @@
 #include <linux/usb/phy.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/usb/otg.h>

 #include "xhci.h"
 #include "xhci-plat.h"
@@ -144,6 +145,37 @@ static const struct of_device_id usb_xhci_of_match[] = {  MODULE_DEVICE_TABLE(of, usb_xhci_of_match);  #endif

+static int usb_otg_set_host(struct device *dev, struct usb_hcd *hcd,
+bool yes) {
+       int ret = 0;
+
+       hcd->usb_phy = usb_get_phy(USB_PHY_TYPE_USB3);
+       if (!IS_ERR_OR_NULL(hcd->usb_phy) && hcd->usb_phy->otg) {
+               dev_dbg(dev, "%s otg support available\n", __func__);
+               if (yes) {
+                       if (otg_set_host(hcd->usb_phy->otg, &hcd->self)) {
+                               dev_err(dev, "%s otg_set_host failed\n",
+                                               __func__);
+                               usb_put_phy(hcd->usb_phy);
+                               goto disable_phy;
+                       }
+               } else {
+                       ret = otg_set_host(hcd->usb_phy->otg, NULL);
+                       usb_put_phy(hcd->usb_phy);
+                       goto disable_phy;
+               }
+
+       } else
+               goto disable_phy;
+
+       return 0;
+
+disable_phy:
+       hcd->usb_phy = NULL;
+
+       return ret;
+}
+
 static int xhci_plat_probe(struct platform_device *pdev)  {
        const struct of_device_id *match;
@@ -255,6 +287,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
        if (ret)
                goto dealloc_usb2_hcd;

+       ret = usb_otg_set_host(&pdev->dev, hcd, 1);
+       if (ret)
+               goto dealloc_usb2_hcd;
+
+
        return 0;


@@ -283,6 +320,8 @@ static int xhci_plat_remove(struct platform_device *dev)
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
        struct clk *clk = xhci->clk;

+       usb_otg_set_host(&dev->dev, hcd, 0);
+
        usb_remove_hcd(xhci->shared_hcd);
        usb_phy_shutdown(hcd->usb_phy);

--
2.1.1



This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

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

* Re: [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call
  2017-01-02  6:30 ` Manish Narani
@ 2017-01-02  9:22   ` gregkh
  2017-01-02  9:35     ` Manish Narani
  0 siblings, 1 reply; 9+ messages in thread
From: gregkh @ 2017-01-02  9:22 UTC (permalink / raw)
  To: Manish Narani
  Cc: Manish Narani, mathias.nyman, linux-usb, linux-kernel,
	Anurag Kumar Vulisha, Punnaiah Choudary Kalluri,
	Anirudha Sarangi

On Mon, Jan 02, 2017 at 06:30:02AM +0000, Manish Narani wrote:
> Ping !!
> 
> -----Original Message-----
> From: Manish Narani [mailto:manish.narani@xilinx.com]
> Sent: Thursday, December 15, 2016 1:24 PM
> To: mathias.nyman@intel.com; gregkh@linuxfoundation.org; linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org
> Cc: Anurag Kumar Vulisha <anuragku@xilinx.com>; Punnaiah Choudary Kalluri <punnaia@xilinx.com>; Anirudha Sarangi <anirudh@xilinx.com>; Manish Narani <MNARANI@xilinx.com>
> Subject: [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call
> 
> This patch will add support for OTG host initialization. This will help OTG drivers to populate their host subsystem.

Don't add new infrastructure that is not used at all :(

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

* RE: [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call
  2017-01-02  9:22   ` gregkh
@ 2017-01-02  9:35     ` Manish Narani
  2017-01-02  9:59       ` gregkh
  0 siblings, 1 reply; 9+ messages in thread
From: Manish Narani @ 2017-01-02  9:35 UTC (permalink / raw)
  To: gregkh
  Cc: mathias.nyman, linux-usb, linux-kernel, Anurag Kumar Vulisha,
	Punnaiah Choudary Kalluri, Anirudha Sarangi

Hi Greg,


I need to have this infrastructure while implementing DWC3 OTG driver. The current scenario is that we are using xHCI drivers with High-Speed OTG because DWC3 uses xHCI framework. So I wanted to confirm that before adding DWC3 OTG driver, this support should be already there. I am planning to add DWC3 OTG driver after this patch is added.

Please let me know your valuable suggestions on this.


Thanks,
Manish

-----Original Message-----
From: gregkh@linuxfoundation.org [mailto:gregkh@linuxfoundation.org]
Sent: Monday, January 02, 2017 2:53 PM
To: Manish Narani <MNARANI@xilinx.com>
Cc: Manish Narani <MNARANI@xilinx.com>; mathias.nyman@intel.com; linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org; Anurag Kumar Vulisha <anuragku@xilinx.com>; Punnaiah Choudary Kalluri <punnaia@xilinx.com>; Anirudha Sarangi <anirudh@xilinx.com>
Subject: Re: [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call

On Mon, Jan 02, 2017 at 06:30:02AM +0000, Manish Narani wrote:
> Ping !!
>
> -----Original Message-----
> From: Manish Narani [mailto:manish.narani@xilinx.com]
> Sent: Thursday, December 15, 2016 1:24 PM
> To: mathias.nyman@intel.com; gregkh@linuxfoundation.org; linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org
> Cc: Anurag Kumar Vulisha <anuragku@xilinx.com>; Punnaiah Choudary Kalluri <punnaia@xilinx.com>; Anirudha Sarangi <anirudh@xilinx.com>; Manish Narani <MNARANI@xilinx.com>
> Subject: [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call
>
> This patch will add support for OTG host initialization. This will help OTG drivers to populate their host subsystem.

Don't add new infrastructure that is not used at all :(


This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

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

* Re: [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call
  2017-01-02  9:35     ` Manish Narani
@ 2017-01-02  9:59       ` gregkh
  0 siblings, 0 replies; 9+ messages in thread
From: gregkh @ 2017-01-02  9:59 UTC (permalink / raw)
  To: Manish Narani
  Cc: mathias.nyman, linux-usb, linux-kernel, Anurag Kumar Vulisha,
	Punnaiah Choudary Kalluri, Anirudha Sarangi


Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Mon, Jan 02, 2017 at 09:35:21AM +0000, Manish Narani wrote:
> Hi Greg,
> 
> 
> I need to have this infrastructure while implementing DWC3 OTG driver.
> The current scenario is that we are using xHCI drivers with High-Speed
> OTG because DWC3 uses xHCI framework. So I wanted to confirm that
> before adding DWC3 OTG driver, this support should be already there. I
> am planning to add DWC3 OTG driver after this patch is added.
> 
> Please let me know your valuable suggestions on this.

Post your whole series, that shows how you are using the new
infrastructure, otherwise how are we supposed to know this?

thanks,

greg k-h

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

* [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call
  2017-01-04 13:22 [RFC PATCH] arch: arm64: dts: add USB OTG interrupts support in ZynqMP device tree Manish Narani
@ 2017-01-04 13:23 ` Manish Narani
  0 siblings, 0 replies; 9+ messages in thread
From: Manish Narani @ 2017-01-04 13:23 UTC (permalink / raw)
  To: robh+dt, mark.rutland, catalin.marinas, will.deacon,
	michal.simek, soren.brinkmann, balbi, gregkh, mathias.nyman,
	agraf, bharatku, punnaiah.choudary.kalluri, dhdang, marc.zyngier,
	mnarani, devicetree, linux-arm-kernel, linux-kernel, linux-usb
  Cc: anirudh, anuragku

This patch will add support for OTG host initialization. This will
help OTG drivers to populate their host subsystem.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
---
 drivers/usb/host/xhci-plat.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ddfab30..aa08bdd 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -19,6 +19,7 @@
 #include <linux/usb/phy.h>
 #include <linux/slab.h>
 #include <linux/acpi.h>
+#include <linux/usb/otg.h>
 
 #include "xhci.h"
 #include "xhci-plat.h"
@@ -144,6 +145,37 @@ static const struct of_device_id usb_xhci_of_match[] = {
 MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
 #endif
 
+static int usb_otg_set_host(struct device *dev, struct usb_hcd *hcd, bool yes)
+{
+	int ret = 0;
+
+	hcd->usb_phy = usb_get_phy(USB_PHY_TYPE_USB3);
+	if (!IS_ERR_OR_NULL(hcd->usb_phy) && hcd->usb_phy->otg) {
+		dev_dbg(dev, "%s otg support available\n", __func__);
+		if (yes) {
+			if (otg_set_host(hcd->usb_phy->otg, &hcd->self)) {
+				dev_err(dev, "%s otg_set_host failed\n",
+						__func__);
+				usb_put_phy(hcd->usb_phy);
+				goto disable_phy;
+			}
+		} else {
+			ret = otg_set_host(hcd->usb_phy->otg, NULL);
+			usb_put_phy(hcd->usb_phy);
+			goto disable_phy;
+		}
+
+	} else
+		goto disable_phy;
+
+	return 0;
+
+disable_phy:
+	hcd->usb_phy = NULL;
+
+	return ret;
+}
+
 static int xhci_plat_probe(struct platform_device *pdev)
 {
 	const struct of_device_id *match;
@@ -255,6 +287,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	if (ret)
 		goto dealloc_usb2_hcd;
 
+	ret = usb_otg_set_host(&pdev->dev, hcd, 1);
+	if (ret)
+		goto dealloc_usb2_hcd;
+
+
 	return 0;
 
 
@@ -283,6 +320,8 @@ static int xhci_plat_remove(struct platform_device *dev)
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
 	struct clk *clk = xhci->clk;
 
+	usb_otg_set_host(&dev->dev, hcd, 0);
+
 	usb_remove_hcd(xhci->shared_hcd);
 	usb_phy_shutdown(hcd->usb_phy);
 
-- 
2.1.1

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

* RE: [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call
  2016-12-14 20:58 ` Greg KH
@ 2016-12-15 12:10   ` Manish Narani
  0 siblings, 0 replies; 9+ messages in thread
From: Manish Narani @ 2016-12-15 12:10 UTC (permalink / raw)
  To: Greg KH
  Cc: mathias.nyman, linux-usb, linux-kernel, Anurag Kumar Vulisha,
	Punnaiah Choudary Kalluri, Anirudha Sarangi

Thanks Greg. I have send another patch with changes as per your suggestions. Please review it and let me know if you have any concerns.

- Manish

-----Original Message-----
From: Greg KH [mailto:gregkh@linuxfoundation.org]
Sent: Thursday, December 15, 2016 2:29 AM
To: Manish Narani <MNARANI@xilinx.com>
Cc: mathias.nyman@intel.com; linux-usb@vger.kernel.org; linux-kernel@vger.kernel.org; Anurag Kumar Vulisha <anuragku@xilinx.com>; Punnaiah Choudary Kalluri <punnaia@xilinx.com>; Anirudha Sarangi <anirudh@xilinx.com>; Manish Narani <MNARANI@xilinx.com>
Subject: Re: [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call

On Thu, Dec 15, 2016 at 12:25:08AM +0530, Manish Narani wrote:
> This patch will add support for OTG host initialization. This will
> help OTG drivers to populate their host subsystem.
>
> Signed-off-by: Manish Narani <mnarani@xilinx.com>
> ---
>  drivers/usb/host/xhci-plat.c |   35 +++++++++++++++++++++++++++++++++++
>  1 files changed, 35 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c
> b/drivers/usb/host/xhci-plat.c index ddfab30..b4cadbd 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -20,6 +20,10 @@
>  #include <linux/slab.h>
>  #include <linux/acpi.h>
>
> +#ifdef CONFIG_USB_OTG
> +#include <linux/usb/otg.h>
> +#endif

never use a #ifdef in a .c file if at all possible.  Here you don't need it at all.

> +
>  #include "xhci.h"
>  #include "xhci-plat.h"
>  #include "xhci-mvebu.h"
> @@ -255,6 +259,24 @@ static int xhci_plat_probe(struct platform_device *pdev)
>       if (ret)
>               goto dealloc_usb2_hcd;
>
> +#ifdef CONFIG_USB_OTG
> +     hcd->usb_phy = usb_get_phy(USB_PHY_TYPE_USB3);
> +     if (!IS_ERR_OR_NULL(hcd->usb_phy) && hcd->usb_phy->otg) {
> +             dev_dbg(&pdev->dev, "%s otg support available\n", __func__);
> +             ret = otg_set_host(hcd->usb_phy->otg, &hcd->self);
> +             if (ret) {
> +                     dev_err(&pdev->dev, "%s otg_set_host failed\n",
> +                                     __func__);
> +                     usb_put_phy(hcd->usb_phy);
> +                     hcd->usb_phy = NULL;
> +                     goto dealloc_usb2_hcd;
> +             }
> +     } else {
> +             usb_put_phy(hcd->usb_phy);
> +             hcd->usb_phy = NULL;
> +     }
> +#endif

Can't you wrap this in a function to get rid of this #ifdef mess?

> +
>       return 0;
>
>
> @@ -283,6 +305,19 @@ static int xhci_plat_remove(struct platform_device *dev)
>       struct xhci_hcd *xhci = hcd_to_xhci(hcd);
>       struct clk *clk = xhci->clk;
>
> +#ifdef CONFIG_USB_OTG
> +     if (hcd->usb_phy) {
> +             if (!IS_ERR(hcd->usb_phy)) {
> +                     if (hcd->usb_phy->otg)
> +                             otg_set_host(hcd->usb_phy->otg, NULL);
> +                     usb_put_phy(hcd->usb_phy);
> +             }
> +             hcd->usb_phy = NULL;
> +             if (xhci->shared_hcd)
> +                     xhci->shared_hcd->usb_phy = NULL;
> +     }
> +#endif

same here.

thanks,

greg k-h


This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

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

* Re: [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call
  2016-12-14 18:55 Manish Narani
@ 2016-12-14 20:58 ` Greg KH
  2016-12-15 12:10   ` Manish Narani
  0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2016-12-14 20:58 UTC (permalink / raw)
  To: Manish Narani
  Cc: mathias.nyman, linux-usb, linux-kernel, anuragku, punnaia,
	anirudh, mnarani

On Thu, Dec 15, 2016 at 12:25:08AM +0530, Manish Narani wrote:
> This patch will add support for OTG host initialization. This will
> help OTG drivers to populate their host subsystem.
> 
> Signed-off-by: Manish Narani <mnarani@xilinx.com>
> ---
>  drivers/usb/host/xhci-plat.c |   35 +++++++++++++++++++++++++++++++++++
>  1 files changed, 35 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index ddfab30..b4cadbd 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -20,6 +20,10 @@
>  #include <linux/slab.h>
>  #include <linux/acpi.h>
>  
> +#ifdef CONFIG_USB_OTG
> +#include <linux/usb/otg.h>
> +#endif

never use a #ifdef in a .c file if at all possible.  Here you don't need
it at all.

> +
>  #include "xhci.h"
>  #include "xhci-plat.h"
>  #include "xhci-mvebu.h"
> @@ -255,6 +259,24 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  	if (ret)
>  		goto dealloc_usb2_hcd;
>  
> +#ifdef CONFIG_USB_OTG
> +	hcd->usb_phy = usb_get_phy(USB_PHY_TYPE_USB3);
> +	if (!IS_ERR_OR_NULL(hcd->usb_phy) && hcd->usb_phy->otg) {
> +		dev_dbg(&pdev->dev, "%s otg support available\n", __func__);
> +		ret = otg_set_host(hcd->usb_phy->otg, &hcd->self);
> +		if (ret) {
> +			dev_err(&pdev->dev, "%s otg_set_host failed\n",
> +					__func__);
> +			usb_put_phy(hcd->usb_phy);
> +			hcd->usb_phy = NULL;
> +			goto dealloc_usb2_hcd;
> +		}
> +	} else {
> +		usb_put_phy(hcd->usb_phy);
> +		hcd->usb_phy = NULL;
> +	}
> +#endif

Can't you wrap this in a function to get rid of this #ifdef mess?

> +
>  	return 0;
>  
>  
> @@ -283,6 +305,19 @@ static int xhci_plat_remove(struct platform_device *dev)
>  	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
>  	struct clk *clk = xhci->clk;
>  
> +#ifdef CONFIG_USB_OTG
> +	if (hcd->usb_phy) {
> +		if (!IS_ERR(hcd->usb_phy)) {
> +			if (hcd->usb_phy->otg)
> +				otg_set_host(hcd->usb_phy->otg, NULL);
> +			usb_put_phy(hcd->usb_phy);
> +		}
> +		hcd->usb_phy = NULL;
> +		if (xhci->shared_hcd)
> +			xhci->shared_hcd->usb_phy = NULL;
> +	}
> +#endif

same here.

thanks,

greg k-h

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

* [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call
@ 2016-12-14 18:55 Manish Narani
  2016-12-14 20:58 ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Manish Narani @ 2016-12-14 18:55 UTC (permalink / raw)
  To: mathias.nyman, gregkh, linux-usb, linux-kernel
  Cc: anuragku, punnaia, anirudh, mnarani

This patch will add support for OTG host initialization. This will
help OTG drivers to populate their host subsystem.

Signed-off-by: Manish Narani <mnarani@xilinx.com>
---
 drivers/usb/host/xhci-plat.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ddfab30..b4cadbd 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -20,6 +20,10 @@
 #include <linux/slab.h>
 #include <linux/acpi.h>
 
+#ifdef CONFIG_USB_OTG
+#include <linux/usb/otg.h>
+#endif
+
 #include "xhci.h"
 #include "xhci-plat.h"
 #include "xhci-mvebu.h"
@@ -255,6 +259,24 @@ static int xhci_plat_probe(struct platform_device *pdev)
 	if (ret)
 		goto dealloc_usb2_hcd;
 
+#ifdef CONFIG_USB_OTG
+	hcd->usb_phy = usb_get_phy(USB_PHY_TYPE_USB3);
+	if (!IS_ERR_OR_NULL(hcd->usb_phy) && hcd->usb_phy->otg) {
+		dev_dbg(&pdev->dev, "%s otg support available\n", __func__);
+		ret = otg_set_host(hcd->usb_phy->otg, &hcd->self);
+		if (ret) {
+			dev_err(&pdev->dev, "%s otg_set_host failed\n",
+					__func__);
+			usb_put_phy(hcd->usb_phy);
+			hcd->usb_phy = NULL;
+			goto dealloc_usb2_hcd;
+		}
+	} else {
+		usb_put_phy(hcd->usb_phy);
+		hcd->usb_phy = NULL;
+	}
+#endif
+
 	return 0;
 
 
@@ -283,6 +305,19 @@ static int xhci_plat_remove(struct platform_device *dev)
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
 	struct clk *clk = xhci->clk;
 
+#ifdef CONFIG_USB_OTG
+	if (hcd->usb_phy) {
+		if (!IS_ERR(hcd->usb_phy)) {
+			if (hcd->usb_phy->otg)
+				otg_set_host(hcd->usb_phy->otg, NULL);
+			usb_put_phy(hcd->usb_phy);
+		}
+		hcd->usb_phy = NULL;
+		if (xhci->shared_hcd)
+			xhci->shared_hcd->usb_phy = NULL;
+	}
+#endif
+
 	usb_remove_hcd(xhci->shared_hcd);
 	usb_phy_shutdown(hcd->usb_phy);
 
-- 
1.7.1

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

end of thread, other threads:[~2017-01-04 13:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-15  7:53 [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call Manish Narani
2017-01-02  6:30 ` Manish Narani
2017-01-02  9:22   ` gregkh
2017-01-02  9:35     ` Manish Narani
2017-01-02  9:59       ` gregkh
  -- strict thread matches above, loose matches on Subject: below --
2017-01-04 13:22 [RFC PATCH] arch: arm64: dts: add USB OTG interrupts support in ZynqMP device tree Manish Narani
2017-01-04 13:23 ` [RFC PATCH] usb: host: xhci: plat: add support for otg_set_host() call Manish Narani
2016-12-14 18:55 Manish Narani
2016-12-14 20:58 ` Greg KH
2016-12-15 12:10   ` Manish Narani

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).