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
8 diff --git a/drivers/usb/host/ehci-bcm63xx.c b/drivers/usb/host/ehci-bcm63xx.c
10 index 0000000..50638f7
12 +++ b/drivers/usb/host/ehci-bcm63xx.c
15 + * This file is subject to the terms and conditions of the GNU General Public
16 + * License. See the file "COPYING" in the main directory of this archive
19 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
22 +#include <linux/init.h>
23 +#include <linux/platform_device.h>
24 +#include <bcm63xx_cpu.h>
25 +#include <bcm63xx_regs.h>
26 +#include <bcm63xx_io.h>
28 +static int ehci_bcm63xx_setup(struct usb_hcd *hcd)
30 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
33 + retval = ehci_halt(ehci);
37 + retval = ehci_init(hcd);
42 + ehci_port_power(ehci, 0);
48 +static const struct hc_driver ehci_bcm63xx_hc_driver = {
49 + .description = hcd_name,
50 + .product_desc = "BCM63XX integrated EHCI controller",
51 + .hcd_priv_size = sizeof(struct ehci_hcd),
54 + .flags = HCD_MEMORY | HCD_USB2,
56 + .reset = ehci_bcm63xx_setup,
59 + .shutdown = ehci_shutdown,
61 + .urb_enqueue = ehci_urb_enqueue,
62 + .urb_dequeue = ehci_urb_dequeue,
63 + .endpoint_disable = ehci_endpoint_disable,
65 + .get_frame_number = ehci_get_frame,
67 + .hub_status_data = ehci_hub_status_data,
68 + .hub_control = ehci_hub_control,
69 + .bus_suspend = ehci_bus_suspend,
70 + .bus_resume = ehci_bus_resume,
71 + .relinquish_port = ehci_relinquish_port,
72 + .port_handed_over = ehci_port_handed_over,
75 +static int __devinit ehci_hcd_bcm63xx_drv_probe(struct platform_device *pdev)
77 + struct resource *res_mem;
78 + struct usb_hcd *hcd;
79 + struct ehci_hcd *ehci;
83 + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
84 + irq = platform_get_irq(pdev, 0);;
85 + if (!res_mem || irq < 0)
88 + reg = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_REG);
89 + reg &= ~USBH_PRIV_SWAP_EHCI_DATA_MASK;
90 + reg |= USBH_PRIV_SWAP_EHCI_ENDN_MASK;
91 + bcm_rset_writel(RSET_USBH_PRIV, reg, USBH_PRIV_SWAP_REG);
94 + * The magic value comes for the original vendor BSP and is
95 + * needed for USB to work. Datasheet does not help, so the
96 + * magic value is used as-is.
98 + bcm_rset_writel(RSET_USBH_PRIV, 0x1c0020, USBH_PRIV_TEST_REG);
100 + hcd = usb_create_hcd(&ehci_bcm63xx_hc_driver, &pdev->dev, "bcm63xx");
103 + hcd->rsrc_start = res_mem->start;
104 + hcd->rsrc_len = res_mem->end - res_mem->start + 1;
106 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
107 + pr_debug("request_mem_region failed\n");
112 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
114 + pr_debug("ioremap failed\n");
119 + ehci = hcd_to_ehci(hcd);
120 + ehci->big_endian_mmio = 1;
121 + ehci->big_endian_desc = 0;
122 + ehci->caps = hcd->regs;
123 + ehci->regs = hcd->regs +
124 + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
125 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
128 + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
132 + platform_set_drvdata(pdev, hcd);
136 + iounmap(hcd->regs);
138 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
144 +static int __devexit ehci_hcd_bcm63xx_drv_remove(struct platform_device *pdev)
146 + struct usb_hcd *hcd;
148 + hcd = platform_get_drvdata(pdev);
149 + usb_remove_hcd(hcd);
150 + iounmap(hcd->regs);
152 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
153 + platform_set_drvdata(pdev, NULL);
157 +static struct platform_driver ehci_hcd_bcm63xx_driver = {
158 + .probe = ehci_hcd_bcm63xx_drv_probe,
159 + .remove = __devexit_p(ehci_hcd_bcm63xx_drv_remove),
160 + .shutdown = usb_hcd_platform_shutdown,
162 + .name = "bcm63xx_ehci",
163 + .owner = THIS_MODULE,
167 +MODULE_ALIAS("platform:bcm63xx_ehci");
168 diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
169 index 1ec3857..8e7c61e 100644
170 --- a/drivers/usb/host/ehci-hcd.c
171 +++ b/drivers/usb/host/ehci-hcd.c
172 @@ -1158,6 +1158,11 @@ MODULE_LICENSE ("GPL");
173 #define PLATFORM_DRIVER ehci_atmel_driver
176 +#ifdef CONFIG_BCM63XX
177 +#include "ehci-bcm63xx.c"
178 +#define PLATFORM_DRIVER ehci_hcd_bcm63xx_driver
181 #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
182 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER)
183 #error "missing bus glue for ehci-hcd"