1 From f4aa3db2fb59983d45a9038daabad76102d32fc4 Mon Sep 17 00:00:00 2001
2 From: Maxime Bizon <mbizon@freebox.fr>
3 Date: Fri, 10 Jun 2011 19:14:30 +0200
4 Subject: [PATCH 20/57] ohci: add driver for bcm63xx integrated controller.
7 drivers/usb/host/Kconfig | 9 ++
8 drivers/usb/host/ohci-bcm63xx.c | 175 +++++++++++++++++++++++++++++++++++++++
9 drivers/usb/host/ohci-hcd.c | 5 +
10 drivers/usb/host/ohci.h | 2 +-
11 4 files changed, 190 insertions(+), 1 deletions(-)
12 create mode 100644 drivers/usb/host/ohci-bcm63xx.c
14 --- a/drivers/usb/host/Kconfig
15 +++ b/drivers/usb/host/Kconfig
16 @@ -296,6 +296,15 @@ config USB_OHCI_HCD
17 To compile this driver as a module, choose M here: the
18 module will be called ohci-hcd.
20 +config USB_OHCI_BCM63XX
21 + bool "Support for Broadcom 63xx on-chip OHCI USB controller"
22 + depends on USB_OHCI_HCD && BCM63XX
23 + select USB_OHCI_BIG_ENDIAN_DESC
24 + select USB_OHCI_BIG_ENDIAN_MMIO
26 + Enables support for the on-chip OHCI controller on
29 config USB_OHCI_HCD_OMAP1
30 bool "OHCI support for OMAP1/2 chips"
31 depends on USB_OHCI_HCD && (ARCH_OMAP1 || ARCH_OMAP2)
33 +++ b/drivers/usb/host/ohci-bcm63xx.c
36 + * This file is subject to the terms and conditions of the GNU General Public
37 + * License. See the file "COPYING" in the main directory of this archive
40 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
43 +#include <linux/init.h>
44 +#include <linux/clk.h>
45 +#include <linux/platform_device.h>
46 +#include <bcm63xx_cpu.h>
47 +#include <bcm63xx_regs.h>
48 +#include <bcm63xx_io.h>
50 +static struct clk *usb_host_clock;
52 +static int __devinit ohci_bcm63xx_start(struct usb_hcd *hcd)
54 + struct ohci_hcd *ohci = hcd_to_ohci(hcd);
57 + ohci->num_ports = 1;
59 + ret = ohci_init(ohci);
63 + /* FIXME: autodetected port 2 is shared with USB slave */
65 + ret = ohci_run(ohci);
67 + err("can't start %s", hcd->self.bus_name);
74 +static const struct hc_driver ohci_bcm63xx_hc_driver = {
75 + .description = hcd_name,
76 + .product_desc = "BCM63XX integrated OHCI controller",
77 + .hcd_priv_size = sizeof(struct ohci_hcd),
80 + .flags = HCD_USB11 | HCD_MEMORY,
81 + .start = ohci_bcm63xx_start,
83 + .shutdown = ohci_shutdown,
84 + .urb_enqueue = ohci_urb_enqueue,
85 + .urb_dequeue = ohci_urb_dequeue,
86 + .endpoint_disable = ohci_endpoint_disable,
87 + .get_frame_number = ohci_get_frame,
88 + .hub_status_data = ohci_hub_status_data,
89 + .hub_control = ohci_hub_control,
90 + .start_port_reset = ohci_start_port_reset,
93 +static int __devinit ohci_hcd_bcm63xx_drv_probe(struct platform_device *pdev)
95 + struct resource *res_mem;
96 + struct usb_hcd *hcd;
97 + struct ohci_hcd *ohci;
102 + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
103 + irq = platform_get_irq(pdev, 0);
104 + if (!res_mem || irq < 0)
107 + /* enable USB host clock */
108 + clk = clk_get(&pdev->dev, "usbh");
113 + usb_host_clock = clk;
116 + if (BCMCPU_IS_6348())
117 + bcm_rset_writel(RSET_OHCI_PRIV, 0, OHCI_PRIV_REG);
118 + else if (BCMCPU_IS_6358()) {
119 + reg = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_6358_REG);
120 + reg &= ~USBH_PRIV_SWAP_OHCI_ENDN_MASK;
121 + reg |= USBH_PRIV_SWAP_OHCI_DATA_MASK;
122 + bcm_rset_writel(RSET_USBH_PRIV, reg, USBH_PRIV_SWAP_6358_REG);
124 + * The magic value comes for the original vendor BSP
125 + * and is needed for USB to work. Datasheet does not
126 + * help, so the magic value is used as-is.
128 + bcm_rset_writel(RSET_USBH_PRIV, 0x1c0020,
129 + USBH_PRIV_TEST_6358_REG);
131 + } else if (BCMCPU_IS_6368()) {
132 + reg = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_6368_REG);
133 + reg &= ~USBH_PRIV_SWAP_OHCI_ENDN_MASK;
134 + reg |= USBH_PRIV_SWAP_OHCI_DATA_MASK;
135 + bcm_rset_writel(RSET_USBH_PRIV, reg, USBH_PRIV_SWAP_6368_REG);
137 + reg = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SETUP_6368_REG);
138 + reg |= USBH_PRIV_SETUP_IOC_MASK;
139 + bcm_rset_writel(RSET_USBH_PRIV, reg, USBH_PRIV_SETUP_6368_REG);
142 + hcd = usb_create_hcd(&ohci_bcm63xx_hc_driver, &pdev->dev, "bcm63xx");
145 + hcd->rsrc_start = res_mem->start;
146 + hcd->rsrc_len = res_mem->end - res_mem->start + 1;
148 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
149 + pr_debug("request_mem_region failed\n");
154 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
156 + pr_debug("ioremap failed\n");
161 + ohci = hcd_to_ohci(hcd);
162 + ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC |
163 + OHCI_QUIRK_FRAME_NO;
164 + ohci_hcd_init(ohci);
166 + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
170 + platform_set_drvdata(pdev, hcd);
174 + iounmap(hcd->regs);
176 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
182 +static int __devexit ohci_hcd_bcm63xx_drv_remove(struct platform_device *pdev)
184 + struct usb_hcd *hcd;
186 + hcd = platform_get_drvdata(pdev);
187 + usb_remove_hcd(hcd);
188 + iounmap(hcd->regs);
190 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
191 + if (usb_host_clock) {
192 + clk_disable(usb_host_clock);
193 + clk_put(usb_host_clock);
195 + platform_set_drvdata(pdev, NULL);
199 +static struct platform_driver ohci_hcd_bcm63xx_driver = {
200 + .probe = ohci_hcd_bcm63xx_drv_probe,
201 + .remove = __devexit_p(ohci_hcd_bcm63xx_drv_remove),
202 + .shutdown = usb_hcd_platform_shutdown,
204 + .name = "bcm63xx_ohci",
205 + .owner = THIS_MODULE,
209 +MODULE_ALIAS("platform:bcm63xx_ohci");
210 --- a/drivers/usb/host/ohci-hcd.c
211 +++ b/drivers/usb/host/ohci-hcd.c
212 @@ -1121,6 +1121,11 @@ MODULE_LICENSE ("GPL");
213 #define PLATFORM_DRIVER ohci_xls_driver
216 +#ifdef CONFIG_USB_OHCI_BCM63XX
217 +#include "ohci-bcm63xx.c"
218 +#define PLATFORM_DRIVER ohci_hcd_bcm63xx_driver
221 #if !defined(PCI_DRIVER) && \
222 !defined(PLATFORM_DRIVER) && \
223 !defined(OMAP1_PLATFORM_DRIVER) && \
224 --- a/drivers/usb/host/ohci.h
225 +++ b/drivers/usb/host/ohci.h
226 @@ -652,7 +652,7 @@ static inline u32 hc32_to_cpup (const st
227 * some big-endian SOC implementations. Same thing happens with PSW access.
230 -#ifdef CONFIG_PPC_MPC52xx
231 +#if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_BCM63XX)
232 #define big_endian_frame_no_quirk(ohci) (ohci->flags & OHCI_QUIRK_FRAME_NO)
234 #define big_endian_frame_no_quirk(ohci) 0