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
10 +++ b/drivers/usb/host/ohci-bcm63xx.c
13 + * This file is subject to the terms and conditions of the GNU General Public
14 + * License. See the file "COPYING" in the main directory of this archive
17 + * Copyright (C) 2010 Maxime Bizon <mbizon@freebox.fr>
20 +#include <linux/init.h>
21 +#include <linux/clk.h>
22 +#include <linux/platform_device.h>
23 +#include <bcm63xx_cpu.h>
24 +#include <bcm63xx_regs.h>
25 +#include <bcm63xx_io.h>
27 +static struct clk *usb_host_clock;
29 +static int __devinit ohci_bcm63xx_start(struct usb_hcd *hcd)
31 + struct ohci_hcd *ohci = hcd_to_ohci(hcd);
35 + * port 2 can be shared with USB slave, but all boards seem to
36 + * have only one host port populated, so we can hardcode it
38 + ohci->num_ports = 1;
40 + ret = ohci_init(ohci);
44 + ret = ohci_run(ohci);
46 + err("can't start %s", hcd->self.bus_name);
53 +static const struct hc_driver ohci_bcm63xx_hc_driver = {
54 + .description = hcd_name,
55 + .product_desc = "BCM63XX integrated OHCI controller",
56 + .hcd_priv_size = sizeof(struct ohci_hcd),
59 + .flags = HCD_USB11 | HCD_MEMORY,
60 + .start = ohci_bcm63xx_start,
62 + .shutdown = ohci_shutdown,
63 + .urb_enqueue = ohci_urb_enqueue,
64 + .urb_dequeue = ohci_urb_dequeue,
65 + .endpoint_disable = ohci_endpoint_disable,
66 + .get_frame_number = ohci_get_frame,
67 + .hub_status_data = ohci_hub_status_data,
68 + .hub_control = ohci_hub_control,
69 + .start_port_reset = ohci_start_port_reset,
72 +static int __devinit ohci_hcd_bcm63xx_drv_probe(struct platform_device *pdev)
74 + struct resource *res_mem;
75 + struct usb_hcd *hcd;
76 + struct ohci_hcd *ohci;
80 + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
81 + irq = platform_get_irq(pdev, 0);
82 + if (!res_mem || irq < 0)
85 + if (BCMCPU_IS_6348()) {
87 + /* enable USB host clock */
88 + clk = clk_get(&pdev->dev, "usbh");
93 + usb_host_clock = clk;
94 + bcm_rset_writel(RSET_OHCI_PRIV, 0, OHCI_PRIV_REG);
96 + } else if (BCMCPU_IS_6358()) {
97 + reg = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_REG);
98 + reg &= ~USBH_PRIV_SWAP_OHCI_ENDN_MASK;
99 + reg |= USBH_PRIV_SWAP_OHCI_DATA_MASK;
100 + bcm_rset_writel(RSET_USBH_PRIV, reg, USBH_PRIV_SWAP_REG);
102 + * The magic value comes for the original vendor BSP
103 + * and is needed for USB to work. Datasheet does not
104 + * help, so the magic value is used as-is.
106 + bcm_rset_writel(RSET_USBH_PRIV, 0x1c0020, USBH_PRIV_TEST_REG);
110 + hcd = usb_create_hcd(&ohci_bcm63xx_hc_driver, &pdev->dev, "bcm63xx");
113 + hcd->rsrc_start = res_mem->start;
114 + hcd->rsrc_len = res_mem->end - res_mem->start + 1;
116 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
117 + pr_debug("request_mem_region failed\n");
122 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
124 + pr_debug("ioremap failed\n");
129 + ohci = hcd_to_ohci(hcd);
130 + ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC |
131 + OHCI_QUIRK_FRAME_NO;
132 + ohci_hcd_init(ohci);
134 + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
138 + platform_set_drvdata(pdev, hcd);
142 + iounmap(hcd->regs);
144 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
150 +static int __devexit ohci_hcd_bcm63xx_drv_remove(struct platform_device *pdev)
152 + struct usb_hcd *hcd;
154 + hcd = platform_get_drvdata(pdev);
155 + usb_remove_hcd(hcd);
156 + iounmap(hcd->regs);
158 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
159 + if (usb_host_clock) {
160 + clk_disable(usb_host_clock);
161 + clk_put(usb_host_clock);
163 + platform_set_drvdata(pdev, NULL);
167 +static struct platform_driver ohci_hcd_bcm63xx_driver = {
168 + .probe = ohci_hcd_bcm63xx_drv_probe,
169 + .remove = __devexit_p(ohci_hcd_bcm63xx_drv_remove),
170 + .shutdown = usb_hcd_platform_shutdown,
172 + .name = "bcm63xx_ohci",
173 + .owner = THIS_MODULE,
177 +MODULE_ALIAS("platform:bcm63xx_ohci");
178 --- a/drivers/usb/host/ohci-hcd.c
179 +++ b/drivers/usb/host/ohci-hcd.c
180 @@ -1051,6 +1051,11 @@ MODULE_LICENSE ("GPL");
181 #define PLATFORM_DRIVER usb_hcd_pnx4008_driver
184 +#ifdef CONFIG_BCM63XX
185 +#include "ohci-bcm63xx.c"
186 +#define PLATFORM_DRIVER ohci_hcd_bcm63xx_driver
189 #if defined(CONFIG_CPU_SUBTYPE_SH7720) || \
190 defined(CONFIG_CPU_SUBTYPE_SH7721) || \
191 defined(CONFIG_CPU_SUBTYPE_SH7763) || \
192 --- a/drivers/usb/host/ohci.h
193 +++ b/drivers/usb/host/ohci.h
194 @@ -655,7 +655,7 @@ static inline u32 hc32_to_cpup (const st
195 * some big-endian SOC implementations. Same thing happens with PSW access.
198 -#ifdef CONFIG_PPC_MPC52xx
199 +#if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_BCM63XX)
200 #define big_endian_frame_no_quirk(ohci) (ohci->flags & OHCI_QUIRK_FRAME_NO)
202 #define big_endian_frame_no_quirk(ohci) 0