Skip to contentSkip to conversation

da8xx USB PHY platform devices and clocks

PATCH Superseded David Lechner 5 participants 13 messages Sep 5, 2016 – Oct 4, 2016

Subsystems (3)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v6 cover da8xx USB PHY platform devices and clocks

Just resending to get these merged into usb. The phy parts of this patch series have already been merged into Linus' tree.

I have rebased on 4.8-rc5 but there have not been any changes to these since the last time I submitted.

David Lechner (3):
usb: ohci-da8xx: Remove code that references mach
usb: musb: da8xx: Use devm in probe
usb: musb: da8xx: Remove mach code

 drivers/usb/host/Kconfig      |   1 +
 drivers/usb/host/ohci-da8xx.c | 102 +++++++++++++++-------------
 drivers/usb/musb/Kconfig      |   2 +-
 drivers/usb/musb/da8xx.c      | 154 +++++++++++++++---------------------------
 4 files changed, 112 insertions(+), 147 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v6 1/3 usb: ohci-da8xx: Remove code that references mach

Including mach/* is frowned upon in device drivers, so get rid of it.

This replaces usb20_clk and code that pokes CFGCHIP2 with a proper phy driver.

---
 drivers/usb/host/Kconfig      |   1 +
 drivers/usb/host/ohci-da8xx.c | 102 +++++++++++++++++++++++-------------------
 2 files changed, 56 insertions(+), 47 deletions(-)
drivers/usb/host/Kconfig +1 -0
index 2e710a4..1f0cdab8 100644
@@ -482,6 +482,7 @@ config USB_OHCI_HCD_DAVINCI
 	bool "OHCI support for TI DaVinci DA8xx"
 	depends on ARCH_DAVINCI_DA8XX
 	depends on USB_OHCI_HCD=y
+	select PHY_DA8XX_USB
 	default y
 	help
 	  Enables support for the DaVinci DA8xx integrated OHCI
drivers/usb/host/ohci-da8xx.c +55 -47

174 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach

Hi Greg,

Quoted 7 lines · David Lechner

Including mach/* is frowned upon in device drivers, so get rid of it.

This replaces usb20_clk and code that pokes CFGCHIP2 with a proper phy driver.

Can you pick up this patch?

Patches 2 & 3 from this series were picked up by Bin for musb, but this one is still outstanding.

Thanks,

Kevin

Quoted 206 lines
---
 drivers/usb/host/Kconfig      |   1 +
 drivers/usb/host/ohci-da8xx.c | 102 +++++++++++++++++++++++-------------------
 2 files changed, 56 insertions(+), 47 deletions(-)
drivers/usb/host/Kconfig +1 -0
index 2e710a4..1f0cdab8 100644
@@ -482,6 +482,7 @@ config USB_OHCI_HCD_DAVINCI
        bool "OHCI support for TI DaVinci DA8xx"
        depends on ARCH_DAVINCI_DA8XX
        depends on USB_OHCI_HCD=y
+       select PHY_DA8XX_USB
        default y
        help
          Enables support for the DaVinci DA8xx integrated OHCI
drivers/usb/host/ohci-da8xx.c +55 -48
index e5c33bc..3656d7c 100644
@@ -15,58 +15,50 @@
 #include <linux/jiffies.h>
 #include <linux/platform_device.h>
 #include <linux/clk.h>
-
-#include <mach/da8xx.h>
+#include <linux/phy/phy.h>
 #include <linux/platform_data/usb-davinci.h>
 
 #ifndef CONFIG_ARCH_DAVINCI_DA8XX
 #error "This file is DA8xx bus glue.  Define CONFIG_ARCH_DAVINCI_DA8XX."
 #endif
 
-#define CFGCHIP2       DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)
-
 static struct clk *usb11_clk;
-static struct clk *usb20_clk;
+static struct phy *usb11_phy;
 
 /* Over-current indicator change bitmask */
 static volatile u16 ocic_mask;
 
-static void ohci_da8xx_clock(int on)
+static int ohci_da8xx_enable(void)
 {
-       u32 cfgchip2;
-
-       cfgchip2 = __raw_readl(CFGCHIP2);
-       if (on) {
-               clk_enable(usb11_clk);
-
-               /*
-                * If USB 1.1 reference clock is sourced from USB 2.0 PHY, we
-                * need to enable the USB 2.0 module clocking, start its PHY,
-                * and not allow it to stop the clock during USB 2.0 suspend.
-                */
-               if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX)) {
-                       clk_enable(usb20_clk);
-
-                       cfgchip2 &= ~(CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN);
-                       cfgchip2 |= CFGCHIP2_PHY_PLLON;
-                       __raw_writel(cfgchip2, CFGCHIP2);
-
-                       pr_info("Waiting for USB PHY clock good...\n");
-                       while (!(__raw_readl(CFGCHIP2) & CFGCHIP2_PHYCLKGD))
-                               cpu_relax();
-               }
+       int ret;
 
-               /* Enable USB 1.1 PHY */
-               cfgchip2 |= CFGCHIP2_USB1SUSPENDM;
-       } else {
-               clk_disable(usb11_clk);
-               if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX))
-                       clk_disable(usb20_clk);
+       ret = clk_prepare_enable(usb11_clk);
+       if (ret)
+               return ret;
 
-               /* Disable USB 1.1 PHY */
-               cfgchip2 &= ~CFGCHIP2_USB1SUSPENDM;
-       }
-       __raw_writel(cfgchip2, CFGCHIP2);
+       ret = phy_init(usb11_phy);
+       if (ret)
+               goto err_phy_init;
+
+       ret = phy_power_on(usb11_phy);
+       if (ret)
+               goto err_phy_power_on;
+
+       return 0;
+
+err_phy_power_on:
+       phy_exit(usb11_phy);
+err_phy_init:
+       clk_disable_unprepare(usb11_clk);
+
+       return ret;
+}
+
+static void ohci_da8xx_disable(void)
+{
+       phy_power_off(usb11_phy);
+       phy_exit(usb11_phy);
+       clk_disable_unprepare(usb11_clk);
 }
 
 /*
@@ -92,7 +84,9 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
 
        dev_dbg(dev, "starting USB controller\n");
 
-       ohci_da8xx_clock(1);
+       result = ohci_da8xx_enable();
+       if (result < 0)
+               return result;
 
        /*
         * DA8xx only have 1 port connected to the pins but the HC root hub
@@ -101,8 +95,10 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
        ohci->num_ports = 1;
 
        result = ohci_init(ohci);
-       if (result < 0)
+       if (result < 0) {
+               ohci_da8xx_disable();
                return result;
+       }
 
        /*
         * Since we're providing a board-specific root hub port power control
@@ -129,7 +125,7 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
 static void ohci_da8xx_stop(struct usb_hcd *hcd)
 {
        ohci_stop(hcd);
-       ohci_da8xx_clock(0);
+       ohci_da8xx_disable();
 }
 
 static int ohci_da8xx_start(struct usb_hcd *hcd)
@@ -301,12 +297,18 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver,
                return -ENODEV;
 
        usb11_clk = devm_clk_get(&pdev->dev, "usb11");
-       if (IS_ERR(usb11_clk))
+       if (IS_ERR(usb11_clk)) {
+               if (PTR_ERR(usb11_clk) != -EPROBE_DEFER)
+                       dev_err(&pdev->dev, "Failed to get clock.\n");
                return PTR_ERR(usb11_clk);
+       }
 
-       usb20_clk = devm_clk_get(&pdev->dev, "usb20");
-       if (IS_ERR(usb20_clk))
-               return PTR_ERR(usb20_clk);
+       usb11_phy = devm_phy_get(&pdev->dev, "usb-phy");
+       if (IS_ERR(usb11_phy)) {
+               if (PTR_ERR(usb11_phy) != -EPROBE_DEFER)
+                       dev_err(&pdev->dev, "Failed to get phy.\n");
+               return PTR_ERR(usb11_phy);
+       }
 
        hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
        if (!hcd)
@@ -316,6 +318,7 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver,
        hcd->regs = devm_ioremap_resource(&pdev->dev, mem);
        if (IS_ERR(hcd->regs)) {
                error = PTR_ERR(hcd->regs);
+               dev_err(&pdev->dev, "failed to map ohci.\n");
                goto err;
        }
        hcd->rsrc_start = mem->start;
@@ -397,7 +400,7 @@ static int ohci_da8xx_suspend(struct platform_device *pdev,
        if (ret)
                return ret;
 
-       ohci_da8xx_clock(0);
+       ohci_da8xx_disable();
        hcd->state = HC_STATE_SUSPENDED;
 
        return ret;
@@ -407,14 +410,19 @@ static int ohci_da8xx_resume(struct platform_device *dev)
 {
        struct usb_hcd  *hcd    = platform_get_drvdata(dev);
        struct ohci_hcd *ohci   = hcd_to_ohci(hcd);
+       int ret;
 
        if (time_before(jiffies, ohci->next_statechange))
                msleep(5);
        ohci->next_statechange = jiffies;
 
-       ohci_da8xx_clock(1);
+       ret = ohci_da8xx_enable();
+       if (ret)
+               return ret;
+
        dev->dev.power.power_state = PMSG_ON;
        usb_hcd_resume_root_hub(hcd);
+
        return 0;
 }
 #endif
--

2.7.4

#3 lore raw

Re: [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach

Quoted 8 lines · Kevin Hilman

Hi Greg,

Quoted 5 lines · David Lechner

Including mach/* is frowned upon in device drivers, so get rid of it.

This replaces usb20_clk and code that pokes CFGCHIP2 with a proper phy driver.

Quoted 7 lines
Quoted 2 lines

Can you pick up this patch?

Patches 2 & 3 from this series were picked up by Bin for musb, but this one is still outstanding.

It's not in my todo queue from what I can tell, so it would have to be resent and I can pick it up after 4.9-rc1 is out.

thanks,

greg k-h

#4 lore raw

Re: [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach

Quoted 17 lines · Greg Kroah-Hartman
Quoted 8 lines · Kevin Hilman

Hi Greg,

Quoted 5 lines · David Lechner

Including mach/* is frowned upon in device drivers, so get rid of it.

This replaces usb20_clk and code that pokes CFGCHIP2 with a proper phy driver.

Quoted 7 lines
Quoted 2 lines

Can you pick up this patch?

Patches 2 & 3 from this series were picked up by Bin for musb, but this one is still outstanding.

Quoted 7 lines

It's not in my todo queue from what I can tell, so it would have to be resent and I can pick it up after 4.9-rc1 is out.

thanks,

greg k-h

Are there any magic email headers needed to make sure you don't miss it or will

Subject: [RESEND PATCH v6 1/3]...
To: gregkh@...

do the trick?

#5 lore raw

Re: [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach

Quoted 26 lines · David Lechner
Quoted 17 lines · Greg Kroah-Hartman
Quoted 8 lines · Kevin Hilman

Hi Greg,

Quoted 5 lines · David Lechner

Including mach/* is frowned upon in device drivers, so get rid of it.

This replaces usb20_clk and code that pokes CFGCHIP2 with a proper phy driver.

Quoted 7 lines
Quoted 2 lines

Can you pick up this patch?

Patches 2 & 3 from this series were picked up by Bin for musb, but this one is still outstanding.

Quoted 7 lines

It's not in my todo queue from what I can tell, so it would have to be resent and I can pick it up after 4.9-rc1 is out.

thanks,

greg k-h

Quoted 7 lines

Are there any magic email headers needed to make sure you don't miss it or will

Subject: [RESEND PATCH v6 1/3]...
To: gregkh@...

do the trick?

As you don't want me to take patches 2 and 3, and you will not be sending them, just resend it as a stand-alone patch.

thanks,

greg k-h

#6 lore raw

PATCH v6 2/3 usb: musb: da8xx: Use devm in probe

In reply to David Lechner

Simplify things a bit by using devm functions where possible.

---
 drivers/usb/musb/da8xx.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/usb/musb/da8xx.c +5 -14
index b03d3b8..0c1997c 100644
@@ -490,20 +490,18 @@ static int da8xx_probe(struct platform_device *pdev)
 	struct da8xx_glue		*glue;
 	struct platform_device_info	pinfo;
 	struct clk			*clk;
+	int				ret;
 
-	int				ret = -ENOMEM;
-
-	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
 	if (!glue) {
 		dev_err(&pdev->dev, "failed to allocate glue context\n");
-		goto err0;
+		return -ENOMEM;
 	}
 
-	clk = clk_get(&pdev->dev, "usb20");
+	clk = devm_clk_get(&pdev->dev, "usb20");
 	if (IS_ERR(clk)) {
 		dev_err(&pdev->dev, "failed to get clock\n");
-		ret = PTR_ERR(clk);
-		goto err3;
+		return PTR_ERR(clk);
 	}
 
 	ret = clk_enable(clk);
@@ -560,12 +558,7 @@ err5:
 	clk_disable(clk);
 
 err4:
-	clk_put(clk);
-
-err3:
-	kfree(glue);
 
-err0:
 	return ret;
 }
 
@@ -576,8 +569,6 @@ static int da8xx_remove(struct platform_device *pdev)
 	platform_device_unregister(glue->musb);
 	usb_phy_generic_unregister(glue->phy);
 	clk_disable(glue->clk);
-	clk_put(glue->clk);
-	kfree(glue);
 
 	return 0;
 }
Signature · 1 line
2.7.4
maintainer
#7 lore raw

Re: [PATCH v6 2/3] usb: musb: da8xx: Use devm in probe

Hi,

Quoted 13 lines · David Lechner

Simplify things a bit by using devm functions where possible.

---
 drivers/usb/musb/da8xx.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/usb/musb/da8xx.c +0 -0
index b03d3b8..0c1997c 100644
@@ -490,20 +490,18 @@ static int da8xx_probe(struct platform_device *pdev)
 	struct da8xx_glue		*glue;

drivers/usb/musb/da8xx.c static int da8xx_probe(struct platform_device *pdev) · line 497

Quoted 10 lines
drivers/usb/musb/da8xx.c +2 -3
 	struct platform_device_info	pinfo;
 	struct clk			*clk;
+	int				ret;
 
-	int				ret = -ENOMEM;
-
-	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
 	if (!glue) {
 		dev_err(&pdev->dev, "failed to allocate glue context\n");

Greg's usb-next already has a patch which drops this line. You might have to rebase this patch, so that it can go to v4.9-rc1.

Thanks,
-Bin.

maintainer
#8 lore raw

Re: [PATCH v6 2/3] usb: musb: da8xx: Use devm in probe

Hi,

Quoted 20 lines · Bin Liu

Hi,

Quoted 17 lines · David Lechner

Simplify things a bit by using devm functions where possible.

---
 drivers/usb/musb/da8xx.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/usb/musb/da8xx.c +1 -0
index b03d3b8..0c1997c 100644
@@ -490,20 +490,18 @@ static int da8xx_probe(struct platform_device *pdev)
 	struct da8xx_glue		*glue;
 	struct platform_device_info	pinfo;
 	struct clk			*clk;
+	int				ret;
 
Quoted 9 lines

drivers/usb/musb/da8xx.c static int da8xx_probe(struct platform_device *pdev) · line 497

Quoted 6 lines
drivers/usb/musb/da8xx.c +1 -3
-	int				ret = -ENOMEM;
-
-	glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+	glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL);
 	if (!glue) {
 		dev_err(&pdev->dev, "failed to allocate glue context\n");

Greg's usb-next already has a patch which drops this line. You might have to rebase this patch, so that it can go to v4.9-rc1.

I fixed the merge conflict locally.

Regards,
-Bin.

#9 lore raw

PATCH v6 3/3 usb: musb: da8xx: Remove mach code

In reply to David Lechner

Use the new phy-da8xx-usb driver to take the place of the mach code that pokes CFGCHIP2 in the da8xx musb glue driver. This unbreaks the driver.

---
 drivers/usb/musb/Kconfig |   2 +-
 drivers/usb/musb/da8xx.c | 135 ++++++++++++++++++-----------------------------
 2 files changed, 51 insertions(+), 86 deletions(-)
drivers/usb/musb/Kconfig +1 -1
index 886526b..c73221a 100644
@@ -82,7 +82,7 @@ config USB_MUSB_DA8XX
 	tristate "DA8xx/OMAP-L1x"
 	depends on ARCH_DAVINCI_DA8XX
 	depends on NOP_USB_XCEIV
-	depends on BROKEN
+	select PHY_DA8XX_USB
 
 config USB_MUSB_TUSB6010
 	tristate "TUSB6010"
drivers/usb/musb/da8xx.c +50 -85

235 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#10 lore raw
In reply to David Lechner

Hi Greg and Alan,

Quoted 10 lines · David Lechner

Just resending to get these merged into usb. The phy parts of this patch series have already been merged into Linus' tree.

I have rebased on 4.8-rc5 but there have not been any changes to these since the last time I submitted.

David Lechner (3):
usb: ohci-da8xx: Remove code that references mach
usb: musb: da8xx: Use devm in probe
usb: musb: da8xx: Remove mach code

How do we take care this kinda patch sets, which touch multiple modules? I take the two for musb or just acked-by them?

Thanks,
-Bin.

maintainer
#11 lore raw

Hi,

Quoted 9 lines · Bin Liu

Hi Greg and Alan,

Quoted 6 lines · David Lechner

Just resending to get these merged into usb. The phy parts of this patch series have already been merged into Linus' tree.

I have rebased on 4.8-rc5 but there have not been any changes to these since the last time I submitted.

Quoted 7 lines
Quoted 4 lines

David Lechner (3):
usb: ohci-da8xx: Remove code that references mach
usb: musb: da8xx: Use devm in probe
usb: musb: da8xx: Remove mach code

How do we take care this kinda patch sets, which touch multiple modules? I take the two for musb or just acked-by them?

I am taking patch 2/3 & 3/3 for musb.

Regards,
-Bin.

#12 lore raw
Quoted 15 lines · Bin Liu
Quoted 14 lines · Bin Liu

Hi Greg and Alan,

Quoted 10 lines · David Lechner

Just resending to get these merged into usb. The phy parts of this patch series have already been merged into Linus' tree.

I have rebased on 4.8-rc5 but there have not been any changes to these since the last time I submitted.

David Lechner (3):
usb: ohci-da8xx: Remove code that references mach
usb: musb: da8xx: Use devm in probe
usb: musb: da8xx: Remove mach code

Quoted 4 lines
Quoted 2 lines

How do we take care this kinda patch sets, which touch multiple modules? I take the two for musb or just acked-by them?

I am taking patch 2/3 & 3/3 for musb.

Greg, can you pick up PATCH 1/3? It's already been ack'd by Alan.

Thanks,

Kevin