* [PATCH v6 0/3] da8xx USB PHY platform devices and clocks
@ 2016-09-05 20:00 David Lechner
2016-09-05 20:00 ` [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach David Lechner
` (3 more replies)
0 siblings, 4 replies; 13+ messages in thread
From: David Lechner @ 2016-09-05 20:00 UTC (permalink / raw)
To: Alan Stern, Bin Liu
Cc: David Lechner, Greg Kroah-Hartman, linux-usb, linux-kernel,
khilman, nsekhar, Kishon Vijay Abraham I, Sergei Shtylyov
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(-)
--
2.7.4
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach
2016-09-05 20:00 [PATCH v6 0/3] da8xx USB PHY platform devices and clocks David Lechner
@ 2016-09-05 20:00 ` David Lechner
2016-10-04 9:18 ` Kevin Hilman
2016-09-05 20:00 ` [PATCH v6 2/3] usb: musb: da8xx: Use devm in probe David Lechner
` (2 subsequent siblings)
3 siblings, 1 reply; 13+ messages in thread
From: David Lechner @ 2016-09-05 20:00 UTC (permalink / raw)
To: Alan Stern, Bin Liu
Cc: David Lechner, Greg Kroah-Hartman, linux-usb, linux-kernel,
khilman, nsekhar, Kishon Vijay Abraham I, Sergei Shtylyov
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.
Signed-off-by: David Lechner <david@lechnology.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
---
drivers/usb/host/Kconfig | 1 +
drivers/usb/host/ohci-da8xx.c | 102 +++++++++++++++++++++++-------------------
2 files changed, 56 insertions(+), 47 deletions(-)
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index 2e710a4..1f0cdab8 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -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
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
index e5c33bc..3656d7c 100644
--- a/drivers/usb/host/ohci-da8xx.c
+++ b/drivers/usb/host/ohci-da8xx.c
@@ -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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v6 2/3] usb: musb: da8xx: Use devm in probe
2016-09-05 20:00 [PATCH v6 0/3] da8xx USB PHY platform devices and clocks David Lechner
2016-09-05 20:00 ` [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach David Lechner
@ 2016-09-05 20:00 ` David Lechner
2016-09-06 19:17 ` Bin Liu
2016-09-05 20:00 ` [PATCH v6 3/3] usb: musb: da8xx: Remove mach code David Lechner
2016-09-06 19:19 ` [PATCH v6 0/3] da8xx USB PHY platform devices and clocks Bin Liu
3 siblings, 1 reply; 13+ messages in thread
From: David Lechner @ 2016-09-05 20:00 UTC (permalink / raw)
To: Alan Stern, Bin Liu
Cc: David Lechner, Greg Kroah-Hartman, linux-usb, linux-kernel,
khilman, nsekhar, Kishon Vijay Abraham I, Sergei Shtylyov
Simplify things a bit by using devm functions where possible.
Signed-off-by: David Lechner <david@lechnology.com>
---
drivers/usb/musb/da8xx.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index b03d3b8..0c1997c 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -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;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v6 3/3] usb: musb: da8xx: Remove mach code
2016-09-05 20:00 [PATCH v6 0/3] da8xx USB PHY platform devices and clocks David Lechner
2016-09-05 20:00 ` [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach David Lechner
2016-09-05 20:00 ` [PATCH v6 2/3] usb: musb: da8xx: Use devm in probe David Lechner
@ 2016-09-05 20:00 ` David Lechner
2016-09-06 19:19 ` [PATCH v6 0/3] da8xx USB PHY platform devices and clocks Bin Liu
3 siblings, 0 replies; 13+ messages in thread
From: David Lechner @ 2016-09-05 20:00 UTC (permalink / raw)
To: Alan Stern, Bin Liu
Cc: David Lechner, Greg Kroah-Hartman, linux-usb, linux-kernel,
khilman, nsekhar, Kishon Vijay Abraham I, Sergei Shtylyov
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.
Signed-off-by: David Lechner <david@lechnology.com>
---
drivers/usb/musb/Kconfig | 2 +-
drivers/usb/musb/da8xx.c | 135 ++++++++++++++++++-----------------------------
2 files changed, 51 insertions(+), 86 deletions(-)
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 886526b..c73221a 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -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"
diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
index 0c1997c..6af8c3d 100644
--- a/drivers/usb/musb/da8xx.c
+++ b/drivers/usb/musb/da8xx.c
@@ -30,13 +30,11 @@
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/io.h>
+#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
#include <linux/usb/usb_phy_generic.h>
-#include <mach/da8xx.h>
-#include <linux/platform_data/usb-davinci.h>
-
#include "musb_core.h"
/*
@@ -80,61 +78,15 @@
#define DA8XX_MENTOR_CORE_OFFSET 0x400
-#define CFGCHIP2 IO_ADDRESS(DA8XX_SYSCFG0_BASE + DA8XX_CFGCHIP2_REG)
-
struct da8xx_glue {
struct device *dev;
struct platform_device *musb;
- struct platform_device *phy;
+ struct platform_device *usb_phy;
struct clk *clk;
+ struct phy *phy;
};
/*
- * REVISIT (PM): we should be able to keep the PHY in low power mode most
- * of the time (24 MHz oscillator and PLL off, etc.) by setting POWER.D0
- * and, when in host mode, autosuspending idle root ports... PHY_PLLON
- * (overriding SUSPENDM?) then likely needs to stay off.
- */
-
-static inline void phy_on(void)
-{
- u32 cfgchip2 = __raw_readl(CFGCHIP2);
-
- /*
- * Start the on-chip PHY and its PLL.
- */
- cfgchip2 &= ~(CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN);
- 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();
-}
-
-static inline void phy_off(void)
-{
- u32 cfgchip2 = __raw_readl(CFGCHIP2);
-
- /*
- * Ensure that USB 1.1 reference clock is not being sourced from
- * USB 2.0 PHY. Otherwise do not power down the PHY.
- */
- if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX) &&
- (cfgchip2 & CFGCHIP2_USB1SUSPENDM)) {
- pr_warning("USB 1.1 clocked from USB 2.0 PHY -- "
- "can't power it down\n");
- return;
- }
-
- /*
- * Power down the on-chip PHY.
- */
- cfgchip2 |= CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN;
- __raw_writel(cfgchip2, CFGCHIP2);
-}
-
-/*
* Because we don't set CTRL.UINT, it's "important" to:
* - not read/write INTRUSB/INTRUSBE (except during
* initial setup, as a workaround);
@@ -385,29 +337,29 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci)
static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode)
{
- u32 cfgchip2 = __raw_readl(CFGCHIP2);
+ struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent);
+ enum phy_mode phy_mode;
- cfgchip2 &= ~CFGCHIP2_OTGMODE;
switch (musb_mode) {
case MUSB_HOST: /* Force VBUS valid, ID = 0 */
- cfgchip2 |= CFGCHIP2_FORCE_HOST;
+ phy_mode = PHY_MODE_USB_HOST;
break;
case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */
- cfgchip2 |= CFGCHIP2_FORCE_DEVICE;
+ phy_mode = PHY_MODE_USB_DEVICE;
break;
case MUSB_OTG: /* Don't override the VBUS/ID comparators */
- cfgchip2 |= CFGCHIP2_NO_OVERRIDE;
+ phy_mode = PHY_MODE_USB_OTG;
break;
default:
- dev_dbg(musb->controller, "Trying to set unsupported mode %u\n", musb_mode);
+ return -EINVAL;
}
- __raw_writel(cfgchip2, CFGCHIP2);
- return 0;
+ return phy_set_mode(glue->phy, phy_mode);
}
static int da8xx_musb_init(struct musb *musb)
{
+ struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent);
void __iomem *reg_base = musb->ctrl_base;
u32 rev;
int ret = -ENODEV;
@@ -425,32 +377,56 @@ static int da8xx_musb_init(struct musb *musb)
goto fail;
}
+ ret = clk_prepare_enable(glue->clk);
+ if (ret) {
+ dev_err(glue->dev, "failed to enable clock\n");
+ goto fail;
+ }
+
setup_timer(&otg_workaround, otg_timer, (unsigned long)musb);
/* Reset the controller */
musb_writel(reg_base, DA8XX_USB_CTRL_REG, DA8XX_SOFT_RESET_MASK);
/* Start the on-chip PHY and its PLL. */
- phy_on();
+ ret = phy_init(glue->phy);
+ if (ret) {
+ dev_err(glue->dev, "Failed to init phy.\n");
+ goto err_phy_init;
+ }
+
+ ret = phy_power_on(glue->phy);
+ if (ret) {
+ dev_err(glue->dev, "Failed to power on phy.\n");
+ goto err_phy_power_on;
+ }
msleep(5);
/* NOTE: IRQs are in mixed mode, not bypass to pure MUSB */
- pr_debug("DA8xx OTG revision %08x, PHY %03x, control %02x\n",
- rev, __raw_readl(CFGCHIP2),
+ pr_debug("DA8xx OTG revision %08x, control %02x\n", rev,
musb_readb(reg_base, DA8XX_USB_CTRL_REG));
musb->isr = da8xx_musb_interrupt;
return 0;
+
+err_phy_power_on:
+ phy_exit(glue->phy);
+err_phy_init:
+ clk_disable_unprepare(glue->clk);
fail:
return ret;
}
static int da8xx_musb_exit(struct musb *musb)
{
+ struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent);
+
del_timer_sync(&otg_workaround);
- phy_off();
+ phy_power_off(glue->phy);
+ phy_exit(glue->phy);
+ clk_disable_unprepare(glue->clk);
usb_put_phy(musb->xceiv);
@@ -504,10 +480,10 @@ static int da8xx_probe(struct platform_device *pdev)
return PTR_ERR(clk);
}
- ret = clk_enable(clk);
- if (ret) {
- dev_err(&pdev->dev, "failed to enable clock\n");
- goto err4;
+ glue->phy = devm_phy_get(&pdev->dev, "usb-phy");
+ if (IS_ERR(glue->phy)) {
+ dev_err(&pdev->dev, "failed to get phy\n");
+ return PTR_ERR(glue->phy);
}
glue->dev = &pdev->dev;
@@ -515,10 +491,10 @@ static int da8xx_probe(struct platform_device *pdev)
pdata->platform_ops = &da8xx_ops;
- glue->phy = usb_phy_generic_register();
- if (IS_ERR(glue->phy)) {
- ret = PTR_ERR(glue->phy);
- goto err5;
+ glue->usb_phy = usb_phy_generic_register();
+ if (IS_ERR(glue->usb_phy)) {
+ dev_err(&pdev->dev, "failed to register usb_phy\n");
+ return PTR_ERR(glue->usb_phy);
}
platform_set_drvdata(pdev, glue);
@@ -544,22 +520,12 @@ static int da8xx_probe(struct platform_device *pdev)
glue->musb = musb = platform_device_register_full(&pinfo);
if (IS_ERR(musb)) {
- ret = PTR_ERR(musb);
dev_err(&pdev->dev, "failed to register musb device: %d\n", ret);
- goto err6;
+ usb_phy_generic_unregister(glue->usb_phy);
+ return PTR_ERR(musb);
}
return 0;
-
-err6:
- usb_phy_generic_unregister(glue->phy);
-
-err5:
- clk_disable(clk);
-
-err4:
-
- return ret;
}
static int da8xx_remove(struct platform_device *pdev)
@@ -567,8 +533,7 @@ static int da8xx_remove(struct platform_device *pdev)
struct da8xx_glue *glue = platform_get_drvdata(pdev);
platform_device_unregister(glue->musb);
- usb_phy_generic_unregister(glue->phy);
- clk_disable(glue->clk);
+ usb_phy_generic_unregister(glue->usb_phy);
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v6 2/3] usb: musb: da8xx: Use devm in probe
2016-09-05 20:00 ` [PATCH v6 2/3] usb: musb: da8xx: Use devm in probe David Lechner
@ 2016-09-06 19:17 ` Bin Liu
2016-09-12 17:19 ` Bin Liu
0 siblings, 1 reply; 13+ messages in thread
From: Bin Liu @ 2016-09-06 19:17 UTC (permalink / raw)
To: David Lechner
Cc: Alan Stern, Greg Kroah-Hartman, linux-usb, linux-kernel, khilman,
nsekhar, Kishon Vijay Abraham I, Sergei Shtylyov
Hi,
On Mon, Sep 05, 2016 at 03:00:32PM -0500, David Lechner wrote:
> Simplify things a bit by using devm functions where possible.
>
> Signed-off-by: David Lechner <david@lechnology.com>
> ---
> drivers/usb/musb/da8xx.c | 19 +++++--------------
> 1 file changed, 5 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
> index b03d3b8..0c1997c 100644
> --- a/drivers/usb/musb/da8xx.c
> +++ b/drivers/usb/musb/da8xx.c
> @@ -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");
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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v6 0/3] da8xx USB PHY platform devices and clocks
2016-09-05 20:00 [PATCH v6 0/3] da8xx USB PHY platform devices and clocks David Lechner
` (2 preceding siblings ...)
2016-09-05 20:00 ` [PATCH v6 3/3] usb: musb: da8xx: Remove mach code David Lechner
@ 2016-09-06 19:19 ` Bin Liu
2016-09-12 17:18 ` Bin Liu
3 siblings, 1 reply; 13+ messages in thread
From: Bin Liu @ 2016-09-06 19:19 UTC (permalink / raw)
To: David Lechner
Cc: Alan Stern, Greg Kroah-Hartman, linux-usb, linux-kernel, khilman,
nsekhar, Kishon Vijay Abraham I, Sergei Shtylyov
Hi Greg and Alan,
On Mon, Sep 05, 2016 at 03:00:30PM -0500, David Lechner wrote:
> 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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v6 0/3] da8xx USB PHY platform devices and clocks
2016-09-06 19:19 ` [PATCH v6 0/3] da8xx USB PHY platform devices and clocks Bin Liu
@ 2016-09-12 17:18 ` Bin Liu
2016-09-12 18:01 ` Kevin Hilman
0 siblings, 1 reply; 13+ messages in thread
From: Bin Liu @ 2016-09-12 17:18 UTC (permalink / raw)
To: David Lechner, Alan Stern, Greg Kroah-Hartman, linux-usb,
linux-kernel, khilman, nsekhar, Kishon Vijay Abraham I,
Sergei Shtylyov
Hi,
On Tue, Sep 06, 2016 at 02:19:52PM -0500, Bin Liu wrote:
> Hi Greg and Alan,
>
> On Mon, Sep 05, 2016 at 03:00:30PM -0500, David Lechner wrote:
> > 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?
I am taking patch 2/3 & 3/3 for musb.
Regards,
-Bin.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v6 2/3] usb: musb: da8xx: Use devm in probe
2016-09-06 19:17 ` Bin Liu
@ 2016-09-12 17:19 ` Bin Liu
0 siblings, 0 replies; 13+ messages in thread
From: Bin Liu @ 2016-09-12 17:19 UTC (permalink / raw)
To: David Lechner, Alan Stern, Greg Kroah-Hartman, linux-usb,
linux-kernel, khilman, nsekhar, Kishon Vijay Abraham I,
Sergei Shtylyov
Hi,
On Tue, Sep 06, 2016 at 02:17:03PM -0500, Bin Liu wrote:
> Hi,
>
> On Mon, Sep 05, 2016 at 03:00:32PM -0500, David Lechner wrote:
> > Simplify things a bit by using devm functions where possible.
> >
> > Signed-off-by: David Lechner <david@lechnology.com>
> > ---
> > drivers/usb/musb/da8xx.c | 19 +++++--------------
> > 1 file changed, 5 insertions(+), 14 deletions(-)
> >
> > diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c
> > index b03d3b8..0c1997c 100644
> > --- a/drivers/usb/musb/da8xx.c
> > +++ b/drivers/usb/musb/da8xx.c
> > @@ -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");
>
> 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.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v6 0/3] da8xx USB PHY platform devices and clocks
2016-09-12 17:18 ` Bin Liu
@ 2016-09-12 18:01 ` Kevin Hilman
0 siblings, 0 replies; 13+ messages in thread
From: Kevin Hilman @ 2016-09-12 18:01 UTC (permalink / raw)
To: Bin Liu, Greg Kroah-Hartman
Cc: David Lechner, Alan Stern, linux-usb, linux-kernel, nsekhar,
Kishon Vijay Abraham I, Sergei Shtylyov
Bin Liu <b-liu@ti.com> writes:
> On Tue, Sep 06, 2016 at 02:19:52PM -0500, Bin Liu wrote:
>> Hi Greg and Alan,
>>
>> On Mon, Sep 05, 2016 at 03:00:30PM -0500, David Lechner wrote:
>> > 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?
>
> 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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach
2016-09-05 20:00 ` [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach David Lechner
@ 2016-10-04 9:18 ` Kevin Hilman
2016-10-04 13:38 ` Greg Kroah-Hartman
0 siblings, 1 reply; 13+ messages in thread
From: Kevin Hilman @ 2016-10-04 9:18 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Alan Stern, Bin Liu, linux-usb, lkml, Kevin Hilman, Sekhar Nori,
Kishon Vijay Abraham I, Sergei Shtylyov, David Lechner
Hi Greg,
On Mon, Sep 5, 2016 at 10:00 PM, David Lechner <david@lechnology.com> wrote:
> 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.
>
> Signed-off-by: David Lechner <david@lechnology.com>
> Acked-by: Alan Stern <stern@rowland.harvard.edu>
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
> ---
> drivers/usb/host/Kconfig | 1 +
> drivers/usb/host/ohci-da8xx.c | 102 +++++++++++++++++++++++-------------------
> 2 files changed, 56 insertions(+), 47 deletions(-)
>
> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> index 2e710a4..1f0cdab8 100644
> --- a/drivers/usb/host/Kconfig
> +++ b/drivers/usb/host/Kconfig
> @@ -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
> diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c
> index e5c33bc..3656d7c 100644
> --- a/drivers/usb/host/ohci-da8xx.c
> +++ b/drivers/usb/host/ohci-da8xx.c
> @@ -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
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach
2016-10-04 9:18 ` Kevin Hilman
@ 2016-10-04 13:38 ` Greg Kroah-Hartman
2016-10-04 17:30 ` David Lechner
0 siblings, 1 reply; 13+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-04 13:38 UTC (permalink / raw)
To: Kevin Hilman
Cc: Alan Stern, Bin Liu, linux-usb, lkml, Sekhar Nori,
Kishon Vijay Abraham I, Sergei Shtylyov, David Lechner
On Tue, Oct 04, 2016 at 11:18:03AM +0200, Kevin Hilman wrote:
> Hi Greg,
>
> On Mon, Sep 5, 2016 at 10:00 PM, David Lechner <david@lechnology.com> wrote:
> > 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.
> >
> > Signed-off-by: David Lechner <david@lechnology.com>
> > Acked-by: Alan Stern <stern@rowland.harvard.edu>
>
> 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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach
2016-10-04 13:38 ` Greg Kroah-Hartman
@ 2016-10-04 17:30 ` David Lechner
2016-10-04 19:52 ` Greg Kroah-Hartman
0 siblings, 1 reply; 13+ messages in thread
From: David Lechner @ 2016-10-04 17:30 UTC (permalink / raw)
To: Greg Kroah-Hartman, Kevin Hilman
Cc: Alan Stern, Bin Liu, linux-usb, lkml, Sekhar Nori,
Kishon Vijay Abraham I, Sergei Shtylyov
On 10/04/2016 08:38 AM, Greg Kroah-Hartman wrote:
> On Tue, Oct 04, 2016 at 11:18:03AM +0200, Kevin Hilman wrote:
>> Hi Greg,
>>
>> On Mon, Sep 5, 2016 at 10:00 PM, David Lechner <david@lechnology.com> wrote:
>>> 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.
>>>
>>> Signed-off-by: David Lechner <david@lechnology.com>
>>> Acked-by: Alan Stern <stern@rowland.harvard.edu>
>>
>> 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
>
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?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach
2016-10-04 17:30 ` David Lechner
@ 2016-10-04 19:52 ` Greg Kroah-Hartman
0 siblings, 0 replies; 13+ messages in thread
From: Greg Kroah-Hartman @ 2016-10-04 19:52 UTC (permalink / raw)
To: David Lechner
Cc: Kevin Hilman, Alan Stern, Bin Liu, linux-usb, lkml, Sekhar Nori,
Kishon Vijay Abraham I, Sergei Shtylyov
On Tue, Oct 04, 2016 at 12:30:58PM -0500, David Lechner wrote:
> On 10/04/2016 08:38 AM, Greg Kroah-Hartman wrote:
> > On Tue, Oct 04, 2016 at 11:18:03AM +0200, Kevin Hilman wrote:
> > > Hi Greg,
> > >
> > > On Mon, Sep 5, 2016 at 10:00 PM, David Lechner <david@lechnology.com> wrote:
> > > > 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.
> > > >
> > > > Signed-off-by: David Lechner <david@lechnology.com>
> > > > Acked-by: Alan Stern <stern@rowland.harvard.edu>
> > >
> > > 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
> >
>
> 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
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2016-10-04 19:52 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-05 20:00 [PATCH v6 0/3] da8xx USB PHY platform devices and clocks David Lechner
2016-09-05 20:00 ` [PATCH v6 1/3] usb: ohci-da8xx: Remove code that references mach David Lechner
2016-10-04 9:18 ` Kevin Hilman
2016-10-04 13:38 ` Greg Kroah-Hartman
2016-10-04 17:30 ` David Lechner
2016-10-04 19:52 ` Greg Kroah-Hartman
2016-09-05 20:00 ` [PATCH v6 2/3] usb: musb: da8xx: Use devm in probe David Lechner
2016-09-06 19:17 ` Bin Liu
2016-09-12 17:19 ` Bin Liu
2016-09-05 20:00 ` [PATCH v6 3/3] usb: musb: da8xx: Remove mach code David Lechner
2016-09-06 19:19 ` [PATCH v6 0/3] da8xx USB PHY platform devices and clocks Bin Liu
2016-09-12 17:18 ` Bin Liu
2016-09-12 18:01 ` Kevin Hilman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).