[PATCH] usb: host: xhci-plat: propagate return value of platform_get_irq()

2017-05-16 Thread Thomas Petazzoni
platform_get_irq() returns an error code, but the xhci-plat driver
ignores it and always returns -ENODEV. This is not correct, and
prevents -EPROBE_DEFER from being propagated properly.

Signed-off-by: Thomas Petazzoni <thomas.petazz...@free-electrons.com>
---
 drivers/usb/host/xhci-plat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 6ed468fa..66ddd08 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -162,7 +162,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
 
irq = platform_get_irq(pdev, 0);
if (irq < 0)
-   return -ENODEV;
+   return irq;
 
/* Try to set 64-bit DMA first */
if (!pdev->dev.dma_mask)
-- 
2.7.4

--
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/3] usb: orion-echi: Add support for the Armada 3700

2017-03-08 Thread Thomas Petazzoni
Hello,

On Wed,  8 Mar 2017 17:24:21 +0100, Gregory CLEMENT wrote:

> Signed-off-by: jinghua <jing...@marvell.com>

I think you need a full first name + last name for this Signed-off-by.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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.10-rc3 07/13] net: mvneta: fix build errors when linux/phy*.h is removed from net/dsa.h

2017-02-01 Thread Thomas Petazzoni
Hello,

On Tue, 31 Jan 2017 19:18:59 +, Russell King wrote:
> drivers/net/ethernet/marvell/mvneta.c:2694:26: error: storage size of 
> 'status' isn't known
> drivers/net/ethernet/marvell/mvneta.c:2695:26: error: storage size of 
> 'changed' isn't known
> drivers/net/ethernet/marvell/mvneta.c:2695:9: error: variable 'changed' has 
> initializer but incomplete type
> drivers/net/ethernet/marvell/mvneta.c:2709:2: error: implicit declaration of 
> function 'fixed_phy_update_state' [-Werror=implicit-function-declaration]
> 
> Add linux/phy_fixed.h to mvneta.c
> 
> Signed-off-by: Russell King <rmk+ker...@armlinux.org.uk>

Acked-by: Thomas Petazzoni <thomas.petazz...@free-electrons.com>
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
--
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: xhci-plat: properly handle probe deferral for devm_clk_get()

2016-04-22 Thread Thomas Petazzoni
On some platforms, the clocks might be registered by a platform
driver. When this is the case, the clock platform driver may very well
be probed after xhci-plat, in which case the first probe() invocation
of xhci-plat will receive -EPROBE_DEFER as the return value of
devm_clk_get().

The current code handles that as a normal error, and simply assumes
that this means that the system doesn't have a clock for the XHCI
controller, and continues probing without calling
clk_prepare_enable(). Unfortunately, this doesn't work on systems
where the XHCI controller does have a clock, but that clock is
provided by another platform driver. In order to fix this situation,
we handle the -EPROBE_DEFER error condition specially, and abort the
XHCI controller probe(). It will be retried later automatically, the
clock will be available, devm_clk_get() will succeed, and the probe()
will continue with the clock prepared and enabled as expected.

In practice, such issue is seen on the ARM64 Marvell 7K/8K platform,
where the clocks are registered by a platform driver.

Signed-off-by: Thomas Petazzoni <thomas.petazz...@free-electrons.com>
---
Changes since v1:
 - Re-order how the EPROBE_DEFER error handling is done, according to
   a suggestion from Heikki Krogerus
   <heikki.kroge...@linux.intel.com>.
---
 drivers/usb/host/xhci-plat.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 5c15e9b..bc6dfbc 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -181,6 +181,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
ret = clk_prepare_enable(clk);
if (ret)
goto put_hcd;
+   } else if (PTR_ERR(clk) == -EPROBE_DEFER) {
+   ret = -EPROBE_DEFER;
+   goto put_hcd;
}
 
xhci = hcd_to_xhci(hcd);
-- 
2.6.4

--
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: xhci-plat: properly handle probe deferral for devm_clk_get()

2016-04-22 Thread Thomas Petazzoni
Hello,

On Fri, 22 Apr 2016 16:44:11 +0300, Heikki Krogerus wrote:

>   if (!IS_ERR(clk)) {
> ...
> } else if (PTR_ERR(clk) == -EPROBE_DEFER)
>   ret = -EPROBE_DEFER;
>   goto put_hcd;
> ...

Thanks for the review! I've just sent a v2 that addresses this comment.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: xhci-plat: properly handle probe deferral for devm_clk_get()

2016-04-22 Thread Thomas Petazzoni
On some platforms, the clocks might be registered by a platform
driver. When this is the case, the clock platform driver may very well
be probed after xhci-plat, in which case the first probe() invocation
of xhci-plat will receive -EPROBE_DEFER as the return value of
devm_clk_get().

The current code handles that as a normal error, and simply assumes
that this means that the system doesn't have a clock for the XHCI
controller, and continues probing without calling
clk_prepare_enable(). Unfortunately, this doesn't work on systems
where the XHCI controller does have a clock, but that clock is
provided by another platform driver. In order to fix this situation,
we handle the -EPROBE_DEFER error condition specially, and abort the
XHCI controller probe(). It will be retried later automatically, the
clock will be available, devm_clk_get() will succeed, and the probe()
will continue with the clock prepared and enabled as expected.

In practice, such issue is seen on the ARM64 Marvell 7K/8K platform,
where the clocks are registered by a platform driver.

Signed-off-by: Thomas Petazzoni <thomas.petazz...@free-electrons.com>
---
 drivers/usb/host/xhci-plat.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 5c15e9b..1a00c9a 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -177,6 +177,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
 * clock does not exists.
 */
clk = devm_clk_get(>dev, NULL);
+   if (IS_ERR(clk) && PTR_ERR(clk) == -EPROBE_DEFER) {
+   ret = -EPROBE_DEFER;
+   goto put_hcd;
+   }
if (!IS_ERR(clk)) {
ret = clk_prepare_enable(clk);
if (ret)
-- 
2.6.4

--
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/4] usb: XHCI: platform: Move the Marvell quirks after the enabling the clocks

2015-01-06 Thread Thomas Petazzoni
Dear Maxime Ripard,

On Tue,  6 Jan 2015 16:45:08 +0100, Maxime Ripard wrote:

 + if (of_device_is_compatible(pdev-dev.of_node,
 + marvell,armada-375-xhci) ||
 + of_device_is_compatible(pdev-dev.of_node,
 + marvell,armada-380-xhci)) {
 + ret = xhci_mvebu_mbus_init_quirk(pdev);
 + if (ret)
 + return ret;
 + }

So on error, you're leaking the struct usb_hcd now if I'm not mistaken.
When moving code around, the error handling should also be fixed. You
probably need goto put_hcd; instead of return ret;.

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: ehci-orion: enable big-endian support

2014-11-19 Thread Thomas Petazzoni
Dear Marcin Wojtas,

On Thu, 13 Nov 2014 00:49:50 +0100, Marcin Wojtas wrote:
 This commit fixes ehci-orion operation in big-endian mode by enabling byteswap
 when accessing registers using 'rdl' and 'wrl' macros.
 
 Signed-off-by: Grzegorz Jaszczyk j...@semihalf.com
 Signed-off-by: Marcin Wojtas m...@semihalf.com
 Reviewed-by: Gregory CLEMENT gregory.clem...@free-electrons.com

Tested-by: Thomas Petazzoni thomas.petazz...@free-electrons.com

Indeed, on Armada XP GP, without this patch, no USB devices are
detected when the kernel runs in big endian mode. With this patch
applied, a USB key is properly detected and I can mount/access it.

Moreover, using {readl,writel}_relaxed() is safe here: even though
those I/O accessors are not yet available on all architectures, the
ehci-orion driver has a depends on PLAT_ORION, so it can only be
enabled on ARM, which has those accessors available.

Greg, Alan, could you apply Marcin's patch?

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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/5] phy: add support for USB cluster on the Armada 375 SoC

2014-05-24 Thread Thomas Petazzoni
Gregory, Kishon,

On Fri, 23 May 2014 23:50:54 +0200, Gregory CLEMENT wrote:

  +MODULE_DESCRIPTION(Armada 375 USB cluster driver);
  +MODULE_AUTHOR(Gregory CLEMENT gregory.clem...@free-electrons.com);
  +MODULE_LICENSE(GPL);
  
  GPL v2?
 
 See the header, I chose GNU General Public License version 2 or later.
 so GPL match it.

And also, the vast majority of kernel drivers use
MODULE_LICENSE(GPL) :

$ git grep 'MODULE_LICENSE(GPL)' | wc -l
5615
$ git grep 'MODULE_LICENSE(GPLv2)' | wc -l
5
$ git grep 'MODULE_LICENSE(GPL v2)' | wc -l
932

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: [PATCHv5 08/20] usb: host: xhci-plat: add support for the Armada 375/38x XHCI controllers

2014-05-12 Thread Thomas Petazzoni
Dear Mathias Nyman,

On Mon, 12 May 2014 20:24:45 +0300, Mathias Nyman wrote:

  +int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev)
  +{
  +   struct resource *res;
  +   void __iomem *base;
  +   const struct mbus_dram_target_info *dram;
 
 Hi
 
 Sparse warns about this:
 
 drivers/usb/host/xhci-mvebu.c:42:5: warning: symbol 
 'xhci_mvebu_mbus_init_quirk' 
 was not declared. Should it be static?

Not, it should not: it gets called from xhci-plat.c. However,
xhci-mvebu.c should include its header xhci-mvebu.h so that sparse
realize that the function is voluntarily exported, and that therefore
not having the static qualifier is expected.

Should we resend a v6 with just this change?

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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


[PATCHv5 03/20] usb: ehci-orion: fix clock reference leaking

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

In order to disable the clock in the -remove() function, a call to
devm_clk_get() is being made, which further increases the reference
count of the clock.

In order to clean this up, a private structure holding a pointer to
the clock is added using the override mechanism provided by the ehci
framework. This makes the driver clock handling much more logical.

The bug was introduced in v3.6, however the ehci framework allowing to
use the override mechanism has only been introduced in v3.8, so this
patch won't apply before it.

[Thomas: reword commit log, fix goto label names.]

Fixes: 8c869edaee07c623066266827371235fb9c12e01 ('ARM: Orion: EHCI: Add support 
for enabling clocks')
Cc: sta...@vger.kernel.org # v3.8+
Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/ehci-orion.c | 45 ---
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 9298be7..9c98bac 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -42,6 +42,12 @@
 
 #define DRIVER_DESC EHCI orion driver
 
+#define hcd_to_orion_priv(h) ((struct orion_ehci_hcd *)hcd_to_ehci(h)-priv)
+
+struct orion_ehci_hcd {
+   struct clk *clk;
+};
+
 static const char hcd_name[] = ehci-orion;
 
 static struct hc_driver __read_mostly ehci_orion_hc_driver;
@@ -137,6 +143,10 @@ ehci_orion_conf_mbus_windows(struct usb_hcd *hcd,
}
 }
 
+static const struct ehci_driver_overrides orion_overrides __initconst = {
+   .extra_priv_size =  sizeof(struct orion_ehci_hcd),
+};
+
 static int ehci_orion_drv_probe(struct platform_device *pdev)
 {
struct orion_ehci_data *pd = dev_get_platdata(pdev-dev);
@@ -144,10 +154,10 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
struct resource *res;
struct usb_hcd *hcd;
struct ehci_hcd *ehci;
-   struct clk *clk;
void __iomem *regs;
int irq, err;
enum orion_ehci_phy_ver phy_version;
+   struct orion_ehci_hcd *priv;
 
if (usb_disabled())
return -ENODEV;
@@ -187,17 +197,11 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
goto err;
}
 
-   /* Not all platforms can gate the clock, so it is not
-  an error if the clock does not exists. */
-   clk = devm_clk_get(pdev-dev, NULL);
-   if (!IS_ERR(clk))
-   clk_prepare_enable(clk);
-
hcd = usb_create_hcd(ehci_orion_hc_driver,
pdev-dev, dev_name(pdev-dev));
if (!hcd) {
err = -ENOMEM;
-   goto err_create_hcd;
+   goto err;
}
 
hcd-rsrc_start = res-start;
@@ -208,6 +212,15 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
ehci-caps = hcd-regs + 0x100;
hcd-has_tt = 1;
 
+   priv = hcd_to_orion_priv(hcd);
+   /*
+* Not all platforms can gate the clock, so it is not an error if
+* the clock does not exists.
+*/
+   priv-clk = devm_clk_get(pdev-dev, NULL);
+   if (!IS_ERR(priv-clk))
+   clk_prepare_enable(priv-clk);
+
/*
 * (Re-)program MBUS remapping windows if we are asked to.
 */
@@ -243,10 +256,9 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
return 0;
 
 err_add_hcd:
+   if (!IS_ERR(priv-clk))
+   clk_disable_unprepare(priv-clk);
usb_put_hcd(hcd);
-err_create_hcd:
-   if (!IS_ERR(clk))
-   clk_disable_unprepare(clk);
 err:
dev_err(pdev-dev, init %s fail, %d\n,
dev_name(pdev-dev), err);
@@ -257,14 +269,15 @@ err:
 static int ehci_orion_drv_remove(struct platform_device *pdev)
 {
struct usb_hcd *hcd = platform_get_drvdata(pdev);
-   struct clk *clk;
+   struct orion_ehci_hcd *priv = hcd_to_orion_priv(hcd);
 
usb_remove_hcd(hcd);
+
+   if (!IS_ERR(priv-clk))
+   clk_disable_unprepare(priv-clk);
+
usb_put_hcd(hcd);
 
-   clk = devm_clk_get(pdev-dev, NULL);
-   if (!IS_ERR(clk))
-   clk_disable_unprepare(clk);
return 0;
 }
 
@@ -292,7 +305,7 @@ static int __init ehci_orion_init(void)
 
pr_info(%s:  DRIVER_DESC \n, hcd_name);
 
-   ehci_init_driver(ehci_orion_hc_driver, NULL);
+   ehci_init_driver(ehci_orion_hc_driver, orion_overrides);
return platform_driver_register(ehci_orion_driver);
 }
 module_init(ehci_orion_init);
-- 
1.9.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


[PATCHv5 02/20] usb: ehci-orion: rename error goto labels in ehci_orion_drv_probe()

2014-05-11 Thread Thomas Petazzoni
In preparation to the introduction of additional initialization steps
in ehci_orion_drv_probe(), we rename the error goto labels from err1,
err2 and err3 names to some more meaningful names.

Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/ehci-orion.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 7728e83..9298be7 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -160,7 +160,7 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
Found HC with no IRQ. Check %s setup!\n,
dev_name(pdev-dev));
err = -ENODEV;
-   goto err1;
+   goto err;
}
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -169,7 +169,7 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
Found HC with no register addr. Check %s setup!\n,
dev_name(pdev-dev));
err = -ENODEV;
-   goto err1;
+   goto err;
}
 
/*
@@ -179,12 +179,12 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
 */
err = dma_coerce_mask_and_coherent(pdev-dev, DMA_BIT_MASK(32));
if (err)
-   goto err1;
+   goto err;
 
regs = devm_ioremap_resource(pdev-dev, res);
if (IS_ERR(regs)) {
err = PTR_ERR(regs);
-   goto err1;
+   goto err;
}
 
/* Not all platforms can gate the clock, so it is not
@@ -197,7 +197,7 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
pdev-dev, dev_name(pdev-dev));
if (!hcd) {
err = -ENOMEM;
-   goto err2;
+   goto err_create_hcd;
}
 
hcd-rsrc_start = res-start;
@@ -237,17 +237,17 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
 
err = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (err)
-   goto err3;
+   goto err_add_hcd;
 
device_wakeup_enable(hcd-self.controller);
return 0;
 
-err3:
+err_add_hcd:
usb_put_hcd(hcd);
-err2:
+err_create_hcd:
if (!IS_ERR(clk))
clk_disable_unprepare(clk);
-err1:
+err:
dev_err(pdev-dev, init %s fail, %d\n,
dev_name(pdev-dev), err);
 
-- 
1.9.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


[PATCHv5 10/20] phy: add support for USB cluster on the Armada 375 SoC

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Armada 375 SoC comes with an USB2 host and device controller and
an USB3 controller. The USB cluster control register allows to manage
common features of both USB controllers.

This commit adds a driver integrated in the generic PHY framework to
control this USB cluster feature.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 drivers/phy/Kconfig  |   6 ++
 drivers/phy/Makefile |   1 +
 drivers/phy/phy-armada375-usb2.c | 157 +++
 3 files changed, 164 insertions(+)
 create mode 100644 drivers/phy/phy-armada375-usb2.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 3bb05f1..e63cf9d 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -15,6 +15,12 @@ config GENERIC_PHY
  phy users can obtain reference to the PHY. All the users of this
  framework should select this config.
 
+config ARMADA375_USBCLUSTER_PHY
+   def_bool y
+   depends on MACH_ARMADA_375 || COMPILE_TEST
+   depends on OF
+   select GENERIC_PHY
+
 config PHY_EXYNOS_MIPI_VIDEO
tristate S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver
depends on HAS_IOMEM
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 2faf78e..47d5a86 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
diff --git a/drivers/phy/phy-armada375-usb2.c b/drivers/phy/phy-armada375-usb2.c
new file mode 100644
index 000..a6f746d
--- /dev/null
+++ b/drivers/phy/phy-armada375-usb2.c
@@ -0,0 +1,157 @@
+/*
+ * USB cluster support for Armada 375 platform.
+ *
+ * Copyright (C) 2014 Marvell
+ *
+ * Gregory CLEMENT gregory.clem...@free-electrons.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2 or later. This program is licensed as is
+ * without any warranty of any kind, whether express or implied.
+ *
+ * Armada 375 comes with an USB2 host and device controller and an
+ * USB3 controller. The USB cluster control register allows to manage
+ * common features of both USB controllers.
+ */
+
+#include linux/init.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of_address.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+#include linux/slab.h
+
+#define USB2_PHY_CONFIG_DISABLE BIT(0)
+
+/* The USB cluster allows to choose between two PHYs */
+#define NB_PHY 2
+
+enum {
+   PHY_USB2 = 0,
+   PHY_USB3 = 1,
+};
+
+struct armada375_cluster_phy {
+   struct phy *phy;
+   void __iomem *reg;
+   bool enable;
+   bool use_usb3;
+};
+
+struct armada375_cluster_phy usb_cluster_phy[NB_PHY];
+
+static int armada375_usb_phy_init(struct phy *phy)
+{
+   struct armada375_cluster_phy *cluster_phy = phy_get_drvdata(phy);
+   u32 reg;
+
+   if (!cluster_phy-enable)
+   return -ENODEV;
+
+   reg = readl(cluster_phy-reg);
+   if (cluster_phy-use_usb3)
+   reg |= USB2_PHY_CONFIG_DISABLE;
+   else
+   reg = ~USB2_PHY_CONFIG_DISABLE;
+   writel(reg, cluster_phy-reg);
+
+   return 0;
+}
+
+static struct phy_ops armada375_usb_phy_ops = {
+   .init = armada375_usb_phy_init,
+   .owner  = THIS_MODULE,
+};
+
+static struct phy *armada375_usb_phy_xlate(struct device *dev,
+   struct of_phandle_args *args)
+{
+   if (WARN_ON(args-args[0] = NB_PHY))
+   return ERR_PTR(-ENODEV);
+
+   return usb_cluster_phy[args-args[0]].phy;
+}
+
+static int armada375_usb_phy_probe(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct phy *phy;
+   struct phy_provider *phy_provider;
+   void __iomem *usb_cluster_base;
+   struct device_node *xhci_node;
+   struct resource *res;
+   int i;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   usb_cluster_base = devm_ioremap_resource(pdev-dev, res);
+   if (!usb_cluster_base)
+   return -ENOMEM;
+
+   for (i = 0; i  NB_PHY; i++) {
+   phy = devm_phy_create(dev, armada375_usb_phy_ops, NULL);
+   if (IS_ERR(phy)) {
+   dev_err(dev, failed to create PHY n%d\n, i);
+   return PTR_ERR(phy);
+   }
+
+   usb_cluster_phy[i].phy = phy;
+   usb_cluster_phy[i].reg = usb_cluster_base;
+   usb_cluster_phy[i].enable = false;
+   phy_set_drvdata(phy, usb_cluster_phy[i

[PATCHv5 12/20] ARM: mvebu: add USB3 support for Armada 38x

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

This patch adds the selection of the config symbol needed to build the
USB3 support for Armada 38x into mvebu_v7_defconfig.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/mach-mvebu/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 3f73eec..7960f21 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -54,6 +54,7 @@ config MACH_ARMADA_38X
select CPU_V7
select MACH_MVEBU_V7
select PINCTRL_ARMADA_38X
+   select USB_ARCH_HAS_XHCI
help
  Say 'Y' here if you want your kernel to support boards based
  on the Marvell Armada 380/385 SoC with device tree.
-- 
1.9.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


[PATCHv5 00/20] USB support for Armada 38x and Armada 375

2014-05-11 Thread Thomas Petazzoni
Hello,

This patch set adds the USB support for the Armada 38x and Armada 375
SOCs. These SoCs use an xHCI but still need specific initialization,
mainly to setup the MBus memory windows. They also have another USB
controller for EHCI, identical to the one used on other mvebu SOCs.

This series is also available in
the branch USB-375-38x-3.15-rc1-V5
https://github.com/MISL-EBU-System-SW/mainline-public.git

Changes between v4 and v5:

 * Fixed a compile time problem when CONFIG_USB_XHCI_MVEBU was
   disabled. Noticed by Shimoda, Yoshihiro
   yoshihiro.shimoda...@renesas.com.

 * Added Acked-by from Alan Stern on patches 1 to 4.

Changes between v3 and v4:

 * Additional patch that removes the use of of_irq_parse_and_map() in
   ehci-orion, and just uses platform_get_irq() instead, to avoid a
   different case between DT and non-T.

 * Additional patch that renames the ehci-orion error handling goto
   labels to have more meaningful names, in preparation for handling
   of additional error cases in followup patches.

 * Additional patch to update the ehci-orion Device Tree binding
   documentation.

 * Merge of 375/38x XHCI support patches: one patch for the driver,
   one patch for the Device Tree binding documentation (instead of one
   patch of these, for each SoC).

 * Update of the XHCI Device Tree binding documentation to indicate
   the new optional clocks property.

 * Update of armada-375.dtsi to add missing spaces in the phy-names
   definition.

 * Update of armada-38x.dtsi to use 0x4000 instead of 0x3fff for the
   register area length. Noticed by Andrew Lunn.

 * Changed the PHY driver Kconfig option to only be enabled either
   when MACH_ARMADA_375 or COMPILE_TEST are enabled. In the previous
   version, the PHY driver was always enabled, regardless of the
   platform.

 * Various improvements to the PHY driver:

- Rename USB2_PHY_CONFIG_ENABLE to USB2_PHY_CONFIG_DISABLE, as
  suggested by Ezequiel Garcia.
- Simplify the logic of armada375_usb_phy_init() by handling the
  !cluster_phy-enable case first.
- Use devm_ioremap_resource() in the -probe() function instead of
  of_iomap().
- Bail out from -probe() when a PHY cannot be created.
- Fix typos in comments.

 * Reworded the Kconfig prompt and help text of XHCI_MVEBU to indicate
   that it's for both 375 and 38x (it was only indicating 38x until
   now).

 * Changed the Makefile bit of the xhci-mvebu driver according to the
   suggestion of Felipe Balbi, so that things work properly when
   CONFIG_USB_XHCI_MVEBU is 'm'.

 * Various improvements in the ehci-orion driver:

- Use better goto labels for error handling in -probe().
- Use devm_phy_optional_get() instead of devm_phy_get(), which
  allows to handle EPROBE_DEFER cases nicely.
- Call phy_power_off() when needed (probe error handling, and
  remove).
- Use __initconst instead of __initdata for override structure, as
  noticed by checkpatch.
- Fix use after free errors noticed by Felipe Balbi.

 * Various improvements to the XHCI driver:

- Don't make xhci_mvebu_mbus_config() an __init function, since
  it's called from probe(), which isn't in __init.
- Don't use the buggy 'priv[0]' solution implemented in the
  previous version of the patch set (see in
  http://lists.infradead.org/pipermail/linux-arm-kernel/2014-May/253871.html
  the details of why it doesn't work). Instead, add a 'struct
  clk*' field in xhci_hcd to support the clock in xhci-plat,
  exactly like xhci_hcd has msix_count and msix_entries for
  xhci-pci.
- Misc minor code style improvements.

Thomas

Gregory CLEMENT (17):
  usb: ehci-orion: fix clock reference leaking
  usb: ehci-orion: add optional PHY support
  usb: host: xhci-plat: sort the headers in alphabetic order
  usb: host: xhci-plat: add clock support
  usb: host: xhci-plat: add support for the Armada 375/38x XHCI
controllers
  Documentation: dt-bindings: update xhci-platform DT binding
  phy: add support for USB cluster on the Armada 375 SoC
  Documentation: dt-bindings: document the Armada 375 USB cluster
binding
  ARM: mvebu: add USB3 support for Armada 38x
  ARM: mvebu: add USB3 support for Armada 375
  ARM: configs: enable XHCI mvebu support in mvebu_v7_defconfig
  ARM: configs: enable XHCI mvebu support in multi_v7_defconfig
  ARM: mvebu: add Device Tree description of xHCI controllers on Armada
38x
  ARM: mvebu: add Device Tree description of the EHCI controller on
Armada 38x
  ARM: mvebu: add Device Tree description of USB cluster controller on
Armada 375
  ARM: mvebu: add Device Tree description of the xHCI controller on
Armada 375
  ARM: mvebu: add Device Tree description of the EHCI controller on
Armada 375

Thomas Petazzoni (3):
  usb: ehci-orion: use platform_get_irq() for DT probing
  usb: ehci-orion: rename error goto labels in ehci_orion_drv_probe()
  Documentation: dt-bindings: update ehci-orion binding

[PATCHv5 13/20] ARM: mvebu: add USB3 support for Armada 375

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

This patch add the selection of the config symbol to build the USB3
support for Armada 375.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/mach-mvebu/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 7960f21..95afc76 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -41,6 +41,7 @@ config MACH_ARMADA_375
select CPU_V7
select MACH_MVEBU_V7
select PINCTRL_ARMADA_375
+   select USB_ARCH_HAS_XHCI
help
  Say 'Y' here if you want your kernel to support boards based
  on the Marvell Armada 375 SoC with device tree.
-- 
1.9.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


[PATCHv5 14/20] ARM: configs: enable XHCI mvebu support in mvebu_v7_defconfig

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Marvell Armada 38x platform needs the xhci_mvebu driver enabled
for the xHCI USB hosts, so this commit enables the corresponding
Kconfig option in mvebu_v7_defconfig.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/configs/mvebu_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/mvebu_v7_defconfig 
b/arch/arm/configs/mvebu_v7_defconfig
index a34713d..e881106 100644
--- a/arch/arm/configs/mvebu_v7_defconfig
+++ b/arch/arm/configs/mvebu_v7_defconfig
@@ -78,6 +78,7 @@ CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_ROOT_HUB_TT=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MVEBU=y
 CONFIG_MMC=y
 CONFIG_MMC_MVSDIO=y
 CONFIG_NEW_LEDS=y
-- 
1.9.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


[PATCHv5 20/20] ARM: mvebu: add Device Tree description of the EHCI controller on Armada 375

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Marvell Armada 375 SoCs contains one EHCI controller. This commit
adds the Device Tree description of this interfaces at the SoC level,
and also enables the USB2 port on the Armada 375 DB platform.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/boot/dts/armada-375-db.dts |  4 
 arch/arm/boot/dts/armada-375.dtsi   | 18 ++
 2 files changed, 22 insertions(+)

diff --git a/arch/arm/boot/dts/armada-375-db.dts 
b/arch/arm/boot/dts/armada-375-db.dts
index 0453d69..01bc5e8 100644
--- a/arch/arm/boot/dts/armada-375-db.dts
+++ b/arch/arm/boot/dts/armada-375-db.dts
@@ -102,6 +102,10 @@
};
};
 
+   usb@54000 {
+   status = okay;
+   };
+
usb3@58000 {
status = okay;
};
diff --git a/arch/arm/boot/dts/armada-375.dtsi 
b/arch/arm/boot/dts/armada-375.dtsi
index 1b81d1e..945df89 100644
--- a/arch/arm/boot/dts/armada-375.dtsi
+++ b/arch/arm/boot/dts/armada-375.dtsi
@@ -320,6 +320,24 @@
clocks = coreclk 0;
};
 
+   usb@5 {
+   compatible = marvell,orion-ehci;
+   reg = 0x5 0x500;
+   interrupts = GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH;
+   clocks = gateclk 18;
+   phys = usbcluster 0;
+   phy-names = usb;
+   status = disabled;
+   };
+
+   usb@54000 {
+   compatible = marvell,orion-ehci;
+   reg = 0x54000 0x500;
+   interrupts = GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH;
+   clocks = gateclk 26;
+   status = disabled;
+   };
+
usb3@58000 {
compatible = marvell,armada-375-xhci;
reg = 0x58000 0x2,0x5b880 0x80;
-- 
1.9.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


[PATCHv5 11/20] Documentation: dt-bindings: document the Armada 375 USB cluster binding

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

Armada 375 comes with an USB2 host and device controller and an USB3
controller. The USB cluster control register allows to manage common
features of both USB controllers. This commit adds the Device Tree
binding documentation for this piece of hardware.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 .../bindings/phy/armada-375-usb-phy-cluster.txt   | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/armada-375-usb-phy-cluster.txt

diff --git 
a/Documentation/devicetree/bindings/phy/armada-375-usb-phy-cluster.txt 
b/Documentation/devicetree/bindings/phy/armada-375-usb-phy-cluster.txt
new file mode 100644
index 000..258407c
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/armada-375-usb-phy-cluster.txt
@@ -0,0 +1,19 @@
+Armada 375 USB cluster
+--
+
+Armada 375 comes with an USB2 host and device controller and an USB3
+controller. The USB cluster control register allows to manage common
+features of both USB controllers.
+
+Required properties:
+
+- compatible: marvell,armada-375-usb-cluster
+- reg: Should contain usb cluster register location and length.
+- #phy-cells : from the generic phy bindings, must be 1
+
+Example:
+   usbcluster: usb-cluster@18400 {
+   compatible = marvell,armada-375-usb-cluster;
+   reg = 0x18400 0x4;
+   #phy-cells = 1
+   };
-- 
1.9.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


[PATCHv5 01/20] usb: ehci-orion: use platform_get_irq() for DT probing

2014-05-11 Thread Thomas Petazzoni
Commit 77dae54ab385033e488d8b07045bc7f8d931740f ('ARM: Kirkwood:
ehci-orion: Add device tree binding') added the Device Tree binding
for the ehci-orion driver. To achieve that with the irq, it used the
irq_of_parse_and_map() function when probed in DT-mode, and
platform_get_irq() when probed in non-DT mode.

This is not necessary: platform_get_irq() works just as fine in
DT-mode, since the conversion from DT information to 'struct resource'
is done by the generic layers of the kernel.

Therefore, this commit switches back to use just platform_get_irq().

Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/ehci-orion.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 30d35e5..7728e83 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -154,10 +154,7 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
 
pr_debug(Initializing Orion-SoC USB Host Controller\n);
 
-   if (pdev-dev.of_node)
-   irq = irq_of_parse_and_map(pdev-dev.of_node, 0);
-   else
-   irq = platform_get_irq(pdev, 0);
+   irq = platform_get_irq(pdev, 0);
if (irq = 0) {
dev_err(pdev-dev,
Found HC with no IRQ. Check %s setup!\n,
-- 
1.9.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


[PATCHv5 05/20] Documentation: dt-bindings: update ehci-orion binding documentation

2014-05-11 Thread Thomas Petazzoni
This commit updates the Device Tree binding documentation of
ehci-orion to take into account the fact that we can now optionally
pass a clock and a PHY reference.

Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 Documentation/devicetree/bindings/usb/ehci-orion.txt | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/ehci-orion.txt 
b/Documentation/devicetree/bindings/usb/ehci-orion.txt
index 6bc09ec..17c3bc8 100644
--- a/Documentation/devicetree/bindings/usb/ehci-orion.txt
+++ b/Documentation/devicetree/bindings/usb/ehci-orion.txt
@@ -6,6 +6,11 @@ Required properties:
   region.
 - interrupts: The EHCI interrupt
 
+Optional properties:
+- clocks: reference to the clock
+- phys: reference to the USB PHY
+- phy-names: name of the USB PHY, should be usb
+
 Example:
 
ehci@5 {
-- 
1.9.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


[PATCHv5 06/20] usb: host: xhci-plat: sort the headers in alphabetic order

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

Sorting the headers in alphabetic order will help to reduce the conflict
when adding new headers later.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Acked-by: Felipe Balbi ba...@ti.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.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 151901c..f5351af 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -11,11 +11,11 @@
  * version 2 as published by the Free Software Foundation.
  */
 
-#include linux/platform_device.h
+#include linux/dma-mapping.h
 #include linux/module.h
-#include linux/slab.h
 #include linux/of.h
-#include linux/dma-mapping.h
+#include linux/platform_device.h
+#include linux/slab.h
 
 #include xhci.h
 
-- 
1.9.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


[PATCHv5 15/20] ARM: configs: enable XHCI mvebu support in multi_v7_defconfig

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Marvell Armada 38x platform needs the xhci_mvebu driver enabled
for the xHCI USB hosts, so this commit enables the corresponding
Kconfig option in multi_v7_defconfig.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
Cc: a...@kernel.org
Cc: Kevin Hilman khil...@linaro.org
Cc: Olof Johansson o...@lixom.net
Cc: Arnd Bergmann a...@arndb.de
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index d4e8a47..820cc35 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -254,6 +254,7 @@ CONFIG_SND_SOC_TEGRA_ALC5632=y
 CONFIG_SND_SOC_TEGRA_MAX98090=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MVEBU=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_EHCI_HCD_PLATFORM=y
-- 
1.9.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


[PATCHv5 08/20] usb: host: xhci-plat: add support for the Armada 375/38x XHCI controllers

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Armada 375 and 38x SoCs come with an XHCI controller that requires
some specific initialization related to the MBus windows
configuration. This patch adds the support for this special
configuration as an XHCI quirk executed during probe.

Two new compatible strings are added to identify the Armada 375 and
Armada 38x XHCI controllers, and therefore enable the relevant quirk.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 drivers/usb/host/Kconfig  |  8 +
 drivers/usb/host/Makefile |  3 ++
 drivers/usb/host/xhci-mvebu.c | 70 +++
 drivers/usb/host/xhci-mvebu.h | 21 +
 drivers/usb/host/xhci-plat.c  | 12 
 5 files changed, 114 insertions(+)
 create mode 100644 drivers/usb/host/xhci-mvebu.c
 create mode 100644 drivers/usb/host/xhci-mvebu.h

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 3d9e540..9247ad2 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -29,6 +29,14 @@ if USB_XHCI_HCD
 config USB_XHCI_PLATFORM
tristate
 
+config USB_XHCI_MVEBU
+   tristate xHCI support for Marvell Armada 375/38x
+   select USB_XHCI_PLATFORM
+   depends on ARCH_MVEBU || COMPILE_TEST
+   ---help---
+ Say 'Y' to enable the support for the xHCI host controller
+ found in Marvell Armada 375/38x ARM SOCs.
+
 endif # USB_XHCI_HCD
 
 config USB_EHCI_HCD
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 7530468..7c0886a 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -19,6 +19,9 @@ xhci-hcd-$(CONFIG_PCI)+= xhci-pci.o
 
 ifneq ($(CONFIG_USB_XHCI_PLATFORM), )
xhci-hcd-y  += xhci-plat.o
+ifneq ($(CONFIG_USB_XHCI_MVEBU), )
+   xhci-hcd-y  += xhci-mvebu.o
+endif
 endif
 
 obj-$(CONFIG_USB_WHCI_HCD) += whci/
diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
new file mode 100644
index 000..fab9d6f
--- /dev/null
+++ b/drivers/usb/host/xhci-mvebu.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2014 Marvell
+ * Author: Gregory CLEMENT gregory.clem...@free-electrons.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ */
+
+#include linux/io.h
+#include linux/mbus.h
+#include linux/of.h
+#include linux/platform_device.h
+
+#define USB3_MAX_WINDOWS   4
+#define USB3_WIN_CTRL(w)   (0x0 + ((w) * 8))
+#define USB3_WIN_BASE(w)   (0x4 + ((w) * 8))
+
+static void xhci_mvebu_mbus_config(void __iomem *base,
+   const struct mbus_dram_target_info *dram)
+{
+   int win;
+
+   /* Clear all existing windows */
+   for (win = 0; win  USB3_MAX_WINDOWS; win++) {
+   writel(0, base + USB3_WIN_CTRL(win));
+   writel(0, base + USB3_WIN_BASE(win));
+   }
+
+   /* Program each DRAM CS in a seperate window */
+   for (win = 0; win  dram-num_cs; win++) {
+   const struct mbus_dram_window *cs = dram-cs + win;
+
+   writel(((cs-size - 1)  0x) | (cs-mbus_attr  8) |
+  (dram-mbus_dram_target_id  4) | 1,
+  base + USB3_WIN_CTRL(win));
+
+   writel((cs-base  0x), base + USB3_WIN_BASE(win));
+   }
+}
+
+int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev)
+{
+   struct resource *res;
+   void __iomem *base;
+   const struct mbus_dram_target_info *dram;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+   if (!res)
+   return -ENODEV;
+
+   /*
+* We don't use devm_ioremap() because this mapping should
+* only exists for the duration of this probe function.
+*/
+   base = ioremap(res-start, resource_size(res));
+   if (!base)
+   return -ENODEV;
+
+   dram = mv_mbus_dram_info();
+   xhci_mvebu_mbus_config(base, dram);
+
+   /*
+* This memory area was only needed to configure the MBus
+* windows, and is therefore no longer useful.
+*/
+   iounmap(base);
+
+   return 0;
+}
diff --git a/drivers/usb/host/xhci-mvebu.h b/drivers/usb/host/xhci-mvebu.h
new file mode 100644
index 000..7ede92a
--- /dev/null
+++ b/drivers/usb/host/xhci-mvebu.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2014 Marvell
+ *
+ * Gregory Clement gregory.clem...@free-electrons.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef __LINUX_XHCI_MVEBU_H
+#define __LINUX_XHCI_MVEBU_H
+#if IS_ENABLED(CONFIG_USB_XHCI_MVEBU)
+int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev

[PATCHv5 16/20] ARM: mvebu: add Device Tree description of xHCI controllers on Armada 38x

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Marvell Armada 38x SoCs contains two xHCI controllers. This commit
adds the Device Tree description of those interfaces at the SoC level,
and also enables the two USB3 ports on the Armada 385 DB platform and
one USB3 port on the Armada 385 RD platform.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/boot/dts/armada-385-db.dts |  8 
 arch/arm/boot/dts/armada-385-rd.dts |  4 
 arch/arm/boot/dts/armada-38x.dtsi   | 17 +
 3 files changed, 29 insertions(+)

diff --git a/arch/arm/boot/dts/armada-385-db.dts 
b/arch/arm/boot/dts/armada-385-db.dts
index 6828d77..d5db146 100644
--- a/arch/arm/boot/dts/armada-385-db.dts
+++ b/arch/arm/boot/dts/armada-385-db.dts
@@ -101,6 +101,14 @@
reg = 0x100 0x3f00;
};
};
+
+   usb3@f {
+   status = okay;
+   };
+
+   usb3@f8000 {
+   status = okay;
+   };
};
 
pcie-controller {
diff --git a/arch/arm/boot/dts/armada-385-rd.dts 
b/arch/arm/boot/dts/armada-385-rd.dts
index 45250c8..a505fe9 100644
--- a/arch/arm/boot/dts/armada-385-rd.dts
+++ b/arch/arm/boot/dts/armada-385-rd.dts
@@ -77,6 +77,10 @@
reg = 1;
};
};
+
+   usb3@f {
+   status = okay;
+   };
};
 
pcie-controller {
diff --git a/arch/arm/boot/dts/armada-38x.dtsi 
b/arch/arm/boot/dts/armada-38x.dtsi
index a064f59..6f97f3d 100644
--- a/arch/arm/boot/dts/armada-38x.dtsi
+++ b/arch/arm/boot/dts/armada-38x.dtsi
@@ -355,6 +355,23 @@
clocks = coredivclk 0;
status = disabled;
};
+
+   usb3@f {
+   compatible = marvell,armada-380-xhci;
+   reg = 0xf 0x4000,0xf4000 0x4000;
+   interrupts = GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH;
+   clocks = gateclk 9;
+   status = disabled;
+   };
+
+   usb3@f8000 {
+   compatible = marvell,armada-380-xhci;
+   reg = 0xf8000 0x4000,0xfc000 0x4000;
+   interrupts = GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH;
+   clocks = gateclk 10;
+   status = disabled;
+   };
+
};
};
 
-- 
1.9.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


[PATCHv5 09/20] Documentation: dt-bindings: update xhci-platform DT binding

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

This commit extends the compatible string list of the xhci-platform
binding with the new armada-375-xhci and armada-380-xhci
compatible strings. It is used to describe the XHCI controller which
is available in the Armada 375 and 38x SoCs.

It also indicates that an optional 'clocks' property is now supported.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 90f8f60..999be5c 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -1,11 +1,16 @@
 USB xHCI controllers
 
 Required properties:
-  - compatible: should be generic-xhci (deprecated: xhci-platform).
+  - compatible: should be one of generic-xhci,
+marvell,armada-375-xhci, marvell,armada-380-xhci (deprecated:
+xhci-platform).
   - reg: should contain address and length of the standard XHCI
 register set for the device.
   - interrupts: one XHCI interrupt should be described here.
 
+Optional property:
+  - clocks: reference to a clock
+
 Example:
usb@f0931000 {
compatible = generic-xhci;
-- 
1.9.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


[PATCHv5 04/20] usb: ehci-orion: add optional PHY support

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

This commit extends the ehci-orion so that it can optionally be passed
a reference to a PHY through the Device Tree. It will be useful for
the Armada 375 SoCs. If no PHY is provided then the behavior of the
driver is unchanged.

[Thomas: use devm_phy_optional_get() so that we handle -EPROBE_DEFER
properly. Also call phy_power_off() when needed, and rename goto
labels.]

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
Acked-by: Alan Stern st...@rowland.harvard.edu
---
 drivers/usb/host/ehci-orion.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 9c98bac..22e15ca 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -15,6 +15,7 @@
 #include linux/clk.h
 #include linux/platform_data/usb-ehci-orion.h
 #include linux/of.h
+#include linux/phy/phy.h
 #include linux/of_device.h
 #include linux/of_irq.h
 #include linux/usb.h
@@ -46,6 +47,7 @@
 
 struct orion_ehci_hcd {
struct clk *clk;
+   struct phy *phy;
 };
 
 static const char hcd_name[] = ehci-orion;
@@ -221,6 +223,20 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
if (!IS_ERR(priv-clk))
clk_prepare_enable(priv-clk);
 
+   priv-phy = devm_phy_optional_get(pdev-dev, usb);
+   if (IS_ERR(priv-phy)) {
+   err = PTR_ERR(priv-phy);
+   goto err_phy_get;
+   } else {
+   err = phy_init(priv-phy);
+   if (err)
+   goto err_phy_init;
+
+   err = phy_power_on(priv-phy);
+   if (err)
+   goto err_phy_power_on;
+   }
+
/*
 * (Re-)program MBUS remapping windows if we are asked to.
 */
@@ -256,6 +272,13 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
return 0;
 
 err_add_hcd:
+   if (!IS_ERR(priv-phy))
+   phy_power_off(priv-phy);
+err_phy_power_on:
+   if (!IS_ERR(priv-phy))
+   phy_exit(priv-phy);
+err_phy_init:
+err_phy_get:
if (!IS_ERR(priv-clk))
clk_disable_unprepare(priv-clk);
usb_put_hcd(hcd);
@@ -273,6 +296,11 @@ static int ehci_orion_drv_remove(struct platform_device 
*pdev)
 
usb_remove_hcd(hcd);
 
+   if (!IS_ERR(priv-phy)) {
+   phy_power_off(priv-phy);
+   phy_exit(priv-phy);
+   }
+
if (!IS_ERR(priv-clk))
clk_disable_unprepare(priv-clk);
 
-- 
1.9.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


[PATCHv5 07/20] usb: host: xhci-plat: add clock support

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

Some platforms (such as the Armada 38x ones) can gate the clock of
their USB controller. This patch adds the support for one clock in
xhci-plat, by enabling it during probe and disabling it on remove.

To achieve this, it adds a 'struct clk *' member in xhci_hcd. While
only used for now in xhci-plat, it might be used by other drivers in
the future. Moreover, the xhci_hcd structure already holds other
members such as msix_count and msix_entries, which are MSI-X specific,
and therefore only used by xhci-pci.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 drivers/usb/host/xhci-plat.c | 24 +++-
 drivers/usb/host/xhci.h  |  2 ++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index f5351af..8108e58 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -11,6 +11,7 @@
  * version 2 as published by the Free Software Foundation.
  */
 
+#include linux/clk.h
 #include linux/dma-mapping.h
 #include linux/module.h
 #include linux/of.h
@@ -91,6 +92,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
struct xhci_hcd *xhci;
struct resource *res;
struct usb_hcd  *hcd;
+   struct clk  *clk;
int ret;
int irq;
 
@@ -137,14 +139,27 @@ static int xhci_plat_probe(struct platform_device *pdev)
goto release_mem_region;
}
 
+   /*
+* Not all platforms have a clk so it is not an error if the
+* clock does not exists.
+*/
+   clk = devm_clk_get(pdev-dev, NULL);
+   if (!IS_ERR(clk)) {
+   ret = clk_prepare_enable(clk);
+   if (ret)
+   goto unmap_registers;
+   }
+
ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (ret)
-   goto unmap_registers;
+   goto disable_clk;
+
device_wakeup_enable(hcd-self.controller);
 
/* USB 2.0 roothub is stored in the platform_device now. */
hcd = platform_get_drvdata(pdev);
xhci = hcd_to_xhci(hcd);
+   xhci-clk = clk;
xhci-shared_hcd = usb_create_shared_hcd(driver, pdev-dev,
dev_name(pdev-dev), hcd);
if (!xhci-shared_hcd) {
@@ -173,6 +188,10 @@ put_usb3_hcd:
 dealloc_usb2_hcd:
usb_remove_hcd(hcd);
 
+disable_clk:
+   if (!IS_ERR(clk))
+   clk_disable_unprepare(clk);
+
 unmap_registers:
iounmap(hcd-regs);
 
@@ -189,11 +208,14 @@ 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;
 
usb_remove_hcd(xhci-shared_hcd);
usb_put_hcd(xhci-shared_hcd);
 
usb_remove_hcd(hcd);
+   if (!IS_ERR(clk))
+   clk_disable_unprepare(clk);
iounmap(hcd-regs);
release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
usb_put_hcd(hcd);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index d280e92..003dc09 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1478,6 +1478,8 @@ struct xhci_hcd {
/* msi-x vectors */
int msix_count;
struct msix_entry   *msix_entries;
+   /* optional clock */
+   struct clk  *clk;
/* data structures */
struct xhci_device_context_array *dcbaa;
struct xhci_ring*cmd_ring;
-- 
1.9.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


[PATCHv5 19/20] ARM: mvebu: add Device Tree description of the xHCI controller on Armada 375

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Marvell Armada 375 SoCs contain a xHCI controller. This commit
adds the Device Tree description of this interfaces at the SoC level,
and also enables the USB3 port on the Armada 375 DB platform.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/boot/dts/armada-375-db.dts |  4 
 arch/arm/boot/dts/armada-375.dtsi   | 10 ++
 2 files changed, 14 insertions(+)

diff --git a/arch/arm/boot/dts/armada-375-db.dts 
b/arch/arm/boot/dts/armada-375-db.dts
index 9378d31..0453d69 100644
--- a/arch/arm/boot/dts/armada-375-db.dts
+++ b/arch/arm/boot/dts/armada-375-db.dts
@@ -102,6 +102,10 @@
};
};
 
+   usb3@58000 {
+   status = okay;
+   };
+
mvsdio@d4000 {
pinctrl-0 = sdio_pins sdio_st_pins;
pinctrl-names = default;
diff --git a/arch/arm/boot/dts/armada-375.dtsi 
b/arch/arm/boot/dts/armada-375.dtsi
index 6724c10..1b81d1e 100644
--- a/arch/arm/boot/dts/armada-375.dtsi
+++ b/arch/arm/boot/dts/armada-375.dtsi
@@ -320,6 +320,16 @@
clocks = coreclk 0;
};
 
+   usb3@58000 {
+   compatible = marvell,armada-375-xhci;
+   reg = 0x58000 0x2,0x5b880 0x80;
+   interrupts = GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH;
+   clocks = gateclk 16;
+   phys = usbcluster 1;
+   phy-names=usb;
+   status = disabled;
+   };
+
usbcluster: usb-cluster@18400 {
compatible = marvell,armada-375-usb-cluster;
reg = 0x18400 0x4;
-- 
1.9.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


[PATCHv5 18/20] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375

2014-05-11 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

On Armada 375, the USB cluster allows to control the cluster composed
of the USB2 and USB3 host controllers.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/boot/dts/armada-375.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/armada-375.dtsi 
b/arch/arm/boot/dts/armada-375.dtsi
index 3877693..6724c10 100644
--- a/arch/arm/boot/dts/armada-375.dtsi
+++ b/arch/arm/boot/dts/armada-375.dtsi
@@ -320,6 +320,12 @@
clocks = coreclk 0;
};
 
+   usbcluster: usb-cluster@18400 {
+   compatible = marvell,armada-375-usb-cluster;
+   reg = 0x18400 0x4;
+   #phy-cells = 1;
+   };
+
xor@60800 {
compatible = marvell,orion-xor;
reg = 0x60800 0x100
-- 
1.9.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 v3 02/20] usb: ehci-orion: Add the optional PHY support

2014-05-07 Thread Thomas Petazzoni
Dear Andrew Lunn,

On Tue, 6 May 2014 15:33:41 +0200, Andrew Lunn wrote:

  +   priv-phy = devm_phy_get(pdev-dev, usb);
  +   if (!IS_ERR(priv-phy)) {
  +   err = phy_init(priv-phy);
  +   if (err)
  +   goto err2;
  +
  +   err = phy_power_on(priv-phy);
  +   if (err)
  +   goto err3;
  +   }
 
 Hi Gregory
 
 What about EPROBE_DEFERRED?

In v4 (to be submitted soon), I've changed this to:

priv-phy = devm_phy_optional_get(pdev-dev, usb);
if (IS_ERR(priv-phy)) {
err = PTR_ERR(priv-phy);
goto err_phy_get;
} else {
err = phy_init(priv-phy);
if (err)
goto err_phy_init;

err = phy_power_on(priv-phy);
if (err)
goto err_phy_power_on;
}

Thanks to devm_phy_optional_get(), the fact of not having a PHY in the
DT is not considered an error. So on any error from
devm_phy_optional_get() (including -EPROBE_DEFER), we simply bail out.
Does this looks good?

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 v3 06/20] usb: host: xhci-plat: Add support for the Armada 38x

2014-05-07 Thread Thomas Petazzoni
Dear Felipe Balbi,

On Tue, 6 May 2014 10:39:53 -0500, Felipe Balbi wrote:

   config USB_EHCI_HCD
  diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
  index 7530468c9a4f..7a8db7f7dc01 100644
  --- a/drivers/usb/host/Makefile
  +++ b/drivers/usb/host/Makefile
  @@ -19,6 +19,7 @@ xhci-hcd-$(CONFIG_PCI)+= xhci-pci.o
   
   ifneq ($(CONFIG_USB_XHCI_PLATFORM), )
  xhci-hcd-y  += xhci-plat.o
  +   xhci-hcd-$(CONFIG_USB_XHCI_MVEBU)   += xhci-mvebu.o
 
 hmm, this has the potential of resulting in:
 
   xhci-hcd-m += xhci-mvebu.o
 
 I guess it's best to turn this into:
 
 ifneq ($(CONFIG_USB_XHCI_PLATFORM), )
   xhci-hcd-y += xhci-mvebu.o
 endif

I guess you meant:

ifneq ($(CONFIG_USB_XHCI_MVEBU), )
xhci-hcd-y += xhci-mvebu.o
endif

Right?

If so, then what about instead making CONFIG_USB_XHCI_MVEBU a bool
instead of a tristate? It's more an option for the xhci-platform
driver than an additional separate module, IMO. What do you think?

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 v3 05/20] usb: host: xhci-plat: Add clocks support

2014-05-07 Thread Thomas Petazzoni
Felipe, Gregory,

On Tue,  6 May 2014 02:14:00 +0200, Gregory CLEMENT wrote:

 +struct xhci_plat_priv {
 + struct clk *clk;
 +};
 +
  static void xhci_plat_quirks(struct device *dev, struct xhci_hcd *xhci)
  {
   /*
 @@ -38,7 +43,8 @@ static int xhci_plat_setup(struct usb_hcd *hcd)
  static const struct hc_driver xhci_plat_xhci_driver = {
   .description =  xhci-hcd,
   .product_desc = xHCI Host Controller,
 - .hcd_priv_size =sizeof(struct xhci_hcd *),
 + .hcd_priv_size =sizeof(struct xhci_hcd *) +
 + sizeof(struct xhci_plat_priv),
  
   /*
* generic hardware linkage
 @@ -85,6 +91,40 @@ static const struct hc_driver xhci_plat_xhci_driver = {
   .bus_resume =   xhci_bus_resume,
  };
  
 +static int xhci_plat_enable_clk(struct platform_device *pdev)
 +{
 + struct usb_hcd *hcd = platform_get_drvdata(pdev);
 + struct xhci_hcd *xhci = hcd_to_xhci(hcd);
 + struct xhci_plat_priv *priv = (struct xhci_plat_priv *) xhci-priv;

Unless I misread the USB code, I believe the way this patch proposes to
handle private data for the XHCI HCD is wrong and leads to memory
corruption.

By growing the size .hcd_priv_size, it increases the memory size
pointed by usb_hcd-hcd_priv. However, this pointer has nothing to do
with xhci-priv, which points to the end of the xhci_hcd structure.

I believe the confusion comes from the fact that OHCI and EHCI do
allocate the entire ohci_hcd and ehci_hcd structure as part of the
usb_hcd private data:

.hcd_priv_size =sizeof(struct ohci_hcd),

or

.hcd_priv_size =sizeof(struct ehci_hcd),

In this case, enlarging hcd_priv_size, and having a ehci-priv or
ohci-priv pointing to the end of {ohci,ehci}_hcd structures works fine.

However, in the XHCI case, the usb_hcd private data is not used to hold
the entire xhci_hcd structure, but only a *pointer* to it:

.hcd_priv_size =sizeof(struct xhci_hcd *),

Therefore, adding more size to .hcd_priv_size isn't going to give extra
room at the end of the xhci_hcd structure. And therefore the whole
strategy of using xhci-priv pointing at the end of xhci_hcd is broken.

In v4, what I will do is simply to add a 'struct clk *' member to
xhci_hcd. A clock is, like a register area or an interrupt, a very
typical resource for any device, so it makes sense to have a pointer to
it from xhci_hcd. If someone complains that the clock would only be
used by xhci_plat, then I could point him to the fact that xhci_hcd
already contains members such as msix_count and msix_entries, that are
only used in xhci_pci :-)

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 v3 17/20] phy: Add support for USB cluster on the Armada 375 SoC

2014-05-07 Thread Thomas Petazzoni
Dear Bartlomiej Zolnierkiewicz,

On Tue, 06 May 2014 13:37:04 +0200, Bartlomiej Zolnierkiewicz wrote:

  +config ARMADA375_USBCLUSTER_PHY
  +   def_bool y
  +   depends on OF
 
 Please limit this driver to Armada 375 or compile testing, i.e. add additional
 
   depends on (ARCH_MVEBU  MACH_ARMADA_375) || COMPILE_TEST

Right, will do.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 v3 17/20] phy: Add support for USB cluster on the Armada 375 SoC

2014-05-07 Thread Thomas Petazzoni
Dear Andrew Lunn,

On Tue, 6 May 2014 15:54:27 +0200, Andrew Lunn wrote:

  +enum {
  +   PHY_USB2 = 0,
  +   PHY_USB3 = 1,
  +};
  +
  +struct armada375_cluster_phy {
  +   struct phy *phy;
  +   void __iomem *reg;
  +   bool enable;
  +   bool use_usb3;
 
 Hi Gregory
 
 nit: How about using the enum you just defined?

Nope, I don't think it's a good idea, because they mean different
things. The enum is used to index the arrays of two PHYs: PHY_USB2 is
the first one, PHY_USB3 is the second one.

On the other hand, the 'use_usb3' field indicates in which mode is a
particular PHY. So it could apply on either of the PHYs, and is
therefore not related to the index of the PHYs in the array.


  +   usb_cluster_base = of_iomap(np, 0);
 
 devm_ API?
 
 Check the return value for an error?

Indeed, I'll use devm_ioremap_resource() here.

  +   BUG_ON(!usb_cluster_base);
  +
  +   for (i = 0; i  NB_PHY; i++) {
  +   phy = devm_phy_create(dev, armada375_usb_phy_ops, NULL);
  +   if (IS_ERR(phy))
  +   dev_err(dev, failed to create PHY n%d\n, i);
  +
  +   usb_cluster_phy[i].phy = phy;
  +   usb_cluster_phy[i].reg = usb_cluster_base;
  +   usb_cluster_phy[i].enable = false;
  +   phy_set_drvdata(phy, usb_cluster_phy[i]);
  +   }
  +
  +   usb_cluster_phy[PHY_USB2].use_usb3 = false;
  +   usb_cluster_phy[PHY_USB3].use_usb3 = true;
  +
  +   /*
  +* We can't use the first usb2 unit and usb3 at the same time
  +* to manage a USB2 device, so let's disable usb2 if usb3 is
  +* slelected. In this case USB2 device will be managed by the
 
 selected

Fixed.

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 v3 17/20] phy: Add support for USB cluster on the Armada 375 SoC

2014-05-07 Thread Thomas Petazzoni
Dear Ezequiel Garcia,

On Tue, 6 May 2014 17:53:30 -0300, Ezequiel Garcia wrote:

  +#define USB2_PHY_CONFIG_ENABLE BIT(0) /* active low */
  +
 
 I still think it's more readable to use USB2_PHY_CONFIG_DISABLE.
 It's just a nitpick, though.

Yes, fixed.

  +static int armada375_usb_phy_probe(struct platform_device *pdev)
  +{
  +   struct device *dev = pdev-dev;
  +   struct phy *phy;
  +   struct device_node *np = dev-of_node;
  +   struct phy_provider *phy_provider;
  +   void __iomem *usb_cluster_base;
  +   struct device_node *xhci_node;
  +   int i;
  +
  +   usb_cluster_base = of_iomap(np, 0);
  +   BUG_ON(!usb_cluster_base);
  +
 
 Isn't a bit extreme to call BUG_ON (and thus bring down the whole system)
 in a phy driver?

Indeed, fixed by a more normal error return.

  +   for (i = 0; i  NB_PHY; i++) {
  +   phy = devm_phy_create(dev, armada375_usb_phy_ops, NULL);
  +   if (IS_ERR(phy))
  +   dev_err(dev, failed to create PHY n%d\n, i);
  +
 
 I think you're missing a continue/break here.

Indeed, fixed, I just do a return from the -probe() function if
creating the PHY fails.

  +MODULE_DESCRIPTION(Armada 375 USB cluster driver);
  +MODULE_AUTHOR(Gregory CLEMENT gregory.clem...@free-electrons.com);
  +MODULE_LICENSE(GPL);
 
 GPL v2 ?

Well, using just GPL seems to be the more common usage through the
kernel:

linux/drivers $ git grep MODULE_LICENSE | grep \GPL\ | wc -l
4276
linux/drivers $ git grep MODULE_LICENSE | grep \GPLv2\ | wc -l
5
linux/drivers $ git grep MODULE_LICENSE | grep \GPL v2\ | wc -l
841

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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


[PATCHv4 16/20] ARM: mvebu: add Device Tree description of xHCI controllers on Armada 38x

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Marvell Armada 38x SoCs contains two xHCI controllers. This commit
adds the Device Tree description of those interfaces at the SoC level,
and also enables the two USB3 ports on the Armada 385 DB platform and
one USB3 port on the Armada 385 RD platform.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/boot/dts/armada-385-db.dts |  8 
 arch/arm/boot/dts/armada-385-rd.dts |  4 
 arch/arm/boot/dts/armada-38x.dtsi   | 17 +
 3 files changed, 29 insertions(+)

diff --git a/arch/arm/boot/dts/armada-385-db.dts 
b/arch/arm/boot/dts/armada-385-db.dts
index 6828d77..d5db146 100644
--- a/arch/arm/boot/dts/armada-385-db.dts
+++ b/arch/arm/boot/dts/armada-385-db.dts
@@ -101,6 +101,14 @@
reg = 0x100 0x3f00;
};
};
+
+   usb3@f {
+   status = okay;
+   };
+
+   usb3@f8000 {
+   status = okay;
+   };
};
 
pcie-controller {
diff --git a/arch/arm/boot/dts/armada-385-rd.dts 
b/arch/arm/boot/dts/armada-385-rd.dts
index 45250c8..a505fe9 100644
--- a/arch/arm/boot/dts/armada-385-rd.dts
+++ b/arch/arm/boot/dts/armada-385-rd.dts
@@ -77,6 +77,10 @@
reg = 1;
};
};
+
+   usb3@f {
+   status = okay;
+   };
};
 
pcie-controller {
diff --git a/arch/arm/boot/dts/armada-38x.dtsi 
b/arch/arm/boot/dts/armada-38x.dtsi
index a064f59..6f97f3d 100644
--- a/arch/arm/boot/dts/armada-38x.dtsi
+++ b/arch/arm/boot/dts/armada-38x.dtsi
@@ -355,6 +355,23 @@
clocks = coredivclk 0;
status = disabled;
};
+
+   usb3@f {
+   compatible = marvell,armada-380-xhci;
+   reg = 0xf 0x4000,0xf4000 0x4000;
+   interrupts = GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH;
+   clocks = gateclk 9;
+   status = disabled;
+   };
+
+   usb3@f8000 {
+   compatible = marvell,armada-380-xhci;
+   reg = 0xf8000 0x4000,0xfc000 0x4000;
+   interrupts = GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH;
+   clocks = gateclk 10;
+   status = disabled;
+   };
+
};
};
 
-- 
1.9.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


[PATCHv4 07/20] usb: host: xhci-plat: add clock support

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

Some platforms (such as the Armada 38x ones) can gate the clock of
their USB controller. This patch adds the support for one clock in
xhci-plat, by enabling it during probe and disabling it on remove.

To achieve this, it adds a 'struct clk *' member in xhci_hcd. While
only used for now in xhci-plat, it might be used by other drivers in
the future. Moreover, the xhci_hcd structure already holds other
members such as msix_count and msix_entries, which are MSI-X specific,
and therefore only used by xhci-pci.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 drivers/usb/host/xhci-plat.c | 24 +++-
 drivers/usb/host/xhci.h  |  2 ++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index f5351af..8108e58 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -11,6 +11,7 @@
  * version 2 as published by the Free Software Foundation.
  */
 
+#include linux/clk.h
 #include linux/dma-mapping.h
 #include linux/module.h
 #include linux/of.h
@@ -91,6 +92,7 @@ static int xhci_plat_probe(struct platform_device *pdev)
struct xhci_hcd *xhci;
struct resource *res;
struct usb_hcd  *hcd;
+   struct clk  *clk;
int ret;
int irq;
 
@@ -137,14 +139,27 @@ static int xhci_plat_probe(struct platform_device *pdev)
goto release_mem_region;
}
 
+   /*
+* Not all platforms have a clk so it is not an error if the
+* clock does not exists.
+*/
+   clk = devm_clk_get(pdev-dev, NULL);
+   if (!IS_ERR(clk)) {
+   ret = clk_prepare_enable(clk);
+   if (ret)
+   goto unmap_registers;
+   }
+
ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (ret)
-   goto unmap_registers;
+   goto disable_clk;
+
device_wakeup_enable(hcd-self.controller);
 
/* USB 2.0 roothub is stored in the platform_device now. */
hcd = platform_get_drvdata(pdev);
xhci = hcd_to_xhci(hcd);
+   xhci-clk = clk;
xhci-shared_hcd = usb_create_shared_hcd(driver, pdev-dev,
dev_name(pdev-dev), hcd);
if (!xhci-shared_hcd) {
@@ -173,6 +188,10 @@ put_usb3_hcd:
 dealloc_usb2_hcd:
usb_remove_hcd(hcd);
 
+disable_clk:
+   if (!IS_ERR(clk))
+   clk_disable_unprepare(clk);
+
 unmap_registers:
iounmap(hcd-regs);
 
@@ -189,11 +208,14 @@ 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;
 
usb_remove_hcd(xhci-shared_hcd);
usb_put_hcd(xhci-shared_hcd);
 
usb_remove_hcd(hcd);
+   if (!IS_ERR(clk))
+   clk_disable_unprepare(clk);
iounmap(hcd-regs);
release_mem_region(hcd-rsrc_start, hcd-rsrc_len);
usb_put_hcd(hcd);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index d280e92..003dc09 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1478,6 +1478,8 @@ struct xhci_hcd {
/* msi-x vectors */
int msix_count;
struct msix_entry   *msix_entries;
+   /* optional clock */
+   struct clk  *clk;
/* data structures */
struct xhci_device_context_array *dcbaa;
struct xhci_ring*cmd_ring;
-- 
1.9.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


[PATCHv4 18/20] ARM: mvebu: add Device Tree description of USB cluster controller on Armada 375

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

On Armada 375, the USB cluster allows to control the cluster composed
of the USB2 and USB3 host controllers.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/boot/dts/armada-375.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/boot/dts/armada-375.dtsi 
b/arch/arm/boot/dts/armada-375.dtsi
index 3877693..6724c10 100644
--- a/arch/arm/boot/dts/armada-375.dtsi
+++ b/arch/arm/boot/dts/armada-375.dtsi
@@ -320,6 +320,12 @@
clocks = coreclk 0;
};
 
+   usbcluster: usb-cluster@18400 {
+   compatible = marvell,armada-375-usb-cluster;
+   reg = 0x18400 0x4;
+   #phy-cells = 1;
+   };
+
xor@60800 {
compatible = marvell,orion-xor;
reg = 0x60800 0x100
-- 
1.9.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


[PATCHv4 20/20] ARM: mvebu: add Device Tree description of the EHCI controller on Armada 375

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Marvell Armada 375 SoCs contains one EHCI controller. This commit
adds the Device Tree description of this interfaces at the SoC level,
and also enables the USB2 port on the Armada 375 DB platform.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/boot/dts/armada-375-db.dts |  4 
 arch/arm/boot/dts/armada-375.dtsi   | 18 ++
 2 files changed, 22 insertions(+)

diff --git a/arch/arm/boot/dts/armada-375-db.dts 
b/arch/arm/boot/dts/armada-375-db.dts
index 0453d69..01bc5e8 100644
--- a/arch/arm/boot/dts/armada-375-db.dts
+++ b/arch/arm/boot/dts/armada-375-db.dts
@@ -102,6 +102,10 @@
};
};
 
+   usb@54000 {
+   status = okay;
+   };
+
usb3@58000 {
status = okay;
};
diff --git a/arch/arm/boot/dts/armada-375.dtsi 
b/arch/arm/boot/dts/armada-375.dtsi
index 1b81d1e..945df89 100644
--- a/arch/arm/boot/dts/armada-375.dtsi
+++ b/arch/arm/boot/dts/armada-375.dtsi
@@ -320,6 +320,24 @@
clocks = coreclk 0;
};
 
+   usb@5 {
+   compatible = marvell,orion-ehci;
+   reg = 0x5 0x500;
+   interrupts = GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH;
+   clocks = gateclk 18;
+   phys = usbcluster 0;
+   phy-names = usb;
+   status = disabled;
+   };
+
+   usb@54000 {
+   compatible = marvell,orion-ehci;
+   reg = 0x54000 0x500;
+   interrupts = GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH;
+   clocks = gateclk 26;
+   status = disabled;
+   };
+
usb3@58000 {
compatible = marvell,armada-375-xhci;
reg = 0x58000 0x2,0x5b880 0x80;
-- 
1.9.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


[PATCHv4 14/20] ARM: configs: enable XHCI mvebu support in mvebu_v7_defconfig

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Marvell Armada 38x platform needs the xhci_mvebu driver enabled
for the xHCI USB hosts, so this commit enables the corresponding
Kconfig option in mvebu_v7_defconfig.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/configs/mvebu_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/mvebu_v7_defconfig 
b/arch/arm/configs/mvebu_v7_defconfig
index a34713d..e881106 100644
--- a/arch/arm/configs/mvebu_v7_defconfig
+++ b/arch/arm/configs/mvebu_v7_defconfig
@@ -78,6 +78,7 @@ CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_ROOT_HUB_TT=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MVEBU=y
 CONFIG_MMC=y
 CONFIG_MMC_MVSDIO=y
 CONFIG_NEW_LEDS=y
-- 
1.9.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


[PATCHv4 01/20] usb: ehci-orion: use platform_get_irq() for DT probing

2014-05-07 Thread Thomas Petazzoni
Commit 77dae54ab385033e488d8b07045bc7f8d931740f ('ARM: Kirkwood:
ehci-orion: Add device tree binding') added the Device Tree binding
for the ehci-orion driver. To achieve that with the irq, it used the
irq_of_parse_and_map() function when probed in DT-mode, and
platform_get_irq() when probed in non-DT mode.

This is not necessary: platform_get_irq() works just as fine in
DT-mode, since the conversion from DT information to 'struct resource'
is done by the generic layers of the kernel.

Therefore, this commit switches back to use just platform_get_irq().

Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 drivers/usb/host/ehci-orion.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 30d35e5..7728e83 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -154,10 +154,7 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
 
pr_debug(Initializing Orion-SoC USB Host Controller\n);
 
-   if (pdev-dev.of_node)
-   irq = irq_of_parse_and_map(pdev-dev.of_node, 0);
-   else
-   irq = platform_get_irq(pdev, 0);
+   irq = platform_get_irq(pdev, 0);
if (irq = 0) {
dev_err(pdev-dev,
Found HC with no IRQ. Check %s setup!\n,
-- 
1.9.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


[PATCHv4 06/20] usb: host: xhci-plat: sort the headers in alphabetic order

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

Sorting the headers in alphabetic order will help to reduce the conflict
when adding new headers later.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Acked-by: Felipe Balbi ba...@ti.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.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 151901c..f5351af 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -11,11 +11,11 @@
  * version 2 as published by the Free Software Foundation.
  */
 
-#include linux/platform_device.h
+#include linux/dma-mapping.h
 #include linux/module.h
-#include linux/slab.h
 #include linux/of.h
-#include linux/dma-mapping.h
+#include linux/platform_device.h
+#include linux/slab.h
 
 #include xhci.h
 
-- 
1.9.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


[PATCHv4 11/20] Documentation: dt-bindings: document the Armada 375 USB cluster binding

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

Armada 375 comes with an USB2 host and device controller and an USB3
controller. The USB cluster control register allows to manage common
features of both USB controllers. This commit adds the Device Tree
binding documentation for this piece of hardware.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 .../bindings/phy/armada-375-usb-phy-cluster.txt   | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/phy/armada-375-usb-phy-cluster.txt

diff --git 
a/Documentation/devicetree/bindings/phy/armada-375-usb-phy-cluster.txt 
b/Documentation/devicetree/bindings/phy/armada-375-usb-phy-cluster.txt
new file mode 100644
index 000..258407c
--- /dev/null
+++ b/Documentation/devicetree/bindings/phy/armada-375-usb-phy-cluster.txt
@@ -0,0 +1,19 @@
+Armada 375 USB cluster
+--
+
+Armada 375 comes with an USB2 host and device controller and an USB3
+controller. The USB cluster control register allows to manage common
+features of both USB controllers.
+
+Required properties:
+
+- compatible: marvell,armada-375-usb-cluster
+- reg: Should contain usb cluster register location and length.
+- #phy-cells : from the generic phy bindings, must be 1
+
+Example:
+   usbcluster: usb-cluster@18400 {
+   compatible = marvell,armada-375-usb-cluster;
+   reg = 0x18400 0x4;
+   #phy-cells = 1
+   };
-- 
1.9.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


[PATCHv4 19/20] ARM: mvebu: add Device Tree description of the xHCI controller on Armada 375

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Marvell Armada 375 SoCs contain a xHCI controller. This commit
adds the Device Tree description of this interfaces at the SoC level,
and also enables the USB3 port on the Armada 375 DB platform.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/boot/dts/armada-375-db.dts |  4 
 arch/arm/boot/dts/armada-375.dtsi   | 10 ++
 2 files changed, 14 insertions(+)

diff --git a/arch/arm/boot/dts/armada-375-db.dts 
b/arch/arm/boot/dts/armada-375-db.dts
index 9378d31..0453d69 100644
--- a/arch/arm/boot/dts/armada-375-db.dts
+++ b/arch/arm/boot/dts/armada-375-db.dts
@@ -102,6 +102,10 @@
};
};
 
+   usb3@58000 {
+   status = okay;
+   };
+
mvsdio@d4000 {
pinctrl-0 = sdio_pins sdio_st_pins;
pinctrl-names = default;
diff --git a/arch/arm/boot/dts/armada-375.dtsi 
b/arch/arm/boot/dts/armada-375.dtsi
index 6724c10..1b81d1e 100644
--- a/arch/arm/boot/dts/armada-375.dtsi
+++ b/arch/arm/boot/dts/armada-375.dtsi
@@ -320,6 +320,16 @@
clocks = coreclk 0;
};
 
+   usb3@58000 {
+   compatible = marvell,armada-375-xhci;
+   reg = 0x58000 0x2,0x5b880 0x80;
+   interrupts = GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH;
+   clocks = gateclk 16;
+   phys = usbcluster 1;
+   phy-names=usb;
+   status = disabled;
+   };
+
usbcluster: usb-cluster@18400 {
compatible = marvell,armada-375-usb-cluster;
reg = 0x18400 0x4;
-- 
1.9.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


[PATCHv4 05/20] Documentation: dt-bindings: update ehci-orion binding documentation

2014-05-07 Thread Thomas Petazzoni
This commit updates the Device Tree binding documentation of
ehci-orion to take into account the fact that we can now optionally
pass a clock and a PHY reference.

Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 Documentation/devicetree/bindings/usb/ehci-orion.txt | 5 +
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/usb/ehci-orion.txt 
b/Documentation/devicetree/bindings/usb/ehci-orion.txt
index 6bc09ec..17c3bc8 100644
--- a/Documentation/devicetree/bindings/usb/ehci-orion.txt
+++ b/Documentation/devicetree/bindings/usb/ehci-orion.txt
@@ -6,6 +6,11 @@ Required properties:
   region.
 - interrupts: The EHCI interrupt
 
+Optional properties:
+- clocks: reference to the clock
+- phys: reference to the USB PHY
+- phy-names: name of the USB PHY, should be usb
+
 Example:
 
ehci@5 {
-- 
1.9.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


[PATCHv4 03/20] usb: ehci-orion: fix clock reference leaking

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

In order to disable the clock in the -remove() function, a call to
devm_clk_get() is being made, which further increases the reference
count of the clock.

In order to clean this up, a private structure holding a pointer to
the clock is added using the override mechanism provided by the ehci
framework. This makes the driver clock handling much more logical.

The bug was introduced in v3.6, however the ehci framework allowing to
use the override mechanism has only been introduced in v3.8, so this
patch won't apply before it.

[Thomas: reword commit log, fix goto label names.]

Fixes: 8c869edaee07c623066266827371235fb9c12e01 ('ARM: Orion: EHCI: Add support 
for enabling clocks')
Cc: sta...@vger.kernel.org # v3.8+
Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 drivers/usb/host/ehci-orion.c | 45 ---
 1 file changed, 29 insertions(+), 16 deletions(-)

diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 9298be7..9c98bac 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -42,6 +42,12 @@
 
 #define DRIVER_DESC EHCI orion driver
 
+#define hcd_to_orion_priv(h) ((struct orion_ehci_hcd *)hcd_to_ehci(h)-priv)
+
+struct orion_ehci_hcd {
+   struct clk *clk;
+};
+
 static const char hcd_name[] = ehci-orion;
 
 static struct hc_driver __read_mostly ehci_orion_hc_driver;
@@ -137,6 +143,10 @@ ehci_orion_conf_mbus_windows(struct usb_hcd *hcd,
}
 }
 
+static const struct ehci_driver_overrides orion_overrides __initconst = {
+   .extra_priv_size =  sizeof(struct orion_ehci_hcd),
+};
+
 static int ehci_orion_drv_probe(struct platform_device *pdev)
 {
struct orion_ehci_data *pd = dev_get_platdata(pdev-dev);
@@ -144,10 +154,10 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
struct resource *res;
struct usb_hcd *hcd;
struct ehci_hcd *ehci;
-   struct clk *clk;
void __iomem *regs;
int irq, err;
enum orion_ehci_phy_ver phy_version;
+   struct orion_ehci_hcd *priv;
 
if (usb_disabled())
return -ENODEV;
@@ -187,17 +197,11 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
goto err;
}
 
-   /* Not all platforms can gate the clock, so it is not
-  an error if the clock does not exists. */
-   clk = devm_clk_get(pdev-dev, NULL);
-   if (!IS_ERR(clk))
-   clk_prepare_enable(clk);
-
hcd = usb_create_hcd(ehci_orion_hc_driver,
pdev-dev, dev_name(pdev-dev));
if (!hcd) {
err = -ENOMEM;
-   goto err_create_hcd;
+   goto err;
}
 
hcd-rsrc_start = res-start;
@@ -208,6 +212,15 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
ehci-caps = hcd-regs + 0x100;
hcd-has_tt = 1;
 
+   priv = hcd_to_orion_priv(hcd);
+   /*
+* Not all platforms can gate the clock, so it is not an error if
+* the clock does not exists.
+*/
+   priv-clk = devm_clk_get(pdev-dev, NULL);
+   if (!IS_ERR(priv-clk))
+   clk_prepare_enable(priv-clk);
+
/*
 * (Re-)program MBUS remapping windows if we are asked to.
 */
@@ -243,10 +256,9 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
return 0;
 
 err_add_hcd:
+   if (!IS_ERR(priv-clk))
+   clk_disable_unprepare(priv-clk);
usb_put_hcd(hcd);
-err_create_hcd:
-   if (!IS_ERR(clk))
-   clk_disable_unprepare(clk);
 err:
dev_err(pdev-dev, init %s fail, %d\n,
dev_name(pdev-dev), err);
@@ -257,14 +269,15 @@ err:
 static int ehci_orion_drv_remove(struct platform_device *pdev)
 {
struct usb_hcd *hcd = platform_get_drvdata(pdev);
-   struct clk *clk;
+   struct orion_ehci_hcd *priv = hcd_to_orion_priv(hcd);
 
usb_remove_hcd(hcd);
+
+   if (!IS_ERR(priv-clk))
+   clk_disable_unprepare(priv-clk);
+
usb_put_hcd(hcd);
 
-   clk = devm_clk_get(pdev-dev, NULL);
-   if (!IS_ERR(clk))
-   clk_disable_unprepare(clk);
return 0;
 }
 
@@ -292,7 +305,7 @@ static int __init ehci_orion_init(void)
 
pr_info(%s:  DRIVER_DESC \n, hcd_name);
 
-   ehci_init_driver(ehci_orion_hc_driver, NULL);
+   ehci_init_driver(ehci_orion_hc_driver, orion_overrides);
return platform_driver_register(ehci_orion_driver);
 }
 module_init(ehci_orion_init);
-- 
1.9.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


[PATCHv4 10/20] phy: add support for USB cluster on the Armada 375 SoC

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Armada 375 SoC comes with an USB2 host and device controller and
an USB3 controller. The USB cluster control register allows to manage
common features of both USB controllers.

This commit adds a driver integrated in the generic PHY framework to
control this USB cluster feature.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 drivers/phy/Kconfig  |   6 ++
 drivers/phy/Makefile |   1 +
 drivers/phy/phy-armada375-usb2.c | 157 +++
 3 files changed, 164 insertions(+)
 create mode 100644 drivers/phy/phy-armada375-usb2.c

diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig
index 3bb05f1..e63cf9d 100644
--- a/drivers/phy/Kconfig
+++ b/drivers/phy/Kconfig
@@ -15,6 +15,12 @@ config GENERIC_PHY
  phy users can obtain reference to the PHY. All the users of this
  framework should select this config.
 
+config ARMADA375_USBCLUSTER_PHY
+   def_bool y
+   depends on MACH_ARMADA_375 || COMPILE_TEST
+   depends on OF
+   select GENERIC_PHY
+
 config PHY_EXYNOS_MIPI_VIDEO
tristate S5P/EXYNOS SoC series MIPI CSI-2/DSI PHY driver
depends on HAS_IOMEM
diff --git a/drivers/phy/Makefile b/drivers/phy/Makefile
index 2faf78e..47d5a86 100644
--- a/drivers/phy/Makefile
+++ b/drivers/phy/Makefile
@@ -3,6 +3,7 @@
 #
 
 obj-$(CONFIG_GENERIC_PHY)  += phy-core.o
+obj-$(CONFIG_ARMADA375_USBCLUSTER_PHY) += phy-armada375-usb2.o
 obj-$(CONFIG_BCM_KONA_USB2_PHY)+= phy-bcm-kona-usb2.o
 obj-$(CONFIG_PHY_EXYNOS_DP_VIDEO)  += phy-exynos-dp-video.o
 obj-$(CONFIG_PHY_EXYNOS_MIPI_VIDEO)+= phy-exynos-mipi-video.o
diff --git a/drivers/phy/phy-armada375-usb2.c b/drivers/phy/phy-armada375-usb2.c
new file mode 100644
index 000..a6f746d
--- /dev/null
+++ b/drivers/phy/phy-armada375-usb2.c
@@ -0,0 +1,157 @@
+/*
+ * USB cluster support for Armada 375 platform.
+ *
+ * Copyright (C) 2014 Marvell
+ *
+ * Gregory CLEMENT gregory.clem...@free-electrons.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2 or later. This program is licensed as is
+ * without any warranty of any kind, whether express or implied.
+ *
+ * Armada 375 comes with an USB2 host and device controller and an
+ * USB3 controller. The USB cluster control register allows to manage
+ * common features of both USB controllers.
+ */
+
+#include linux/init.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/of_address.h
+#include linux/phy/phy.h
+#include linux/platform_device.h
+#include linux/slab.h
+
+#define USB2_PHY_CONFIG_DISABLE BIT(0)
+
+/* The USB cluster allows to choose between two PHYs */
+#define NB_PHY 2
+
+enum {
+   PHY_USB2 = 0,
+   PHY_USB3 = 1,
+};
+
+struct armada375_cluster_phy {
+   struct phy *phy;
+   void __iomem *reg;
+   bool enable;
+   bool use_usb3;
+};
+
+struct armada375_cluster_phy usb_cluster_phy[NB_PHY];
+
+static int armada375_usb_phy_init(struct phy *phy)
+{
+   struct armada375_cluster_phy *cluster_phy = phy_get_drvdata(phy);
+   u32 reg;
+
+   if (!cluster_phy-enable)
+   return -ENODEV;
+
+   reg = readl(cluster_phy-reg);
+   if (cluster_phy-use_usb3)
+   reg |= USB2_PHY_CONFIG_DISABLE;
+   else
+   reg = ~USB2_PHY_CONFIG_DISABLE;
+   writel(reg, cluster_phy-reg);
+
+   return 0;
+}
+
+static struct phy_ops armada375_usb_phy_ops = {
+   .init = armada375_usb_phy_init,
+   .owner  = THIS_MODULE,
+};
+
+static struct phy *armada375_usb_phy_xlate(struct device *dev,
+   struct of_phandle_args *args)
+{
+   if (WARN_ON(args-args[0] = NB_PHY))
+   return ERR_PTR(-ENODEV);
+
+   return usb_cluster_phy[args-args[0]].phy;
+}
+
+static int armada375_usb_phy_probe(struct platform_device *pdev)
+{
+   struct device *dev = pdev-dev;
+   struct phy *phy;
+   struct phy_provider *phy_provider;
+   void __iomem *usb_cluster_base;
+   struct device_node *xhci_node;
+   struct resource *res;
+   int i;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   usb_cluster_base = devm_ioremap_resource(pdev-dev, res);
+   if (!usb_cluster_base)
+   return -ENOMEM;
+
+   for (i = 0; i  NB_PHY; i++) {
+   phy = devm_phy_create(dev, armada375_usb_phy_ops, NULL);
+   if (IS_ERR(phy)) {
+   dev_err(dev, failed to create PHY n%d\n, i);
+   return PTR_ERR(phy);
+   }
+
+   usb_cluster_phy[i].phy = phy;
+   usb_cluster_phy[i].reg = usb_cluster_base;
+   usb_cluster_phy[i].enable = false;
+   phy_set_drvdata(phy, usb_cluster_phy[i

[PATCHv4 09/20] Documentation: dt-bindings: update xhci-platform DT binding

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

This commit extends the compatible string list of the xhci-platform
binding with the new armada-375-xhci and armada-380-xhci
compatible strings. It is used to describe the XHCI controller which
is available in the Armada 375 and 38x SoCs.

It also indicates that an optional 'clocks' property is now supported.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 90f8f60..999be5c 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -1,11 +1,16 @@
 USB xHCI controllers
 
 Required properties:
-  - compatible: should be generic-xhci (deprecated: xhci-platform).
+  - compatible: should be one of generic-xhci,
+marvell,armada-375-xhci, marvell,armada-380-xhci (deprecated:
+xhci-platform).
   - reg: should contain address and length of the standard XHCI
 register set for the device.
   - interrupts: one XHCI interrupt should be described here.
 
+Optional property:
+  - clocks: reference to a clock
+
 Example:
usb@f0931000 {
compatible = generic-xhci;
-- 
1.9.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


[PATCHv4 04/20] usb: ehci-orion: add optional PHY support

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

This commit extends the ehci-orion so that it can optionally be passed
a reference to a PHY through the Device Tree. It will be useful for
the Armada 375 SoCs. If no PHY is provided then the behavior of the
driver is unchanged.

[Thomas: use devm_phy_optional_get() so that we handle -EPROBE_DEFER
properly. Also call phy_power_off() when needed, and rename goto
labels.]

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 drivers/usb/host/ehci-orion.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 9c98bac..22e15ca 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -15,6 +15,7 @@
 #include linux/clk.h
 #include linux/platform_data/usb-ehci-orion.h
 #include linux/of.h
+#include linux/phy/phy.h
 #include linux/of_device.h
 #include linux/of_irq.h
 #include linux/usb.h
@@ -46,6 +47,7 @@
 
 struct orion_ehci_hcd {
struct clk *clk;
+   struct phy *phy;
 };
 
 static const char hcd_name[] = ehci-orion;
@@ -221,6 +223,20 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
if (!IS_ERR(priv-clk))
clk_prepare_enable(priv-clk);
 
+   priv-phy = devm_phy_optional_get(pdev-dev, usb);
+   if (IS_ERR(priv-phy)) {
+   err = PTR_ERR(priv-phy);
+   goto err_phy_get;
+   } else {
+   err = phy_init(priv-phy);
+   if (err)
+   goto err_phy_init;
+
+   err = phy_power_on(priv-phy);
+   if (err)
+   goto err_phy_power_on;
+   }
+
/*
 * (Re-)program MBUS remapping windows if we are asked to.
 */
@@ -256,6 +272,13 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
return 0;
 
 err_add_hcd:
+   if (!IS_ERR(priv-phy))
+   phy_power_off(priv-phy);
+err_phy_power_on:
+   if (!IS_ERR(priv-phy))
+   phy_exit(priv-phy);
+err_phy_init:
+err_phy_get:
if (!IS_ERR(priv-clk))
clk_disable_unprepare(priv-clk);
usb_put_hcd(hcd);
@@ -273,6 +296,11 @@ static int ehci_orion_drv_remove(struct platform_device 
*pdev)
 
usb_remove_hcd(hcd);
 
+   if (!IS_ERR(priv-phy)) {
+   phy_power_off(priv-phy);
+   phy_exit(priv-phy);
+   }
+
if (!IS_ERR(priv-clk))
clk_disable_unprepare(priv-clk);
 
-- 
1.9.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


[PATCHv4 17/20] ARM: mvebu: add Device Tree description of the EHCI controller on Armada 38x

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Marvell Armada 38x SoCs contains one EHCI controller. This commit
adds the Device Tree description of this interface at the SoC level,
and also enables the USB2 port on the Armada 385 DB platform.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/boot/dts/armada-385-db.dts | 4 
 arch/arm/boot/dts/armada-38x.dtsi   | 8 
 2 files changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/armada-385-db.dts 
b/arch/arm/boot/dts/armada-385-db.dts
index d5db146..91e3e44 100644
--- a/arch/arm/boot/dts/armada-385-db.dts
+++ b/arch/arm/boot/dts/armada-385-db.dts
@@ -65,6 +65,10 @@
phy-mode = rgmii-id;
};
 
+   usb@5 {
+   status = ok;
+   };
+
ethernet@7 {
status = okay;
phy = phy0;
diff --git a/arch/arm/boot/dts/armada-38x.dtsi 
b/arch/arm/boot/dts/armada-38x.dtsi
index 6f97f3d..fa2501d 100644
--- a/arch/arm/boot/dts/armada-38x.dtsi
+++ b/arch/arm/boot/dts/armada-38x.dtsi
@@ -283,6 +283,14 @@
status = disabled;
};
 
+   usb@5 {
+   compatible = marvell,orion-ehci;
+   reg = 0x58000 0x500;
+   interrupts = GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH;
+   clocks = gateclk 18;
+   status = disabled;
+   };
+
xor@60800 {
compatible = marvell,orion-xor;
reg = 0x60800 0x100
-- 
1.9.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


[PATCHv4 15/20] ARM: configs: enable XHCI mvebu support in multi_v7_defconfig

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Marvell Armada 38x platform needs the xhci_mvebu driver enabled
for the xHCI USB hosts, so this commit enables the corresponding
Kconfig option in multi_v7_defconfig.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
Cc: a...@kernel.org
Cc: Kevin Hilman khil...@linaro.org
Cc: Olof Johansson o...@lixom.net
Cc: Arnd Bergmann a...@arndb.de
---
 arch/arm/configs/multi_v7_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/configs/multi_v7_defconfig 
b/arch/arm/configs/multi_v7_defconfig
index d4e8a47..820cc35 100644
--- a/arch/arm/configs/multi_v7_defconfig
+++ b/arch/arm/configs/multi_v7_defconfig
@@ -254,6 +254,7 @@ CONFIG_SND_SOC_TEGRA_ALC5632=y
 CONFIG_SND_SOC_TEGRA_MAX98090=y
 CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_XHCI_MVEBU=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_EHCI_HCD_PLATFORM=y
-- 
1.9.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


[PATCHv4 02/20] usb: ehci-orion: rename error goto labels in ehci_orion_drv_probe()

2014-05-07 Thread Thomas Petazzoni
In preparation to the introduction of additional initialization steps
in ehci_orion_drv_probe(), we rename the error goto labels from err1,
err2 and err3 names to some more meaningful names.

Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 drivers/usb/host/ehci-orion.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index 7728e83..9298be7 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -160,7 +160,7 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
Found HC with no IRQ. Check %s setup!\n,
dev_name(pdev-dev));
err = -ENODEV;
-   goto err1;
+   goto err;
}
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -169,7 +169,7 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
Found HC with no register addr. Check %s setup!\n,
dev_name(pdev-dev));
err = -ENODEV;
-   goto err1;
+   goto err;
}
 
/*
@@ -179,12 +179,12 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
 */
err = dma_coerce_mask_and_coherent(pdev-dev, DMA_BIT_MASK(32));
if (err)
-   goto err1;
+   goto err;
 
regs = devm_ioremap_resource(pdev-dev, res);
if (IS_ERR(regs)) {
err = PTR_ERR(regs);
-   goto err1;
+   goto err;
}
 
/* Not all platforms can gate the clock, so it is not
@@ -197,7 +197,7 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
pdev-dev, dev_name(pdev-dev));
if (!hcd) {
err = -ENOMEM;
-   goto err2;
+   goto err_create_hcd;
}
 
hcd-rsrc_start = res-start;
@@ -237,17 +237,17 @@ static int ehci_orion_drv_probe(struct platform_device 
*pdev)
 
err = usb_add_hcd(hcd, irq, IRQF_SHARED);
if (err)
-   goto err3;
+   goto err_add_hcd;
 
device_wakeup_enable(hcd-self.controller);
return 0;
 
-err3:
+err_add_hcd:
usb_put_hcd(hcd);
-err2:
+err_create_hcd:
if (!IS_ERR(clk))
clk_disable_unprepare(clk);
-err1:
+err:
dev_err(pdev-dev, init %s fail, %d\n,
dev_name(pdev-dev), err);
 
-- 
1.9.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


[PATCHv4 12/20] ARM: mvebu: add USB3 support for Armada 38x

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

This patch adds the selection of the config symbol needed to build the
USB3 support for Armada 38x into mvebu_v7_defconfig.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/mach-mvebu/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 3f73eec..7960f21 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -54,6 +54,7 @@ config MACH_ARMADA_38X
select CPU_V7
select MACH_MVEBU_V7
select PINCTRL_ARMADA_38X
+   select USB_ARCH_HAS_XHCI
help
  Say 'Y' here if you want your kernel to support boards based
  on the Marvell Armada 380/385 SoC with device tree.
-- 
1.9.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


[PATCHv4 08/20] usb: host: xhci-plat: add support for the Armada 375/38x XHCI controllers

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

The Armada 375 and 38x SoCs come with an XHCI controller that requires
some specific initialization related to the MBus windows
configuration. This patch adds the support for this special
configuration as an XHCI quirk executed during probe.

Two new compatible strings are added to identify the Armada 375 and
Armada 38x XHCI controllers, and therefore enable the relevant quirk.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 drivers/usb/host/Kconfig  |  8 +
 drivers/usb/host/Makefile |  3 ++
 drivers/usb/host/xhci-mvebu.c | 70 +++
 drivers/usb/host/xhci-mvebu.h | 21 +
 drivers/usb/host/xhci-plat.c  | 12 
 5 files changed, 114 insertions(+)
 create mode 100644 drivers/usb/host/xhci-mvebu.c
 create mode 100644 drivers/usb/host/xhci-mvebu.h

diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 3d9e540..9247ad2 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -29,6 +29,14 @@ if USB_XHCI_HCD
 config USB_XHCI_PLATFORM
tristate
 
+config USB_XHCI_MVEBU
+   tristate xHCI support for Marvell Armada 375/38x
+   select USB_XHCI_PLATFORM
+   depends on ARCH_MVEBU || COMPILE_TEST
+   ---help---
+ Say 'Y' to enable the support for the xHCI host controller
+ found in Marvell Armada 375/38x ARM SOCs.
+
 endif # USB_XHCI_HCD
 
 config USB_EHCI_HCD
diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
index 7530468..7c0886a 100644
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -19,6 +19,9 @@ xhci-hcd-$(CONFIG_PCI)+= xhci-pci.o
 
 ifneq ($(CONFIG_USB_XHCI_PLATFORM), )
xhci-hcd-y  += xhci-plat.o
+ifneq ($(CONFIG_USB_XHCI_MVEBU), )
+   xhci-hcd-y  += xhci-mvebu.o
+endif
 endif
 
 obj-$(CONFIG_USB_WHCI_HCD) += whci/
diff --git a/drivers/usb/host/xhci-mvebu.c b/drivers/usb/host/xhci-mvebu.c
new file mode 100644
index 000..fab9d6f
--- /dev/null
+++ b/drivers/usb/host/xhci-mvebu.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2014 Marvell
+ * Author: Gregory CLEMENT gregory.clem...@free-electrons.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ */
+
+#include linux/io.h
+#include linux/mbus.h
+#include linux/of.h
+#include linux/platform_device.h
+
+#define USB3_MAX_WINDOWS   4
+#define USB3_WIN_CTRL(w)   (0x0 + ((w) * 8))
+#define USB3_WIN_BASE(w)   (0x4 + ((w) * 8))
+
+static void xhci_mvebu_mbus_config(void __iomem *base,
+   const struct mbus_dram_target_info *dram)
+{
+   int win;
+
+   /* Clear all existing windows */
+   for (win = 0; win  USB3_MAX_WINDOWS; win++) {
+   writel(0, base + USB3_WIN_CTRL(win));
+   writel(0, base + USB3_WIN_BASE(win));
+   }
+
+   /* Program each DRAM CS in a seperate window */
+   for (win = 0; win  dram-num_cs; win++) {
+   const struct mbus_dram_window *cs = dram-cs + win;
+
+   writel(((cs-size - 1)  0x) | (cs-mbus_attr  8) |
+  (dram-mbus_dram_target_id  4) | 1,
+  base + USB3_WIN_CTRL(win));
+
+   writel((cs-base  0x), base + USB3_WIN_BASE(win));
+   }
+}
+
+int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev)
+{
+   struct resource *res;
+   void __iomem *base;
+   const struct mbus_dram_target_info *dram;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+   if (!res)
+   return -ENODEV;
+
+   /*
+* We don't use devm_ioremap() because this mapping should
+* only exists for the duration of this probe function.
+*/
+   base = ioremap(res-start, resource_size(res));
+   if (!base)
+   return -ENODEV;
+
+   dram = mv_mbus_dram_info();
+   xhci_mvebu_mbus_config(base, dram);
+
+   /*
+* This memory area was only needed to configure the MBus
+* windows, and is therefore no longer useful.
+*/
+   iounmap(base);
+
+   return 0;
+}
diff --git a/drivers/usb/host/xhci-mvebu.h b/drivers/usb/host/xhci-mvebu.h
new file mode 100644
index 000..61d09b6
--- /dev/null
+++ b/drivers/usb/host/xhci-mvebu.h
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2014 Marvell
+ *
+ * Gregory Clement gregory.clem...@free-electrons.com
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed as is without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef __LINUX_XHCI_MVEBU_H
+#define __LINUX_XHCI_MVEBU_H
+#if IS_ENABLED(CONFIG_USB_XHCI_MVEBU)
+int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev

[PATCHv4 13/20] ARM: mvebu: add USB3 support for Armada 375

2014-05-07 Thread Thomas Petazzoni
From: Gregory CLEMENT gregory.clem...@free-electrons.com

This patch add the selection of the config symbol to build the USB3
support for Armada 375.

Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
 arch/arm/mach-mvebu/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 7960f21..95afc76 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -41,6 +41,7 @@ config MACH_ARMADA_375
select CPU_V7
select MACH_MVEBU_V7
select PINCTRL_ARMADA_375
+   select USB_ARCH_HAS_XHCI
help
  Say 'Y' here if you want your kernel to support boards based
  on the Marvell Armada 375 SoC with device tree.
-- 
1.9.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 v3 02/20] usb: ehci-orion: Add the optional PHY support

2014-05-07 Thread Thomas Petazzoni
Dear Andrew Lunn,

On Wed, 7 May 2014 15:21:50 +0200, Andrew Lunn wrote:

  Thanks to devm_phy_optional_get(), the fact of not having a PHY in the
  DT is not considered an error. So on any error from
  devm_phy_optional_get() (including -EPROBE_DEFER), we simply bail out.
  Does this looks good?
 
 Hi Thomas
 
 That looks good.
 
 To avoid the SATA phy problems we had last time, i would like to test
 this on a few systems. Please could you let me know what branch v4 is
 in when it is ready.

Sure. It's now up at
https://github.com/MISL-EBU-System-SW/mainline-public/tree/USB-375-38x-3.15-rc1-V4.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 v3 06/20] usb: host: xhci-plat: Add support for the Armada 38x

2014-05-07 Thread Thomas Petazzoni
Dear Felipe Balbi,

On Wed, 7 May 2014 10:10:08 -0500, Felipe Balbi wrote:

  ifneq ($(CONFIG_USB_XHCI_MVEBU), )
  xhci-hcd-y += xhci-mvebu.o
  endif
  
  Right?
 
 correct :-)
 
  If so, then what about instead making CONFIG_USB_XHCI_MVEBU a bool
  instead of a tristate? It's more an option for the xhci-platform
  driver than an additional separate module, IMO. What do you think?
 
 fine by me too. It simply adds a quirk callback to xhci-plat.

In the end, I settled on keeping the tristate, and used your
suggestion. Because since xhci-plat itself is a blind option, and
xhci-mvebu selects it, if xhci-mvebu is a bool, there would no longer
be a way to have xhci-plat as a module. At least that's my
understanding of the kconfig stuff :)

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 v3 06/20] usb: host: xhci-plat: Add support for the Armada 38x

2014-05-06 Thread Thomas Petazzoni
Dear Arnd Bergmann,

On Tue, 06 May 2014 13:57:44 +0200, Arnd Bergmann wrote:

  Please limit this driver to mvebu arch and compile testing, i.e.
  
  depends on ARCH_MVEBU || COMPILE_TEST
 
 I think it actually needs a dependency on MVEBU_MBUS.

That's not what we do for any of the other drivers that use the
MVEBU_MBUS functions.

 You probably need something like
 
   depends on MVEBU_MBUS=y || (MVEBU_MBUS=m  USB_XHCI=m)

MVEBU_MBUS is a bool, so there is no way is can be =m.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 v3 06/20] usb: host: xhci-plat: Add support for the Armada 38x

2014-05-06 Thread Thomas Petazzoni
Dear Arnd Bergmann,

On Tue, 06 May 2014 14:21:55 +0200, Arnd Bergmann wrote:

  That's not what we do for any of the other drivers that use the
  MVEBU_MBUS functions.
 
 Fair enough. I guess using ARCH_MVEBU as the dependency works as well
 because it implies MVEBU_MBUS. However, you can't use COMPILE_TEST
 then because the driver itself needs the interfaces provided by MBUS.
 
 It could be
 
   depends on ARCH_MVEBU || (MVEBU_MBUS  COMPILE_TEST)
 
 to describe the dependency most accurately.

Right, that would work indeed, but is in fact not necessary, at least
for this driver. The only mbus function used by this driver is
mv_mbus_dram_info(), and linux/mbus.h provides an empty stub for this
function (returning NULL) when MVEBU_MBUS is disabled. So from a
compile time point of view, there is no problem with compiling the
xhci-plat driver with MVEBU_MBUS disabled, so in fact:

depends on ARCH_MVEBU || COMPILE_TEST

will work just fine.

The only case where this doesn't work is for drivers that use the other
mbus functions to create/remove windows, because no stubs are provided
for these ones. However, as things are today, the only driver in this
situation is the pci-mvebu driver, and its dependency is:

depends on ARCH_MVEBU || ARCH_DOVE || ARCH_KIRKWOOD

For this one, we could indeed add || (MVEBU_MBUS  COMPILE_TEST)

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 v2 02/18] usb: host: xhci-plat: Add clocks support

2014-04-25 Thread Thomas Petazzoni
Dear Gregory CLEMENT,

On Fri, 25 Apr 2014 16:07:00 +0200, Gregory CLEMENT wrote:
 Some platform (such as the Armada 38x ones) can gate the clock of
 their USB controller. This patch add the support for the clock, by
 enabling them during probe and disabling them on remove.
 
 As not all platforms have clock support then enabling and disabling
 the clocks have been placed in separate functions. Then if the clocks
 are not supported we still can use the same calls, and there is no
 
 Signed-off-by: Gregory CLEMENT gregory.clem...@free-electrons.com
 ---
  drivers/usb/host/xhci-plat.c | 52 
 ++--
  1 file changed, 50 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
 index f5351af4b2c5..bb5d563f729c 100644
 --- a/drivers/usb/host/xhci-plat.c
 +++ b/drivers/usb/host/xhci-plat.c
 @@ -11,6 +11,7 @@
   * version 2 as published by the Free Software Foundation.
   */
  
 +#include linux/clk.h
  #include linux/dma-mapping.h
  #include linux/module.h
  #include linux/of.h
 @@ -85,6 +86,42 @@ static const struct hc_driver xhci_plat_xhci_driver = {
   .bus_resume =   xhci_bus_resume,
  };
  
 +#if defined(CONFIG_HAVE_CLK)
 +static int try_enable_clk(struct platform_device *pdev)
 +{
 + struct clk *clk = devm_clk_get(pdev-dev, NULL);
 +
 + /* Not all platforms have a clk so it is not an error if the clock
 +does not exists. */
 + if (!IS_ERR(clk))

Instead, do:

if (IS_ERR(clk))
return 0;

return clk_prepare_enable(clk);

 + if (clk_prepare_enable(clk))
 + return  -ENODEV;
 + return 0;
 +}
 +
 +static int try_disable_clk(struct platform_device *pdev)
 +{
 + struct clk *clk = devm_clk_get(pdev-dev, NULL);

No, this isn't correct: you shouldn't be getting the clock to
disable/unprepare it, otherwise you have an unbalanced number of
get()/put() calls on the clocks.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 v2 03/18] usb: host: xhci-plat: Add support for the Armada 38x

2014-04-25 Thread Thomas Petazzoni
Dear Gregory CLEMENT,

On Fri, 25 Apr 2014 16:07:01 +0200, Gregory CLEMENT wrote:

 +#define USB3_MAX_WINDOWS 4
 +#define USB3_WIN_CTRL(w) (0x0 + ((w) * 8))
 +#define USB3_WIN_BASE(w) (0x4 + ((w) * 8))
 +
 +static void __init mv_usb3_conf_mbus_windows(void __iomem *base,
 + const struct mbus_dram_target_info *dram)

That's a nitpick, but the name of this function looks like it was
copy/pasted from the Marvell LSP, and isn't very consistent with the
other function name. What about:

xhci_mvebu_mbus_config()

instead, or something like that?

 +int xhci_mvebu_mbus_init_quirk(struct platform_device *pdev)

I believe this should give you a warning about section mismatch: you
have a non-init function calling an __init function, no?

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 v2 03/18] usb: host: xhci-plat: Add support for the Armada 38x

2014-04-25 Thread Thomas Petazzoni
Dear Arnd Bergmann,

On Fri, 25 Apr 2014 22:01:51 +0200, Arnd Bergmann wrote:

 I think you're doing it the wrong way around: You have a specialized
 version of the generic xhci-plat driver. The normal way to handle this
 is to have a loadable module that contains all the Armada specific
 code and that registers a platform_driver. In the probe() function of
 that driver, you can do the platform specific setup and then call
 the generic xhci_plat_probe() function, which of course has to
 be provided using EXPORT_SYMBOL_GPL.

You should have a look at the v1 Gregory sent: it was implementing
exactly what you suggest here, but Felipe explicitly requested the
patches to be changed like is now proposed in v2.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: [BUG] FL1009: xHCI host not responding to stop endpoint command.

2014-02-18 Thread Thomas Petazzoni
Dear Arnaud Ebalard,

On Sat, 18 Jan 2014 22:49:17 +0100, Arnaud Ebalard wrote:

 I started suspecting the introduction of MSI support in Marvell PCIe
 host controller driver (FL1009 is on the PCIe bus) and compiled a
 a 3.13.0-rc8 w/ CONFIG_PCI_MSI disabled (it was enabled in all my
 previous tests): I did not manage to reproduce the issue with this
 kernel. As a side note, commits 5b4deb6526bd, 31f614edb726 and
 627dfcc249e2 are
 
 ATM, I do not know if the problem is related to a bug in introduced MSI
 support or some weird incompatibility of that functionality with the
 FL1009 which would require some quirk in XHCI stack.
 
 Thomas, I took a look at the changes but I am not familiar w/ how MSI
 work. You may have an idea on what is going on here.

I finally got some idea: your kernel 3.13-rc7 lacks a very important
fix we did in the irqchip driver MSI handling. You really need to have
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/irqchip/irq-armada-370-xp.c?id=c7f7bd4a136e4b02dd2a66bf95aec545bd93e8db
applied to get proper MSI behavior. Without this patch, there is a race
condition, and some MSI interrupts might be lost.

This commit was merged in v3.14-rc2, and backported to 3.13 and
previous stable releases.

Can you test after applying this commit?

 ps: Thomas, this is completely unrelated but the code below caught my
 eye at the beginning of a hunk in 31f614edb726. When CONFIG_PCI_MSI is
 disabled, why is irqnr now compared to 1 instead of 0?

This is not important. IRQs 0 and 1 are reserved for doorbells, which
are only used for IPI (IRQ 0) and MSI (IRQ 1). Therefore, doing
irq_find_mapping() for either IRQ 0 or IRQ 1 is not useful.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: [BUG] FL1009: xHCI host not responding to stop endpoint command.

2014-02-18 Thread Thomas Petazzoni
Dear Arnaud Ebalard,

On Tue, 18 Feb 2014 21:54:31 +0100, Arnaud Ebalard wrote:

  I finally got some idea: your kernel 3.13-rc7 lacks a very important
  fix we did in the irqchip driver MSI handling. You really need to have
  http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/irqchip/irq-armada-370-xp.c?id=c7f7bd4a136e4b02dd2a66bf95aec545bd93e8db
  applied to get proper MSI behavior. Without this patch, there is a race
  condition, and some MSI interrupts might be lost.
 
  This commit was merged in v3.14-rc2, and backported to 3.13 and
  previous stable releases.
 
  Can you test after applying this commit?
 
 Just to be sure, I compiled a 3.13 w/ PCI_MSI enabled and w/o the fix:
 it failed as usual. Then, I just applied the fix on top of it and tested
 again: I was unable to make it fail, i.e. this oneline fixes the issue.

Cool!

 Sarah, I guess this also validates the fact that FL1009 has good MSI
 support ;-)
 
 Thanks for the time you both spent. Let's close the case.

You're welcome. Sorry for having realized so late from where the
problem could be coming from, and that it was in fact already fixed.

Thanks to you for reporting and investigating the issue in the first
place!

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: [BUG] FL1009: xHCI host not responding to stop endpoint command.

2014-02-14 Thread Thomas Petazzoni
Sarah, Arnaud,

On Thu, 13 Feb 2014 16:09:10 -0800, Sarah Sharp wrote:

  Unless you have some objections or some positive feedback from Fresco
  Logic people, can you queue your quirks for FL1009 for 3.14-rc* and
  -stable? Note that I am just asking, i.e. if you want to wait a bit
  more, I am not that in a hurry.
 
 Sorry for not getting back to you sooner.  The Fresco Logic folks said
 that the FL1000 and FL1400 hosts are actually the same chipset, and it
 doesn't support MSI.  However, they say the FL1009 *should* support MSI.
 
 So that doesn't rule out issues with the Marvell PCI MSI code.  I
 suspect that's actually the root cause, since I haven't gotten any bug
 reports that the FL1009 doesn't work with MSI enabled on other systems.

Ok, I'll try to have a look into this, by re-reading the entire
thread, and trying to propose some patches that add debugging details
in the Marvell PCI MSI code to try to understand what's going on.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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: [BUG] FL1009: xHCI host not responding to stop endpoint command.

2014-01-26 Thread Thomas Petazzoni
Dear Arnaud Ebalard,

On Thu, 23 Jan 2014 09:24:41 +0100, Arnaud Ebalard wrote:

 The various Armada-based devices I have are NAS which do not have PCIe
 slots to plug additional devices (everything is soldered). I don't know
 which device Thomas used for its tests. Just in case, I also added Willy
 in CC: who have various boards and may also have done more test with
 additional PCIe devices and CONFIG_PCI_MSI enabled on 3.13 kernel.

The device I've used to test MSI is a e1000e PCIe Intel network card.
It uses one MSI interrupt, so admittedly, the MSI testing is quite
limited for now.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 11/12] usb: phy-mxs: update binding for adding disconnect line property

2013-10-12 Thread Thomas Petazzoni
Dear Peter Chen,

On Sat, 12 Oct 2013 17:09:45 +0800, Peter Chen wrote:
 This property is used to disconnect line between USB PHY and
 USB controller.
 
 Signed-off-by: Peter Chen peter.c...@freescale.com
 ---
  Documentation/devicetree/bindings/usb/mxs-phy.txt |4 
  1 files changed, 4 insertions(+), 0 deletions(-)
 
 diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt 
 b/Documentation/devicetree/bindings/usb/mxs-phy.txt
 index 1a9bd85..099b0bb 100644
 --- a/Documentation/devicetree/bindings/usb/mxs-phy.txt
 +++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt
 @@ -5,6 +5,9 @@ Required properties:
  - reg: Should contain registers location and length
  - interrupts: Should contain phy interrupt
  - fsl,anatop: phandle for anatop register
 +- disconnect_line_without_vbus: needs to disconnect
 +connection between USB PHY and controller, it can avoid
 +unexpected wakeup interrupt when the PHY is out of power
  
  Example:
  usbphy1: usbphy@020c9000 {
 @@ -12,4 +15,5 @@ usbphy1: usbphy@020c9000 {
   reg = 0x020c9000 0x1000;
   interrupts = 0 44 0x04;
   fsl,anatop = anatop;
 + disconnect_line_without_vbus;
  };

Device Tree properties use - as a separator, not _. So, it should
be:

disconnect-line-without-vbus

Also, all your patches touching Device Tree bindings should be Cc'ed to
the devicetree@ mailing list.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
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 00/19] driver:usbnet: add missing platform_driver owner

2013-05-21 Thread Thomas Petazzoni
Dear Gu Zheng,

On Tue, 21 May 2013 16:00:19 +0800, Gu Zheng wrote:

  Or, maybe make the existing module_platform_driver() macro do this?
 
 But not all the modules use module_platform_driver() macro to replace the 
 module init/exit.

Then maybe it's a good opportunity to convert those ones to use
module_platform_driver() ?

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
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 v2 2/3] arm: mvebu: Enable USB controllers on Armada 370/XP boards

2013-01-23 Thread Thomas Petazzoni
Dear Ezequiel Garcia,

On Wed, 23 Jan 2013 14:04:42 -0300, Ezequiel Garcia wrote:

 from the OpenBlocks AX3-4 board dts file, since you mentioned this
 board uses that USB
 port for a PCIe connector -- if I understood correctly.

No. The OpenBlocks has a different USB controller that sits on the PCIe
bus. There is nothing like a PCIe port that uses a USB port, that
doesn't make sense.

 So, IMHO, if OpenBlocks uses third USB port to connect some PCIe
 controller, we should activate it in the dts file.
 
 What do you think?

No, see above.

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
--
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