1 Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
3 drivers/usb/host/ohci-bcm63xx.c | 166 +++++++++++++++++++++++++++++++++++++++
4 drivers/usb/host/ohci-hcd.c | 5 +
5 drivers/usb/host/ohci.h | 2 +-
6 3 files changed, 172 insertions(+), 1 deletions(-)
7 create mode 100644 drivers/usb/host/ohci-bcm63xx.c
9 diff --git a/drivers/usb/host/ohci-bcm63xx.c b/drivers/usb/host/ohci-bcm63xx.c
11 index 0000000..c9bccec
13 +++ b/drivers/usb/host/ohci-bcm63xx.c
16 + * This file is subject to the terms and conditions of the GNU General Public
17 + * License. See the file "COPYING" in the main directory of this archive
20 + * Copyright (C) 2010 Maxime Bizon <mbizon@freebox.fr>
23 +#include <linux/init.h>
24 +#include <linux/clk.h>
25 +#include <linux/platform_device.h>
26 +#include <bcm63xx_cpu.h>
27 +#include <bcm63xx_regs.h>
28 +#include <bcm63xx_io.h>
30 +static struct clk *usb_host_clock;
32 +static int __devinit ohci_bcm63xx_start(struct usb_hcd *hcd)
34 + struct ohci_hcd *ohci = hcd_to_ohci(hcd);
38 + * port 2 can be shared with USB slave, but all boards seem to
39 + * have only one host port populated, so we can hardcode it
41 + ohci->num_ports = 1;
43 + ret = ohci_init(ohci);
47 + ret = ohci_run(ohci);
49 + err("can't start %s", hcd->self.bus_name);
56 +static const struct hc_driver ohci_bcm63xx_hc_driver = {
57 + .description = hcd_name,
58 + .product_desc = "BCM63XX integrated OHCI controller",
59 + .hcd_priv_size = sizeof(struct ohci_hcd),
62 + .flags = HCD_USB11 | HCD_MEMORY,
63 + .start = ohci_bcm63xx_start,
65 + .shutdown = ohci_shutdown,
66 + .urb_enqueue = ohci_urb_enqueue,
67 + .urb_dequeue = ohci_urb_dequeue,
68 + .endpoint_disable = ohci_endpoint_disable,
69 + .get_frame_number = ohci_get_frame,
70 + .hub_status_data = ohci_hub_status_data,
71 + .hub_control = ohci_hub_control,
72 + .start_port_reset = ohci_start_port_reset,
75 +static int __devinit ohci_hcd_bcm63xx_drv_probe(struct platform_device *pdev)
77 + struct resource *res_mem;
78 + struct usb_hcd *hcd;
79 + struct ohci_hcd *ohci;
83 + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
84 + irq = platform_get_irq(pdev, 0);
85 + if (!res_mem || irq < 0)
88 + if (BCMCPU_IS_6348()) {
90 + /* enable USB host clock */
91 + clk = clk_get(&pdev->dev, "usbh");
96 + usb_host_clock = clk;
97 + bcm_rset_writel(RSET_OHCI_PRIV, 0, OHCI_PRIV_REG);
99 + } else if (BCMCPU_IS_6358()) {
100 + reg = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_REG);
101 + reg &= ~USBH_PRIV_SWAP_OHCI_ENDN_MASK;
102 + reg |= USBH_PRIV_SWAP_OHCI_DATA_MASK;
103 + bcm_rset_writel(RSET_USBH_PRIV, reg, USBH_PRIV_SWAP_REG);
105 + * The magic value comes for the original vendor BSP
106 + * and is needed for USB to work. Datasheet does not
107 + * help, so the magic value is used as-is.
109 + bcm_rset_writel(RSET_USBH_PRIV, 0x1c0020, USBH_PRIV_TEST_REG);
113 + hcd = usb_create_hcd(&ohci_bcm63xx_hc_driver, &pdev->dev, "bcm63xx");
116 + hcd->rsrc_start = res_mem->start;
117 + hcd->rsrc_len = res_mem->end - res_mem->start + 1;
119 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
120 + pr_debug("request_mem_region failed\n");
125 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
127 + pr_debug("ioremap failed\n");
132 + ohci = hcd_to_ohci(hcd);
133 + ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC |
134 + OHCI_QUIRK_FRAME_NO;
135 + ohci_hcd_init(ohci);
137 + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
141 + platform_set_drvdata(pdev, hcd);
145 + iounmap(hcd->regs);
147 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
153 +static int __devexit ohci_hcd_bcm63xx_drv_remove(struct platform_device *pdev)
155 + struct usb_hcd *hcd;
157 + hcd = platform_get_drvdata(pdev);
158 + usb_remove_hcd(hcd);
159 + iounmap(hcd->regs);
161 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
162 + if (usb_host_clock) {
163 + clk_disable(usb_host_clock);
164 + clk_put(usb_host_clock);
166 + platform_set_drvdata(pdev, NULL);
170 +static struct platform_driver ohci_hcd_bcm63xx_driver = {
171 + .probe = ohci_hcd_bcm63xx_drv_probe,
172 + .remove = __devexit_p(ohci_hcd_bcm63xx_drv_remove),
173 + .shutdown = usb_hcd_platform_shutdown,
175 + .name = "bcm63xx_ohci",
176 + .owner = THIS_MODULE,
180 +MODULE_ALIAS("platform:bcm63xx_ohci");
181 diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
182 index 24eb747..1c82a60 100644
183 --- a/drivers/usb/host/ohci-hcd.c
184 +++ b/drivers/usb/host/ohci-hcd.c
185 @@ -1051,6 +1051,11 @@ MODULE_LICENSE ("GPL");
186 #define PLATFORM_DRIVER usb_hcd_pnx4008_driver
189 +#ifdef CONFIG_BCM63XX
190 +#include "ohci-bcm63xx.c"
191 +#define PLATFORM_DRIVER ohci_hcd_bcm63xx_driver
194 #if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
195 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
196 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
197 diff --git a/drivers/usb/host/ohci.h b/drivers/usb/host/ohci.h
198 index 5bf15fe..3c54d3e 100644
199 --- a/drivers/usb/host/ohci.h
200 +++ b/drivers/usb/host/ohci.h
201 @@ -655,7 +655,7 @@ static inline u32 hc32_to_cpup (const struct ohci_hcd *ohci, const __hc32 *x)
202 * some big-endian SOC implementations. Same thing happens with PSW access.
205 -#ifdef CONFIG_PPC_MPC52xx
206 +#if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_BCM63XX)
207 #define big_endian_frame_no_quirk(ohci) (ohci->flags & OHCI_QUIRK_FRAME_NO)
209 #define big_endian_frame_no_quirk(ohci) 0