Commit 6110c425 authored by David Lechner's avatar David Lechner Committed by Greg Kroah-Hartman

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.
Signed-off-by: default avatarDavid Lechner <david@lechnology.com>
Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6fbbcf38
...@@ -482,6 +482,7 @@ config USB_OHCI_HCD_DAVINCI ...@@ -482,6 +482,7 @@ config USB_OHCI_HCD_DAVINCI
bool "OHCI support for TI DaVinci DA8xx" bool "OHCI support for TI DaVinci DA8xx"
depends on ARCH_DAVINCI_DA8XX depends on ARCH_DAVINCI_DA8XX
depends on USB_OHCI_HCD=y depends on USB_OHCI_HCD=y
select PHY_DA8XX_USB
default y default y
help help
Enables support for the DaVinci DA8xx integrated OHCI Enables support for the DaVinci DA8xx integrated OHCI
......
...@@ -15,58 +15,50 @@ ...@@ -15,58 +15,50 @@
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/phy/phy.h>
#include <mach/da8xx.h>
#include <linux/platform_data/usb-davinci.h> #include <linux/platform_data/usb-davinci.h>
#ifndef CONFIG_ARCH_DAVINCI_DA8XX #ifndef CONFIG_ARCH_DAVINCI_DA8XX
#error "This file is DA8xx bus glue. Define CONFIG_ARCH_DAVINCI_DA8XX." #error "This file is DA8xx bus glue. Define CONFIG_ARCH_DAVINCI_DA8XX."
#endif #endif
#define CFGCHIP2 DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)
static struct clk *usb11_clk; static struct clk *usb11_clk;
static struct clk *usb20_clk; static struct phy *usb11_phy;
/* Over-current indicator change bitmask */ /* Over-current indicator change bitmask */
static volatile u16 ocic_mask; static volatile u16 ocic_mask;
static void ohci_da8xx_clock(int on) static int ohci_da8xx_enable(void)
{ {
u32 cfgchip2; int ret;
cfgchip2 = __raw_readl(CFGCHIP2); ret = clk_prepare_enable(usb11_clk);
if (on) { if (ret)
clk_enable(usb11_clk); return ret;
/* ret = phy_init(usb11_phy);
* If USB 1.1 reference clock is sourced from USB 2.0 PHY, we if (ret)
* need to enable the USB 2.0 module clocking, start its PHY, goto err_phy_init;
* 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); ret = phy_power_on(usb11_phy);
cfgchip2 |= CFGCHIP2_PHY_PLLON; if (ret)
__raw_writel(cfgchip2, CFGCHIP2); goto err_phy_power_on;
pr_info("Waiting for USB PHY clock good...\n"); return 0;
while (!(__raw_readl(CFGCHIP2) & CFGCHIP2_PHYCLKGD))
cpu_relax();
}
/* Enable USB 1.1 PHY */ err_phy_power_on:
cfgchip2 |= CFGCHIP2_USB1SUSPENDM; phy_exit(usb11_phy);
} else { err_phy_init:
clk_disable(usb11_clk); clk_disable_unprepare(usb11_clk);
if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX))
clk_disable(usb20_clk);
/* Disable USB 1.1 PHY */ return ret;
cfgchip2 &= ~CFGCHIP2_USB1SUSPENDM; }
}
__raw_writel(cfgchip2, CFGCHIP2); 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) ...@@ -92,7 +84,9 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
dev_dbg(dev, "starting USB controller\n"); 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 * 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) ...@@ -101,8 +95,10 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
ohci->num_ports = 1; ohci->num_ports = 1;
result = ohci_init(ohci); result = ohci_init(ohci);
if (result < 0) if (result < 0) {
ohci_da8xx_disable();
return result; return result;
}
/* /*
* Since we're providing a board-specific root hub port power control * 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) ...@@ -129,7 +125,7 @@ static int ohci_da8xx_init(struct usb_hcd *hcd)
static void ohci_da8xx_stop(struct usb_hcd *hcd) static void ohci_da8xx_stop(struct usb_hcd *hcd)
{ {
ohci_stop(hcd); ohci_stop(hcd);
ohci_da8xx_clock(0); ohci_da8xx_disable();
} }
static int ohci_da8xx_start(struct usb_hcd *hcd) static int ohci_da8xx_start(struct usb_hcd *hcd)
...@@ -301,12 +297,18 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver, ...@@ -301,12 +297,18 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver,
return -ENODEV; return -ENODEV;
usb11_clk = devm_clk_get(&pdev->dev, "usb11"); 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); return PTR_ERR(usb11_clk);
}
usb20_clk = devm_clk_get(&pdev->dev, "usb20"); usb11_phy = devm_phy_get(&pdev->dev, "usb-phy");
if (IS_ERR(usb20_clk)) if (IS_ERR(usb11_phy)) {
return PTR_ERR(usb20_clk); 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)); hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev));
if (!hcd) if (!hcd)
...@@ -316,6 +318,7 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver, ...@@ -316,6 +318,7 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver,
hcd->regs = devm_ioremap_resource(&pdev->dev, mem); hcd->regs = devm_ioremap_resource(&pdev->dev, mem);
if (IS_ERR(hcd->regs)) { if (IS_ERR(hcd->regs)) {
error = PTR_ERR(hcd->regs); error = PTR_ERR(hcd->regs);
dev_err(&pdev->dev, "failed to map ohci.\n");
goto err; goto err;
} }
hcd->rsrc_start = mem->start; hcd->rsrc_start = mem->start;
...@@ -397,7 +400,7 @@ static int ohci_da8xx_suspend(struct platform_device *pdev, ...@@ -397,7 +400,7 @@ static int ohci_da8xx_suspend(struct platform_device *pdev,
if (ret) if (ret)
return ret; return ret;
ohci_da8xx_clock(0); ohci_da8xx_disable();
hcd->state = HC_STATE_SUSPENDED; hcd->state = HC_STATE_SUSPENDED;
return ret; return ret;
...@@ -407,14 +410,19 @@ static int ohci_da8xx_resume(struct platform_device *dev) ...@@ -407,14 +410,19 @@ static int ohci_da8xx_resume(struct platform_device *dev)
{ {
struct usb_hcd *hcd = platform_get_drvdata(dev); struct usb_hcd *hcd = platform_get_drvdata(dev);
struct ohci_hcd *ohci = hcd_to_ohci(hcd); struct ohci_hcd *ohci = hcd_to_ohci(hcd);
int ret;
if (time_before(jiffies, ohci->next_statechange)) if (time_before(jiffies, ohci->next_statechange))
msleep(5); msleep(5);
ohci->next_statechange = jiffies; ohci->next_statechange = jiffies;
ohci_da8xx_clock(1); ret = ohci_da8xx_enable();
if (ret)
return ret;
dev->dev.power.power_state = PMSG_ON; dev->dev.power.power_state = PMSG_ON;
usb_hcd_resume_root_hub(hcd); usb_hcd_resume_root_hub(hcd);
return 0; return 0;
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment