Re: [PATCH resend] usb: chipidea: Don't select EXTCON

2018-04-23 Thread Jisheng Zhang
On Fri, 20 Apr 2018 09:35:54 + Peter Chen wrote:

>  
> > >
> > > Sorry to reply late, are you really care 2KB code side? Since many
> > > users use EXTCON to handle vbus and id, it is hard just delete it. I
> > > could accept patch for your specific platforms, like:
> > >
> > > + select EXTCON if !ARCH_  
> > 
> > The patch doesn't remove extcon support from chipidea driver.
> > I just want to not select EXTCON unconditionally, but let the users choose. 
> > If the
> > users need extcon, they could enable EXTCON themselves
> > 
> > I just searched all the dts in arch/arm/boot/dts and arch/arm64/boot/dts 
> > only the four
> > dts give extcon phandle to chipidea host, other users don't make use of it:
> > 
> > arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi
> > 
> > arch/arm/boot/dts/qcom-apq8074-dragonboard.dts
> > 
> > arch/arm/boot/dts/qcom-msm8974-fairphone-fp2.dts
> > 
> > arch/arm/boot/dts/qcom-msm8974-sony-xperia-castor.dts
> >   
> 
> I see, but I do not want to break msm platforms. You may try to create Glue 
> driver Kconfig
> entry for chipidea like dwc3, and let msm depends on EXTCON.

Got your points. Since multi_v7_defconfig has selected EXTCON, and
EXTCON_USB_GPIO(which depends on EXTCON) is enabled in arm64 defconfig, so
what about:

enable EXTCON explicitly in arm64 defconfig?
then add this patch?

Is it acceptable?

Thanks,
Jisheng
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH resend] usb: chipidea: Don't select EXTCON

2018-04-20 Thread Jisheng Zhang
Hi Peter

On Fri, 20 Apr 2018 01:38:42 + Peter Chen wrote:

>  
> >  drivers/usb/chipidea/Kconfig | 1 -
> >  1 file changed, 1 deletion(-)
> > 
> > diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig 
> > index
> > 785f0ed037f7..97509172d536 100644
> > --- a/drivers/usb/chipidea/Kconfig
> > +++ b/drivers/usb/chipidea/Kconfig
> > @@ -1,7 +1,6 @@
> >  config USB_CHIPIDEA
> > tristate "ChipIdea Highspeed Dual Role Controller"
> > depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD
> > && !USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA
> > -   select EXTCON
> > select RESET_CONTROLLER
> > help
> >   Say Y here if your system has a dual role high speed USB
> > --
> > 2.17.0  
> 
> Hi Jisheng,
> 
> Sorry to reply late, are you really care 2KB code side? Since many users use
> EXTCON to handle vbus and id, it is hard just delete it. I could accept patch
> for your specific platforms, like:
> 
> + select EXTCON if !ARCH_

The patch doesn't remove extcon support from chipidea driver.
I just want to not select EXTCON unconditionally, but let the users
choose. If the users need extcon, they could enable EXTCON themselves

I just searched all the dts in arch/arm/boot/dts and arch/arm64/boot/dts
only the four dts give extcon phandle to chipidea host, other users
don't make use of it:

arch/arm64/boot/dts/qcom/apq8016-sbc.dtsi

arch/arm/boot/dts/qcom-apq8074-dragonboard.dts

arch/arm/boot/dts/qcom-msm8974-fairphone-fp2.dts

arch/arm/boot/dts/qcom-msm8974-sony-xperia-castor.dts

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


[PATCH resend] usb: chipidea: Don't select EXTCON

2018-04-19 Thread Jisheng Zhang
Not all chipidea users need EXTCON, so it's better to avoid
unconditionally select EXTCON, this could save us 2KB kernel Image size.

Signed-off-by: Jisheng Zhang <jisheng.zh...@synaptics.com>
---
 drivers/usb/chipidea/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig
index 785f0ed037f7..97509172d536 100644
--- a/drivers/usb/chipidea/Kconfig
+++ b/drivers/usb/chipidea/Kconfig
@@ -1,7 +1,6 @@
 config USB_CHIPIDEA
tristate "ChipIdea Highspeed Dual Role Controller"
depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && 
!USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA
-   select EXTCON
select RESET_CONTROLLER
help
  Say Y here if your system has a dual role high speed USB
-- 
2.17.0

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


[PATCH] usb: chipidea: Don't select EXTCON

2018-03-29 Thread Jisheng Zhang
Not all chipidea users need EXTCON, so it's better to avoid
unconditionally select EXTCON, this could save us 2KB kernel Image size.

Signed-off-by: Jisheng Zhang <jisheng.zh...@synaptics.com>
---
 drivers/usb/chipidea/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/chipidea/Kconfig b/drivers/usb/chipidea/Kconfig
index 785f0ed037f7..97509172d536 100644
--- a/drivers/usb/chipidea/Kconfig
+++ b/drivers/usb/chipidea/Kconfig
@@ -1,7 +1,6 @@
 config USB_CHIPIDEA
tristate "ChipIdea Highspeed Dual Role Controller"
depends on ((USB_EHCI_HCD && USB_GADGET) || (USB_EHCI_HCD && 
!USB_GADGET) || (!USB_EHCI_HCD && USB_GADGET)) && HAS_DMA
-   select EXTCON
select RESET_CONTROLLER
help
  Say Y here if your system has a dual role high speed USB
-- 
2.16.3

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


[PATCH] usb: host: xhci-plat: move clk to plat own private structure

2017-11-27 Thread Jisheng Zhang
commit 4efb2f694114 ("usb: host: xhci-plat: add struct xhci_plat_priv")
introduced struct xhci_plat_priv to hold the plat driver's specific
variables. The clk is only for plat driver, so let's move it to the
proper structure.

Signed-off-by: Jisheng Zhang <jisheng.zh...@synaptics.com>
---
 drivers/usb/host/xhci-plat.c | 17 +++--
 drivers/usb/host/xhci-plat.h |  2 ++
 drivers/usb/host/xhci.h  |  2 --
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 09f164f..4cd9162 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -152,6 +152,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 {
const struct xhci_plat_priv *priv_match;
const struct hc_driver  *driver;
+   struct xhci_plat_priv   *priv;
struct device   *sysdev;
struct xhci_hcd *xhci;
struct resource *res;
@@ -240,6 +241,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
}
 
xhci = hcd_to_xhci(hcd);
+   priv = hcd_to_xhci_priv(hcd);
priv_match = of_device_get_match_data(>dev);
if (priv_match) {
struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
@@ -251,7 +253,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 
device_wakeup_enable(hcd->self.controller);
 
-   xhci->clk = clk;
+   priv->clk = clk;
xhci->main_hcd = hcd;
xhci->shared_hcd = __usb_create_hcd(driver, sysdev, >dev,
dev_name(>dev), hcd);
@@ -331,7 +333,8 @@ static int xhci_plat_remove(struct platform_device *dev)
 {
struct usb_hcd  *hcd = platform_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
-   struct clk *clk = xhci->clk;
+   struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
+   struct clk *clk = priv->clk;
 
xhci->xhc_state |= XHCI_STATE_REMOVING;
 
@@ -355,6 +358,7 @@ static int __maybe_unused xhci_plat_suspend(struct device 
*dev)
 {
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
int ret;
 
/*
@@ -367,8 +371,8 @@ static int __maybe_unused xhci_plat_suspend(struct device 
*dev)
 */
ret = xhci_suspend(xhci, device_may_wakeup(dev));
 
-   if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
-   clk_disable_unprepare(xhci->clk);
+   if (!device_may_wakeup(dev) && !IS_ERR(priv->clk))
+   clk_disable_unprepare(priv->clk);
 
return ret;
 }
@@ -377,10 +381,11 @@ static int __maybe_unused xhci_plat_resume(struct device 
*dev)
 {
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd);
int ret;
 
-   if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk))
-   clk_prepare_enable(xhci->clk);
+   if (!device_may_wakeup(dev) && !IS_ERR(priv->clk))
+   clk_prepare_enable(priv->clk);
 
ret = xhci_priv_resume_quirk(hcd);
if (ret)
diff --git a/drivers/usb/host/xhci-plat.h b/drivers/usb/host/xhci-plat.h
index ae29f22..4d6f048 100644
--- a/drivers/usb/host/xhci-plat.h
+++ b/drivers/usb/host/xhci-plat.h
@@ -12,6 +12,8 @@
 
 struct xhci_plat_priv {
const char *firmware_name;
+   /* optional clock */
+   struct clk *clk;
void (*plat_start)(struct usb_hcd *);
int (*init_quirk)(struct usb_hcd *);
int (*resume_quirk)(struct usb_hcd *);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 99a014a..55c3441 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1724,8 +1724,6 @@ struct xhci_hcd {
int page_shift;
/* msi-x vectors */
int msix_count;
-   /* optional clock */
-   struct clk  *clk;
/* data structures */
struct xhci_device_context_array *dcbaa;
struct xhci_ring*cmd_ring;
-- 
1.9.1

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


[PATCH v2] usb: chipidea: properly handle host or gadget initialization failure

2017-04-26 Thread Jisheng Zhang
If ci_hdrc_host_init() or ci_hdrc_gadget_init() returns error and the
error != -ENXIO, as Peter pointed out, "it stands for initialization
for host or gadget has failed", so we'd better return failure rather
continue.

And before destroying the otg, i.e ci_hdrc_otg_destroy(ci), we should
also check ci->roles[CI_ROLE_GADGET].

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
Since v1:
 - check ci->roles[CI_ROLE_GADGET] before destroying the otg, suggested
   by Peter.

 drivers/usb/chipidea/core.c | 29 +
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 79ad8e91632e..0192a26ec0f9 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -821,7 +821,7 @@ static inline void ci_role_destroy(struct ci_hdrc *ci)
 {
ci_hdrc_gadget_destroy(ci);
ci_hdrc_host_destroy(ci);
-   if (ci->is_otg)
+   if (ci->is_otg && ci->roles[CI_ROLE_GADGET])
ci_hdrc_otg_destroy(ci);
 }
 
@@ -930,27 +930,35 @@ static int ci_hdrc_probe(struct platform_device *pdev)
/* initialize role(s) before the interrupt is requested */
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
ret = ci_hdrc_host_init(ci);
-   if (ret)
-   dev_info(dev, "doesn't support host\n");
+   if (ret) {
+   if (ret == -ENXIO)
+   dev_info(dev, "doesn't support host\n");
+   else
+   goto deinit_phy;
+   }
}
 
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
ret = ci_hdrc_gadget_init(ci);
-   if (ret)
-   dev_info(dev, "doesn't support gadget\n");
+   if (ret) {
+   if (ret == -ENXIO)
+   dev_info(dev, "doesn't support gadget\n");
+   else
+   goto deinit_host;
+   }
}
 
if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
dev_err(dev, "no supported roles\n");
ret = -ENODEV;
-   goto deinit_phy;
+   goto deinit_gadget;
}
 
if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) {
ret = ci_hdrc_otg_init(ci);
if (ret) {
dev_err(dev, "init otg fails, ret = %d\n", ret);
-   goto stop;
+   goto deinit_gadget;
}
}
 
@@ -1013,7 +1021,12 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return 0;
 
 stop:
-   ci_role_destroy(ci);
+   if (ci->is_otg && ci->roles[CI_ROLE_GADGET])
+   ci_hdrc_otg_destroy(ci);
+deinit_gadget:
+   ci_hdrc_gadget_destroy(ci);
+deinit_host:
+   ci_hdrc_host_destroy(ci);
 deinit_phy:
ci_usb_phy_exit(ci);
 ulpi_exit:
-- 
2.11.0

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


Re: [RFC] usb: chipidea: set dma_ops for the created ci_hdrc platform_device

2017-04-26 Thread Jisheng Zhang

On Tue, 25 Apr 2017 13:09:27 +0200 Arnd Bergmann wrote:

> On Tue, Apr 25, 2017 at 12:01 PM, Jisheng Zhang <jszh...@marvell.com> wrote:
> > Hi all,
> >
> > After commit 1dccb598df549 ("arm64: simplify dma_get_ops"), the chipidea
> > driver can't work any more on Marvell Berlin arm64 platforms, the reason
> > is the created ci_hdrc platform_device's dma_ops is dummy_dma_ops, so all
> > dma related operations will fail. The fix I can think of would be something
> > as below:
> >
> > And I noticed that dwc3 has the same issue[1], and as pointed out in its
> > discussion, the patch can't fix None-DT platforms, so could you please
> > guide me what's the proper fix which can be mainlined?  
> 
> I think the right solution is:
> 
> - Set the "sysdev" pointer tin the USB device o the device structure that
>   was created by DT or the legacy board file and remove the manual
>   setting of dma_mask,  parms and the dma_configure. This should
>   make everything work as expected in case of DT
> 

oh yeah! I see a proper fix in linux-next tree, thanks for fixing it.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: chipidea: udc: fix NULL pointer dereference if udc_start failed

2017-04-26 Thread Jisheng Zhang
On Tue, 25 Apr 2017 17:21:59 +0200
Stefan Wahren  wrote:

> Am 25.04.2017 um 11:20 schrieb Peter Chen:
> >
>  diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
>  index f88e9157fad0..60a786c87c06 100644
>  --- a/drivers/usb/chipidea/udc.c
>  +++ b/drivers/usb/chipidea/udc.c
>  @@ -1984,6 +1984,7 @@ static void udc_id_switch_for_host(struct
>  ci_hdrc *ci)  int ci_hdrc_gadget_init(struct ci_hdrc *ci)  {
>   struct ci_role_driver *rdrv;
>  +int ret;
> 
>   if (!hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DC))
>   return -ENXIO;
>  @@ -1996,7 +1997,10 @@ int ci_hdrc_gadget_init(struct ci_hdrc *ci)
>   rdrv->stop  = udc_id_switch_for_host;
>   rdrv->irq   = udc_irq;
>   rdrv->name  = "gadget";
>  -ci->roles[CI_ROLE_GADGET] = rdrv;
> 
>  -return udc_start(ci);
>  +ret = udc_start(ci);
>  +if (!ret)
>  +ci->roles[CI_ROLE_GADGET] = rdrv;
>  +
>  +return ret;
>   }
>  --  
> >>> Thanks for fixing it. In fact, we'd better return failure if ret &&
> >>> ret != -ENXIO at probe, it stands for initialization for host or
> >>> gadget has failed.
> >>>  
> >> I got your meaning. I'll cook v2. I don't have preference, since either 
> >> one can fix the
> >> issue.
> >>  
> > Both are needed, you don't need to send this one again. Only a new one, 
> > thanks.  
> 
> I'm not sure how easy it is to reproduce the issue.

It's easy to reproduce it (100%) on arm64 platforms after commit
1dccb598df549 ("arm64: simplify dma_get_ops"). This commit could
make all dma related operations failed, then udc_start() would fail
with -ENOMEM.

On other platforms, it's not easy.

> 
> Shouldn't make a Fixes tag sense at least?

maybe 3f124d233e97 ("usb: chipidea: add role init and destroy APIs"
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC] usb: chipidea: set dma_ops for the created ci_hdrc platform_device

2017-04-25 Thread Jisheng Zhang
Hi all,

After commit 1dccb598df549 ("arm64: simplify dma_get_ops"), the chipidea
driver can't work any more on Marvell Berlin arm64 platforms, the reason
is the created ci_hdrc platform_device's dma_ops is dummy_dma_ops, so all
dma related operations will fail. The fix I can think of would be something
as below:

And I noticed that dwc3 has the same issue[1], and as pointed out in its
discussion, the patch can't fix None-DT platforms, so could you please
guide me what's the proper fix which can be mainlined?

Any suggestion is appreciated!

Thanks,
Jisheng

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-April/425079.html

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 047afdbb7049..acb80457603c 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -62,6 +62,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -786,6 +787,7 @@ struct platform_device *ci_hdrc_add_device(struct device 
*dev,
pdev->dev.dma_mask = dev->dma_mask;
pdev->dev.dma_parms = dev->dma_parms;
dma_set_coherent_mask(>dev, dev->coherent_dma_mask);
+   of_dma_configure(>dev, dev->of_node);
 
ret = platform_device_add_resources(pdev, res, nres);
if (ret)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: chipidea: properly handle host or gadget initialization failure

2017-04-25 Thread Jisheng Zhang
If ci_hdrc_host_init() or ci_hdrc_gadget_init() returns error and the
error != -ENXIO, as Peter pointed out, "it stands for initialization
for host or gadget has failed", so we'd better return failure rather
continue.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/chipidea/core.c | 25 +++--
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 79ad8e91632e..047afdbb7049 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -930,20 +930,28 @@ static int ci_hdrc_probe(struct platform_device *pdev)
/* initialize role(s) before the interrupt is requested */
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
ret = ci_hdrc_host_init(ci);
-   if (ret)
-   dev_info(dev, "doesn't support host\n");
+   if (ret) {
+   if (ret == -ENXIO)
+   dev_info(dev, "doesn't support host\n");
+   else
+   goto deinit_phy;
+   }
}
 
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
ret = ci_hdrc_gadget_init(ci);
-   if (ret)
-   dev_info(dev, "doesn't support gadget\n");
+   if (ret) {
+   if (ret == -ENXIO)
+   dev_info(dev, "doesn't support gadget\n");
+   else
+   goto deinit_host;
+   }
}
 
if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
dev_err(dev, "no supported roles\n");
ret = -ENODEV;
-   goto deinit_phy;
+   goto deinit_gadget;
}
 
if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) {
@@ -1013,7 +1021,12 @@ static int ci_hdrc_probe(struct platform_device *pdev)
return 0;
 
 stop:
-   ci_role_destroy(ci);
+   if (ci->is_otg)
+   ci_hdrc_otg_destroy(ci);
+deinit_gadget:
+   ci_hdrc_gadget_destroy(ci);
+deinit_host:
+   ci_hdrc_host_destroy(ci);
 deinit_phy:
ci_usb_phy_exit(ci);
 ulpi_exit:
-- 
2.11.0

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


Re: [PATCH] usb: chipidea: udc: fix NULL pointer dereference if udc_start failed

2017-04-25 Thread Jisheng Zhang
Hi Peter,

On Tue, 25 Apr 2017 16:29:48 +0800 Peter Chen wrote:

> On Mon, Apr 24, 2017 at 12:35:51PM +0000, Jisheng Zhang wrote:
> > Fix below NULL pointer dereference. we set ci->roles[CI_ROLE_GADGET]
> > too early in ci_hdrc_gadget_init(), if udc_start() fails due to some
> > reason, the ci->roles[CI_ROLE_GADGET] check in  ci_hdrc_gadget_destroy
> > can't protect us.
> > 
> > We fix this issue by only setting ci->roles[CI_ROLE_GADGET] if
> > udc_start() succeed.
> > 
> > [1.398550] Unable to handle kernel NULL pointer dereference at
> > virtual address 
> > ...
> > [1.448600] PC is at dma_pool_free+0xb8/0xf0
> > [1.453012] LR is at dma_pool_free+0x28/0xf0
> > [2.113369] [] dma_pool_free+0xb8/0xf0
> > [2.118857] [] destroy_eps+0x4c/0x68
> > [2.124165] [] ci_hdrc_gadget_destroy+0x28/0x50
> > [2.130461] [] ci_hdrc_probe+0x588/0x7e8
> > [2.136129] [] platform_drv_probe+0x50/0xb8
> > [2.142066] [] driver_probe_device+0x1fc/0x2a8
> > [2.148270] [] __device_attach_driver+0x9c/0xf8
> > [2.154563] [] bus_for_each_drv+0x58/0x98
> > [2.160317] [] __device_attach+0xc4/0x138
> > [2.166072] [] device_initial_probe+0x10/0x18
> > [2.172185] [] bus_probe_device+0x94/0xa0
> > [2.177940] [] device_add+0x3f0/0x560
> > [2.183337] [] platform_device_add+0x180/0x240
> > [2.189541] [] ci_hdrc_add_device+0x440/0x4f8
> > [2.195654] [] ci_hdrc_usb2_probe+0x13c/0x2d8
> > [2.201769] [] platform_drv_probe+0x50/0xb8
> > [2.207705] [] driver_probe_device+0x1fc/0x2a8
> > [2.213910] [] __driver_attach+0xac/0xb0
> > [2.219575] [] bus_for_each_dev+0x60/0xa0
> > [2.225329] [] driver_attach+0x20/0x28
> > [2.230816] [] bus_add_driver+0x1d0/0x238
> > [2.236571] [] driver_register+0x60/0xf8
> > [2.242237] [] __platform_driver_register+0x44/0x50
> > [2.248891] [] ci_hdrc_usb2_driver_init+0x18/0x20
> > [2.255365] [] do_one_initcall+0x38/0x128
> > [2.261121] [] kernel_init_freeable+0x1ac/0x250
> > [2.267414] [] kernel_init+0x10/0x100
> > [2.272810] [] ret_from_fork+0x10/0x50
> > 
> > Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> > ---
> >  drivers/usb/chipidea/udc.c | 8 ++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
> > index f88e9157fad0..60a786c87c06 100644
> > --- a/drivers/usb/chipidea/udc.c
> > +++ b/drivers/usb/chipidea/udc.c
> > @@ -1984,6 +1984,7 @@ static void udc_id_switch_for_host(struct ci_hdrc *ci)
> >  int ci_hdrc_gadget_init(struct ci_hdrc *ci)
> >  {
> > struct ci_role_driver *rdrv;
> > +   int ret;
> >  
> > if (!hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DC))
> > return -ENXIO;
> > @@ -1996,7 +1997,10 @@ int ci_hdrc_gadget_init(struct ci_hdrc *ci)
> > rdrv->stop  = udc_id_switch_for_host;
> > rdrv->irq   = udc_irq;
> > rdrv->name  = "gadget";
> > -   ci->roles[CI_ROLE_GADGET] = rdrv;
> >  
> > -   return udc_start(ci);
> > +   ret = udc_start(ci);
> > +   if (!ret)
> > +   ci->roles[CI_ROLE_GADGET] = rdrv;
> > +
> > +   return ret;
> >  }
> > --   
> 
> Thanks for fixing it. In fact, we'd better return failure if
> ret && ret != -ENXIO at probe, it stands for initialization
> for host or gadget has failed.
> 

I got your meaning. I'll cook v2. I don't have preference, since either
one can fix the issue.

Thanks for your suggestion,
Jisheng
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: chipidea: udc: fix NULL pointer dereference if udc_start failed

2017-04-24 Thread Jisheng Zhang
Fix below NULL pointer dereference. we set ci->roles[CI_ROLE_GADGET]
too early in ci_hdrc_gadget_init(), if udc_start() fails due to some
reason, the ci->roles[CI_ROLE_GADGET] check in  ci_hdrc_gadget_destroy
can't protect us.

We fix this issue by only setting ci->roles[CI_ROLE_GADGET] if
udc_start() succeed.

[1.398550] Unable to handle kernel NULL pointer dereference at
virtual address 
...
[1.448600] PC is at dma_pool_free+0xb8/0xf0
[1.453012] LR is at dma_pool_free+0x28/0xf0
[2.113369] [] dma_pool_free+0xb8/0xf0
[2.118857] [] destroy_eps+0x4c/0x68
[2.124165] [] ci_hdrc_gadget_destroy+0x28/0x50
[2.130461] [] ci_hdrc_probe+0x588/0x7e8
[2.136129] [] platform_drv_probe+0x50/0xb8
[2.142066] [] driver_probe_device+0x1fc/0x2a8
[2.148270] [] __device_attach_driver+0x9c/0xf8
[2.154563] [] bus_for_each_drv+0x58/0x98
[2.160317] [] __device_attach+0xc4/0x138
[2.166072] [] device_initial_probe+0x10/0x18
[2.172185] [] bus_probe_device+0x94/0xa0
[2.177940] [] device_add+0x3f0/0x560
[2.183337] [] platform_device_add+0x180/0x240
[2.189541] [] ci_hdrc_add_device+0x440/0x4f8
[2.195654] [] ci_hdrc_usb2_probe+0x13c/0x2d8
[2.201769] [] platform_drv_probe+0x50/0xb8
[2.207705] [] driver_probe_device+0x1fc/0x2a8
[2.213910] [] __driver_attach+0xac/0xb0
[2.219575] [] bus_for_each_dev+0x60/0xa0
[2.225329] [] driver_attach+0x20/0x28
[2.230816] [] bus_add_driver+0x1d0/0x238
[2.236571] [] driver_register+0x60/0xf8
[2.242237] [] __platform_driver_register+0x44/0x50
[2.248891] [] ci_hdrc_usb2_driver_init+0x18/0x20
[2.255365] [] do_one_initcall+0x38/0x128
[2.261121] [] kernel_init_freeable+0x1ac/0x250
[2.267414] [] kernel_init+0x10/0x100
[2.272810] [] ret_from_fork+0x10/0x50

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/chipidea/udc.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index f88e9157fad0..60a786c87c06 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -1984,6 +1984,7 @@ static void udc_id_switch_for_host(struct ci_hdrc *ci)
 int ci_hdrc_gadget_init(struct ci_hdrc *ci)
 {
struct ci_role_driver *rdrv;
+   int ret;
 
if (!hw_read(ci, CAP_DCCPARAMS, DCCPARAMS_DC))
return -ENXIO;
@@ -1996,7 +1997,10 @@ int ci_hdrc_gadget_init(struct ci_hdrc *ci)
rdrv->stop  = udc_id_switch_for_host;
rdrv->irq   = udc_irq;
rdrv->name  = "gadget";
-   ci->roles[CI_ROLE_GADGET] = rdrv;
 
-   return udc_start(ci);
+   ret = udc_start(ci);
+   if (!ret)
+   ci->roles[CI_ROLE_GADGET] = rdrv;
+
+   return ret;
 }
-- 
2.11.0

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


[RESEND PATCH] usb: chipidea: usb2: delete the redundant setting default DMA mask code

2017-01-22 Thread Jisheng Zhang
Similar as commit 2b2fe36def08 ("usb: chipidea: imx: delete the
redundant setting default DMA mask code"), the ci_hdrc_usb2 platform
device is also created by device tree, the default DMA mask should be
already set by of_dma_configure when the device are created. So delete
the redundant code at driver.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/chipidea/ci_hdrc_usb2.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c 
b/drivers/usb/chipidea/ci_hdrc_usb2.c
index 4456d2cf80ff..d162cc0bb8ce 100644
--- a/drivers/usb/chipidea/ci_hdrc_usb2.c
+++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
@@ -74,10 +74,6 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
}
}
 
-   ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
-   if (ret)
-   goto clk_err;
-
ci_pdata->name = dev_name(dev);
 
priv->ci_pdev = ci_hdrc_add_device(dev, pdev->resource,
-- 
2.11.0

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


[RESEND PATCH] usb: chipidea: delete an useless header include

2017-01-22 Thread Jisheng Zhang
 is for net phy drivers, we don't need it.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/chipidea/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 3dbb4a21ab44..77078083e9fb 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -62,7 +62,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
-- 
2.11.0

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


Re: [PATCH] usb: chipidea: support generic phy in PM code path

2016-08-22 Thread Jisheng Zhang


On Mon, 22 Aug 2016 13:53:37 +0530 Kishon Vijay Abraham I wrote:

> Hi,
> 
> On Monday 22 August 2016 01:44 PM, Jisheng Zhang wrote:
> > + Kishon
> > 
> > Hi Peter, Kishon,
> > 
> > On Mon, 22 Aug 2016 15:29:07 +0800 Peter Chen wrote:
> >   
> >> On Mon, Aug 22, 2016 at 02:39:21PM +0800, Jisheng Zhang wrote:  
> >>> Hi Peter,
> >>>
> >>> On Mon, 22 Aug 2016 13:33:08 +0800 Peter Chen wrote:
> >>> 
> >>>> On Fri, Aug 19, 2016 at 08:10:13PM +0800, Jisheng Zhang wrote:
> >>>>> Support generic phy in PM code path: call phy_power_off/phy_power_on
> >>>>> in ci_controller_suspend/ci_controller_resume.
> >>>>>
> >>>>> Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> >>>>> ---
> >>>>>  drivers/usb/chipidea/core.c | 4 +++-
> >>>>>  1 file changed, 3 insertions(+), 1 deletion(-)
> >>>>>
> >>>>> diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> >>>>> index ae12595..ef9fb0b 100644
> >>>>> --- a/drivers/usb/chipidea/core.c
> >>>>> +++ b/drivers/usb/chipidea/core.c
> >>>>> @@ -1116,6 +1116,7 @@ static void ci_controller_suspend(struct ci_hdrc 
> >>>>> *ci)
> >>>>> usleep_range(ci->platdata->phy_clkgate_delay_us,
> >>>>>  ci->platdata->phy_clkgate_delay_us + 50);
> >>>>> usb_phy_set_suspend(ci->usb_phy, 1);
> >>>>> +   phy_power_off(ci->phy);  
> >>>>
> >>>> How could you support USB wakeup after PHY is powered off?
> >>>
> >>> Per my understanding, the PHY's power off just power off data 
> >>> communication part
> >>> but leaves the circuits involved in wakeup detection active.
> >>> 
> >>
> >> Ok, I hope so.  
> > 
> > If most parts of the phy can be powered off during runtime suspend to save
> > power, or phy HW support suspend mode, with usb phy, usb_phy_set_suspend() 
> > could
> > be used, but with the generic phy, it seems there's no corresponding API for
> > this purpose. I'm not sure whether using phy_power_off() is correct here. 
> > Is it
> > acceptable to extend the generic phy? such as, phy_suspend()/phy_resume()?  
> 
> phy_pm_runtime_put() could be used right?
> 

oh yeah, Great!!! Thanks for the inspiration. Now, I know what should I do for 
my
platform and the chipidea core driver ;)

Will cook a v2 patch

Thank you so much,
Jisheng
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: chipidea: support generic phy in PM code path

2016-08-22 Thread Jisheng Zhang
+ Kishon

Hi Peter, Kishon,

On Mon, 22 Aug 2016 15:29:07 +0800 Peter Chen wrote:

> On Mon, Aug 22, 2016 at 02:39:21PM +0800, Jisheng Zhang wrote:
> > Hi Peter,
> > 
> > On Mon, 22 Aug 2016 13:33:08 +0800 Peter Chen wrote:
> >   
> > > On Fri, Aug 19, 2016 at 08:10:13PM +0800, Jisheng Zhang wrote:  
> > > > Support generic phy in PM code path: call phy_power_off/phy_power_on
> > > > in ci_controller_suspend/ci_controller_resume.
> > > > 
> > > > Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> > > > ---
> > > >  drivers/usb/chipidea/core.c | 4 +++-
> > > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > > > index ae12595..ef9fb0b 100644
> > > > --- a/drivers/usb/chipidea/core.c
> > > > +++ b/drivers/usb/chipidea/core.c
> > > > @@ -1116,6 +1116,7 @@ static void ci_controller_suspend(struct ci_hdrc 
> > > > *ci)
> > > > usleep_range(ci->platdata->phy_clkgate_delay_us,
> > > >  ci->platdata->phy_clkgate_delay_us + 50);
> > > > usb_phy_set_suspend(ci->usb_phy, 1);
> > > > +   phy_power_off(ci->phy);
> > > 
> > > How could you support USB wakeup after PHY is powered off?  
> > 
> > Per my understanding, the PHY's power off just power off data communication 
> > part
> > but leaves the circuits involved in wakeup detection active.
> >   
> 
> Ok, I hope so.

If most parts of the phy can be powered off during runtime suspend to save
power, or phy HW support suspend mode, with usb phy, usb_phy_set_suspend() could
be used, but with the generic phy, it seems there's no corresponding API for
this purpose. I'm not sure whether using phy_power_off() is correct here. Is it
acceptable to extend the generic phy? such as, phy_suspend()/phy_resume()?

Thanks,
Jisheng
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] usb: chipidea: support generic phy in PM code path

2016-08-22 Thread Jisheng Zhang
Hi Peter,

On Mon, 22 Aug 2016 13:33:08 +0800 Peter Chen wrote:

> On Fri, Aug 19, 2016 at 08:10:13PM +0800, Jisheng Zhang wrote:
> > Support generic phy in PM code path: call phy_power_off/phy_power_on
> > in ci_controller_suspend/ci_controller_resume.
> > 
> > Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> > ---
> >  drivers/usb/chipidea/core.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
> > index ae12595..ef9fb0b 100644
> > --- a/drivers/usb/chipidea/core.c
> > +++ b/drivers/usb/chipidea/core.c
> > @@ -1116,6 +1116,7 @@ static void ci_controller_suspend(struct ci_hdrc *ci)
> > usleep_range(ci->platdata->phy_clkgate_delay_us,
> >  ci->platdata->phy_clkgate_delay_us + 50);
> > usb_phy_set_suspend(ci->usb_phy, 1);
> > +   phy_power_off(ci->phy);  
> 
> How could you support USB wakeup after PHY is powered off?

Per my understanding, the PHY's power off just power off data communication part
but leaves the circuits involved in wakeup detection active.

Thanks,
Jisheng

> 
> Peter
> 
> > ci->in_lpm = true;
> > enable_irq(ci->irq);
> >  }
> > @@ -1132,9 +1133,10 @@ static int ci_controller_resume(struct device *dev)
> > }
> >  
> > ci_hdrc_enter_lpm(ci, false);
> > -   if (ci->usb_phy) {
> > +   if (ci->usb_phy || ci->phy) {
> > usb_phy_set_suspend(ci->usb_phy, 0);
> > usb_phy_set_wakeup(ci->usb_phy, false);
> > +   phy_power_on(ci->phy);
> > hw_wait_phy_stable();
> > }
> >  
> > -- 
> > 2.9.3
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> > the body of a message to majord...@vger.kernel.org
> > 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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] usb: chipidea: delete an useless header include

2016-08-19 Thread Jisheng Zhang
 is for net phy drivers, we don't need it.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---

Since v1:
  - fix commit subject. Thank Sergei for pointing it out.

 drivers/usb/chipidea/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 69426e6..ae12595 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -62,7 +62,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
-- 
2.9.3

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


[PATCH] usb: chipidea: support generic phy in PM code path

2016-08-19 Thread Jisheng Zhang
Support generic phy in PM code path: call phy_power_off/phy_power_on
in ci_controller_suspend/ci_controller_resume.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/chipidea/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index ae12595..ef9fb0b 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -1116,6 +1116,7 @@ static void ci_controller_suspend(struct ci_hdrc *ci)
usleep_range(ci->platdata->phy_clkgate_delay_us,
 ci->platdata->phy_clkgate_delay_us + 50);
usb_phy_set_suspend(ci->usb_phy, 1);
+   phy_power_off(ci->phy);
ci->in_lpm = true;
enable_irq(ci->irq);
 }
@@ -1132,9 +1133,10 @@ static int ci_controller_resume(struct device *dev)
}
 
ci_hdrc_enter_lpm(ci, false);
-   if (ci->usb_phy) {
+   if (ci->usb_phy || ci->phy) {
usb_phy_set_suspend(ci->usb_phy, 0);
usb_phy_set_wakeup(ci->usb_phy, false);
+   phy_power_on(ci->phy);
hw_wait_phy_stable();
}
 
-- 
2.9.3

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


[PATCH] usb: chipidea: delete an useless header file

2016-08-19 Thread Jisheng Zhang
 is for net phy drivers, we don't need it.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/chipidea/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c
index 69426e6..ae12595 100644
--- a/drivers/usb/chipidea/core.c
+++ b/drivers/usb/chipidea/core.c
@@ -62,7 +62,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
-- 
2.9.3

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


[PATCH] usb: chipidea: usb2: delete the redundant setting default DMA mask code

2016-08-19 Thread Jisheng Zhang
Similar as commit 2b2fe36def08 ("usb: chipidea: imx: delete the
redundant setting default DMA mask code"), the ci_hdrc_usb2 platform
device is also created by device tree, the default DMA mask should be
already set by of_dma_configure when the device are created. So delete
the redundant code at driver.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/chipidea/ci_hdrc_usb2.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c 
b/drivers/usb/chipidea/ci_hdrc_usb2.c
index 4456d2c..d162cc0 100644
--- a/drivers/usb/chipidea/ci_hdrc_usb2.c
+++ b/drivers/usb/chipidea/ci_hdrc_usb2.c
@@ -74,10 +74,6 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev)
}
}
 
-   ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32));
-   if (ret)
-   goto clk_err;
-
ci_pdata->name = dev_name(dev);
 
priv->ci_pdev = ci_hdrc_add_device(dev, pdev->resource,
-- 
2.9.3

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


Re: [RESEND PATCH v2 7/7] usb: xhci: plat: add vbus regulator control

2016-04-27 Thread Jisheng Zhang
Dear Mark,

On Wed, 27 Apr 2016 10:57:39 +0100 Mark Brown wrote:

> On Wed, Apr 27, 2016 at 08:37:20AM +0300, Felipe Balbi wrote:
> > Jisheng Zhang <jszh...@marvell.com> writes:  
> 
> > > + vbus = devm_regulator_get(>dev, "vbus");  
> 
> > devm_regulator_get_optional() ??  
> 
> Does USB work without a VBUS?  Unless the answer is yes then I'd expect
> this to be just a normal regulator_get().

Per spec no. But the vbus may be transparent to SW on some platforms, so I
think devm_regulator_get_optional() is better.

> 
> >   
> > > + if (PTR_ERR(vbus) == -ENODEV) {
> > > + vbus = NULL;
> > > + } else if (IS_ERR(vbus)) {
> > > + ret = PTR_ERR(vbus);
> > > + goto disable_clk;
> > > + } else if (vbus) {
> > > + ret = regulator_enable(vbus);
> > > + if (ret) {
> > > + dev_err(>dev,
> > > + "failed to enable usb vbus regulator: %d\n",
> > > + ret);
> > > + goto disable_clk;
> > > + }
> > > + }  
> 
> This is all completely broken unless the supply is optional.

The supply is optional.

Thanks for your review,
Jisheng
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH v2 6/7] usb: xhci: plat: add generic PHY support

2016-04-27 Thread Jisheng Zhang
Dear Felipe,

On Wed, 27 Apr 2016 08:35:58 +0300 Felipe Balbi wrote:

> Hi,
> 
> Jisheng Zhang <jszh...@marvell.com> writes:
> > Marvell BG4CT SoC needs two phy: one for usb2 and another for usb3. Add
> > the calls to retrieve generic PHY to xhci plat in order to support this.
> >
> > Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> > ---
> >  drivers/usb/host/xhci-plat.c | 87 
> > ++--
> >  1 file changed, 75 insertions(+), 12 deletions(-)
> >
> > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> > index 83669d0..d7f4f3c 100644
> > --- a/drivers/usb/host/xhci-plat.c
> > +++ b/drivers/usb/host/xhci-plat.c
> > @@ -16,6 +16,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -134,6 +135,37 @@ static const struct of_device_id usb_xhci_of_match[] = 
> > {
> >  MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
> >  #endif
> >  
> > +static int xhci_plat_phy_init(struct usb_hcd *hcd)
> > +{
> > +   int ret;
> > +
> > +   if (hcd->phy) {
> > +   ret = phy_init(hcd->phy);
> > +   if (ret)
> > +   return ret;
> > +
> > +   ret = phy_power_on(hcd->phy);
> > +   if (ret) {
> > +   phy_exit(hcd->phy);
> > +   return ret;
> > +   }
> > +   } else {
> > +   ret = usb_phy_init(hcd->usb_phy);
> > +   }
> > +
> > +   return ret;
> > +}
> > +
> > +static void xhci_plat_phy_exit(struct usb_hcd *hcd)
> > +{
> > +   if (hcd->phy) {
> > +   phy_power_off(hcd->phy);
> > +   phy_exit(hcd->phy);
> > +   } else {
> > +   usb_phy_shutdown(hcd->usb_phy);
> > +   }
> > +}
> > +
> >  static int xhci_plat_probe(struct platform_device *pdev)
> >  {
> > struct device_node  *node = pdev->dev.of_node;
> > @@ -145,6 +177,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
> > struct usb_hcd  *hcd;
> > struct clk  *clk;
> > struct usb_phy  *usb_phy;
> > +   struct phy  *phy;  
> 
> so, one phy driver using USB PHY layer and another using generic PHY
> layer ? Why ? I think the first thing your series should do would be to

It's different platforms. E.g
platform A may write the phy driver under usb phy layer, while platform B
may have generic phy driver.

The questions are: when adding phy support to xhci-plat, the generic phy
has existed for a long time, what's the reason to use the deprecated usb
phy APIs.

And per my check, it's only MVEBU platforms use this support? I'm not sure
if we could remove usbphy code from xhci-plat first then add generic phy then
adding MVEBU xhci phy support bak with the new code. So Cc mvebu maintainers

Thanks,
Jisheng

> add proper suport for both APIs with two PHYs and make them all optional
> for xhci-plat.
> 
> > @@ -232,22 +265,44 @@ static int xhci_plat_probe(struct platform_device 
> > *pdev)
> > if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
> > xhci->shared_hcd->can_do_streams = 1;
> >  
> > +   hcd->phy = devm_phy_get(>dev, "usb2-phy");
> > +   if (IS_ERR(hcd->phy)) {
> > +   ret = PTR_ERR(hcd->phy);
> > +   if (ret == -EPROBE_DEFER)
> > +   goto put_usb3_hcd;
> > +   hcd->phy = NULL;
> > +   }
> > +
> > +   phy = devm_phy_get(>dev, "usb-phy");
> > +   if (IS_ERR(phy)) {
> > +   ret = PTR_ERR(phy);
> > +   if (ret == -EPROBE_DEFER)
> > +   goto put_usb3_hcd;
> > +   phy = NULL;
> > +   }
> > +
> > usb_phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
> > if (IS_ERR(usb_phy)) {
> > ret = PTR_ERR(usb_phy);
> > if (ret == -EPROBE_DEFER)
> > goto put_usb3_hcd;
> > usb_phy = NULL;
> > -   } else {
> > -   ret = usb_phy_init(usb_phy);
> > -   if (ret)
> > -   goto put_usb3_hcd;
> > }
> > +
> > xhci->shared_hcd->usb_phy = usb_phy;
> > +   xhci->shared_hcd->phy = phy;
> > +
> > +   ret = xhci_plat_phy_init(hcd);
> > +   if (ret)
> > +   goto put_usb3_hcd;
> > +
> > +   ret = xhci_plat_phy_init(xhci->shared_hcd);
> > + 

Re: [RESEND PATCH v2 5/7] usb: xhci: plat: Remove checks for optional clock in error/remove path

2016-04-27 Thread Jisheng Zhang
Dear Felipe,

On Wed, 27 Apr 2016 08:33:52 +0300 Felipe Balbi wrote:

> Jisheng Zhang <jszh...@marvell.com> writes:
> > Commit 63589e92c2d9 ("clk: Ignore error and NULL pointers passed to
> > clk_{unprepare, disable}()") allows NULL or error pointer to be passed
> > unconditionally.
> >
> > This patch is to simplify probe error and remove code paths.  
> 
> this seems wrong to me. xhci->clk isn't initialized to NULL, it's either
> initialized to a valid struct clk * or some ERR_PTR() value.

Commit 63589e92c2d9 could also ignore error value ;)

> 
> Care to explain ?
> 
> > Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> > ---
> >  drivers/usb/host/xhci-plat.c | 6 ++
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> > index 0e69712..83669d0 100644
> > --- a/drivers/usb/host/xhci-plat.c
> > +++ b/drivers/usb/host/xhci-plat.c
> > @@ -266,8 +266,7 @@ put_usb3_hcd:
> > usb_put_hcd(xhci->shared_hcd);
> >  
> >  disable_clk:
> > -   if (!IS_ERR(clk))
> > -   clk_disable_unprepare(clk);
> > +   clk_disable_unprepare(clk);
> >  
> >  put_hcd:
> > usb_put_hcd(hcd);
> > @@ -287,8 +286,7 @@ static int xhci_plat_remove(struct platform_device *dev)
> > usb_remove_hcd(hcd);
> > usb_put_hcd(xhci->shared_hcd);
> >  
> > -   if (!IS_ERR(clk))
> > -   clk_disable_unprepare(clk);
> > +   clk_disable_unprepare(clk);
> > usb_put_hcd(hcd);
> >  
> > return 0;
> > -- 
> > 2.8.1
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> > the body of a message to majord...@vger.kernel.org
> > 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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH v2 2/7] usb: xhci: plat: attach the usb_phy to the correct hcd

2016-04-27 Thread Jisheng Zhang
Dear Felipe,

On Wed, 27 Apr 2016 08:29:34 +0300 Felipe Balbi wrote:

> Hi,
> 
> (Cc authors and maintainer, otherwise you're patch might be forgotten ;-)

Thanks a lot for the kind remind. I just run get_maintainer.pl to get the
To and Cc lists. It seems Mathias's email changed, MAINTAINERS need to updated.

> 
> Jisheng Zhang <jszh...@marvell.com> writes:
> > Commit 7b8ef22ea547 ("usb: xhci: plat: Add USB phy support") adds the
> > usb_phy for usb3, but it attached the usb_phy to incorrect hcd. The  
> 
> where did you see that's the USB3 phy ? I can't see it.

Commit 7b8ef22ea547 ("usb: xhci: plat: Add USB phy support") says:

"The Marvell Armada 385 AP needs a dumb phy in order to enable the USB3 VBUS."

So I think it means USB3 phy.

Here I have two questions: Per my understanding, usb_phy is deprecated, all
users and new code are encouraged to use generic phy. I think there must
be some special reason commit 7b8ef22ea547 still made use of usb_phy, could
I know what's the reason?

And could the "USB3 VBUS" support be achieved through regulator framework?

Thanks in advance,
Jisheng


> 
> > xhci->shared_hcd is the hcd for usb3, this patch fixes this issue
> > by attach the usb_phy to the xhci->shared_hcd.  
> 
> Fixes: 7b8ef22ea547 ("usb: xhci: plat: Add USB phy support")
> Cc: <sta...@vger.kernel.org # v4.1+
> 
> Maxime, any comments ? It _is_ odd that only one PHY got added.
> 
> > Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> > ---
> >  drivers/usb/host/xhci-plat.c | 16 +---
> >  1 file changed, 9 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> > index 8cb46cb..9ff89e9 100644
> > --- a/drivers/usb/host/xhci-plat.c
> > +++ b/drivers/usb/host/xhci-plat.c
> > @@ -144,6 +144,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
> > struct resource *res;
> > struct usb_hcd  *hcd;
> > struct clk  *clk;
> > +   struct usb_phy  *usb_phy;
> > int ret;
> > int irq;
> >  
> > @@ -231,17 +232,18 @@ static int xhci_plat_probe(struct platform_device 
> > *pdev)
> > if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
> > xhci->shared_hcd->can_do_streams = 1;
> >  
> > -   hcd->usb_phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
> > -   if (IS_ERR(hcd->usb_phy)) {
> > -   ret = PTR_ERR(hcd->usb_phy);
> > +   usb_phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
> > +   if (IS_ERR(usb_phy)) {
> > +   ret = PTR_ERR(usb_phy);
> > if (ret == -EPROBE_DEFER)
> > goto put_usb3_hcd;
> > -   hcd->usb_phy = NULL;
> > +   usb_phy = NULL;
> > } else {
> > -   ret = usb_phy_init(hcd->usb_phy);
> > +   ret = usb_phy_init(usb_phy);
> > if (ret)
> > goto put_usb3_hcd;
> > }
> > +   xhci->shared_hcd->usb_phy = usb_phy;
> >  
> > ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
> > if (ret)
> > @@ -258,7 +260,7 @@ dealloc_usb2_hcd:
> > usb_remove_hcd(hcd);
> >  
> >  disable_usb_phy:
> > -   usb_phy_shutdown(hcd->usb_phy);
> > +   usb_phy_shutdown(usb_phy);
> >  
> >  put_usb3_hcd:
> > usb_put_hcd(xhci->shared_hcd);
> > @@ -280,7 +282,7 @@ static int xhci_plat_remove(struct platform_device *dev)
> > struct clk *clk = xhci->clk;
> >  
> > usb_remove_hcd(xhci->shared_hcd);
> > -   usb_phy_shutdown(hcd->usb_phy);
> > +   usb_phy_shutdown(xhci->shared_hcd->usb_phy);
> >  
> > usb_remove_hcd(hcd);
> > usb_put_hcd(xhci->shared_hcd);
> > -- 
> > 2.8.1
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> > the body of a message to majord...@vger.kernel.org
> > 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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RESEND PATCH v2 1/7] usb: xhci: plat: Fix suspend/resume when the optional clk exists

2016-04-26 Thread Jisheng Zhang
Dear Felipe,

On Wed, 27 Apr 2016 08:25:38 +0300 Felipe Balbi wrote:

> Hi,
> 
> (since you're fixing somebody else's commit, it's nice to Cc authors)
> 
> Jisheng Zhang <jszh...@marvell.com> writes:
> > Commit 4718c1774051 ("usb: host: xhci-plat: add clock support") adds
> > optional clk support, but it forgets to prepare/disable and  
>   ^^^
>   prepare/enable ?
> 
> > enable/unprepare the clk in the resume/suspend path. This path fixes  
>     
>   disable/unprepare ?   patch
> 
> > this issue by adding missing clk related calls.  
> 
> frankly, I'm not sure this patch is entirely correct. At minimum, it's
> not necessarily a bug fix. Original commit had no intent in gating
> clocks during suspend/resume and, IMHO, that might not be what *all*
> XHCI implementations want, though I'm not entirely sure.

Thanks for the hint. Indeed, that's not all xhci-plat users want. I'll drop
this patch in v3.

Thanks a lot for the review,
Jisheng

> 
> > Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> > Fixes: 4718c1774051 ("usb: host: xhci-plat: add clock support")  
> 
> Assuming this is, indeed, a fix; you need to Cc stable here. Just add:
> 
> Cc: <sta...@vger.kernel.org> # v3.16+
> 
> > ---
> >  drivers/usb/host/xhci-plat.c | 14 +-
> >  1 file changed, 13 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> > index 474b5fa..8cb46cb 100644
> > --- a/drivers/usb/host/xhci-plat.c
> > +++ b/drivers/usb/host/xhci-plat.c
> > @@ -295,6 +295,7 @@ static int xhci_plat_remove(struct platform_device *dev)
> >  #ifdef CONFIG_PM_SLEEP
> >  static int xhci_plat_suspend(struct device *dev)
> >  {
> > +   int ret;  
> 
> this would look neater after hcd and xhci declarations below
> 
> > struct usb_hcd  *hcd = dev_get_drvdata(dev);
> > struct xhci_hcd *xhci = hcd_to_xhci(hcd);
> >  
> > @@ -306,14 +307,25 @@ static int xhci_plat_suspend(struct device *dev)
> >  * reconsider this when xhci_plat_suspend enlarges its scope, e.g.,
> >  * also applies to runtime suspend.
> >  */
> > -   return xhci_suspend(xhci, device_may_wakeup(dev));
> > +   ret = xhci_suspend(xhci, device_may_wakeup(dev));
> > +   if (ret)
> > +   return ret;
> > +
> > +   clk_disable_unprepare(xhci->clk);
> > +
> > +   return ret;
> >  }
> >  
> >  static int xhci_plat_resume(struct device *dev)
> >  {
> > +   int ret;  
> 
> ditto
> 
> > struct usb_hcd  *hcd = dev_get_drvdata(dev);
> > struct xhci_hcd *xhci = hcd_to_xhci(hcd);
> >  
> > +   ret = clk_prepare_enable(xhci->clk);
> > +   if (ret)
> > +   return ret;
> > +
> > return xhci_resume(xhci, 0);
> >  }
> >  
> > -- 
> > 2.8.1
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> > the body of a message to majord...@vger.kernel.org
> > 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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RESEND PATCH v2 3/7] usb: xhci: plat: Fix suspend/resume when the optional usb_phy exists

2016-04-26 Thread Jisheng Zhang
Commit 7b8ef22ea547 ("usb: xhci: plat: Add USB phy support") adds the
usb_phy for usb3, but it forgets to shutdown/init the usb_phy in the
suspend/resume path. This patch fixes this issue by adding missing
usb_phy related calls.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/host/xhci-plat.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 9ff89e9..fbd23fd 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -313,6 +313,7 @@ static int xhci_plat_suspend(struct device *dev)
if (ret)
return ret;
 
+   usb_phy_shutdown(xhci->shared_hcd->usb_phy);
clk_disable_unprepare(xhci->clk);
 
return ret;
@@ -328,6 +329,10 @@ static int xhci_plat_resume(struct device *dev)
if (ret)
return ret;
 
+   ret = usb_phy_init(xhci->shared_hcd->usb_phy);
+   if (ret)
+   return ret;
+
return xhci_resume(xhci, 0);
 }
 
-- 
2.8.1

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


[RESEND PATCH v2 6/7] usb: xhci: plat: add generic PHY support

2016-04-26 Thread Jisheng Zhang
Marvell BG4CT SoC needs two phy: one for usb2 and another for usb3. Add
the calls to retrieve generic PHY to xhci plat in order to support this.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/host/xhci-plat.c | 87 ++--
 1 file changed, 75 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 83669d0..d7f4f3c 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -134,6 +135,37 @@ static const struct of_device_id usb_xhci_of_match[] = {
 MODULE_DEVICE_TABLE(of, usb_xhci_of_match);
 #endif
 
+static int xhci_plat_phy_init(struct usb_hcd *hcd)
+{
+   int ret;
+
+   if (hcd->phy) {
+   ret = phy_init(hcd->phy);
+   if (ret)
+   return ret;
+
+   ret = phy_power_on(hcd->phy);
+   if (ret) {
+   phy_exit(hcd->phy);
+   return ret;
+   }
+   } else {
+   ret = usb_phy_init(hcd->usb_phy);
+   }
+
+   return ret;
+}
+
+static void xhci_plat_phy_exit(struct usb_hcd *hcd)
+{
+   if (hcd->phy) {
+   phy_power_off(hcd->phy);
+   phy_exit(hcd->phy);
+   } else {
+   usb_phy_shutdown(hcd->usb_phy);
+   }
+}
+
 static int xhci_plat_probe(struct platform_device *pdev)
 {
struct device_node  *node = pdev->dev.of_node;
@@ -145,6 +177,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
struct usb_hcd  *hcd;
struct clk  *clk;
struct usb_phy  *usb_phy;
+   struct phy  *phy;
int ret;
int irq;
 
@@ -232,22 +265,44 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
xhci->shared_hcd->can_do_streams = 1;
 
+   hcd->phy = devm_phy_get(>dev, "usb2-phy");
+   if (IS_ERR(hcd->phy)) {
+   ret = PTR_ERR(hcd->phy);
+   if (ret == -EPROBE_DEFER)
+   goto put_usb3_hcd;
+   hcd->phy = NULL;
+   }
+
+   phy = devm_phy_get(>dev, "usb-phy");
+   if (IS_ERR(phy)) {
+   ret = PTR_ERR(phy);
+   if (ret == -EPROBE_DEFER)
+   goto put_usb3_hcd;
+   phy = NULL;
+   }
+
usb_phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
if (IS_ERR(usb_phy)) {
ret = PTR_ERR(usb_phy);
if (ret == -EPROBE_DEFER)
goto put_usb3_hcd;
usb_phy = NULL;
-   } else {
-   ret = usb_phy_init(usb_phy);
-   if (ret)
-   goto put_usb3_hcd;
}
+
xhci->shared_hcd->usb_phy = usb_phy;
+   xhci->shared_hcd->phy = phy;
+
+   ret = xhci_plat_phy_init(hcd);
+   if (ret)
+   goto put_usb3_hcd;
+
+   ret = xhci_plat_phy_init(xhci->shared_hcd);
+   if (ret)
+   goto disable_usb2_phy;
 
ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (ret)
-   goto disable_usb_phy;
+   goto disable_usb3_phy;
 
ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
if (ret)
@@ -259,8 +314,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
 dealloc_usb2_hcd:
usb_remove_hcd(hcd);
 
-disable_usb_phy:
-   usb_phy_shutdown(usb_phy);
+disable_usb3_phy:
+   xhci_plat_phy_exit(xhci->shared_hcd);
+
+disable_usb2_phy:
+   xhci_plat_phy_exit(hcd);
 
 put_usb3_hcd:
usb_put_hcd(xhci->shared_hcd);
@@ -281,11 +339,11 @@ static int xhci_plat_remove(struct platform_device *dev)
struct clk *clk = xhci->clk;
 
usb_remove_hcd(xhci->shared_hcd);
-   usb_phy_shutdown(xhci->shared_hcd->usb_phy);
-
-   usb_remove_hcd(hcd);
+   xhci_plat_phy_exit(xhci->shared_hcd);
usb_put_hcd(xhci->shared_hcd);
 
+   usb_remove_hcd(hcd);
+   xhci_plat_phy_exit(hcd);
clk_disable_unprepare(clk);
usb_put_hcd(hcd);
 
@@ -311,7 +369,8 @@ static int xhci_plat_suspend(struct device *dev)
if (ret)
return ret;
 
-   usb_phy_shutdown(xhci->shared_hcd->usb_phy);
+   xhci_plat_phy_exit(xhci->shared_hcd);
+   xhci_plat_phy_exit(hcd);
clk_disable_unprepare(xhci->clk);
 
return ret;
@@ -327,7 +386,11 @@ static int xhci_plat_resume(struct device *dev)
if (ret)
return ret;
 
-   ret = usb_phy_init(xhci->shared_hcd->usb_phy);
+   ret = xhci_plat_phy_init(hcd);
+   if (ret)
+   return ret;

[RESEND PATCH v2 2/7] usb: xhci: plat: attach the usb_phy to the correct hcd

2016-04-26 Thread Jisheng Zhang
Commit 7b8ef22ea547 ("usb: xhci: plat: Add USB phy support") adds the
usb_phy for usb3, but it attached the usb_phy to incorrect hcd. The
xhci->shared_hcd is the hcd for usb3, this patch fixes this issue
by attach the usb_phy to the xhci->shared_hcd.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/host/xhci-plat.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 8cb46cb..9ff89e9 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -144,6 +144,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
struct resource *res;
struct usb_hcd  *hcd;
struct clk  *clk;
+   struct usb_phy  *usb_phy;
int ret;
int irq;
 
@@ -231,17 +232,18 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
xhci->shared_hcd->can_do_streams = 1;
 
-   hcd->usb_phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
-   if (IS_ERR(hcd->usb_phy)) {
-   ret = PTR_ERR(hcd->usb_phy);
+   usb_phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
+   if (IS_ERR(usb_phy)) {
+   ret = PTR_ERR(usb_phy);
if (ret == -EPROBE_DEFER)
goto put_usb3_hcd;
-   hcd->usb_phy = NULL;
+   usb_phy = NULL;
} else {
-   ret = usb_phy_init(hcd->usb_phy);
+   ret = usb_phy_init(usb_phy);
if (ret)
goto put_usb3_hcd;
}
+   xhci->shared_hcd->usb_phy = usb_phy;
 
ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (ret)
@@ -258,7 +260,7 @@ dealloc_usb2_hcd:
usb_remove_hcd(hcd);
 
 disable_usb_phy:
-   usb_phy_shutdown(hcd->usb_phy);
+   usb_phy_shutdown(usb_phy);
 
 put_usb3_hcd:
usb_put_hcd(xhci->shared_hcd);
@@ -280,7 +282,7 @@ static int xhci_plat_remove(struct platform_device *dev)
struct clk *clk = xhci->clk;
 
usb_remove_hcd(xhci->shared_hcd);
-   usb_phy_shutdown(hcd->usb_phy);
+   usb_phy_shutdown(xhci->shared_hcd->usb_phy);
 
usb_remove_hcd(hcd);
usb_put_hcd(xhci->shared_hcd);
-- 
2.8.1

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


[RESEND PATCH v2 5/7] usb: xhci: plat: Remove checks for optional clock in error/remove path

2016-04-26 Thread Jisheng Zhang
Commit 63589e92c2d9 ("clk: Ignore error and NULL pointers passed to
clk_{unprepare, disable}()") allows NULL or error pointer to be passed
unconditionally.

This patch is to simplify probe error and remove code paths.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/host/xhci-plat.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 0e69712..83669d0 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -266,8 +266,7 @@ put_usb3_hcd:
usb_put_hcd(xhci->shared_hcd);
 
 disable_clk:
-   if (!IS_ERR(clk))
-   clk_disable_unprepare(clk);
+   clk_disable_unprepare(clk);
 
 put_hcd:
usb_put_hcd(hcd);
@@ -287,8 +286,7 @@ static int xhci_plat_remove(struct platform_device *dev)
usb_remove_hcd(hcd);
usb_put_hcd(xhci->shared_hcd);
 
-   if (!IS_ERR(clk))
-   clk_disable_unprepare(clk);
+   clk_disable_unprepare(clk);
usb_put_hcd(hcd);
 
return 0;
-- 
2.8.1

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


[RESEND PATCH v2 4/7] usb: xhci: plat: sort the headers in alphabetic order

2016-04-26 Thread Jisheng Zhang
Sorting the headers in alphabetic order will help to reduce the conflict
when adding new headers later.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/host/xhci-plat.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index fbd23fd..0e69712 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -11,19 +11,19 @@
  * version 2 as published by the Free Software Foundation.
  */
 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
-#include 
 
 #include "xhci.h"
-#include "xhci-plat.h"
 #include "xhci-mvebu.h"
+#include "xhci-plat.h"
 #include "xhci-rcar.h"
 
 static struct hc_driver __read_mostly xhci_plat_hc_driver;
-- 
2.8.1

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


[RESEND PATCH v2 0/7] usb: xhci-plat: support generic PHY and vbus regulator

2016-04-26 Thread Jisheng Zhang
The Marvell BG4CT has xhci controller. This controller has two phys:
one for usb2 and another for usb3. BG4CT boards have board level vbus
control through gpio.

I plan to add the xhci support in two steps: first of all, add generic
PHY and vbus regulator control support to the xhci-plat driver. Then
add the usb2 and usb3 phy drivers, after that, we add the phy and xhci
nodes in the dtsi.

This series takes the first step. The first three patches are bug fix.
Then two clean up patches. The last two patches add generic PHY and
vbus regulator control support.

Since v1:
 - fix NULL pointer dereference in [PATCH 7/7]

Jisheng Zhang (7):
  usb: xhci: plat: Fix suspend/resume when the optional clk exists
  usb: xhci: plat: attach the usb_phy to the correct hcd
  usb: xhci: plat: Fix suspend/resume when the optional usb_phy exists
  usb: xhci: plat: sort the headers in alphabetic order
  usb: xhci: plat: Remove checks for optional clock in error/remove path
  usb: xhci: plat: add generic PHY support
  usb: xhci: plat: add vbus regulator control

 drivers/usb/host/xhci-plat.c | 162 +--
 drivers/usb/host/xhci.h  |   2 +
 2 files changed, 142 insertions(+), 22 deletions(-)

-- 
2.8.1

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


[RESEND PATCH v2 1/7] usb: xhci: plat: Fix suspend/resume when the optional clk exists

2016-04-26 Thread Jisheng Zhang
Commit 4718c1774051 ("usb: host: xhci-plat: add clock support") adds
optional clk support, but it forgets to prepare/disable and
enable/unprepare the clk in the resume/suspend path. This path fixes
this issue by adding missing clk related calls.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
Fixes: 4718c1774051 ("usb: host: xhci-plat: add clock support")
---
 drivers/usb/host/xhci-plat.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 474b5fa..8cb46cb 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -295,6 +295,7 @@ static int xhci_plat_remove(struct platform_device *dev)
 #ifdef CONFIG_PM_SLEEP
 static int xhci_plat_suspend(struct device *dev)
 {
+   int ret;
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 
@@ -306,14 +307,25 @@ static int xhci_plat_suspend(struct device *dev)
 * reconsider this when xhci_plat_suspend enlarges its scope, e.g.,
 * also applies to runtime suspend.
 */
-   return xhci_suspend(xhci, device_may_wakeup(dev));
+   ret = xhci_suspend(xhci, device_may_wakeup(dev));
+   if (ret)
+   return ret;
+
+   clk_disable_unprepare(xhci->clk);
+
+   return ret;
 }
 
 static int xhci_plat_resume(struct device *dev)
 {
+   int ret;
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 
+   ret = clk_prepare_enable(xhci->clk);
+   if (ret)
+   return ret;
+
return xhci_resume(xhci, 0);
 }
 
-- 
2.8.1

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


[PATCH v2 6/7] usb: xhci: plat: add generic PHY support

2015-12-07 Thread Jisheng Zhang
Marvell BG4CT SoC needs two phy: one for usb2 and another for usb3. Add
the calls to retrieve generic PHY to xhci plat in order to support this.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/host/xhci-plat.c | 87 ++--
 1 file changed, 75 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 62f02e5..bb972a6 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -73,6 +74,37 @@ static int xhci_plat_start(struct usb_hcd *hcd)
return xhci_run(hcd);
 }
 
+static int xhci_plat_phy_init(struct usb_hcd *hcd)
+{
+   int ret;
+
+   if (hcd->phy) {
+   ret = phy_init(hcd->phy);
+   if (ret)
+   return ret;
+
+   ret = phy_power_on(hcd->phy);
+   if (ret) {
+   phy_exit(hcd->phy);
+   return ret;
+   }
+   } else {
+   ret = usb_phy_init(hcd->usb_phy);
+   }
+
+   return ret;
+}
+
+static void xhci_plat_phy_exit(struct usb_hcd *hcd)
+{
+   if (hcd->phy) {
+   phy_power_off(hcd->phy);
+   phy_exit(hcd->phy);
+   } else {
+   usb_phy_shutdown(hcd->usb_phy);
+   }
+}
+
 static int xhci_plat_probe(struct platform_device *pdev)
 {
struct device_node  *node = pdev->dev.of_node;
@@ -83,6 +115,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
struct usb_hcd  *hcd;
struct clk  *clk;
struct usb_phy  *usb_phy;
+   struct phy  *phy;
int ret;
int irq;
 
@@ -163,22 +196,44 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
xhci->shared_hcd->can_do_streams = 1;
 
+   hcd->phy = devm_phy_get(>dev, "usb2-phy");
+   if (IS_ERR(hcd->phy)) {
+   ret = PTR_ERR(hcd->phy);
+   if (ret == -EPROBE_DEFER)
+   goto put_usb3_hcd;
+   hcd->phy = NULL;
+   }
+
+   phy = devm_phy_get(>dev, "usb-phy");
+   if (IS_ERR(phy)) {
+   ret = PTR_ERR(phy);
+   if (ret == -EPROBE_DEFER)
+   goto put_usb3_hcd;
+   phy = NULL;
+   }
+
usb_phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
if (IS_ERR(usb_phy)) {
ret = PTR_ERR(usb_phy);
if (ret == -EPROBE_DEFER)
goto put_usb3_hcd;
usb_phy = NULL;
-   } else {
-   ret = usb_phy_init(usb_phy);
-   if (ret)
-   goto put_usb3_hcd;
}
+
xhci->shared_hcd->usb_phy = usb_phy;
+   xhci->shared_hcd->phy = phy;
+
+   ret = xhci_plat_phy_init(hcd);
+   if (ret)
+   goto put_usb3_hcd;
+
+   ret = xhci_plat_phy_init(xhci->shared_hcd);
+   if (ret)
+   goto disable_usb2_phy;
 
ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (ret)
-   goto disable_usb_phy;
+   goto disable_usb3_phy;
 
ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
if (ret)
@@ -190,8 +245,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
 dealloc_usb2_hcd:
usb_remove_hcd(hcd);
 
-disable_usb_phy:
-   usb_phy_shutdown(usb_phy);
+disable_usb3_phy:
+   xhci_plat_phy_exit(xhci->shared_hcd);
+
+disable_usb2_phy:
+   xhci_plat_phy_exit(hcd);
 
 put_usb3_hcd:
usb_put_hcd(xhci->shared_hcd);
@@ -212,11 +270,11 @@ static int xhci_plat_remove(struct platform_device *dev)
struct clk *clk = xhci->clk;
 
usb_remove_hcd(xhci->shared_hcd);
-   usb_phy_shutdown(xhci->shared_hcd->usb_phy);
-
-   usb_remove_hcd(hcd);
+   xhci_plat_phy_exit(xhci->shared_hcd);
usb_put_hcd(xhci->shared_hcd);
 
+   usb_remove_hcd(hcd);
+   xhci_plat_phy_exit(hcd);
clk_disable_unprepare(clk);
usb_put_hcd(hcd);
 
@@ -242,7 +300,8 @@ static int xhci_plat_suspend(struct device *dev)
if (ret)
return ret;
 
-   usb_phy_shutdown(xhci->shared_hcd->usb_phy);
+   xhci_plat_phy_exit(xhci->shared_hcd);
+   xhci_plat_phy_exit(hcd);
clk_disable_unprepare(xhci->clk);
 
return ret;
@@ -258,7 +317,11 @@ static int xhci_plat_resume(struct device *dev)
if (ret)
return ret;
 
-   ret = usb_phy_init(xhci->shared_hcd->usb_phy);
+   ret = xhci_plat_phy_init(hcd);
+   if (ret)
+   return ret;
+
+   ret = xhci_pl

[PATCH v2 7/7] usb: xhci: plat: add vbus regulator control

2015-12-07 Thread Jisheng Zhang
The Marvell BG4CT STB board has board level vbus control through gpio.
This patch adds the vbus regulator control to support this board.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/host/xhci-plat.c | 39 ++-
 drivers/usb/host/xhci.h  |  2 ++
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index bb972a6..c03e8d5 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -116,6 +117,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
struct clk  *clk;
struct usb_phy  *usb_phy;
struct phy  *phy;
+   struct regulator*vbus;
int ret;
int irq;
 
@@ -179,14 +181,31 @@ static int xhci_plat_probe(struct platform_device *pdev)
 
device_wakeup_enable(hcd->self.controller);
 
+   vbus = devm_regulator_get(>dev, "vbus");
+   if (PTR_ERR(vbus) == -ENODEV) {
+   vbus = NULL;
+   } else if (IS_ERR(vbus)) {
+   ret = PTR_ERR(vbus);
+   goto disable_clk;
+   } else if (vbus) {
+   ret = regulator_enable(vbus);
+   if (ret) {
+   dev_err(>dev,
+   "failed to enable usb vbus regulator: %d\n",
+   ret);
+   goto disable_clk;
+   }
+   }
+
xhci = hcd_to_xhci(hcd);
xhci->clk = clk;
+   xhci->vbus = vbus;
xhci->main_hcd = hcd;
xhci->shared_hcd = usb_create_shared_hcd(driver, >dev,
dev_name(>dev), hcd);
if (!xhci->shared_hcd) {
ret = -ENOMEM;
-   goto disable_clk;
+   goto disable_vbus;
}
 
if ((node && of_property_read_bool(node, "usb3-lpm-capable")) ||
@@ -254,6 +273,10 @@ disable_usb2_phy:
 put_usb3_hcd:
usb_put_hcd(xhci->shared_hcd);
 
+disable_vbus:
+   if (vbus)
+   regulator_disable(vbus);
+
 disable_clk:
clk_disable_unprepare(clk);
 
@@ -268,6 +291,7 @@ static int xhci_plat_remove(struct platform_device *dev)
struct usb_hcd  *hcd = platform_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
struct clk *clk = xhci->clk;
+   struct regulator *vbus = xhci->vbus;
 
usb_remove_hcd(xhci->shared_hcd);
xhci_plat_phy_exit(xhci->shared_hcd);
@@ -278,6 +302,9 @@ static int xhci_plat_remove(struct platform_device *dev)
clk_disable_unprepare(clk);
usb_put_hcd(hcd);
 
+   if (vbus)
+   regulator_disable(vbus);
+
return 0;
 }
 
@@ -287,6 +314,7 @@ static int xhci_plat_suspend(struct device *dev)
int ret;
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   struct regulator *vbus = xhci->vbus;
 
/*
 * xhci_suspend() needs `do_wakeup` to know whether host is allowed
@@ -303,6 +331,8 @@ static int xhci_plat_suspend(struct device *dev)
xhci_plat_phy_exit(xhci->shared_hcd);
xhci_plat_phy_exit(hcd);
clk_disable_unprepare(xhci->clk);
+   if (vbus)
+   ret = regulator_disable(vbus);
 
return ret;
 }
@@ -312,11 +342,18 @@ static int xhci_plat_resume(struct device *dev)
int ret;
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
+   struct regulator *vbus = xhci->vbus;
 
ret = clk_prepare_enable(xhci->clk);
if (ret)
return ret;
 
+   if (vbus) {
+   ret = regulator_enable(vbus);
+   if (ret)
+   return ret;
+   }
+
ret = xhci_plat_phy_init(hcd);
if (ret)
return ret;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 0b94512..1355d2a 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1541,6 +1541,8 @@ struct xhci_hcd {
struct msix_entry   *msix_entries;
/* optional clock */
struct clk  *clk;
+   /* optional regulator */
+   struct regulator*vbus;
/* data structures */
struct xhci_device_context_array *dcbaa;
struct xhci_ring*cmd_ring;
-- 
2.6.2

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


[PATCH v2 0/7] usb: xhci-plat: support generic PHY and vbus regulator

2015-12-07 Thread Jisheng Zhang
The Marvell BG4CT has xhci controller. This controller has two phys:
one for usb2 and another for usb3. BG4CT boards have board level vbus
control through gpio.

I plan to add the xhci support in two steps: first of all, add generic
PHY and vbus regulator control support to the xhci-plat driver. Then
add the usb2 and usb3 phy drivers, after that, we add the phy and xhci
nodes in the dtsi.

This series takes the first step. The first three patches are bug fix.
Then two clean up patches. The last two patches add generic PHY and
vbus regulator control support.

Since v1:
 - fix NULL pointer dereference in [PATCH 7/7]

Jisheng Zhang (7):
  usb: xhci: plat: Fix suspend/resume when the optional clk exists
  usb: xhci: plat: attach the usb_phy to the correct hcd
  usb: xhci: plat: Fix suspend/resume when the optional usb_phy exists
  usb: xhci: plat: sort the headers in alphabetic order
  usb: xhci: plat: Remove checks for optional clock in error/remove path
  usb: xhci: plat: add generic PHY support
  usb: xhci: plat: add vbus regulator control

 drivers/usb/host/xhci-plat.c | 159 +--
 drivers/usb/host/xhci.h  |   2 +
 2 files changed, 140 insertions(+), 21 deletions(-)

-- 
2.6.2

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


[PATCH v2 2/7] usb: xhci: plat: attach the usb_phy to the correct hcd

2015-12-07 Thread Jisheng Zhang
Commit 7b8ef22ea547 ("usb: xhci: plat: Add USB phy support") adds the
usb_phy for usb3, but it attached the usb_phy to incorrect hcd. The
xhci->shared_hcd is the hcd for usb3, this patch fixes this issue
by attach the usb_phy to the xhci->shared_hcd.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/host/xhci-plat.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index b566304..a8c465a 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -82,6 +82,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
struct resource *res;
struct usb_hcd  *hcd;
struct clk  *clk;
+   struct usb_phy  *usb_phy;
int ret;
int irq;
 
@@ -162,17 +163,18 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
xhci->shared_hcd->can_do_streams = 1;
 
-   hcd->usb_phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
-   if (IS_ERR(hcd->usb_phy)) {
-   ret = PTR_ERR(hcd->usb_phy);
+   usb_phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
+   if (IS_ERR(usb_phy)) {
+   ret = PTR_ERR(usb_phy);
if (ret == -EPROBE_DEFER)
goto put_usb3_hcd;
-   hcd->usb_phy = NULL;
+   usb_phy = NULL;
} else {
-   ret = usb_phy_init(hcd->usb_phy);
+   ret = usb_phy_init(usb_phy);
if (ret)
goto put_usb3_hcd;
}
+   xhci->shared_hcd->usb_phy = usb_phy;
 
ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (ret)
@@ -189,7 +191,7 @@ dealloc_usb2_hcd:
usb_remove_hcd(hcd);
 
 disable_usb_phy:
-   usb_phy_shutdown(hcd->usb_phy);
+   usb_phy_shutdown(usb_phy);
 
 put_usb3_hcd:
usb_put_hcd(xhci->shared_hcd);
@@ -211,7 +213,7 @@ static int xhci_plat_remove(struct platform_device *dev)
struct clk *clk = xhci->clk;
 
usb_remove_hcd(xhci->shared_hcd);
-   usb_phy_shutdown(hcd->usb_phy);
+   usb_phy_shutdown(xhci->shared_hcd->usb_phy);
 
usb_remove_hcd(hcd);
usb_put_hcd(xhci->shared_hcd);
-- 
2.6.2

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


[PATCH v2 1/7] usb: xhci: plat: Fix suspend/resume when the optional clk exists

2015-12-07 Thread Jisheng Zhang
Commit 4718c1774051 ("usb: host: xhci-plat: add clock support") adds
optional clk support, but it forgets to prepare/disable and
enable/unprepare the clk in the resume/suspend path. This path fixes
this issue by adding missing clk related calls.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
Fixes: 4718c1774051 ("usb: host: xhci-plat: add clock support")
---
 drivers/usb/host/xhci-plat.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 05647e6..b566304 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -226,6 +226,7 @@ static int xhci_plat_remove(struct platform_device *dev)
 #ifdef CONFIG_PM_SLEEP
 static int xhci_plat_suspend(struct device *dev)
 {
+   int ret;
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 
@@ -237,14 +238,25 @@ static int xhci_plat_suspend(struct device *dev)
 * reconsider this when xhci_plat_suspend enlarges its scope, e.g.,
 * also applies to runtime suspend.
 */
-   return xhci_suspend(xhci, device_may_wakeup(dev));
+   ret = xhci_suspend(xhci, device_may_wakeup(dev));
+   if (ret)
+   return ret;
+
+   clk_disable_unprepare(xhci->clk);
+
+   return ret;
 }
 
 static int xhci_plat_resume(struct device *dev)
 {
+   int ret;
struct usb_hcd  *hcd = dev_get_drvdata(dev);
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 
+   ret = clk_prepare_enable(xhci->clk);
+   if (ret)
+   return ret;
+
return xhci_resume(xhci, 0);
 }
 
-- 
2.6.2

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


[PATCH v2 5/7] usb: xhci: plat: Remove checks for optional clock in error/remove path

2015-12-07 Thread Jisheng Zhang
Commit 63589e92c2d9 ("clk: Ignore error and NULL pointers passed to
clk_{unprepare, disable}()") allows NULL or error pointer to be passed
unconditionally.

This patch is to simplify probe error and remove code paths.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/host/xhci-plat.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index d990135..62f02e5 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -197,8 +197,7 @@ put_usb3_hcd:
usb_put_hcd(xhci->shared_hcd);
 
 disable_clk:
-   if (!IS_ERR(clk))
-   clk_disable_unprepare(clk);
+   clk_disable_unprepare(clk);
 
 put_hcd:
usb_put_hcd(hcd);
@@ -218,8 +217,7 @@ static int xhci_plat_remove(struct platform_device *dev)
usb_remove_hcd(hcd);
usb_put_hcd(xhci->shared_hcd);
 
-   if (!IS_ERR(clk))
-   clk_disable_unprepare(clk);
+   clk_disable_unprepare(clk);
usb_put_hcd(hcd);
 
return 0;
-- 
2.6.2

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


[PATCH v2 3/7] usb: xhci: plat: Fix suspend/resume when the optional usb_phy exists

2015-12-07 Thread Jisheng Zhang
Commit 7b8ef22ea547 ("usb: xhci: plat: Add USB phy support") adds the
usb_phy for usb3, but it forgets to shutdown/init the usb_phy in the
suspend/resume path. This patch fixes this issue by adding missing
usb_phy related calls.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/host/xhci-plat.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index a8c465a..cd49ae5 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -244,6 +244,7 @@ static int xhci_plat_suspend(struct device *dev)
if (ret)
return ret;
 
+   usb_phy_shutdown(xhci->shared_hcd->usb_phy);
clk_disable_unprepare(xhci->clk);
 
return ret;
@@ -259,6 +260,10 @@ static int xhci_plat_resume(struct device *dev)
if (ret)
return ret;
 
+   ret = usb_phy_init(xhci->shared_hcd->usb_phy);
+   if (ret)
+   return ret;
+
return xhci_resume(xhci, 0);
 }
 
-- 
2.6.2

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


[PATCH v2 4/7] usb: xhci: plat: sort the headers in alphabetic order

2015-12-07 Thread Jisheng Zhang
Sorting the headers in alphabetic order will help to reduce the conflict
when adding new headers later.

Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
---
 drivers/usb/host/xhci-plat.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index cd49ae5..d990135 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -11,15 +11,15 @@
  * version 2 as published by the Free Software Foundation.
  */
 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
 #include 
-#include 
 
 #include "xhci.h"
 #include "xhci-mvebu.h"
-- 
2.6.2

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


Re: [PATCH 5/7] usb: xhci: plat: Remove checks for optional clock in error/remove path

2015-12-04 Thread Jisheng Zhang
cc linux-usb@vger.kernel.org

On Fri, 4 Dec 2015 22:10:50 +0800
Jisheng Zhang wrote:

> Commit 63589e92c2d9 ("clk: Ignore error and NULL pointers passed to
> clk_{unprepare, disable}()") allows NULL or error pointer to be passed
> unconditionally.
> 
> This patch is to simplify probe error and remove code paths.
> 
> Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> ---
>  drivers/usb/host/xhci-plat.c | 6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index d990135..62f02e5 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -197,8 +197,7 @@ put_usb3_hcd:
>   usb_put_hcd(xhci->shared_hcd);
>  
>  disable_clk:
> - if (!IS_ERR(clk))
> - clk_disable_unprepare(clk);
> + clk_disable_unprepare(clk);
>  
>  put_hcd:
>   usb_put_hcd(hcd);
> @@ -218,8 +217,7 @@ static int xhci_plat_remove(struct platform_device *dev)
>   usb_remove_hcd(hcd);
>   usb_put_hcd(xhci->shared_hcd);
>  
> - if (!IS_ERR(clk))
> - clk_disable_unprepare(clk);
> + clk_disable_unprepare(clk);
>   usb_put_hcd(hcd);
>  
>   return 0;

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


Re: [PATCH 4/7] usb: xhci: plat: sort the headers in alphabetic order

2015-12-04 Thread Jisheng Zhang
cc linux-usb@vger.kernel.org

On Fri, 4 Dec 2015 22:10:49 +0800
Jisheng Zhang wrote:

> Sorting the headers in alphabetic order will help to reduce the conflict
> when adding new headers later.
> 
> Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> ---
>  drivers/usb/host/xhci-plat.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index cd49ae5..d990135 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -11,15 +11,15 @@
>   * version 2 as published by the Free Software Foundation.
>   */
>  
> +#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
> +#include 
>  #include 
> -#include 
>  
>  #include "xhci.h"
>  #include "xhci-mvebu.h"

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


Re: [PATCH 6/7] usb: xhci: plat: add generic PHY support

2015-12-04 Thread Jisheng Zhang
cc linux-usb@vger.kernel.org

On Fri, 4 Dec 2015 22:10:51 +0800
Jisheng Zhang wrote:

> Marvell BG4CT SoC needs two phy: one for usb2 and another for usb3. Add
> the calls to retrieve generic PHY to xhci plat in order to support this.
> 
> Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> ---
>  drivers/usb/host/xhci-plat.c | 87 
> ++--
>  1 file changed, 75 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 62f02e5..bb972a6 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -16,6 +16,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -73,6 +74,37 @@ static int xhci_plat_start(struct usb_hcd *hcd)
>   return xhci_run(hcd);
>  }
>  
> +static int xhci_plat_phy_init(struct usb_hcd *hcd)
> +{
> + int ret;
> +
> + if (hcd->phy) {
> + ret = phy_init(hcd->phy);
> + if (ret)
> + return ret;
> +
> + ret = phy_power_on(hcd->phy);
> + if (ret) {
> + phy_exit(hcd->phy);
> + return ret;
> + }
> + } else {
> + ret = usb_phy_init(hcd->usb_phy);
> + }
> +
> + return ret;
> +}
> +
> +static void xhci_plat_phy_exit(struct usb_hcd *hcd)
> +{
> + if (hcd->phy) {
> + phy_power_off(hcd->phy);
> + phy_exit(hcd->phy);
> + } else {
> + usb_phy_shutdown(hcd->usb_phy);
> + }
> +}
> +
>  static int xhci_plat_probe(struct platform_device *pdev)
>  {
>   struct device_node  *node = pdev->dev.of_node;
> @@ -83,6 +115,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
>   struct usb_hcd  *hcd;
>   struct clk  *clk;
>   struct usb_phy  *usb_phy;
> + struct phy  *phy;
>   int ret;
>   int irq;
>  
> @@ -163,22 +196,44 @@ static int xhci_plat_probe(struct platform_device *pdev)
>   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
>   xhci->shared_hcd->can_do_streams = 1;
>  
> + hcd->phy = devm_phy_get(>dev, "usb2-phy");
> + if (IS_ERR(hcd->phy)) {
> + ret = PTR_ERR(hcd->phy);
> + if (ret == -EPROBE_DEFER)
> + goto put_usb3_hcd;
> + hcd->phy = NULL;
> + }
> +
> + phy = devm_phy_get(>dev, "usb-phy");
> + if (IS_ERR(phy)) {
> + ret = PTR_ERR(phy);
> + if (ret == -EPROBE_DEFER)
> + goto put_usb3_hcd;
> + phy = NULL;
> + }
> +
>   usb_phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
>   if (IS_ERR(usb_phy)) {
>   ret = PTR_ERR(usb_phy);
>   if (ret == -EPROBE_DEFER)
>   goto put_usb3_hcd;
>   usb_phy = NULL;
> - } else {
> - ret = usb_phy_init(usb_phy);
> - if (ret)
> - goto put_usb3_hcd;
>   }
> +
>   xhci->shared_hcd->usb_phy = usb_phy;
> + xhci->shared_hcd->phy = phy;
> +
> + ret = xhci_plat_phy_init(hcd);
> + if (ret)
> + goto put_usb3_hcd;
> +
> + ret = xhci_plat_phy_init(xhci->shared_hcd);
> + if (ret)
> + goto disable_usb2_phy;
>  
>   ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
>   if (ret)
> - goto disable_usb_phy;
> + goto disable_usb3_phy;
>  
>   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
>   if (ret)
> @@ -190,8 +245,11 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  dealloc_usb2_hcd:
>   usb_remove_hcd(hcd);
>  
> -disable_usb_phy:
> - usb_phy_shutdown(usb_phy);
> +disable_usb3_phy:
> + xhci_plat_phy_exit(xhci->shared_hcd);
> +
> +disable_usb2_phy:
> + xhci_plat_phy_exit(hcd);
>  
>  put_usb3_hcd:
>   usb_put_hcd(xhci->shared_hcd);
> @@ -212,11 +270,11 @@ static int xhci_plat_remove(struct platform_device *dev)
>   struct clk *clk = xhci->clk;
>  
>   usb_remove_hcd(xhci->shared_hcd);
> - usb_phy_shutdown(xhci->shared_hcd->usb_phy);
> -
> - usb_remove_hcd(hcd);
> + xhci_plat_phy_exit(xhci->shared_hcd);
>   usb_put_hcd(xhci->shared_hcd);
>  
> + usb_remove_hcd(hcd);
> + xhci_plat_phy_exit(hcd);
>   clk_disable_unprepare(clk);
>

Re: [PATCH 7/7] usb: xhci: plat: add vbus regulator control

2015-12-04 Thread Jisheng Zhang
cc linux-usb@vger.kernel.org

On Fri, 4 Dec 2015 22:10:52 +0800
Jisheng Zhang  wrote:

> The Marvell BG4CT STB board has board level vbus control through gpio.
> This patch adds the vbus regulator control to support this board.
> 
> Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> ---
>  drivers/usb/host/xhci-plat.c | 39 ++-
>  drivers/usb/host/xhci.h  |  2 ++
>  2 files changed, 40 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index bb972a6..9bf44569 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -18,6 +18,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -116,6 +117,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
>   struct clk  *clk;
>   struct usb_phy  *usb_phy;
>   struct phy  *phy;
> + struct regulator*vbus;
>   int ret;
>   int irq;
>  
> @@ -179,14 +181,31 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  
>   device_wakeup_enable(hcd->self.controller);
>  
> + vbus = devm_regulator_get(>dev, "vbus");
> + if (PTR_ERR(vbus) == -ENODEV) {
> + vbus = NULL;
> + } else if (IS_ERR(vbus)) {
> + ret = PTR_ERR(vbus);
> + goto disable_clk;
> + } else {
> + ret = regulator_enable(vbus);
> + if (ret) {
> + dev_err(>dev,
> + "failed to enable usb vbus regulator: %d\n",
> + ret);
> + goto disable_clk;
> + }
> + }
> +
>   xhci = hcd_to_xhci(hcd);
>   xhci->clk = clk;
> + xhci->vbus = vbus;
>   xhci->main_hcd = hcd;
>   xhci->shared_hcd = usb_create_shared_hcd(driver, >dev,
>   dev_name(>dev), hcd);
>   if (!xhci->shared_hcd) {
>   ret = -ENOMEM;
> - goto disable_clk;
> + goto disable_vbus;
>   }
>  
>   if ((node && of_property_read_bool(node, "usb3-lpm-capable")) ||
> @@ -254,6 +273,10 @@ disable_usb2_phy:
>  put_usb3_hcd:
>   usb_put_hcd(xhci->shared_hcd);
>  
> +disable_vbus:
> + if (!vbus)
> + regulator_disable(vbus);
> +
>  disable_clk:
>   clk_disable_unprepare(clk);
>  
> @@ -268,6 +291,7 @@ static int xhci_plat_remove(struct platform_device *dev)
>   struct usb_hcd  *hcd = platform_get_drvdata(dev);
>   struct xhci_hcd *xhci = hcd_to_xhci(hcd);
>   struct clk *clk = xhci->clk;
> + struct regulator *vbus = xhci->vbus;
>  
>   usb_remove_hcd(xhci->shared_hcd);
>   xhci_plat_phy_exit(xhci->shared_hcd);
> @@ -278,6 +302,9 @@ static int xhci_plat_remove(struct platform_device *dev)
>   clk_disable_unprepare(clk);
>   usb_put_hcd(hcd);
>  
> + if (!vbus)
> + regulator_disable(vbus);
> +
>   return 0;
>  }
>  
> @@ -287,6 +314,7 @@ static int xhci_plat_suspend(struct device *dev)
>   int ret;
>   struct usb_hcd  *hcd = dev_get_drvdata(dev);
>   struct xhci_hcd *xhci = hcd_to_xhci(hcd);
> + struct regulator *vbus = xhci->vbus;
>  
>   /*
>* xhci_suspend() needs `do_wakeup` to know whether host is allowed
> @@ -303,6 +331,8 @@ static int xhci_plat_suspend(struct device *dev)
>   xhci_plat_phy_exit(xhci->shared_hcd);
>   xhci_plat_phy_exit(hcd);
>   clk_disable_unprepare(xhci->clk);
> + if (!vbus)
> + ret = regulator_disable(vbus);
>  
>   return ret;
>  }
> @@ -312,11 +342,18 @@ static int xhci_plat_resume(struct device *dev)
>   int ret;
>   struct usb_hcd  *hcd = dev_get_drvdata(dev);
>   struct xhci_hcd *xhci = hcd_to_xhci(hcd);
> + struct regulator *vbus = xhci->vbus;
>  
>   ret = clk_prepare_enable(xhci->clk);
>   if (ret)
>   return ret;
>  
> + if (!vbus) {
> + ret = regulator_enable(vbus);
> + if (ret)
> + return ret;
> + }
> +
>   ret = xhci_plat_phy_init(hcd);
>   if (ret)
>   return ret;
> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
> index 0b94512..1355d2a 100644
> --- a/drivers/usb/host/xhci.h
> +++ b/drivers/usb/host/xhci.h
> @@ -1541,6 +1541,8 @@ struct xhci_hcd {
>   struct msix_entry   *msix_entries;
>   /* optional clock */
>   struct clk  *clk;
> + /* optional regulator */
> + struct regulator*vbus;
>   /* data structures */
>   struct xhci_device_context_array *dcbaa;
>   struct xhci_ring*cmd_ring;

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


Re: [PATCH 2/7] usb: xhci: plat: attach the usb_phy to the correct hcd

2015-12-04 Thread Jisheng Zhang
cc linux-usb@vger.kernel.org

On Fri, 4 Dec 2015 22:10:47 +0800
Jisheng Zhang wrote:

> Commit 7b8ef22ea547 ("usb: xhci: plat: Add USB phy support") adds the
> usb_phy for usb3, but it attached the usb_phy to incorrect hcd. The
> xhci->shared_hcd is the hcd for usb3, this patch fixes this issue
> by attach the usb_phy to the xhci->shared_hcd.
> 
> Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> ---
>  drivers/usb/host/xhci-plat.c | 16 +---
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index b566304..a8c465a 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -82,6 +82,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
>   struct resource *res;
>   struct usb_hcd  *hcd;
>   struct clk  *clk;
> + struct usb_phy  *usb_phy;
>   int ret;
>   int irq;
>  
> @@ -162,17 +163,18 @@ static int xhci_plat_probe(struct platform_device *pdev)
>   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
>   xhci->shared_hcd->can_do_streams = 1;
>  
> - hcd->usb_phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
> - if (IS_ERR(hcd->usb_phy)) {
> - ret = PTR_ERR(hcd->usb_phy);
> + usb_phy = devm_usb_get_phy_by_phandle(>dev, "usb-phy", 0);
> + if (IS_ERR(usb_phy)) {
> + ret = PTR_ERR(usb_phy);
>   if (ret == -EPROBE_DEFER)
>   goto put_usb3_hcd;
> - hcd->usb_phy = NULL;
> + usb_phy = NULL;
>   } else {
> - ret = usb_phy_init(hcd->usb_phy);
> + ret = usb_phy_init(usb_phy);
>   if (ret)
>   goto put_usb3_hcd;
>   }
> + xhci->shared_hcd->usb_phy = usb_phy;
>  
>   ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
>   if (ret)
> @@ -189,7 +191,7 @@ dealloc_usb2_hcd:
>   usb_remove_hcd(hcd);
>  
>  disable_usb_phy:
> - usb_phy_shutdown(hcd->usb_phy);
> + usb_phy_shutdown(usb_phy);
>  
>  put_usb3_hcd:
>   usb_put_hcd(xhci->shared_hcd);
> @@ -211,7 +213,7 @@ static int xhci_plat_remove(struct platform_device *dev)
>   struct clk *clk = xhci->clk;
>  
>   usb_remove_hcd(xhci->shared_hcd);
> - usb_phy_shutdown(hcd->usb_phy);
> + usb_phy_shutdown(xhci->shared_hcd->usb_phy);
>  
>   usb_remove_hcd(hcd);
>   usb_put_hcd(xhci->shared_hcd);

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


Re: [PATCH 1/7] usb: xhci: plat: Fix suspend/resume when the optional clk exists

2015-12-04 Thread Jisheng Zhang
cc linux-usb@vger.kernel.org

On Fri, 4 Dec 2015 22:10:46 +0800
Jisheng Zhang wrote:

> Commit 4718c1774051 ("usb: host: xhci-plat: add clock support") adds
> optional clk support, but it forgets to prepare/disable and
> enable/unprepare the clk in the resume/suspend path. This path fixes
> this issue by adding missing clk related calls.
> 
> Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> Fixes: 4718c1774051 ("usb: host: xhci-plat: add clock support")
> ---
>  drivers/usb/host/xhci-plat.c | 14 +-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 05647e6..b566304 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -226,6 +226,7 @@ static int xhci_plat_remove(struct platform_device *dev)
>  #ifdef CONFIG_PM_SLEEP
>  static int xhci_plat_suspend(struct device *dev)
>  {
> + int ret;
>   struct usb_hcd  *hcd = dev_get_drvdata(dev);
>   struct xhci_hcd *xhci = hcd_to_xhci(hcd);
>  
> @@ -237,14 +238,25 @@ static int xhci_plat_suspend(struct device *dev)
>* reconsider this when xhci_plat_suspend enlarges its scope, e.g.,
>* also applies to runtime suspend.
>*/
> - return xhci_suspend(xhci, device_may_wakeup(dev));
> + ret = xhci_suspend(xhci, device_may_wakeup(dev));
> + if (ret)
> + return ret;
> +
> + clk_disable_unprepare(xhci->clk);
> +
> + return ret;
>  }
>  
>  static int xhci_plat_resume(struct device *dev)
>  {
> + int ret;
>   struct usb_hcd  *hcd = dev_get_drvdata(dev);
>   struct xhci_hcd *xhci = hcd_to_xhci(hcd);
>  
> + ret = clk_prepare_enable(xhci->clk);
> + if (ret)
> + return ret;
> +
>   return xhci_resume(xhci, 0);
>  }
>  

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


Re: [PATCH 3/7] usb: xhci: plat: Fix suspend/resume when the optional usb_phy exists

2015-12-04 Thread Jisheng Zhang
cc linux-usb@vger.kernel.org

On Fri, 4 Dec 2015 22:10:48 +0800
Jisheng Zhang wrote:

> Commit 7b8ef22ea547 ("usb: xhci: plat: Add USB phy support") adds the
> usb_phy for usb3, but it forgets to shutdown/init the usb_phy in the
> suspend/resume path. This patch fixes this issue by adding missing
> usb_phy related calls.
> 
> Signed-off-by: Jisheng Zhang <jszh...@marvell.com>
> ---
>  drivers/usb/host/xhci-plat.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index a8c465a..cd49ae5 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -244,6 +244,7 @@ static int xhci_plat_suspend(struct device *dev)
>   if (ret)
>   return ret;
>  
> + usb_phy_shutdown(xhci->shared_hcd->usb_phy);
>   clk_disable_unprepare(xhci->clk);
>  
>   return ret;
> @@ -259,6 +260,10 @@ static int xhci_plat_resume(struct device *dev)
>   if (ret)
>   return ret;
>  
> + ret = usb_phy_init(xhci->shared_hcd->usb_phy);
> + if (ret)
> + return ret;
> +
>   return xhci_resume(xhci, 0);
>  }
>  

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


Re: [PATCH 0/7] usb: xhci-plat: support generic PHY and vbus regulator

2015-12-04 Thread Jisheng Zhang
cc linux-usb@vger.kernel.org

Sorry, I forget to do so. Will cc linux-usb in the future.

On Fri, 4 Dec 2015 22:10:45 +0800
Jisheng Zhang wrote:

> The Marvell BG4CT has xhci controller. This controller has two phys:
> one for usb2 and another for usb3. BG4CT boards have board level vbus
> control through gpio.
> 
> I plan to add the xhci support in two steps: first of all, add generic
> PHY and vbus regulator control support to the xhci-plat driver. Then
> add the usb2 and usb3 phy drivers, after that, we add the phy and xhci
> nodes in the dtsi.
> 
> This series takes the first step. The first three patches are bug fix.
> Then two clean up patches. The last two patches add generic PHY and
> vbus regulator control support.
> 
> 
> Jisheng Zhang (7):
>   usb: xhci: plat: Fix suspend/resume when the optional clk exists
>   usb: xhci: plat: attach the usb_phy to the correct hcd
>   usb: xhci: plat: Fix suspend/resume when the optional usb_phy exists
>   usb: xhci: plat: sort the headers in alphabetic order
>   usb: xhci: plat: Remove checks for optional clock in error/remove path
>   usb: xhci: plat: add generic PHY support
>   usb: xhci: plat: add vbus regulator control
> 
>  drivers/usb/host/xhci-plat.c | 159 
> +--
>  drivers/usb/host/xhci.h  |   2 +
>  2 files changed, 140 insertions(+), 21 deletions(-)
> 

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


Re: [RESEND] phy: core: Get a refcount to phy in devm_of_phy_get_by_index()

2015-11-16 Thread Jisheng Zhang
Hi,

On Tue, 17 Nov 2015 13:56:48 +0800
Chunfeng Yun  wrote:

> On driver detach, devm_phy_release() will put a refcount to
> the phy, so gets a refconut to it before return.
> 
> Change-Id: I56fe428bf945f19c38d56245978c8ca17340eb2c

This line need to be removed



> Signed-off-by: Chunfeng Yun 
> ---
>  drivers/phy/phy-core.c | 21 +++--
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c
> index fc48fac..8c7f27d 100644
> --- a/drivers/phy/phy-core.c
> +++ b/drivers/phy/phy-core.c
> @@ -636,8 +636,9 @@ EXPORT_SYMBOL_GPL(devm_of_phy_get);
>   * @np: node containing the phy
>   * @index: index of the phy
>   *
> - * Gets the phy using _of_phy_get(), and associates a device with it using
> - * devres. On driver detach, release function is invoked on the devres data,
> + * Gets the phy using _of_phy_get(), then gets a refcount to it,
> + * and associates a device with it using devres. On driver detach,
> + * release function is invoked on the devres data,
>   * then, devres data is freed.
>   *
>   */
> @@ -651,13 +652,21 @@ struct phy *devm_of_phy_get_by_index(struct device 
> *dev, struct device_node *np,
>   return ERR_PTR(-ENOMEM);
>  
>   phy = _of_phy_get(np, index);
> - if (!IS_ERR(phy)) {
> - *ptr = phy;
> - devres_add(dev, ptr);
> - } else {
> + if (IS_ERR(phy)) {
>   devres_free(ptr);
> + return phy;
>   }
>  
> + if (!try_module_get(phy->ops->owner)) {
> + devres_free(ptr);
> + return ERR_PTR(-EPROBE_DEFER);
> + }
> +
> + get_device(>dev);
> +
> + *ptr = phy;
> + devres_add(dev, ptr);
> +
>   return phy;
>  }
>  EXPORT_SYMBOL_GPL(devm_of_phy_get_by_index);

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


Re: [RFC] usb: dwc3: add DWC3_SKIP_USB3PHY and DWC3_SKIP_USB2_PHY quirks

2015-01-08 Thread Jisheng Zhang
Hi Felipe,

On Thu, 8 Jan 2015 09:08:15 -0800
Felipe Balbi ba...@ti.com wrote:

 Hi,
 
 On Mon, Dec 08, 2014 at 09:35:51PM +0800, Jisheng Zhang wrote:
  On platforms which has native usb hosts/phys and pci-dwc3 controller,
  the dwc3 core may get the wrong usb2_phy and usb3_phy by
  devm_usb_get_phy(). It depends on which usb phy driver is initialized
  firstly, the usb_phy_generic or the native/real usb phy driver.
 
 why are you initializing generic PHY if you have a real PHY ?

we have two kind of usb hosts: the native usb hosts which can be probed via. DT
and the usb hosts from pci-dwc3. The former has real phy and the latter doesn't.

 
  Before all old USB phy library usage removed, the solution I can have
  is to add DWC3_SKIP_USB3PHY and DWC3_SKIP_USB2_PHY quirks and set them
  in dwc3-pci.
  Could such modification can be accepted? If not, could you please give
  alternative suggestions?
 
 we will not accept a quirk to skip PHYs, sorry. A better way of handling
 this needs to be found.
 

OK, Got your points. It seems we need to deprecate old usb phy library usage
early.

Thanks,
Jisheng
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC] usb: dwc3: add DWC3_SKIP_USB3PHY and DWC3_SKIP_USB2_PHY quirks

2014-12-08 Thread Jisheng Zhang
Hi list,

On platforms which has native usb hosts/phys and pci-dwc3 controller, the dwc3
core may get the wrong usb2_phy and usb3_phy by devm_usb_get_phy(). It depends
on which usb phy driver is initialized firstly, the usb_phy_generic or the
native/real usb phy driver.

Before all old USB phy library usage removed, the solution I can have is to
add DWC3_SKIP_USB3PHY and DWC3_SKIP_USB2_PHY quirks and set them in dwc3-pci.
Could such modification can be accepted? If not, could you please give 
alternative
suggestions?

Thanks,
Jisheng
--
To unsubscribe from this list: send the line unsubscribe linux-usb in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] usb: Use dma_zalloc_coherent

2014-11-12 Thread Jisheng Zhang
Use the zeroing version instead of dma_alloc_coherent and memset() as 0.

Signed-off-by: Jisheng Zhang jszh...@marvell.com
---
 drivers/usb/dwc2/hcd_ddma.c | 5 +
 drivers/usb/host/uhci-hcd.c | 3 +--
 drivers/usb/host/xhci-mem.c | 3 +--
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/dwc2/hcd_ddma.c b/drivers/usb/dwc2/hcd_ddma.c
index 3376177..d17e3cf 100644
--- a/drivers/usb/dwc2/hcd_ddma.c
+++ b/drivers/usb/dwc2/hcd_ddma.c
@@ -87,7 +87,7 @@ static u16 dwc2_frame_incr_val(struct dwc2_qh *qh)
 static int dwc2_desc_list_alloc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh,
gfp_t flags)
 {
-   qh-desc_list = dma_alloc_coherent(hsotg-dev,
+   qh-desc_list = dma_zalloc_coherent(hsotg-dev,
sizeof(struct dwc2_hcd_dma_desc) *
dwc2_max_desc_num(qh), qh-desc_list_dma,
flags);
@@ -95,9 +95,6 @@ static int dwc2_desc_list_alloc(struct dwc2_hsotg *hsotg, 
struct dwc2_qh *qh,
if (!qh-desc_list)
return -ENOMEM;
 
-   memset(qh-desc_list, 0,
-  sizeof(struct dwc2_hcd_dma_desc) * dwc2_max_desc_num(qh));
-
qh-n_bytes = kzalloc(sizeof(u32) * dwc2_max_desc_num(qh), flags);
if (!qh-n_bytes) {
dma_free_coherent(hsotg-dev, sizeof(struct dwc2_hcd_dma_desc)
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c
index a7de8e8..1d055f4 100644
--- a/drivers/usb/host/uhci-hcd.c
+++ b/drivers/usb/host/uhci-hcd.c
@@ -589,7 +589,7 @@ static int uhci_start(struct usb_hcd *hcd)
uhci-dentry = dentry;
 #endif
 
-   uhci-frame = dma_alloc_coherent(uhci_dev(uhci),
+   uhci-frame = dma_zalloc_coherent(uhci_dev(uhci),
UHCI_NUMFRAMES * sizeof(*uhci-frame),
uhci-frame_dma_handle, GFP_KERNEL);
if (!uhci-frame) {
@@ -597,7 +597,6 @@ static int uhci_start(struct usb_hcd *hcd)
unable to allocate consistent memory for frame 
list\n);
goto err_alloc_frame;
}
-   memset(uhci-frame, 0, UHCI_NUMFRAMES * sizeof(*uhci-frame));
 
uhci-frame_cpu = kcalloc(UHCI_NUMFRAMES, sizeof(*uhci-frame_cpu),
GFP_KERNEL);
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 5cb3d7a..183ada4 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -2455,7 +2455,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
if (xhci_check_trb_in_td_math(xhci, flags)  0)
goto fail;
 
-   xhci-erst.entries = dma_alloc_coherent(dev,
+   xhci-erst.entries = dma_zalloc_coherent(dev,
sizeof(struct xhci_erst_entry) * ERST_NUM_SEGS, dma,
GFP_KERNEL);
if (!xhci-erst.entries)
@@ -2464,7 +2464,6 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
// Allocated event ring segment table at 0x%llx,
(unsigned long long)dma);
 
-   memset(xhci-erst.entries, 0, sizeof(struct 
xhci_erst_entry)*ERST_NUM_SEGS);
xhci-erst.num_entries = ERST_NUM_SEGS;
xhci-erst.erst_dma_addr = dma;
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
-- 
2.1.3

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


Re: [PATCH 4/9] usb: phy: add the Berlin USB PHY driver

2014-06-09 Thread Jisheng Zhang
Dear Sebastian and Antoine,

On Fri, 6 Jun 2014 03:54:06 -0700
Sebastian Hesselbarth sebastian.hesselba...@gmail.com wrote:

  +
  +#define to_berlin_phy_priv(p)  container_of((p), struct
  berlin_phy_priv, phy) +
  +struct berlin_phy_priv {
  +   void __iomem*base;
  +   struct usb_phy  phy;
  +   struct reset_control*rst_ctrl;
  +   int pwr_gpio;
 
 Is the GPIO used for USB power? If so, we should not rely on

The GPIO is used for vbus. Sorry for using the confusing pwr. Do we still
need to use regulator API?

 GPIO at all but use regulator API. Thinking of Chromecast which
 is externally powered over USB, there will be no regulator nor
 GPIO at all.
 
  +};
  +
  +static int berlin_phy_init(struct usb_phy *phy)
  +{
  +   struct berlin_phy_priv *priv = to_berlin_phy_priv(phy);
  +   int ret;
  +
  +   reset_control_reset(priv-rst_ctrl);
  +
  +   writel(CLK_REF_DIV(0xc) | FEEDBACK_CLK_DIV(0x54),
  +  priv-base + USB_PHY_PLL);
 
 @Jisheng: IIRC the dividers above are different for BG2? Can you please
 evaluate?

Yes, BG2 uses different refdiv and fbdiv. Is there any suggestions about how to
handle this difference? The value is chosen after carefully tunning

 
  +   writel(CLK_STABLE | PLL_CTRL_REG | PHASE_OFF_TOL_250 |
  KVC0_REG_CTRL |
  +  CLK_BLK_EN, priv-base + USB_PHY_PLL_CONTROL);
  +   writel(V2I_VCO_RATIO(0x5) | R_ROTATE_0 | ANA_TEST_DC_CTRL(0x5),
  +  priv-base + USB_PHY_ANALOG);
  +   writel(PHASE_FREEZE_DLY_4_CL | ACK_LENGTH_16_CL | SQ_LENGTH_12 |
  +  DISCON_THRESHOLD_260 | SQ_THRESHOLD(0xa) | LPF_COEF(0x2) |
  +  INTPL_CUR_30, priv-base + USB_PHY_RX_CTRL);
  +
  +   writel(TX_VDD12_13 | TX_OUT_AMP(0x3), priv-base +
  USB_PHY_TX_CTRL1);
  +   writel(EXT_HS_RCAL_EN | IMPCAL_VTH_DIV(0x3) |
  EXT_RS_RCAL_DIV(0x4),
  +  priv-base + USB_PHY_TX_CTRL0);
  +
  +   writel(EXT_HS_RCAL_EN | IMPCAL_VTH_DIV(0x3) |
  EXT_RS_RCAL_DIV(0x4) |
  +  EXT_FS_RCAL_DIV(0x2), priv-base + USB_PHY_TX_CTRL0);
  +
  +   writel(EXT_HS_RCAL_EN | IMPCAL_VTH_DIV(0x3) |
  EXT_RS_RCAL_DIV(0x4),
  +  priv-base + USB_PHY_TX_CTRL0);
  +   writel(TX_CHAN_CTRL_REG(0xf) | DRV_SLEWRATE(0x3) |
  IMP_CAL_FS_HS_DLY_3 |
  +  FS_DRV_EN_MASK(0xd), priv-base + USB_PHY_TX_CTRL2);
  +
  +   ret = gpio_direction_output(priv-pwr_gpio, 0);
 
 As mentioned above, this should be using regulator API. And also, if
 there is no dummy regulator allowed, it should be optional.
 
  +   if (ret)
  +   return ret;
  +
  +   gpio_set_value(priv-pwr_gpio, 1);
  +
  +   return 0;
  +}
  +
  +static void berlin_phy_shutdown(struct usb_phy *phy)
  +{
  +   struct berlin_phy_priv *priv = to_berlin_phy_priv(phy);
  +
  +   gpio_set_value(priv-pwr_gpio, 0);
  +}
  +
  +static int berlin_phy_probe(struct platform_device *pdev)
  +{
  +   struct device_node *np = pdev-dev.of_node;
  +   struct berlin_phy_priv *priv;
  +   struct resource *res;
  +   int ret, gpio;
  +
  +   priv = devm_kzalloc(pdev-dev, sizeof(*priv), GFP_KERNEL);
  +   if (!priv)
  +   return -ENOMEM;
  +
  +   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  +   priv-base = devm_ioremap_resource(pdev-dev, res);
  +   if (IS_ERR(priv-base))
  +   return PTR_ERR(priv-base);
  +
  +   priv-rst_ctrl = devm_reset_control_get(pdev-dev, NULL);
  +   if (IS_ERR(priv-rst_ctrl)) {
  +   ret = PTR_ERR(priv-rst_ctrl);
  +   dev_err(pdev-dev, cannot get reset controller: %d\n,
  ret);
 
 Hmm, considering a non arch_init call registered reset driver, it does
 also spit out an error for -EPROBE_DEFER, does it?
 
  +   return ret;
  +   }
  +
  +   gpio = of_get_named_gpio(np, power-gpio, 0);
  +   if (!gpio_is_valid(gpio))
  +   return gpio;

Some BG2Q boards hardwired the vbus to be always powered on, we should continue
the probe if vbus gpio is missing.

Thanks,
Jisheng

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


[PATCH] usb: phy: phy-mxs-usb: set the correct platform drvdata

2013-11-06 Thread Jisheng Zhang
We need to set mxs_phy rather as the platform drvdata so that we can get
the correct mxs_phy in mxs_phy_remove().

Change-Id: I6e1753cc978e2ed3fbb3d1865be0c54031d337d2
Signed-off-by: Jisheng Zhang jszh...@marvell.com
---
 drivers/usb/phy/phy-mxs-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index fdd33b4..545844b 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -164,7 +164,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
 
mxs_phy-clk = clk;
 
-   platform_set_drvdata(pdev, mxs_phy-phy);
+   platform_set_drvdata(pdev, mxs_phy);
 
ret = usb_add_phy_dev(mxs_phy-phy);
if (ret)
-- 
1.8.4.2

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


Re: [PATCH] usb: phy: phy-mxs-usb: set the correct platform drvdata

2013-11-06 Thread Jisheng Zhang
On Wed, 6 Nov 2013 18:34:47 -0800
Shawn Guo shawn@linaro.org wrote:

 On Thu, Nov 07, 2013 at 10:26:20AM +0800, Jisheng Zhang wrote:
  We need to set mxs_phy rather as the platform drvdata so that we can get
  the correct mxs_phy in mxs_phy_remove().
  
  Change-Id: I6e1753cc978e2ed3fbb3d1865be0c54031d337d2
  Signed-off-by: Jisheng Zhang jszh...@marvell.com
 
 Acked-by: Shawn Guo shawn@linaro.org
 
 Change-Id should be dropped though.

OOPs, sorry, I should take care of that. I'll remind myself every time.

Thank you for your pointing out

Jisheng
 
 Shawn
 
  ---
   drivers/usb/phy/phy-mxs-usb.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
  
  diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
  index fdd33b4..545844b 100644
  --- a/drivers/usb/phy/phy-mxs-usb.c
  +++ b/drivers/usb/phy/phy-mxs-usb.c
  @@ -164,7 +164,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
   
  mxs_phy-clk = clk;
   
  -   platform_set_drvdata(pdev, mxs_phy-phy);
  +   platform_set_drvdata(pdev, mxs_phy);
   
  ret = usb_add_phy_dev(mxs_phy-phy);
  if (ret)
  -- 
  1.8.4.2
  
 

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


[PATCH v2] usb: phy: phy-mxs-usb: set the correct platform drvdata

2013-11-06 Thread Jisheng Zhang
We need to set mxs_phy rather as the platform drvdata so that we can get
the correct mxs_phy in mxs_phy_remove().

Signed-off-by: Jisheng Zhang jszh...@marvell.com
---
 drivers/usb/phy/phy-mxs-usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index fdd33b4..545844b 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -164,7 +164,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
 
mxs_phy-clk = clk;
 
-   platform_set_drvdata(pdev, mxs_phy-phy);
+   platform_set_drvdata(pdev, mxs_phy);
 
ret = usb_add_phy_dev(mxs_phy-phy);
if (ret)
-- 
1.8.4.2

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