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_readl(ehci, &ehci->caps->hc_capbase));
122 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
125 + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
129 + platform_set_drvdata(pdev, hcd);
133 + iounmap(hcd->regs);
135 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
141 +static int __devexit ehci_hcd_bcm63xx_drv_remove(struct platform_device *pdev)
143 + struct usb_hcd *hcd;
145 + hcd = platform_get_drvdata(pdev);
146 + usb_remove_hcd(hcd);
147 + iounmap(hcd->regs);
149 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
150 + platform_set_drvdata(pdev, NULL);
154 +static struct platform_driver ehci_hcd_bcm63xx_driver = {
155 + .probe = ehci_hcd_bcm63xx_drv_probe,
156 + .remove = __devexit_p(ehci_hcd_bcm63xx_drv_remove),
157 + .shutdown = usb_hcd_platform_shutdown,
159 + .name = "bcm63xx_ehci",
160 + .owner = THIS_MODULE,
164 +MODULE_ALIAS("platform:bcm63xx_ehci");
165 --- a/drivers/usb/host/ehci-hcd.c
166 +++ b/drivers/usb/host/ehci-hcd.c
167 @@ -1141,6 +1141,11 @@ MODULE_LICENSE ("GPL");
168 #define PLATFORM_DRIVER ehci_atmel_driver
171 +#ifdef CONFIG_BCM63XX
172 +#include "ehci-bcm63xx.c"
173 +#define PLATFORM_DRIVER ehci_hcd_bcm63xx_driver
176 #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
177 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER)
178 #error "missing bus glue for ehci-hcd"