331753bd5a98bc4d79992639162b0839c2a48762
[openwrt.git] / target / linux / brcm63xx / patches-2.6.35 / 011-add_bcm63xx_ehci_controller.patch
1 Signed-off-by: Maxime Bizon <mbizon@freebox.fr>
2 ---
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
7
8 --- /dev/null
9 +++ b/drivers/usb/host/ehci-bcm63xx.c
10 @@ -0,0 +1,154 @@
11 +/*
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
14 + * for more details.
15 + *
16 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
17 + */
18 +
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>
24 +
25 +static int ehci_bcm63xx_setup(struct usb_hcd *hcd)
26 +{
27 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
28 + int retval;
29 +
30 + retval = ehci_halt(ehci);
31 + if (retval)
32 + return retval;
33 +
34 + retval = ehci_init(hcd);
35 + if (retval)
36 + return retval;
37 +
38 + ehci_reset(ehci);
39 + ehci_port_power(ehci, 0);
40 +
41 + return retval;
42 +}
43 +
44 +
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),
49 +
50 + .irq = ehci_irq,
51 + .flags = HCD_MEMORY | HCD_USB2,
52 +
53 + .reset = ehci_bcm63xx_setup,
54 + .start = ehci_run,
55 + .stop = ehci_stop,
56 + .shutdown = ehci_shutdown,
57 +
58 + .urb_enqueue = ehci_urb_enqueue,
59 + .urb_dequeue = ehci_urb_dequeue,
60 + .endpoint_disable = ehci_endpoint_disable,
61 +
62 + .get_frame_number = ehci_get_frame,
63 +
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,
70 +};
71 +
72 +static int __devinit ehci_hcd_bcm63xx_drv_probe(struct platform_device *pdev)
73 +{
74 + struct resource *res_mem;
75 + struct usb_hcd *hcd;
76 + struct ehci_hcd *ehci;
77 + u32 reg;
78 + int ret, irq;
79 +
80 + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
81 + irq = platform_get_irq(pdev, 0);;
82 + if (!res_mem || irq < 0)
83 + return -ENODEV;
84 +
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);
89 +
90 + /*
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.
94 + */
95 + bcm_rset_writel(RSET_USBH_PRIV, 0x1c0020, USBH_PRIV_TEST_REG);
96 +
97 + hcd = usb_create_hcd(&ehci_bcm63xx_hc_driver, &pdev->dev, "bcm63xx");
98 + if (!hcd)
99 + return -ENOMEM;
100 + hcd->rsrc_start = res_mem->start;
101 + hcd->rsrc_len = res_mem->end - res_mem->start + 1;
102 +
103 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
104 + pr_debug("request_mem_region failed\n");
105 + ret = -EBUSY;
106 + goto out;
107 + }
108 +
109 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
110 + if (!hcd->regs) {
111 + pr_debug("ioremap failed\n");
112 + ret = -EIO;
113 + goto out1;
114 + }
115 +
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);
123 + ehci->sbrn = 0x20;
124 +
125 + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
126 + if (ret)
127 + goto out2;
128 +
129 + platform_set_drvdata(pdev, hcd);
130 + return 0;
131 +
132 +out2:
133 + iounmap(hcd->regs);
134 +out1:
135 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
136 +out:
137 + usb_put_hcd(hcd);
138 + return ret;
139 +}
140 +
141 +static int __devexit ehci_hcd_bcm63xx_drv_remove(struct platform_device *pdev)
142 +{
143 + struct usb_hcd *hcd;
144 +
145 + hcd = platform_get_drvdata(pdev);
146 + usb_remove_hcd(hcd);
147 + iounmap(hcd->regs);
148 + usb_put_hcd(hcd);
149 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
150 + platform_set_drvdata(pdev, NULL);
151 + return 0;
152 +}
153 +
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,
158 + .driver = {
159 + .name = "bcm63xx_ehci",
160 + .owner = THIS_MODULE,
161 + },
162 +};
163 +
164 +MODULE_ALIAS("platform:bcm63xx_ehci");
165 --- a/drivers/usb/host/ehci-hcd.c
166 +++ b/drivers/usb/host/ehci-hcd.c
167 @@ -1158,6 +1158,11 @@ MODULE_LICENSE ("GPL");
168 #define PLATFORM_DRIVER ehci_atmel_driver
169 #endif
170
171 +#ifdef CONFIG_BCM63XX
172 +#include "ehci-bcm63xx.c"
173 +#define PLATFORM_DRIVER ehci_hcd_bcm63xx_driver
174 +#endif
175 +
176 #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
177 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) && \
178 !defined(XILINX_OF_PLATFORM_DRIVER)
This page took 0.055479 seconds and 3 git commands to generate.