Skip to contentSkip to conversation

Kesytone II USB host and PHY drivers

PATCH Superseded WingMan Kwok 4 participants 17 messages Dec 9, 2013 – Dec 12, 2013

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover Kesytone II USB host and PHY drivers

Here is the updated version of the series which addresses comments from earlier version [1]. The lock in the isr is removed as per the discussion.

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.

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

Cc Felipe Balbi <[email protected]>
Cc Santosh Shilimkar <[email protected]>

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

 drivers/usb/dwc3/Kconfig         |    7 ++
 drivers/usb/dwc3/Makefile        |    1 +
 drivers/usb/dwc3/dwc3-keystone.c |  205 ++++++++++++++++++++++++++++++++++++++
 drivers/usb/phy/Kconfig          |   10 ++
 drivers/usb/phy/Makefile         |    1 +
 drivers/usb/phy/phy-keystone.c   |  142 ++++++++++++++++++++++++++
 6 files changed, 366 insertions(+)
 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/msg98861.html

Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/2 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 |  205 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 213 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 +205 -0

205 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v3 1/2 usb: dwc3: Add Keystone specific glue layer

Hi,

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

Quoted 6 lines · WingMan Kwok
drivers/usb/dwc3/dwc3-keystone.c new file +6 -0
+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;

this misses the | in |=. I can fix it up while applying, this time only.

Quoted 21 lines
drivers/usb/dwc3/dwc3-keystone.c new file +21 -0
+static int kdwc3_probe(struct platform_device *pdev)
+{
+	struct device		*dev = &pdev->dev;
+	struct device_node	*node = pdev->dev.of_node;
+	struct dwc3_keystone	*kdwc;
+	struct resource		*res;
+	int			error, irq;
+
+	kdwc = devm_kzalloc(dev, sizeof(*kdwc), GFP_KERNEL);
+	if (!kdwc)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, kdwc);
+
+	kdwc->dev = dev;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(dev, "missing usbss resource\n");
+		return -EINVAL;
+	}

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

Quoted 10 lines
drivers/usb/dwc3/dwc3-keystone.c new file +10 -0
+
+	kdwc->usbss = devm_ioremap_resource(dev, res);
+	if (IS_ERR(kdwc->usbss))
+		return PTR_ERR(kdwc->usbss);
+
+	kdwc3_dma_mask = dma_get_mask(dev);
+	dev->dma_mask = &kdwc3_dma_mask;
+
+	kdwc->clk = devm_clk_get(kdwc->dev, "usb");
+	if (IS_ERR_OR_NULL(kdwc->clk)) {

clk_get() will never return NULL. This time, I'll fix it while applying.

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

Quoted 6 lines
drivers/usb/dwc3/dwc3-keystone.c new file +6 -0
+static int kdwc3_remove(struct platform_device *pdev)
+{
+	struct dwc3_keystone *kdwc = platform_get_drvdata(pdev);
+
+	kdwc3_disable_irqs(kdwc);
+	clk_disable_unprepare(kdwc->clk);

I hope the clock isn't shared between core and wrapper, otherwise you could run into some troubles here. Can you confirm ?

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/20131209/50050cfb/attachment.sig>
#3 lore raw

PATCH v3 1/2 usb: dwc3: Add Keystone specific glue layer

Quoted 46 lines · Felipe

Hi,

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

Quoted 6 lines · WingMan Kwok
drivers/usb/dwc3/dwc3-keystone.c new file +6 -0
+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;

this misses the | in |=. I can fix it up while applying, this time only.

Quoted 21 lines
drivers/usb/dwc3/dwc3-keystone.c new file +21 -0
+static int kdwc3_probe(struct platform_device *pdev)
+{
+	struct device		*dev = &pdev->dev;
+	struct device_node	*node = pdev->dev.of_node;
+	struct dwc3_keystone	*kdwc;
+	struct resource		*res;
+	int			error, irq;
+
+	kdwc = devm_kzalloc(dev, sizeof(*kdwc), GFP_KERNEL);
+	if (!kdwc)
+		return -ENOMEM;
+
+	platform_set_drvdata(pdev, kdwc);
+
+	kdwc->dev = dev;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(dev, "missing usbss resource\n");
+		return -EINVAL;
+	}

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

Quoted 10 lines
drivers/usb/dwc3/dwc3-keystone.c new file +10 -0
+
+	kdwc->usbss = devm_ioremap_resource(dev, res);
+	if (IS_ERR(kdwc->usbss))
+		return PTR_ERR(kdwc->usbss);
+
+	kdwc3_dma_mask = dma_get_mask(dev);
+	dev->dma_mask = &kdwc3_dma_mask;
+
+	kdwc->clk = devm_clk_get(kdwc->dev, "usb");
+	if (IS_ERR_OR_NULL(kdwc->clk)) {

clk_get() will never return NULL. This time, I'll fix it while applying.

Quoted 10 lines

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

Quoted 6 lines
drivers/usb/dwc3/dwc3-keystone.c new file +6 -0
+static int kdwc3_remove(struct platform_device *pdev)
+{
+	struct dwc3_keystone *kdwc = platform_get_drvdata(pdev);
+
+	kdwc3_disable_irqs(kdwc);
+	clk_disable_unprepare(kdwc->clk);

I hope the clock isn't shared between core and wrapper, otherwise you could run into some troubles here. Can you confirm ?

Yes. the clock isn't shared. Thanks for taking care of other parts.

#4 lore raw

PATCH v3 1/2 usb: dwc3: Add Keystone specific glue layer

Hi,

Quoted 11 lines · Santosh Shilimkar
Quoted 10 lines

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

Quoted 6 lines
drivers/usb/dwc3/dwc3-keystone.c new file +6 -0
+static int kdwc3_remove(struct platform_device *pdev)
+{
+	struct dwc3_keystone *kdwc = platform_get_drvdata(pdev);
+
+	kdwc3_disable_irqs(kdwc);
+	clk_disable_unprepare(kdwc->clk);

I hope the clock isn't shared between core and wrapper, otherwise you could run into some troubles here. Can you confirm ?

Yes. the clock isn't shared. Thanks for taking care of other parts.

so clock for core is always running too ?

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/20131212/ec33f2df/attachment.sig>
#5 lore raw

PATCH v3 1/2 usb: dwc3: Add Keystone specific glue layer

Quoted 13 lines · Felipe Balbi

Hi,

Quoted 10 lines · Santosh Shilimkar
Quoted 10 lines

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

Quoted 6 lines
drivers/usb/dwc3/dwc3-keystone.c new file +6 -0
+static int kdwc3_remove(struct platform_device *pdev)
+{
+	struct dwc3_keystone *kdwc = platform_get_drvdata(pdev);
+
+	kdwc3_disable_irqs(kdwc);
+	clk_disable_unprepare(kdwc->clk);

I hope the clock isn't shared between core and wrapper, otherwise you could run into some troubles here. Can you confirm ?

Quoted 4 lines
Quoted 1 line

Yes. the clock isn't shared. Thanks for taking care of other parts.

so clock for core is always running too ?

I take that back. The clock is actually common so we should disable it after removing the kdwc3_remove_core() as you suggested.

You won't see issue since the kdwc3_remove_core() not doing any register access but moving the clock disable after the core remove is right thing to do.

Regards,
Santosh

#6 lore raw

PATCH v3 1/2 usb: dwc3: Add Keystone specific glue layer

Quoted 16 lines · Santosh Shilimkar
Quoted 15 lines · Felipe Balbi

Hi,

Quoted 11 lines · Santosh Shilimkar
Quoted 10 lines

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

Quoted 6 lines
drivers/usb/dwc3/dwc3-keystone.c new file +6 -0
+static int kdwc3_remove(struct platform_device *pdev)
+{
+	struct dwc3_keystone *kdwc = platform_get_drvdata(pdev);
+
+	kdwc3_disable_irqs(kdwc);
+	clk_disable_unprepare(kdwc->clk);

I hope the clock isn't shared between core and wrapper, otherwise you could run into some troubles here. Can you confirm ?

Yes. the clock isn't shared. Thanks for taking care of other parts.

Quoted 8 lines
Quoted 2 lines

so clock for core is always running too ?

I take that back. The clock is actually common so we should disable it after removing the kdwc3_remove_core() as you suggested.

You won't see issue since the kdwc3_remove_core() not doing any register access but moving the clock disable after the core remove is right thing to do.

the problem is not kdwc3_remove_core() accessing registers, but dwc3_remove() _does_ access registers during remove. If you just mopdrobe -r dwc3-keystone without removing dwc3.ko first, then kdwc3_remove_core() will cause dwc3.ko to be removed (because of platform_driver_unregister()) and, since clocks have already been disabled, then we'd die :-)

cheers

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/20131212/fe9d8c4c/attachment.sig>
#7 lore raw

PATCH v3 1/2 usb: dwc3: Add Keystone specific glue layer

Quoted 26 lines · Felipe Balbi
Quoted 16 lines · Santosh Shilimkar
Quoted 15 lines · Felipe Balbi

Hi,

Quoted 11 lines · Santosh Shilimkar
Quoted 10 lines

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

Quoted 6 lines
drivers/usb/dwc3/dwc3-keystone.c new file +6 -0
+static int kdwc3_remove(struct platform_device *pdev)
+{
+	struct dwc3_keystone *kdwc = platform_get_drvdata(pdev);
+
+	kdwc3_disable_irqs(kdwc);
+	clk_disable_unprepare(kdwc->clk);

I hope the clock isn't shared between core and wrapper, otherwise you could run into some troubles here. Can you confirm ?

Yes. the clock isn't shared. Thanks for taking care of other parts.

Quoted 8 lines
Quoted 2 lines

so clock for core is always running too ?

I take that back. The clock is actually common so we should disable it after removing the kdwc3_remove_core() as you suggested.

You won't see issue since the kdwc3_remove_core() not doing any register access but moving the clock disable after the core remove is right thing to do.

Quoted 7 lines

the problem is not kdwc3_remove_core() accessing registers, but dwc3_remove() _does_ access registers during remove. If you just mopdrobe -r dwc3-keystone without removing dwc3.ko first, then kdwc3_remove_core() will cause dwc3.ko to be removed (because of platform_driver_unregister()) and, since clocks have already been disabled, then we'd die :-)

Oh yes, you are right. I see Wingman already posted the updated patch.

Regards,
Santosh

#8 lore raw

PATCH v3 2/2 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 v3 2/2 usb: phy: Add keystone usb phy driver

Hi,

drivers/usb/phy/phy-keystone.c line 105

Quoted 5 lines · WingMan Kwok
drivers/usb/phy/phy-keystone.c new file +5 -0
+	ret = usb_add_phy_dev(&k_phy->usb_phy_gen.phy);
+	if (ret)
+		return ret;
+	k_phy->usb_phy_gen.phy.init = keystone_usbphy_init;
+	k_phy->usb_phy_gen.phy.shutdown = keystone_usbphy_shutdown;

this *must* be initialized before adding the PHY to the subsystem. So these two lines must be moved before usb_add_phy_dev().

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/20131209/ba92a459/attachment.sig>
#10 lore raw

PATCH v3 2/2 usb: phy: Add keystone usb phy driver

Quoted 12 lines · Felipe

Hi,

drivers/usb/phy/phy-keystone.c line 105

Quoted 5 lines · WingMan Kwok
drivers/usb/phy/phy-keystone.c new file +5 -0
+	ret = usb_add_phy_dev(&k_phy->usb_phy_gen.phy);
+	if (ret)
+		return ret;
+	k_phy->usb_phy_gen.phy.init = keystone_usbphy_init;
+	k_phy->usb_phy_gen.phy.shutdown = keystone_usbphy_shutdown;

this *must* be initialized before adding the PHY to the subsystem. So these two lines must be moved before usb_add_phy_dev().

Make sense. Probably its good idea to repost the $subject patch with above as well as other delay related comment.

Regards,
Santosh

#11 lore raw

PATCH v3 2/2 usb: phy: Add keystone usb phy driver

Quoted 21 lines

-----Original Message-----
From: Shilimkar, Santosh
Sent: Tuesday, December 10, 2013 10:15 AM
To: Balbi, Felipe
Cc: Kwok, WingMan; linux-usb at vger.kernel.org; linux-arm- kernel at lists.infradead.org; Greg Kroah-Hartman
Subject: Re: [PATCH v3 2/2] usb: phy: Add keystone usb phy driver

Quoted 12 lines · Felipe

Hi,

drivers/usb/phy/phy-keystone.c line 105

Quoted 5 lines · WingMan Kwok
drivers/usb/phy/phy-keystone.c new file +5 -0
+	ret = usb_add_phy_dev(&k_phy->usb_phy_gen.phy);
+	if (ret)
+		return ret;
+	k_phy->usb_phy_gen.phy.init = keystone_usbphy_init;
+	k_phy->usb_phy_gen.phy.shutdown = keystone_usbphy_shutdown;

this *must* be initialized before adding the PHY to the subsystem. So these two lines must be moved before usb_add_phy_dev().

Quoted 2 lines

Make sense. Probably its good idea to repost the $subject patch with above as well as other delay related comment.

Thanks. I have updated my patch accordingly. Please note that the same issue exists on drivers/usb/phy/phy-am335x.c also. If you want, I can send a fix for that.

Regards
WingMan

#12 lore raw

PATCH v3 2/2 usb: phy: Add keystone usb phy driver

Quoted 21 lines · WingMan
Quoted 21 lines

-----Original Message-----
From: Shilimkar, Santosh
Sent: Tuesday, December 10, 2013 10:15 AM
To: Balbi, Felipe
Cc: Kwok, WingMan; linux-usb at vger.kernel.org; linux-arm- kernel at lists.infradead.org; Greg Kroah-Hartman
Subject: Re: [PATCH v3 2/2] usb: phy: Add keystone usb phy driver

Quoted 12 lines · Felipe

Hi,

drivers/usb/phy/phy-keystone.c line 105

Quoted 5 lines · WingMan Kwok
drivers/usb/phy/phy-keystone.c new file +5 -0
+	ret = usb_add_phy_dev(&k_phy->usb_phy_gen.phy);
+	if (ret)
+		return ret;
+	k_phy->usb_phy_gen.phy.init = keystone_usbphy_init;
+	k_phy->usb_phy_gen.phy.shutdown = keystone_usbphy_shutdown;

this *must* be initialized before adding the PHY to the subsystem. So these two lines must be moved before usb_add_phy_dev().

Quoted 5 lines
Quoted 2 lines

Make sense. Probably its good idea to repost the $subject patch with above as well as other delay related comment.

Thanks. I have updated my patch accordingly. Please note that the same issue exists on drivers/usb/phy/phy-am335x.c also. If you want, I can send a fix for that.

Will do, thanks for notifying me :-)

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/20131212/99d347fa/attachment.sig>
#13 lore raw

PATCH v3 2/2 usb: phy: Add keystone usb phy driver

In reply to WingMan Kwok
Quoted 21 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]>
---
 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 +0 -0
index 08e2f39..c6792f43 100644

drivers/usb/phy/Kconfig config ISP1301_OMAP · line 46

Quoted 7 lines
drivers/usb/phy/Kconfig +4 -0
@@ -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

NOP_USB_XCEIV selects USB_PHY so not necessary.

Quoted 14 lines
drivers/usb/phy/Kconfig +6 -0
+	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 +0 -0
index 022c1da..311b47b 100644

drivers/usb/phy/Makefile obj-$(CONFIG_USB_RCAR_PHY) += phy-rcar-usb.o · line 33

Quoted 4 lines
drivers/usb/phy/Makefile +1 -0
@@ -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

cheers,
-roger

#14 lore raw

PATCH v3 2/2 usb: phy: Add keystone usb phy driver

Quoted 36 lines

-----Original Message-----
From: Quadros, Roger
Sent: Monday, December 09, 2013 10:09 PM
To: Kwok, WingMan; linux-usb at vger.kernel.org
Cc: linux-arm-kernel at lists.infradead.org; Shilimkar, Santosh; Balbi, Felipe; Greg Kroah-Hartman
Subject: Re: [PATCH v3 2/2] usb: phy: Add keystone usb phy driver

Quoted 25 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]>
---
 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 index renamed from drivers/usb/phy/Kconfig +0 -0

08e2f39..c6792f43 100644

drivers/usb/phy/Kconfig +0 -0
@@ -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.
 
Quoted 7 lines

drivers/usb/phy/Kconfig config ISP1301_OMAP · line 46

Quoted 4 lines
drivers/usb/phy/Kconfig +4 -0
+config KEYSTONE_USB_PHY
+	tristate "Keystone USB PHY Driver"
+	depends on ARCH_KEYSTONE
+	select USB_PHY

NOP_USB_XCEIV selects USB_PHY so not necessary.

Yes I have fixed it and updated patch which I'll post. " config AM335X_PHY_USB" needs to be fixed as well.

Regards
WingMan

#15 lore raw

PATCH v3 2/2 usb: phy: Add keystone usb phy driver

In reply to WingMan Kwok

Hi again,

drivers/usb/phy/phy-keystone.c line 60

Quoted 8 lines · WingMan Kwok
drivers/usb/phy/phy-keystone.c new file +8 -0
+static int keystone_usbphy_init(struct usb_phy *phy)
+{
+	struct keystone_usbphy *k_phy = dev_get_drvdata(phy->dev);
+	u32 val;
+
+	val  = keystone_usbphy_readl(k_phy->phy_ctrl, USB_PHY_CTL_CLOCK);
+	keystone_usbphy_writel(k_phy->phy_ctrl, USB_PHY_CTL_CLOCK,
+				val | PHY_REF_SSP_EN);

you need to enable this device's clock to access its registers right ?

drivers/usb/phy/phy-keystone.c line 61

Quoted 1 line
drivers/usb/phy/phy-keystone.c new file +1 -0
+	udelay(20);

why the magic 20 usecs ? Where does that come from ? Empirically found or is there a documentation reference ? At least add a comment there.

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/20131209/7850247a/attachment-0001.sig>
#16 lore raw

PATCH v3 2/2 usb: phy: Add keystone usb phy driver

Quoted 14 lines · Felipe Balbi

Hi again,

drivers/usb/phy/phy-keystone.c line 60

Quoted 8 lines · WingMan Kwok
drivers/usb/phy/phy-keystone.c new file +8 -0
+static int keystone_usbphy_init(struct usb_phy *phy)
+{
+	struct keystone_usbphy *k_phy = dev_get_drvdata(phy->dev);
+	u32 val;
+
+	val  = keystone_usbphy_readl(k_phy->phy_ctrl, USB_PHY_CTL_CLOCK);
+	keystone_usbphy_writel(k_phy->phy_ctrl, USB_PHY_CTL_CLOCK,
+				val | PHY_REF_SSP_EN);

you need to enable this device's clock to access its registers right ?

Nope.. This clock is always running for CFG block where the phy control is residing.

Quoted 5 lines

drivers/usb/phy/phy-keystone.c line 61

Quoted 1 line
drivers/usb/phy/phy-keystone.c new file +1 -0
+	udelay(20);

why the magic 20 usecs ? Where does that come from ? Empirically found or is there a documentation reference ? At least add a comment there.

Above probably isn't needed either but good to check why was this added. In refreshed patch, this can be either removed or a comment can be added accordingly.

Thanks for spotting that.

Regards,
Santosh