summaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/musb_host.c
diff options
context:
space:
mode:
authorDaniel Mack2013-04-10 21:55:45 +0200
committerFelipe Balbi2013-05-28 18:22:23 +0200
commit74c2e93600581d80695604126a3725a157d0ab72 (patch)
treef1cf1d021097255eaecb85219f372e012982d632 /drivers/usb/musb/musb_host.c
parentusb: musb: move musb_start to musb_virthub.c (diff)
downloadkernel-qcow2-linux-74c2e93600581d80695604126a3725a157d0ab72.tar.gz
kernel-qcow2-linux-74c2e93600581d80695604126a3725a157d0ab72.tar.xz
kernel-qcow2-linux-74c2e93600581d80695604126a3725a157d0ab72.zip
usb: musb: factor out hcd initalization
The musb struct is currently allocated along with the hcd, which makes it difficult to build a driver that only acts as gadget device. Fix this by allocating musb directly, and keep the hcd around as a pointer in the musb struct. struct hc_driver musb_hc_driver can now also be static to musb_host.c, and the macro musb_to_hcd() is just a pointer dereferencer for now, and will be eliminated later. Signed-off-by: Daniel Mack <zonque@gmail.com> Acked-by: Peter Korsgaard <jacmet@sunsite.dk> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/musb/musb_host.c')
-rw-r--r--drivers/usb/musb/musb_host.c46
1 files changed, 39 insertions, 7 deletions
diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index 8b977d23ddfb..e6ece8a4e8b6 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -95,6 +95,11 @@
* of transfers between endpoints, or anything clever.
*/
+struct musb *hcd_to_musb(struct usb_hcd *hcd)
+{
+ return *(struct musb **) hcd->hcd_priv;
+}
+
static void musb_ep_program(struct musb *musb, u8 epnum,
struct urb *urb, int is_out,
@@ -2464,7 +2469,6 @@ static int musb_bus_resume(struct usb_hcd *hcd)
return 0;
}
-
#ifndef CONFIG_MUSB_PIO_ONLY
#define MUSB_USB_DMA_ALIGN 4
@@ -2576,10 +2580,10 @@ static void musb_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
}
#endif /* !CONFIG_MUSB_PIO_ONLY */
-const struct hc_driver musb_hc_driver = {
+static const struct hc_driver musb_hc_driver = {
.description = "musb-hcd",
.product_desc = "MUSB HDRC host driver",
- .hcd_priv_size = sizeof(struct musb),
+ .hcd_priv_size = sizeof(struct musb *),
.flags = HCD_USB2 | HCD_MEMORY,
/* not using irq handler or reset hooks from usbcore, since
@@ -2608,16 +2612,44 @@ const struct hc_driver musb_hc_driver = {
/* .hub_irq_enable = NULL, */
};
+int musb_host_alloc(struct musb *musb)
+{
+ struct device *dev = musb->controller;
+
+ /* usbcore sets dev->driver_data to hcd, and sometimes uses that... */
+ musb->hcd = usb_create_hcd(&musb_hc_driver, dev, dev_name(dev));
+ if (!musb->hcd)
+ return -EINVAL;
+
+ *musb->hcd->hcd_priv = (unsigned long) musb;
+ musb->hcd->self.uses_pio_for_control = 1;
+ musb->hcd->uses_new_polling = 1;
+ musb->hcd->has_tt = 1;
+
+ return 0;
+}
+
+void musb_host_cleanup(struct musb *musb)
+{
+ usb_remove_hcd(musb->hcd);
+ musb->hcd = NULL;
+}
+
+void musb_host_free(struct musb *musb)
+{
+ usb_put_hcd(musb->hcd);
+}
+
void musb_host_resume_root_hub(struct musb *musb)
{
- usb_hcd_resume_root_hub(musb_to_hcd(musb));
+ usb_hcd_resume_root_hub(musb->hcd);
}
void musb_host_poke_root_hub(struct musb *musb)
{
MUSB_HST_MODE(musb);
- if (musb_to_hcd(musb)->status_urb)
- usb_hcd_poll_rh_status(musb_to_hcd(musb));
+ if (musb->hcd->status_urb)
+ usb_hcd_poll_rh_status(musb->hcd);
else
- usb_hcd_resume_root_hub(musb_to_hcd(musb));
+ usb_hcd_resume_root_hub(musb->hcd);
}