alpha: fix trivial section mismatch warnings
[pv_ops_mirror.git] / drivers / usb / host / ehci-ppc-soc.c
blobc2cedb09ed8bf02699aff32c0010e8d81ab0d841
1 /*
2 * EHCI HCD (Host Controller Driver) for USB.
4 * (C) Copyright 2006-2007 Stefan Roese <sr@denx.de>, DENX Software Engineering
6 * Bus Glue for PPC On-Chip EHCI driver
7 * Tested on AMCC 440EPx
9 * Based on "ehci-au12xx.c" by David Brownell <dbrownell@users.sourceforge.net>
11 * This file is licenced under the GPL.
14 #include <linux/platform_device.h>
16 extern int usb_disabled(void);
18 /**
19 * usb_ehci_ppc_soc_probe - initialize PPC-SoC-based HCDs
20 * Context: !in_interrupt()
22 * Allocates basic resources for this USB host controller, and
23 * then invokes the start() method for the HCD associated with it
24 * through the hotplug entry's driver_data.
27 int usb_ehci_ppc_soc_probe(const struct hc_driver *driver,
28 struct usb_hcd **hcd_out,
29 struct platform_device *dev)
31 int retval;
32 struct usb_hcd *hcd;
33 struct ehci_hcd *ehci;
35 if (dev->resource[1].flags != IORESOURCE_IRQ) {
36 pr_debug("resource[1] is not IORESOURCE_IRQ");
37 retval = -ENOMEM;
39 hcd = usb_create_hcd(driver, &dev->dev, "PPC-SOC EHCI");
40 if (!hcd)
41 return -ENOMEM;
42 hcd->rsrc_start = dev->resource[0].start;
43 hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1;
45 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
46 pr_debug("request_mem_region failed");
47 retval = -EBUSY;
48 goto err1;
51 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
52 if (!hcd->regs) {
53 pr_debug("ioremap failed");
54 retval = -ENOMEM;
55 goto err2;
58 ehci = hcd_to_ehci(hcd);
59 ehci->big_endian_mmio = 1;
60 ehci->big_endian_desc = 1;
61 ehci->caps = hcd->regs;
62 ehci->regs = hcd->regs + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
64 /* cache this readonly data; minimize chip reads */
65 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
67 #if defined(CONFIG_440EPX)
69 * 440EPx Errata USBH_3
70 * Fix: Enable Break Memory Transfer (BMT) in INSNREG3
72 out_be32((void *)((ulong)(&ehci->regs->command) + 0x8c), (1 << 0));
73 ehci_dbg(ehci, "Break Memory Transfer (BMT) has beed enabled!\n");
74 #endif
76 retval = usb_add_hcd(hcd, dev->resource[1].start, IRQF_DISABLED);
77 if (retval == 0)
78 return retval;
80 iounmap(hcd->regs);
81 err2:
82 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
83 err1:
84 usb_put_hcd(hcd);
85 return retval;
88 /* may be called without controller electrically present */
89 /* may be called with controller, bus, and devices active */
91 /**
92 * usb_ehci_hcd_ppc_soc_remove - shutdown processing for PPC-SoC-based HCDs
93 * @dev: USB Host Controller being removed
94 * Context: !in_interrupt()
96 * Reverses the effect of usb_ehci_hcd_ppc_soc_probe(), first invoking
97 * the HCD's stop() method. It is always called from a thread
98 * context, normally "rmmod", "apmd", or something similar.
101 void usb_ehci_ppc_soc_remove(struct usb_hcd *hcd, struct platform_device *dev)
103 usb_remove_hcd(hcd);
104 iounmap(hcd->regs);
105 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
106 usb_put_hcd(hcd);
109 static const struct hc_driver ehci_ppc_soc_hc_driver = {
110 .description = hcd_name,
111 .product_desc = "PPC-SOC EHCI",
112 .hcd_priv_size = sizeof(struct ehci_hcd),
115 * generic hardware linkage
117 .irq = ehci_irq,
118 .flags = HCD_MEMORY | HCD_USB2,
121 * basic lifecycle operations
123 .reset = ehci_init,
124 .start = ehci_run,
125 .stop = ehci_stop,
126 .shutdown = ehci_shutdown,
129 * managing i/o requests and associated device resources
131 .urb_enqueue = ehci_urb_enqueue,
132 .urb_dequeue = ehci_urb_dequeue,
133 .endpoint_disable = ehci_endpoint_disable,
136 * scheduling support
138 .get_frame_number = ehci_get_frame,
141 * root hub support
143 .hub_status_data = ehci_hub_status_data,
144 .hub_control = ehci_hub_control,
145 #ifdef CONFIG_PM
146 .hub_suspend = ehci_hub_suspend,
147 .hub_resume = ehci_hub_resume,
148 #endif
151 static int ehci_hcd_ppc_soc_drv_probe(struct platform_device *pdev)
153 struct usb_hcd *hcd = NULL;
154 int ret;
156 pr_debug("In ehci_hcd_ppc_soc_drv_probe\n");
158 if (usb_disabled())
159 return -ENODEV;
161 ret = usb_ehci_ppc_soc_probe(&ehci_ppc_soc_hc_driver, &hcd, pdev);
162 return ret;
165 static int ehci_hcd_ppc_soc_drv_remove(struct platform_device *pdev)
167 struct usb_hcd *hcd = platform_get_drvdata(pdev);
169 usb_ehci_ppc_soc_remove(hcd, pdev);
170 return 0;
173 MODULE_ALIAS("ppc-soc-ehci");
174 static struct platform_driver ehci_ppc_soc_driver = {
175 .probe = ehci_hcd_ppc_soc_drv_probe,
176 .remove = ehci_hcd_ppc_soc_drv_remove,
177 .shutdown = usb_hcd_platform_shutdown,
178 .driver = {
179 .name = "ppc-soc-ehci",
180 .bus = &platform_bus_type