Skip to contentSkip to conversation

Kesytone II USB support

PATCH Superseded WingMan Kwok 4 participants 18 messages Dec 4, 2013 – Dec 7, 2013

Subsystems (4)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Kesytone II USB support

Here is the updated version of the series which addresses comments from earlier version [1]. The PHY register programming is moved to a separate PHY driver.

Series adds USB host support for Keystone SOCs. Keystone SOCs uses dwc3 hardware IP implementation. On Keystone II platforms, we use no-op phy driver.

All three patches are posted together just for completeness. Only first patch is expected to go via usb tree and other two via linux-keystone tree.

Patchset are tested on Keystone II EVM with USB2.0 and USB3.0 flash drives.

Cc Santosh Shilimkar <[email protected]>

WingMan Kwok (5):
usb: dwc3: Add Keystone specific glue layer
usb: phy: Add keystone usb phy driver
ARM: dts: keystone: Add usb phy devicetree bindings
ARM: dts: keystone: Add usb devicetree bindings
ARM: keystone: defconfig: enable USB support

 .../devicetree/bindings/usb/keystone-phy.txt       |   19 ++
 .../devicetree/bindings/usb/keystone-usb.txt       |   41 ++++
 arch/arm/boot/dts/keystone.dtsi                    |   25 +++
 arch/arm/configs/keystone_defconfig                |   20 +-
 drivers/usb/dwc3/Kconfig                           |    7 +
 drivers/usb/dwc3/Makefile                          |    1 +
 drivers/usb/dwc3/dwc3-keystone.c                   |  210 ++++++++++++++++++++
 drivers/usb/phy/Kconfig                            |   10 +
 drivers/usb/phy/Makefile                           |    1 +
 drivers/usb/phy/phy-keystone.c                     |  142 +++++++++++++
 10 files changed, 475 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/usb/keystone-phy.txt
 create mode 100644 Documentation/devicetree/bindings/usb/keystone-usb.txt
 create mode 100644 drivers/usb/dwc3/dwc3-keystone.c
 create mode 100644 drivers/usb/phy/phy-keystone.c

[1] http://www.spinics.net/lists/linux-usb/msg98166.html

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/5 usb: dwc3: Add Keystone specific glue layer

Add Keystone platform specific glue layer to support USB3 Host mode.

Cc Santosh Shilimkar <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/usb/dwc3/Kconfig         |    7 ++
 drivers/usb/dwc3/Makefile        |    1 +
 drivers/usb/dwc3/dwc3-keystone.c |  210 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 218 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-keystone.c
drivers/usb/dwc3/Kconfig +7 -0
index 70fc430..e2c730f 100644
@@ -70,6 +70,13 @@ config USB_DWC3_PCI
 	  One such PCIe-based platform is Synopsys' PCIe HAPS model of
 	  this IP.
 
+config USB_DWC3_KEYSTONE
+	tristate "Texas Instruments Keystone2 Platforms"
+	default USB_DWC3
+	help
+	  Support of USB2/3 functionality in TI Keystone2 platforms.
+	  Say 'Y' or 'M' here if you have one such device
+
 comment "Debugging features"
 
 config USB_DWC3_DEBUG
drivers/usb/dwc3/Makefile +1 -0
index dd17601..10ac3e7 100644
@@ -32,3 +32,4 @@ endif
 obj-$(CONFIG_USB_DWC3_OMAP)		+= dwc3-omap.o
 obj-$(CONFIG_USB_DWC3_EXYNOS)		+= dwc3-exynos.o
 obj-$(CONFIG_USB_DWC3_PCI)		+= dwc3-pci.o
+obj-$(CONFIG_USB_DWC3_KEYSTONE)		+= dwc3-keystone.o
drivers/usb/dwc3/dwc3-keystone.c new file +210 -0

210 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 1/5 usb: dwc3: Add Keystone specific glue layer

Hi,

Quoted 121 lines · WingMan Kwok

Add Keystone platform specific glue layer to support USB3 Host mode.

Cc Santosh Shilimkar <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/usb/dwc3/Kconfig         |    7 ++
 drivers/usb/dwc3/Makefile        |    1 +
 drivers/usb/dwc3/dwc3-keystone.c |  210 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 218 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-keystone.c
drivers/usb/dwc3/Kconfig +7 -0
index 70fc430..e2c730f 100644
@@ -70,6 +70,13 @@ config USB_DWC3_PCI
 	  One such PCIe-based platform is Synopsys' PCIe HAPS model of
 	  this IP.
 
+config USB_DWC3_KEYSTONE
+	tristate "Texas Instruments Keystone2 Platforms"
+	default USB_DWC3
+	help
+	  Support of USB2/3 functionality in TI Keystone2 platforms.
+	  Say 'Y' or 'M' here if you have one such device
+
 comment "Debugging features"
 
 config USB_DWC3_DEBUG
drivers/usb/dwc3/Makefile +1 -0
index dd17601..10ac3e7 100644
@@ -32,3 +32,4 @@ endif
 obj-$(CONFIG_USB_DWC3_OMAP)		+= dwc3-omap.o
 obj-$(CONFIG_USB_DWC3_EXYNOS)		+= dwc3-exynos.o
 obj-$(CONFIG_USB_DWC3_PCI)		+= dwc3-pci.o
+obj-$(CONFIG_USB_DWC3_KEYSTONE)		+= dwc3-keystone.o
drivers/usb/dwc3/dwc3-keystone.c new file +74 -0
new file mode 100644
index 0000000..d3c0dc5
@@ -0,0 +1,210 @@
+/**
+ * dwc3-keystone.c - Keystone Specific Glue layer
+ *
+ * Copyright (C) 2010-2013 Texas Instruments Incorporated - http://www.ti.com
+ *
+ * Author: WingMan Kwok <[email protected]>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2  of
+ * the License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/clk.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/platform_device.h>
+#include <linux/dma-mapping.h>
+#include <linux/io.h>
+#include <linux/of_platform.h>
+
+/* USBSS register offsets */
+#define USBSS_REVISION		0x0000
+#define USBSS_SYSCONFIG		0x0010
+#define USBSS_IRQ_EOI		0x0018
+#define USBSS_IRQSTATUS_RAW_0	0x0020
+#define USBSS_IRQSTATUS_0	0x0024
+#define USBSS_IRQENABLE_SET_0	0x0028
+#define USBSS_IRQENABLE_CLR_0	0x002c
+
+/* IRQ register bits */
+#define USBSS_IRQ_EOI_LINE(n)	BIT(n)
+#define USBSS_IRQ_EVENT_ST	BIT(0)
+#define USBSS_IRQ_COREIRQ_EN	BIT(0)
+#define USBSS_IRQ_COREIRQ_CLR	BIT(0)
+
+static u64 kdwc3_dma_mask;
+
+struct dwc3_keystone {
+	spinlock_t			lock;
+	struct device			*dev;
+	struct clk			*clk;
+	void __iomem			*usbss;
+};
+
+static inline u32 kdwc3_readl(void __iomem *base, u32 offset)
+{
+	return readl(base + offset);
+}
+
+static inline void kdwc3_writel(void __iomem *base, u32 offset, u32 value)
+{
+	writel(value, base + offset);
+}
+
+static void kdwc3_enable_irqs(struct dwc3_keystone *kdwc)
+{
+	u32 val;
+
+	val = kdwc3_readl(kdwc->usbss, USBSS_IRQENABLE_SET_0);
+	val = USBSS_IRQ_COREIRQ_EN;
+	kdwc3_writel(kdwc->usbss, USBSS_IRQENABLE_SET_0, val);
+}
+
+static void kdwc3_disable_irqs(struct dwc3_keystone *kdwc)
+{
+	u32 val;
+

drivers/usb/dwc3/dwc3-keystone.c line 84

Quoted 10 lines
drivers/usb/dwc3/dwc3-keystone.c new file +10 -0
+	val = kdwc3_readl(kdwc->usbss, USBSS_IRQENABLE_SET_0);
+	val &= ~USBSS_IRQ_COREIRQ_EN;
+	kdwc3_writel(kdwc->usbss, USBSS_IRQENABLE_SET_0, val);
+}
+
+static irqreturn_t dwc3_keystone_interrupt(int irq, void *_kdwc)
+{
+	struct dwc3_keystone	*kdwc = _kdwc;
+
+	spin_lock(&kdwc->lock);

Isn't this lock unnecessary ? This handler will run with IRQs disabled anyway.

drivers/usb/dwc3/dwc3-keystone.c line 97

Quoted 13 lines
drivers/usb/dwc3/dwc3-keystone.c new file +13 -0
+	kdwc3_writel(kdwc->usbss, USBSS_IRQENABLE_CLR_0, USBSS_IRQ_COREIRQ_CLR);
+	kdwc3_writel(kdwc->usbss, USBSS_IRQSTATUS_0, USBSS_IRQ_EVENT_ST);
+	kdwc3_writel(kdwc->usbss, USBSS_IRQENABLE_SET_0, USBSS_IRQ_COREIRQ_EN);
+	kdwc3_writel(kdwc->usbss, USBSS_IRQ_EOI, USBSS_IRQ_EOI_LINE(0));
+	spin_unlock(&kdwc->lock);
+
+	return IRQ_HANDLED;
+}
+
+static int kdwc3_probe(struct platform_device *pdev)
+{
+	struct device_node	*node = pdev->dev.of_node;
+	struct device		*dev = &pdev->dev;

if you invert these lines, it'll look a little nicer:

	struct device		*dev = &pdev->dev;
	struct device_node	*node = dev->of_node;

everything else looks pretty good, thanks

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131206/69c07116/attachment.sig>
#3 lore raw

PATCH v2 1/5 usb: dwc3: Add Keystone specific glue layer

Quoted 16 lines · Felipe Balbi

Hi,

Quoted 13 lines · WingMan Kwok

Add Keystone platform specific glue layer to support USB3 Host mode.

Cc Santosh Shilimkar <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/usb/dwc3/Kconfig         |    7 ++
 drivers/usb/dwc3/Makefile        |    1 +
 drivers/usb/dwc3/dwc3-keystone.c |  210 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 218 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-keystone.c

[..]

Quoted 9 lines

drivers/usb/dwc3/dwc3-keystone.c line 84

Quoted 5 lines
drivers/usb/dwc3/dwc3-keystone.c new file +5 -0
+static irqreturn_t dwc3_keystone_interrupt(int irq, void *_kdwc)
+{
+	struct dwc3_keystone	*kdwc = _kdwc;
+
+	spin_lock(&kdwc->lock);

Isn't this lock unnecessary ? This handler will run with IRQs disabled anyway.

Indeed.

Quoted 16 lines

drivers/usb/dwc3/dwc3-keystone.c line 97

Quoted 13 lines
drivers/usb/dwc3/dwc3-keystone.c new file +13 -0
+	kdwc3_writel(kdwc->usbss, USBSS_IRQENABLE_CLR_0, USBSS_IRQ_COREIRQ_CLR);
+	kdwc3_writel(kdwc->usbss, USBSS_IRQSTATUS_0, USBSS_IRQ_EVENT_ST);
+	kdwc3_writel(kdwc->usbss, USBSS_IRQENABLE_SET_0, USBSS_IRQ_COREIRQ_EN);
+	kdwc3_writel(kdwc->usbss, USBSS_IRQ_EOI, USBSS_IRQ_EOI_LINE(0));
+	spin_unlock(&kdwc->lock);
+
+	return IRQ_HANDLED;
+}
+
+static int kdwc3_probe(struct platform_device *pdev)
+{
+	struct device_node	*node = pdev->dev.of_node;
+	struct device		*dev = &pdev->dev;

if you invert these lines, it'll look a little nicer:

Quoted 5 lines
	struct device		*dev = &pdev->dev;
	struct device_node	*node = dev->of_node;

everything else looks pretty good, thanks

Looks good to me as well. With above update,

#4 lore raw

PATCH v2 1/5 usb: dwc3: Add Keystone specific glue layer

Quoted 32 lines

From: linux-usb-owner at vger.kernel.org [mailto:linux-usb-owner at vger.kernel.org] On Behalf Of Santosh Shilimkar
Sent: Friday, December 06, 2013 1:40 PM

Quoted 16 lines · Felipe Balbi

Hi,

Quoted 13 lines · WingMan Kwok

Add Keystone platform specific glue layer to support USB3 Host mode.

Cc Santosh Shilimkar <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/usb/dwc3/Kconfig         |    7 ++
 drivers/usb/dwc3/Makefile        |    1 +
 drivers/usb/dwc3/dwc3-keystone.c |  210 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 218 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-keystone.c

[..]

Quoted 9 lines

drivers/usb/dwc3/dwc3-keystone.c line 84

Quoted 5 lines
drivers/usb/dwc3/dwc3-keystone.c new file +5 -0
+static irqreturn_t dwc3_keystone_interrupt(int irq, void *_kdwc)
+{
+	struct dwc3_keystone	*kdwc = _kdwc;
+
+	spin_lock(&kdwc->lock);

Isn't this lock unnecessary ? This handler will run with IRQs disabled anyway.

Quoted 1 line

Indeed.

Say what? AFAIK it's necessary to take the driver lock inside the interrupt handler, because of SMP. Here is the equivalent routine from dwc3-omap.c:

static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)

{
        struct dwc3_omap        *omap = _omap;
        u32                     reg;

        spin_lock(&omap->lock);

        ...
}

Has this now become unnecessary?

Signature · 1 line
Paul
#5 lore raw

PATCH v2 1/5 usb: dwc3: Add Keystone specific glue layer

(sorry for html reply)
________________________________________
From: Paul Zimmerman [Paul.Zimmerman at synopsys.com]
Sent: Friday, December 06, 2013 5:23 PM
To: Shilimkar, Santosh; Balbi, Felipe; Kwok, WingMan
Cc: linux-arm-kernel at lists.infradead.org; linux-usb at vger.kernel.org; Greg Kroah-Hartman
Subject: RE: [PATCH v2 1/5] usb: dwc3: Add Keystone specific glue layer

Quoted 32 lines

From: linux-usb-owner at vger.kernel.org [mailto:linux-usb-owner at vger.kernel.org] On Behalf Of Santosh Shilimkar
Sent: Friday, December 06, 2013 1:40 PM

Quoted 16 lines · Felipe Balbi

Hi,

Quoted 13 lines · WingMan Kwok

Add Keystone platform specific glue layer to support USB3 Host mode.

Cc Santosh Shilimkar <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/usb/dwc3/Kconfig         |    7 ++
 drivers/usb/dwc3/Makefile        |    1 +
 drivers/usb/dwc3/dwc3-keystone.c |  210 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 218 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-keystone.c

[..]

Quoted 9 lines

drivers/usb/dwc3/dwc3-keystone.c line 84

Quoted 5 lines
drivers/usb/dwc3/dwc3-keystone.c new file +5 -0
+static irqreturn_t dwc3_keystone_interrupt(int irq, void *_kdwc)
+{
+  struct dwc3_keystone    *kdwc = _kdwc;
+
+  spin_lock(&kdwc->lock);

Isn't this lock unnecessary ? This handler will run with IRQs disabled anyway.

Quoted 1 line

Indeed.

-------------------------------
Say what? AFAIK it's necessary to take the driver lock inside the interrupt handler, because of SMP. Here is the equivalent routine from dwc3-omap.c:

static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)

{
        struct dwc3_omap        *omap = _omap;
        u32                     reg;

        spin_lock(&omap->lock);

        ...--

Paul

}

Has this now become unnecessary?
----------------

[Santosh] Not sure if i am missing your point, but this lock is not needed IMHO. The register update which is protected by the lock happens only in ISR where the source of the irq is disabled, so even on SMP machines there is no race possible which needs to be protected.

I would have agreed to you if there was some additional code outside isr and the code in ISR were both needed lock and that would have been issue on SMP machine without spin lock.

On OMAP code as well the lock is not needed but I let Felipe comment about it.

Regards,
Santosh

#6 lore raw

PATCH v2 1/5 usb: dwc3: Add Keystone specific glue layer

Quoted 61 lines

From: Shilimkar, Santosh [mailto:santosh.shilimkar at ti.com]
Sent: Friday, December 06, 2013 9:25 PM

Quoted 50 lines

From: Paul Zimmerman [Paul.Zimmerman at synopsys.com]
Sent: Friday, December 06, 2013 5:23 PM

Quoted 32 lines

From: linux-usb-owner at vger.kernel.org [mailto:linux-usb-owner at vger.kernel.org] On Behalf Of Santosh Shilimkar
Sent: Friday, December 06, 2013 1:40 PM

Quoted 16 lines · Felipe Balbi

Hi,

Quoted 13 lines · WingMan Kwok

Add Keystone platform specific glue layer to support USB3 Host mode.

Cc Santosh Shilimkar <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/usb/dwc3/Kconfig         |    7 ++
 drivers/usb/dwc3/Makefile        |    1 +
 drivers/usb/dwc3/dwc3-keystone.c |  210 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 218 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-keystone.c

[..]

Quoted 9 lines

drivers/usb/dwc3/dwc3-keystone.c line 84

Quoted 5 lines
drivers/usb/dwc3/dwc3-keystone.c new file +5 -0
+static irqreturn_t dwc3_keystone_interrupt(int irq, void *_kdwc)
+{
+  struct dwc3_keystone    *kdwc = _kdwc;
+
+  spin_lock(&kdwc->lock);

Isn't this lock unnecessary ? This handler will run with IRQs disabled anyway.

Quoted 1 line

Indeed.

Say what? AFAIK it's necessary to take the driver lock inside the interrupt handler, because of SMP. Here is the equivalent routine from dwc3-omap.c:

static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)

{
        struct dwc3_omap        *omap = _omap;
        u32                     reg;

        spin_lock(&omap->lock);

        ...
}
Quoted 1 line

Has this now become unnecessary?

[Santosh] Not sure if i am missing your point, but this lock is not needed IMHO. The register update which is protected by the lock happens only in ISR where the source of the irq is disabled, so even on SMP machines there is no race possible which needs to be protected.

Quoted 6 lines

I would have agreed to you if there was some additional code outside isr and the code in ISR were both needed lock and that would have been issue on SMP machine without spin lock.

On OMAP code as well the lock is not needed but I let Felipe comment about it.

Yes sorry, I see now the lock is only taken in the ISR.

So you should probably get rid of the lock altogether, no?

Signature · 1 line
Paul
#7 lore raw

PATCH v2 1/5 usb: dwc3: Add Keystone specific glue layer

In reply to Shilimkar, Santosh
Quoted 67 lines · Santosh

(sorry for html reply)
________________________________________
From: Paul Zimmerman [Paul.Zimmerman at synopsys.com]
Sent: Friday, December 06, 2013 5:23 PM
To: Shilimkar, Santosh; Balbi, Felipe; Kwok, WingMan
Cc: linux-arm-kernel at lists.infradead.org; linux-usb at vger.kernel.org; Greg Kroah-Hartman
Subject: RE: [PATCH v2 1/5] usb: dwc3: Add Keystone specific glue layer

Quoted 32 lines

From: linux-usb-owner at vger.kernel.org [mailto:linux-usb-owner at vger.kernel.org] On Behalf Of Santosh Shilimkar
Sent: Friday, December 06, 2013 1:40 PM

Quoted 16 lines · Felipe Balbi

Hi,

Quoted 13 lines · WingMan Kwok

Add Keystone platform specific glue layer to support USB3 Host mode.

Cc Santosh Shilimkar <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/usb/dwc3/Kconfig         |    7 ++
 drivers/usb/dwc3/Makefile        |    1 +
 drivers/usb/dwc3/dwc3-keystone.c |  210 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 218 insertions(+)
 create mode 100644 drivers/usb/dwc3/dwc3-keystone.c

[..]

Quoted 9 lines

drivers/usb/dwc3/dwc3-keystone.c line 84

Quoted 5 lines
drivers/usb/dwc3/dwc3-keystone.c new file +5 -0
+static irqreturn_t dwc3_keystone_interrupt(int irq, void *_kdwc)
+{
+  struct dwc3_keystone    *kdwc = _kdwc;
+
+  spin_lock(&kdwc->lock);

Isn't this lock unnecessary ? This handler will run with IRQs disabled anyway.

Quoted 1 line

Indeed.

-------------------------------
Say what? AFAIK it's necessary to take the driver lock inside the interrupt handler, because of SMP. Here is the equivalent routine from dwc3-omap.c:

static irqreturn_t dwc3_omap_interrupt(int irq, void *_omap)

{
        struct dwc3_omap        *omap = _omap;
        u32                     reg;

        spin_lock(&omap->lock);

        ...--

Paul

}

Has this now become unnecessary?
----------------

[Santosh] Not sure if i am missing your point, but this lock is not needed IMHO. The register update which is protected by the lock happens only in ISR where the source of the irq is disabled, so even on SMP machines there is no race possible which needs to be protected.

Quoted 6 lines

I would have agreed to you if there was some additional code outside isr and the code in ISR were both needed lock and that would have been issue on SMP machine without spin lock.

On OMAP code as well the lock is not needed but I let Felipe comment about it.

correct, I'll patch that up for v3.14 :-)

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131207/6584a472/attachment.sig>
#8 lore raw

PATCH v2 2/5 usb: phy: Add keystone usb phy driver

In reply to WingMan Kwok

Add Keystone platform USB PHY driver support. Current main purpose of this driver is to enable the PHY reference clock gate on the Keystone SoC. Otherwise it is a nop PHY.

Cc Santosh Shilimkar <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/usb/phy/Kconfig        |   10 +++
 drivers/usb/phy/Makefile       |    1 +
 drivers/usb/phy/phy-keystone.c |  142 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 153 insertions(+)
 create mode 100644 drivers/usb/phy/phy-keystone.c
drivers/usb/phy/Kconfig +10 -0
index 08e2f39..c6792f43 100644
@@ -40,6 +40,16 @@ config ISP1301_OMAP
 	  This driver can also be built as a module.  If so, the module
 	  will be called isp1301_omap.
 
+config KEYSTONE_USB_PHY
+	tristate "Keystone USB PHY Driver"
+	depends on ARCH_KEYSTONE
+	select USB_PHY
+	select NOP_USB_XCEIV
+	help
+	  Enable this to support Keystone USB phy. This driver provides
+	  interface to interact with USB 2.0 and USB 3.0 PHY that is part
+	  of the Keystone SOC.
+
 config MV_U3D_PHY
 	bool "Marvell USB 3.0 PHY controller Driver"
 	depends on CPU_MMP3
drivers/usb/phy/Makefile +1 -0
index 022c1da..311b47b 100644
@@ -30,3 +30,4 @@ obj-$(CONFIG_USB_RCAR_PHY)		+= phy-rcar-usb.o
 obj-$(CONFIG_USB_RCAR_GEN2_PHY)		+= phy-rcar-gen2-usb.o
 obj-$(CONFIG_USB_ULPI)			+= phy-ulpi.o
 obj-$(CONFIG_USB_ULPI_VIEWPORT)		+= phy-ulpi-viewport.o
+obj-$(CONFIG_KEYSTONE_USB_PHY)		+= phy-keystone.o
drivers/usb/phy/phy-keystone.c new file +142 -0

142 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v2 2/5 usb: phy: Add keystone usb phy driver

Hi,

Quoted 8 lines · WingMan Kwok

Add Keystone platform USB PHY driver support. Current main purpose of this driver is to enable the PHY reference clock gate on the Keystone SoC. Otherwise it is a nop PHY.

Cc Santosh Shilimkar <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>

looks good.

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131206/3ea2de7e/attachment.sig>
#10 lore raw

PATCH v2 2/5 usb: phy: Add keystone usb phy driver

In reply to WingMan Kwok
Quoted 8 lines · WingMan Kwok

Add Keystone platform USB PHY driver support. Current main purpose of this driver is to enable the PHY reference clock gate on the Keystone SoC. Otherwise it is a nop PHY.

Cc Santosh Shilimkar <[email protected]>
Cc Felipe Balbi <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Quoted 7 lines
---
 drivers/usb/phy/Kconfig        |   10 +++
 drivers/usb/phy/Makefile       |    1 +
 drivers/usb/phy/phy-keystone.c |  142 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 153 insertions(+)
 create mode 100644 drivers/usb/phy/phy-keystone.c
#11 lore raw

PATCH v2 3/5 ARM: dts: keystone: Add usb phy devicetree bindings

In reply to WingMan Kwok

Added device tree support for TI's Keystone USB PHY driver and updated the Documentation with device tree binding information.

Cc Santosh Shilimkar <[email protected]>
---
 .../devicetree/bindings/usb/keystone-phy.txt       |   19 +++++++++++++++++++
 arch/arm/boot/dts/keystone.dtsi                    |    7 +++++++
 2 files changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/keystone-phy.txt
Documentation/devicetree/bindings/usb/keystone-phy.txt new file +19 -0
new file mode 100644
index 0000000..300830d
@@ -0,0 +1,19 @@
+TI Keystone USB PHY
+
+Required properties:
+ - compatible: should be "ti,keystone-usbphy".
+ - #address-cells, #size-cells : should be '1' if the device has sub-nodes
+   with 'reg' property.
+ - reg : Address and length of the usb phy control register set.
+
+The main purpose of this PHY driver is to enable the USB PHY reference clock
+gate on the Keystone SOC for both the USB2 and USB3 PHY. Otherwise it is just
+an NOP PHY driver.  Hence this node is referenced as both the usb2 and usb3
+phy node in the USB Glue layer driver node.
+
+usb_phy: usb_phy at 2620738 {
+	compatible = "ti,keystone-usbphy";
+	#address-cells = <1>;
+	#size-cells = <1>;
+	reg = <0x2620738 32>;
+};
arch/arm/boot/dts/keystone.dtsi +7 -0
index f6d6d9e..d497d9e 100644
@@ -181,5 +181,12 @@
 			interrupts = <GIC_SPI 300 IRQ_TYPE_EDGE_RISING>;
 			clocks = <&clkspi>;
 		};
+
+		usb_phy: usb_phy at 2620738 {
+			compatible = "ti,keystone-usbphy";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			reg = <0x2620738 32>;
+		};
 	};
 };
Signature · 1 line
1.7.9.5
#12 lore raw

PATCH v2 3/5 ARM: dts: keystone: Add usb phy devicetree bindings

Quoted 41 lines · WingMan Kwok

Added device tree support for TI's Keystone USB PHY driver and updated the Documentation with device tree binding information.

Cc Santosh Shilimkar <[email protected]>
---
 .../devicetree/bindings/usb/keystone-phy.txt       |   19 +++++++++++++++++++
 arch/arm/boot/dts/keystone.dtsi                    |    7 +++++++
 2 files changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/keystone-phy.txt
Documentation/devicetree/bindings/usb/keystone-phy.txt new file +19 -0
new file mode 100644
index 0000000..300830d
@@ -0,0 +1,19 @@
+TI Keystone USB PHY
+
+Required properties:
+ - compatible: should be "ti,keystone-usbphy".
+ - #address-cells, #size-cells : should be '1' if the device has sub-nodes
+   with 'reg' property.
+ - reg : Address and length of the usb phy control register set.
+
+The main purpose of this PHY driver is to enable the USB PHY reference clock
+gate on the Keystone SOC for both the USB2 and USB3 PHY. Otherwise it is just
+an NOP PHY driver.  Hence this node is referenced as both the usb2 and usb3
+phy node in the USB Glue layer driver node.
+
+usb_phy: usb_phy at 2620738 {
+	compatible = "ti,keystone-usbphy";
+	#address-cells = <1>;
+	#size-cells = <1>;
+	reg = <0x2620738 32>;
+};
arch/arm/boot/dts/keystone.dtsi +0 -0
index f6d6d9e..d497d9e 100644

arch/arm/boot/dts/keystone.dtsi line 189

Quoted 9 lines
arch/arm/boot/dts/keystone.dtsi +6 -0
@@ -181,5 +181,12 @@
 			interrupts = <GIC_SPI 300 IRQ_TYPE_EDGE_RISING>;
 			clocks = <&clkspi>;
 		};
+
+		usb_phy: usb_phy at 2620738 {
+			compatible = "ti,keystone-usbphy";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			reg = <0x2620738 32>;

should this one have status = "disabled"; and let board dts enable the PHY ?

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131206/0e279e40/attachment.sig>
#13 lore raw

PATCH v2 3/5 ARM: dts: keystone: Add usb phy devicetree bindings

Quoted 46 lines · Felipe Balbi
Quoted 45 lines · WingMan Kwok

Added device tree support for TI's Keystone USB PHY driver and updated the Documentation with device tree binding information.

Cc Santosh Shilimkar <[email protected]>
---
 .../devicetree/bindings/usb/keystone-phy.txt       |   19 +++++++++++++++++++
 arch/arm/boot/dts/keystone.dtsi                    |    7 +++++++
 2 files changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/keystone-phy.txt
Documentation/devicetree/bindings/usb/keystone-phy.txt new file +19 -0
new file mode 100644
index 0000000..300830d
@@ -0,0 +1,19 @@
+TI Keystone USB PHY
+
+Required properties:
+ - compatible: should be "ti,keystone-usbphy".
+ - #address-cells, #size-cells : should be '1' if the device has sub-nodes
+   with 'reg' property.
+ - reg : Address and length of the usb phy control register set.
+
+The main purpose of this PHY driver is to enable the USB PHY reference clock
+gate on the Keystone SOC for both the USB2 and USB3 PHY. Otherwise it is just
+an NOP PHY driver.  Hence this node is referenced as both the usb2 and usb3
+phy node in the USB Glue layer driver node.
+
+usb_phy: usb_phy at 2620738 {
+	compatible = "ti,keystone-usbphy";
+	#address-cells = <1>;
+	#size-cells = <1>;
+	reg = <0x2620738 32>;
+};
arch/arm/boot/dts/keystone.dtsi +1 -0
index f6d6d9e..d497d9e 100644
@@ -181,5 +181,12 @@
 			interrupts = <GIC_SPI 300 IRQ_TYPE_EDGE_RISING>;
 			clocks = <&clkspi>;
 		};
+
Quoted 9 lines

arch/arm/boot/dts/keystone.dtsi line 189

Quoted 5 lines
arch/arm/boot/dts/keystone.dtsi +5 -0
+		usb_phy: usb_phy at 2620738 {
+			compatible = "ti,keystone-usbphy";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			reg = <0x2620738 32>;

should this one have status = "disabled"; and let board dts enable the PHY ?

Currently there is only one board but probably not a bad idea to enable it from board dts. Lets do that

Regards,
Santosh

#14 lore raw

PATCH v2 4/5 ARM: dts: keystone: Add usb devicetree bindings

In reply to WingMan Kwok

Added device tree support for TI's Keystone USB driver and updated the Documentation with device tree binding information.

Cc Santosh Shilimkar <[email protected]>
---
 .../devicetree/bindings/usb/keystone-usb.txt       |   41 ++++++++++++++++++++
 arch/arm/boot/dts/keystone.dtsi                    |   18 +++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/keystone-usb.txt
Documentation/devicetree/bindings/usb/keystone-usb.txt new file +41 -0
new file mode 100644
index 0000000..ac2c7cc
@@ -0,0 +1,41 @@
+TI Keystone Soc USB Controller
+
+DWC3 GLUE
+
+Required properties:
+ - compatible: should be "ti,keystone-dwc3".
+ - #address-cells, #size-cells : should be '1' if the device has sub-nodes
+   with 'reg' property.
+ - reg : Address and length of the register set for the USB subsystem on
+   the SOC.
+ - interrupts : The irq number of this device that is used to interrupt the
+   MPU.
+ - ranges: allows valid 1:1 translation between child's address space and
+   parent's address space.
+ - clocks: Clock IDs array as required by the controller.
+ - clock-names: names of clocks correseponding to IDs in the clock property.
+
+Sub-nodes:
+The dwc3 core should be added as subnode to Keystone DWC3 glue.
+- dwc3 :
+   The binding details of dwc3 can be found in:
+   Documentation/devicetree/bindings/usb/dwc3.txt
+
+Example:
+	usb: usb at 2680000 {
+		compatible = "ti,keystone-dwc3";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0x2680000 0x10000>;
+		clocks = <&clkusb>;
+		clock-names = "usb";
+		interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
+		ranges;
+
+		dwc3 at 2690000 {
+			compatible = "synopsys,dwc3";
+			reg = <0x2690000 0x70000>;
+			interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
+			usb-phy = <&usb_phy>, <&usb_phy>;
+		};
+	};
arch/arm/boot/dts/keystone.dtsi +18 -0
index d497d9e..0911bb7 100644
@@ -188,5 +188,23 @@
 			#size-cells = <1>;
 			reg = <0x2620738 32>;
 		};
+
+		usb: usb at 2680000 {
+			compatible = "ti,keystone-dwc3";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			reg = <0x2680000 0x10000>;
+			clocks = <&clkusb>;
+			clock-names = "usb";
+			interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
+			ranges;
+
+			dwc3 at 2690000 {
+				compatible = "synopsys,dwc3";
+				reg = <0x2690000 0x70000>;
+				interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
+				usb-phy = <&usb_phy>, <&usb_phy>;
+			};
+		};
 	};
 };
Signature · 1 line
1.7.9.5
#15 lore raw

PATCH v2 4/5 ARM: dts: keystone: Add usb devicetree bindings

Hi,

Quoted 52 lines · WingMan Kwok
Documentation/devicetree/bindings/usb/keystone-usb.txt new file +41 -0
new file mode 100644
index 0000000..ac2c7cc
@@ -0,0 +1,41 @@
+TI Keystone Soc USB Controller
+
+DWC3 GLUE
+
+Required properties:
+ - compatible: should be "ti,keystone-dwc3".
+ - #address-cells, #size-cells : should be '1' if the device has sub-nodes
+   with 'reg' property.
+ - reg : Address and length of the register set for the USB subsystem on
+   the SOC.
+ - interrupts : The irq number of this device that is used to interrupt the
+   MPU.
+ - ranges: allows valid 1:1 translation between child's address space and
+   parent's address space.
+ - clocks: Clock IDs array as required by the controller.
+ - clock-names: names of clocks correseponding to IDs in the clock property.
+
+Sub-nodes:
+The dwc3 core should be added as subnode to Keystone DWC3 glue.
+- dwc3 :
+   The binding details of dwc3 can be found in:
+   Documentation/devicetree/bindings/usb/dwc3.txt
+
+Example:
+	usb: usb at 2680000 {
+		compatible = "ti,keystone-dwc3";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0x2680000 0x10000>;
+		clocks = <&clkusb>;
+		clock-names = "usb";
+		interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
+		ranges;
+
+		dwc3 at 2690000 {
+			compatible = "synopsys,dwc3";
+			reg = <0x2690000 0x70000>;
+			interrupts = <GIC_SPI 393 IRQ_TYPE_EDGE_RISING>;
+			usb-phy = <&usb_phy>, <&usb_phy>;
+		};
+	};
arch/arm/boot/dts/keystone.dtsi +0 -0
index d497d9e..0911bb7 100644

arch/arm/boot/dts/keystone.dtsi line 192

Quoted 5 lines
arch/arm/boot/dts/keystone.dtsi +2 -0
@@ -188,5 +188,23 @@
 			#size-cells = <1>;
 			reg = <0x2620738 32>;
 		};
+
+		usb: usb at 2680000 {

likewise, status = disabled ?

Signature · 8 lines
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131206/1d736762/attachment-0001.sig>
#16 lore raw

PATCH v2 5/5 ARM: keystone: defconfig: enable USB support

In reply to WingMan Kwok

Enable the USB support (Host mode only) on TI's Keystone platform. It also enables the support of usb mass storage, FAT and Ext4 filesystems to test rootfs mount over an USB disk.

Cc Santosh Shilimkar <[email protected]>
---
 arch/arm/configs/keystone_defconfig |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
arch/arm/configs/keystone_defconfig +19 -1
index 9943e5d..a018244 100644
@@ -115,6 +115,8 @@ CONFIG_MTD_UBI=y
 CONFIG_PROC_DEVICETREE=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_EEPROM_AT24=y
+CONFIG_SCSI=y
+CONFIG_BLK_DEV_SD=y
 CONFIG_NETDEVICES=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
@@ -129,10 +131,24 @@ CONFIG_SPI_DAVINCI=y
 CONFIG_SPI_SPIDEV=y
 # CONFIG_HWMON is not set
 CONFIG_WATCHDOG=y
-# CONFIG_USB_SUPPORT is not set
+CONFIG_USB=y
+CONFIG_USB_DEBUG=y
+CONFIG_USB_ANNOUNCE_NEW_DEVICES=y
+CONFIG_USB_MON=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_DEBUG=y
+CONFIG_USB_DWC3_VERBOSE=y
+CONFIG_KEYSTONE_USB_PHY=y
 CONFIG_DMADEVICES=y
 CONFIG_COMMON_CLK_DEBUG=y
 CONFIG_MEMORY=y
+CONFIG_EXT4_FS=y
+CONFIG_EXT4_FS_POSIX_ACL=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_NTFS_FS=y
 CONFIG_TMPFS=y
 CONFIG_JFFS2_FS=y
 CONFIG_JFFS2_FS_WBUF_VERIFY=y
@@ -144,6 +160,8 @@ CONFIG_ROOT_NFS=y
 CONFIG_NFSD=y
 CONFIG_NFSD_V3=y
 CONFIG_NFSD_V3_ACL=y
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ISO8859_1=y
 CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_SHIRQ=y
 CONFIG_DEBUG_INFO=y
Signature · 1 line
1.7.9.5
#17 lore raw

v2 cover Kesytone II USB support

In reply to WingMan Kwok

Wingman,

Quoted 10 lines · WingMan Kwok

Here is the updated version of the series which addresses comments from earlier version [1]. The PHY register programming is moved to a separate PHY driver.

Series adds USB host support for Keystone SOCs. Keystone SOCs uses dwc3 hardware IP implementation. On Keystone II platforms, we use no-op phy driver.

All three patches are posted together just for completeness. Only first patch is expected to go via usb tree and other two via linux-keystone tree.

The series looks fine now and probably can be split now.

Quoted 7 lines

Patchset are tested on Keystone II EVM with USB2.0 and USB3.0 flash drives.

Cc Santosh Shilimkar <[email protected]>

WingMan Kwok (5):
usb: dwc3: Add Keystone specific glue layer
usb: phy: Add keystone usb phy driver

Please update the minor comments on patch 1 and resubmit above two patches so that Felipe can pick these up.

Quoted 4 lines

ARM: dts: keystone: Add usb phy devicetree bindings
ARM: dts: keystone: Add usb devicetree bindings
ARM: keystone: defconfig: enable USB support

On the dts part just enable the phy,usb3 nodes from board dts file and have status disabled in common dts file. With those update, please repost them and I will take them in my 3.14 queue.

Regards,
Santosh