Commit bd35078f authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

USB: build fixes: ohci-omap

The ohci-omap code has diverged from the working version in the linux-omap
tree; this syncs up the versions:

  - Another clock is needed in various cases
  - The omap-1510 iommu code needs to be #ifdeffed out on newer parts
  - Saner use of the HCD framework
  - Various other changes, e.g. a Nokia 770 quirk

And some minor dead-whitespace removal.
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent eb6d8c2d
...@@ -66,15 +66,20 @@ extern int usb_disabled(void); ...@@ -66,15 +66,20 @@ extern int usb_disabled(void);
extern int ocpi_enable(void); extern int ocpi_enable(void);
static struct clk *usb_host_ck; static struct clk *usb_host_ck;
static struct clk *usb_dc_ck;
static int host_enabled;
static int host_initialized;
static void omap_ohci_clock_power(int on) static void omap_ohci_clock_power(int on)
{ {
if (on) { if (on) {
clk_enable(usb_dc_ck);
clk_enable(usb_host_ck); clk_enable(usb_host_ck);
/* guesstimate for T5 == 1x 32K clock + APLL lock time */ /* guesstimate for T5 == 1x 32K clock + APLL lock time */
udelay(100); udelay(100);
} else { } else {
clk_disable(usb_host_ck); clk_disable(usb_host_ck);
clk_disable(usb_dc_ck);
} }
} }
...@@ -103,6 +108,7 @@ static int omap_ohci_transceiver_power(int on) ...@@ -103,6 +108,7 @@ static int omap_ohci_transceiver_power(int on)
return 0; return 0;
} }
#ifdef CONFIG_ARCH_OMAP15XX
/* /*
* OMAP-1510 specific Local Bus clock on/off * OMAP-1510 specific Local Bus clock on/off
*/ */
...@@ -152,6 +158,10 @@ static int omap_1510_local_bus_init(void) ...@@ -152,6 +158,10 @@ static int omap_1510_local_bus_init(void)
return 0; return 0;
} }
#else
#define omap_1510_local_bus_power(x) {}
#define omap_1510_local_bus_init() {}
#endif
#ifdef CONFIG_USB_OTG #ifdef CONFIG_USB_OTG
...@@ -173,13 +183,14 @@ static void start_hnp(struct ohci_hcd *ohci) ...@@ -173,13 +183,14 @@ static void start_hnp(struct ohci_hcd *ohci)
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev) static int ohci_omap_init(struct usb_hcd *hcd)
{ {
struct omap_usb_config *config = pdev->dev.platform_data; struct ohci_hcd *ohci = hcd_to_ohci(hcd);
struct omap_usb_config *config = hcd->self.controller->platform_data;
int need_transceiver = (config->otg != 0); int need_transceiver = (config->otg != 0);
int ret; int ret;
dev_dbg(&pdev->dev, "starting USB Controller\n"); dev_dbg(hcd->self.controller, "starting USB Controller\n");
if (config->otg) { if (config->otg) {
ohci_to_hcd(ohci)->self.otg_port = config->otg; ohci_to_hcd(ohci)->self.otg_port = config->otg;
...@@ -200,7 +211,7 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev) ...@@ -200,7 +211,7 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev)
if (ohci->transceiver) { if (ohci->transceiver) {
int status = otg_set_host(ohci->transceiver, int status = otg_set_host(ohci->transceiver,
&ohci_to_hcd(ohci)->self); &ohci_to_hcd(ohci)->self);
dev_dbg(&pdev->dev, "init %s transceiver, status %d\n", dev_dbg(hcd->self.controller, "init %s transceiver, status %d\n",
ohci->transceiver->label, status); ohci->transceiver->label, status);
if (status) { if (status) {
if (ohci->transceiver) if (ohci->transceiver)
...@@ -208,7 +219,7 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev) ...@@ -208,7 +219,7 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev)
return status; return status;
} }
} else { } else {
dev_err(&pdev->dev, "can't find transceiver\n"); dev_err(hcd->self.controller, "can't find transceiver\n");
return -ENODEV; return -ENODEV;
} }
} }
...@@ -247,6 +258,10 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev) ...@@ -247,6 +258,10 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev)
} }
ohci_writel(ohci, rh, &ohci->regs->roothub.a); ohci_writel(ohci, rh, &ohci->regs->roothub.a);
distrust_firmware = 0; distrust_firmware = 0;
} else if (machine_is_nokia770()) {
/* We require a self-powered hub, which should have
* plenty of power. */
ohci_to_hcd(ohci)->power_budget = 0;
} }
/* FIXME khubd hub requests should manage power switching */ /* FIXME khubd hub requests should manage power switching */
...@@ -260,21 +275,15 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev) ...@@ -260,21 +275,15 @@ static int omap_start_hc(struct ohci_hcd *ohci, struct platform_device *pdev)
return 0; return 0;
} }
static void omap_stop_hc(struct platform_device *pdev) static void ohci_omap_stop(struct usb_hcd *hcd)
{ {
dev_dbg(&pdev->dev, "stopping USB Controller\n"); dev_dbg(hcd->self.controller, "stopping USB Controller\n");
omap_ohci_clock_power(0); omap_ohci_clock_power(0);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
void usb_hcd_omap_remove (struct usb_hcd *, struct platform_device *);
/* configure so an HC device and id are always provided */
/* always called with process context; sleeping is OK */
/** /**
* usb_hcd_omap_probe - initialize OMAP-based HCDs * usb_hcd_omap_probe - initialize OMAP-based HCDs
* Context: !in_interrupt() * Context: !in_interrupt()
...@@ -283,7 +292,7 @@ void usb_hcd_omap_remove (struct usb_hcd *, struct platform_device *); ...@@ -283,7 +292,7 @@ void usb_hcd_omap_remove (struct usb_hcd *, struct platform_device *);
* then invokes the start() method for the HCD associated with it * then invokes the start() method for the HCD associated with it
* through the hotplug entry's driver_data. * through the hotplug entry's driver_data.
*/ */
int usb_hcd_omap_probe (const struct hc_driver *driver, static int usb_hcd_omap_probe (const struct hc_driver *driver,
struct platform_device *pdev) struct platform_device *pdev)
{ {
int retval, irq; int retval, irq;
...@@ -306,6 +315,17 @@ int usb_hcd_omap_probe (const struct hc_driver *driver, ...@@ -306,6 +315,17 @@ int usb_hcd_omap_probe (const struct hc_driver *driver,
if (IS_ERR(usb_host_ck)) if (IS_ERR(usb_host_ck))
return PTR_ERR(usb_host_ck); return PTR_ERR(usb_host_ck);
if (!cpu_is_omap1510())
usb_dc_ck = clk_get(0, "usb_dc_ck");
else
usb_dc_ck = clk_get(0, "lb_ck");
if (IS_ERR(usb_dc_ck)) {
clk_put(usb_host_ck);
return PTR_ERR(usb_dc_ck);
}
hcd = usb_create_hcd (driver, &pdev->dev, pdev->dev.bus_id); hcd = usb_create_hcd (driver, &pdev->dev, pdev->dev.bus_id);
if (!hcd) { if (!hcd) {
retval = -ENOMEM; retval = -ENOMEM;
...@@ -325,9 +345,8 @@ int usb_hcd_omap_probe (const struct hc_driver *driver, ...@@ -325,9 +345,8 @@ int usb_hcd_omap_probe (const struct hc_driver *driver,
ohci = hcd_to_ohci(hcd); ohci = hcd_to_ohci(hcd);
ohci_hcd_init(ohci); ohci_hcd_init(ohci);
retval = omap_start_hc(ohci, pdev); host_initialized = 0;
if (retval < 0) host_enabled = 1;
goto err2;
irq = platform_get_irq(pdev, 0); irq = platform_get_irq(pdev, 0);
if (irq < 0) { if (irq < 0) {
...@@ -335,15 +354,21 @@ int usb_hcd_omap_probe (const struct hc_driver *driver, ...@@ -335,15 +354,21 @@ int usb_hcd_omap_probe (const struct hc_driver *driver,
goto err2; goto err2;
} }
retval = usb_add_hcd(hcd, irq, IRQF_DISABLED); retval = usb_add_hcd(hcd, irq, IRQF_DISABLED);
if (retval == 0) if (retval)
return retval; goto err2;
host_initialized = 1;
if (!host_enabled)
omap_ohci_clock_power(0);
omap_stop_hc(pdev); return 0;
err2: err2:
release_mem_region(hcd->rsrc_start, hcd->rsrc_len); release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
err1: err1:
usb_put_hcd(hcd); usb_put_hcd(hcd);
err0: err0:
clk_put(usb_dc_ck);
clk_put(usb_host_ck); clk_put(usb_host_ck);
return retval; return retval;
} }
...@@ -359,28 +384,36 @@ err0: ...@@ -359,28 +384,36 @@ err0:
* Reverses the effect of usb_hcd_omap_probe(), first invoking * Reverses the effect of usb_hcd_omap_probe(), first invoking
* the HCD's stop() method. It is always called from a thread * the HCD's stop() method. It is always called from a thread
* context, normally "rmmod", "apmd", or something similar. * context, normally "rmmod", "apmd", or something similar.
*
*/ */
void usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev) static inline void
usb_hcd_omap_remove (struct usb_hcd *hcd, struct platform_device *pdev)
{ {
struct ohci_hcd *ohci = hcd_to_ohci (hcd);
usb_remove_hcd(hcd); usb_remove_hcd(hcd);
if (ohci->transceiver) {
(void) otg_set_host(ohci->transceiver, 0);
put_device(ohci->transceiver->dev);
}
if (machine_is_omap_osk()) if (machine_is_omap_osk())
omap_free_gpio(9); omap_free_gpio(9);
omap_stop_hc(pdev);
release_mem_region(hcd->rsrc_start, hcd->rsrc_len); release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
usb_put_hcd(hcd); usb_put_hcd(hcd);
clk_put(usb_dc_ck);
clk_put(usb_host_ck); clk_put(usb_host_ck);
} }
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static int __devinit static int
ohci_omap_start (struct usb_hcd *hcd) ohci_omap_start (struct usb_hcd *hcd)
{ {
struct omap_usb_config *config; struct omap_usb_config *config;
struct ohci_hcd *ohci = hcd_to_ohci (hcd); struct ohci_hcd *ohci = hcd_to_ohci (hcd);
int ret; int ret;
if (!host_enabled)
return 0;
config = hcd->self.controller->platform_data; config = hcd->self.controller->platform_data;
if (config->otg || config->rwc) { if (config->otg || config->rwc) {
ohci->hc_control = OHCI_CTRL_RWC; ohci->hc_control = OHCI_CTRL_RWC;
...@@ -411,8 +444,9 @@ static const struct hc_driver ohci_omap_hc_driver = { ...@@ -411,8 +444,9 @@ static const struct hc_driver ohci_omap_hc_driver = {
/* /*
* basic lifecycle operations * basic lifecycle operations
*/ */
.reset = ohci_omap_init,
.start = ohci_omap_start, .start = ohci_omap_start,
.stop = ohci_stop, .stop = ohci_omap_stop,
/* /*
* managing i/o requests and associated device resources * managing i/o requests and associated device resources
...@@ -449,13 +483,8 @@ static int ohci_hcd_omap_drv_probe(struct platform_device *dev) ...@@ -449,13 +483,8 @@ static int ohci_hcd_omap_drv_probe(struct platform_device *dev)
static int ohci_hcd_omap_drv_remove(struct platform_device *dev) static int ohci_hcd_omap_drv_remove(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);
usb_hcd_omap_remove(hcd, dev); usb_hcd_omap_remove(hcd, dev);
if (ohci->transceiver) {
(void) otg_set_host(ohci->transceiver, 0);
put_device(ohci->transceiver->dev);
}
platform_set_drvdata(dev, NULL); platform_set_drvdata(dev, NULL);
return 0; return 0;
...@@ -475,7 +504,7 @@ static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message) ...@@ -475,7 +504,7 @@ static int ohci_omap_suspend(struct platform_device *dev, pm_message_t message)
omap_ohci_clock_power(0); omap_ohci_clock_power(0);
ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED; ohci_to_hcd(ohci)->state = HC_STATE_SUSPENDED;
dev->power.power_state = PMSG_SUSPEND; dev->dev.power.power_state = PMSG_SUSPEND;
return 0; return 0;
} }
...@@ -488,8 +517,8 @@ static int ohci_omap_resume(struct platform_device *dev) ...@@ -488,8 +517,8 @@ static int ohci_omap_resume(struct platform_device *dev)
ohci->next_statechange = jiffies; ohci->next_statechange = jiffies;
omap_ohci_clock_power(1); omap_ohci_clock_power(1);
dev->power.power_state = PMSG_ON; dev->dev.power.power_state = PMSG_ON;
usb_hcd_resume_root_hub(dev_get_drvdata(dev)); usb_hcd_resume_root_hub(platform_get_drvdata(dev));
return 0; return 0;
} }
......
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