1 Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
3 drivers/usb/host/ehci-bcm63xx.c | 154 +++++++++++++++++++++++++++++++++++++++
4 drivers/usb/host/ehci-hcd.c | 5 +
5 2 files changed, 159 insertions(+), 0 deletions(-)
6 create mode 100644 drivers/usb/host/ehci-bcm63xx.c
9 +++ b/drivers/usb/host/ehci-bcm63xx.c
12 + * This file is subject to the terms and conditions of the GNU General Public
13 + * License. See the file "COPYING" in the main directory of this archive
16 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
19 +#include <linux/init.h>
20 +#include <linux/platform_device.h>
21 +#include <bcm63xx_cpu.h>
22 +#include <bcm63xx_regs.h>
23 +#include <bcm63xx_io.h>
25 +static int ehci_bcm63xx_setup(struct usb_hcd *hcd)
27 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
30 + retval = ehci_halt(ehci);
34 + retval = ehci_init(hcd);
39 + ehci_port_power(ehci, 0);
45 +static const struct hc_driver ehci_bcm63xx_hc_driver = {
46 + .description = hcd_name,
47 + .product_desc = "BCM63XX integrated EHCI controller",
48 + .hcd_priv_size = sizeof(struct ehci_hcd),
51 + .flags = HCD_MEMORY | HCD_USB2,
53 + .reset = ehci_bcm63xx_setup,
56 + .shutdown = ehci_shutdown,
58 + .urb_enqueue = ehci_urb_enqueue,
59 + .urb_dequeue = ehci_urb_dequeue,
60 + .endpoint_disable = ehci_endpoint_disable,
62 + .get_frame_number = ehci_get_frame,
64 + .hub_status_data = ehci_hub_status_data,
65 + .hub_control = ehci_hub_control,
66 + .bus_suspend = ehci_bus_suspend,
67 + .bus_resume = ehci_bus_resume,
68 + .relinquish_port = ehci_relinquish_port,
69 + .port_handed_over = ehci_port_handed_over,
72 +static int __devinit ehci_hcd_bcm63xx_drv_probe(struct platform_device *pdev)
74 + struct resource *res_mem;
75 + struct usb_hcd *hcd;
76 + struct ehci_hcd *ehci;
80 + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
81 + irq = platform_get_irq(pdev, 0);;
82 + if (!res_mem || irq < 0)
85 + reg = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_REG);
86 + reg &= ~USBH_PRIV_SWAP_EHCI_DATA_MASK;
87 + reg |= USBH_PRIV_SWAP_EHCI_ENDN_MASK;
88 + bcm_rset_writel(RSET_USBH_PRIV, reg, USBH_PRIV_SWAP_REG);
91 + * The magic value comes for the original vendor BSP and is
92 + * needed for USB to work. Datasheet does not help, so the
93 + * magic value is used as-is.
95 + bcm_rset_writel(RSET_USBH_PRIV, 0x1c0020, USBH_PRIV_TEST_REG);
97 + hcd = usb_create_hcd(&ehci_bcm63xx_hc_driver, &pdev->dev, "bcm63xx");
100 + hcd->rsrc_start = res_mem->start;
101 + hcd->rsrc_len = res_mem->end - res_mem->start + 1;
103 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
104 + pr_debug("request_mem_region failed\n");
109 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
111 + pr_debug("ioremap failed\n");
116 + ehci = hcd_to_ehci(hcd);
117 + ehci->big_endian_mmio = 1;
118 + ehci->big_endian_desc = 0;
119 + ehci->caps = hcd->regs;
120 + ehci->regs = hcd->regs +
121 + HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
122 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
124 + ehci->ignore_oc = 1;
126 + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
130 + platform_set_drvdata(pdev, hcd);
134 + iounmap(hcd->regs);
136 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
142 +static int __devexit ehci_hcd_bcm63xx_drv_remove(struct platform_device *pdev)
144 + struct usb_hcd *hcd;
146 + hcd = platform_get_drvdata(pdev);
147 + usb_remove_hcd(hcd);
148 + iounmap(hcd->regs);
150 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
151 + platform_set_drvdata(pdev, NULL);
155 +static struct platform_driver ehci_hcd_bcm63xx_driver = {
156 + .probe = ehci_hcd_bcm63xx_drv_probe,
157 + .remove = __devexit_p(ehci_hcd_bcm63xx_drv_remove),
158 + .shutdown = usb_hcd_platform_shutdown,
160 + .name = "bcm63xx_ehci",
161 + .owner = THIS_MODULE,
165 +MODULE_ALIAS("platform:bcm63xx_ehci");
166 --- a/drivers/usb/host/ehci-hcd.c
167 +++ b/drivers/usb/host/ehci-hcd.c
168 @@ -1319,6 +1319,11 @@ MODULE_LICENSE ("GPL");
169 #define PLATFORM_DRIVER ehci_grlib_driver
172 +#ifdef CONFIG_BCM63XX
173 +#include "ehci-bcm63xx.c"
174 +#define PLATFORM_DRIVER ehci_hcd_bcm63xx_driver
177 #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
178 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \
179 !defined(XILINX_OF_PLATFORM_DRIVER)