[brcm63xx] add support for 2.6.32, dropped the SPI patch for now
[openwrt.git] / target / linux / brcm63xx / patches-2.6.32 / 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 diff --git a/drivers/usb/host/ehci-bcm63xx.c b/drivers/usb/host/ehci-bcm63xx.c
9 new file mode 100644
10 index 0000000..50638f7
11 --- /dev/null
12 +++ b/drivers/usb/host/ehci-bcm63xx.c
13 @@ -0,0 +1,154 @@
14 +/*
15 + * This file is subject to the terms and conditions of the GNU General Public
16 + * License. See the file "COPYING" in the main directory of this archive
17 + * for more details.
18 + *
19 + * Copyright (C) 2008 Maxime Bizon <mbizon@freebox.fr>
20 + */
21 +
22 +#include <linux/init.h>
23 +#include <linux/platform_device.h>
24 +#include <bcm63xx_cpu.h>
25 +#include <bcm63xx_regs.h>
26 +#include <bcm63xx_io.h>
27 +
28 +static int ehci_bcm63xx_setup(struct usb_hcd *hcd)
29 +{
30 + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
31 + int retval;
32 +
33 + retval = ehci_halt(ehci);
34 + if (retval)
35 + return retval;
36 +
37 + retval = ehci_init(hcd);
38 + if (retval)
39 + return retval;
40 +
41 + ehci_reset(ehci);
42 + ehci_port_power(ehci, 0);
43 +
44 + return retval;
45 +}
46 +
47 +
48 +static const struct hc_driver ehci_bcm63xx_hc_driver = {
49 + .description = hcd_name,
50 + .product_desc = "BCM63XX integrated EHCI controller",
51 + .hcd_priv_size = sizeof(struct ehci_hcd),
52 +
53 + .irq = ehci_irq,
54 + .flags = HCD_MEMORY | HCD_USB2,
55 +
56 + .reset = ehci_bcm63xx_setup,
57 + .start = ehci_run,
58 + .stop = ehci_stop,
59 + .shutdown = ehci_shutdown,
60 +
61 + .urb_enqueue = ehci_urb_enqueue,
62 + .urb_dequeue = ehci_urb_dequeue,
63 + .endpoint_disable = ehci_endpoint_disable,
64 +
65 + .get_frame_number = ehci_get_frame,
66 +
67 + .hub_status_data = ehci_hub_status_data,
68 + .hub_control = ehci_hub_control,
69 + .bus_suspend = ehci_bus_suspend,
70 + .bus_resume = ehci_bus_resume,
71 + .relinquish_port = ehci_relinquish_port,
72 + .port_handed_over = ehci_port_handed_over,
73 +};
74 +
75 +static int __devinit ehci_hcd_bcm63xx_drv_probe(struct platform_device *pdev)
76 +{
77 + struct resource *res_mem;
78 + struct usb_hcd *hcd;
79 + struct ehci_hcd *ehci;
80 + u32 reg;
81 + int ret, irq;
82 +
83 + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
84 + irq = platform_get_irq(pdev, 0);;
85 + if (!res_mem || irq < 0)
86 + return -ENODEV;
87 +
88 + reg = bcm_rset_readl(RSET_USBH_PRIV, USBH_PRIV_SWAP_REG);
89 + reg &= ~USBH_PRIV_SWAP_EHCI_DATA_MASK;
90 + reg |= USBH_PRIV_SWAP_EHCI_ENDN_MASK;
91 + bcm_rset_writel(RSET_USBH_PRIV, reg, USBH_PRIV_SWAP_REG);
92 +
93 + /*
94 + * The magic value comes for the original vendor BSP and is
95 + * needed for USB to work. Datasheet does not help, so the
96 + * magic value is used as-is.
97 + */
98 + bcm_rset_writel(RSET_USBH_PRIV, 0x1c0020, USBH_PRIV_TEST_REG);
99 +
100 + hcd = usb_create_hcd(&ehci_bcm63xx_hc_driver, &pdev->dev, "bcm63xx");
101 + if (!hcd)
102 + return -ENOMEM;
103 + hcd->rsrc_start = res_mem->start;
104 + hcd->rsrc_len = res_mem->end - res_mem->start + 1;
105 +
106 + if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
107 + pr_debug("request_mem_region failed\n");
108 + ret = -EBUSY;
109 + goto out;
110 + }
111 +
112 + hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
113 + if (!hcd->regs) {
114 + pr_debug("ioremap failed\n");
115 + ret = -EIO;
116 + goto out1;
117 + }
118 +
119 + ehci = hcd_to_ehci(hcd);
120 + ehci->big_endian_mmio = 1;
121 + ehci->big_endian_desc = 0;
122 + ehci->caps = hcd->regs;
123 + ehci->regs = hcd->regs +
124 + HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
125 + ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
126 + ehci->sbrn = 0x20;
127 +
128 + ret = usb_add_hcd(hcd, irq, IRQF_DISABLED);
129 + if (ret)
130 + goto out2;
131 +
132 + platform_set_drvdata(pdev, hcd);
133 + return 0;
134 +
135 +out2:
136 + iounmap(hcd->regs);
137 +out1:
138 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
139 +out:
140 + usb_put_hcd(hcd);
141 + return ret;
142 +}
143 +
144 +static int __devexit ehci_hcd_bcm63xx_drv_remove(struct platform_device *pdev)
145 +{
146 + struct usb_hcd *hcd;
147 +
148 + hcd = platform_get_drvdata(pdev);
149 + usb_remove_hcd(hcd);
150 + iounmap(hcd->regs);
151 + usb_put_hcd(hcd);
152 + release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
153 + platform_set_drvdata(pdev, NULL);
154 + return 0;
155 +}
156 +
157 +static struct platform_driver ehci_hcd_bcm63xx_driver = {
158 + .probe = ehci_hcd_bcm63xx_drv_probe,
159 + .remove = __devexit_p(ehci_hcd_bcm63xx_drv_remove),
160 + .shutdown = usb_hcd_platform_shutdown,
161 + .driver = {
162 + .name = "bcm63xx_ehci",
163 + .owner = THIS_MODULE,
164 + },
165 +};
166 +
167 +MODULE_ALIAS("platform:bcm63xx_ehci");
168 diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
169 index 1ec3857..8e7c61e 100644
170 --- a/drivers/usb/host/ehci-hcd.c
171 +++ b/drivers/usb/host/ehci-hcd.c
172 @@ -1158,6 +1158,11 @@ MODULE_LICENSE ("GPL");
173 #define PLATFORM_DRIVER ehci_atmel_driver
174 #endif
175
176 +#ifdef CONFIG_BCM63XX
177 +#include "ehci-bcm63xx.c"
178 +#define PLATFORM_DRIVER ehci_hcd_bcm63xx_driver
179 +#endif
180 +
181 #if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
182 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER)
183 #error "missing bus glue for ehci-hcd"
184 --
185 1.6.3.3
186
187
This page took 0.073452 seconds and 5 git commands to generate.