1 --- a/drivers/usb/host/adm5120.h
2 +++ b/drivers/usb/host/adm5120.h
3 @@ -403,6 +403,7 @@ struct admhcd {
4 * other external transceivers should be software-transparent
6 struct otg_transceiver *transceiver;
7 + void (*start_hnp)(struct admhcd *ahcd);
11 @@ -537,15 +538,7 @@ static inline struct usb_hcd *admhcd_to_
12 * Big-endian read/write functions are arch-specific.
13 * Other arches can be added if/when they're needed.
15 - * REVISIT: arch/powerpc now has readl/writel_be, so the
16 - * definition below can die once the STB04xxx support is
17 - * finally ported over.
19 -#if defined(CONFIG_PPC) && !defined(CONFIG_PPC_MERGE)
20 -#define readl_be(addr) in_be32((__force unsigned *)addr)
21 -#define writel_be(val, addr) out_be32((__force unsigned *)addr, val)
24 static inline unsigned int admhc_readl(const struct admhcd *ahcd,
27 --- a/drivers/usb/host/adm5120-drv.c
28 +++ b/drivers/usb/host/adm5120-drv.c
30 * (C) Copyright 2002 Hewlett-Packard Company
32 * Written by Christopher Hoover <ch@hpl.hp.com>
33 - * Based on fragments of previous driver by Rusell King et al.
34 + * Based on fragments of previous driver by Russell King et al.
36 * Modified for LH7A404 from ahcd-sa1111.c
37 * by Durgesh Pattamatta <pattamattad@sharpsec.com>
38 @@ -81,7 +81,7 @@ static int admhc_adm5120_probe(const str
40 admhc_hcd_init(hcd_to_admhcd(hcd));
42 - retval = usb_add_hcd(hcd, irq, IRQF_DISABLED);
43 + retval = usb_add_hcd(hcd, irq, 0);
47 @@ -109,10 +109,7 @@ static void admhc_adm5120_remove(struct
51 -/*-------------------------------------------------------------------------*/
54 -admhc_adm5120_start(struct usb_hcd *hcd)
55 +static int __devinit admhc_adm5120_start(struct usb_hcd *hcd)
57 struct admhcd *ahcd = hcd_to_admhcd(hcd);
59 @@ -137,8 +134,6 @@ err:
63 -/*-------------------------------------------------------------------------*/
65 static const struct hc_driver adm5120_hc_driver = {
66 .description = hcd_name,
67 .product_desc = "ADM5120 built-in USB 1.1 Host Controller",
68 @@ -181,8 +176,6 @@ static const struct hc_driver adm5120_hc
69 .start_port_reset = admhc_start_port_reset,
72 -/*-------------------------------------------------------------------------*/
74 static int usb_hcd_adm5120_probe(struct platform_device *pdev)
77 --- a/drivers/usb/host/adm5120-dbg.c
78 +++ b/drivers/usb/host/adm5120-dbg.c
79 @@ -401,25 +401,28 @@ static const struct file_operations debu
80 .open = debug_async_open,
82 .release = debug_close,
83 + .llseek = default_llseek,
85 static const struct file_operations debug_periodic_fops = {
87 .open = debug_periodic_open,
89 .release = debug_close,
90 + .llseek = default_llseek,
92 static const struct file_operations debug_registers_fops = {
94 .open = debug_registers_open,
96 .release = debug_close,
97 + .llseek = default_llseek,
100 static struct dentry *admhc_debug_root;
102 struct debug_buffer {
103 ssize_t (*fill_func)(struct debug_buffer *); /* fill method */
104 - struct device *dev;
105 + struct admhcd *ahcd;
106 struct mutex mutex; /* protect filling of buffer */
107 size_t count; /* number of characters filled into buffer */
109 @@ -494,15 +497,11 @@ show_list(struct admhcd *ahcd, char *buf
111 static ssize_t fill_async_buffer(struct debug_buffer *buf)
113 - struct usb_bus *bus;
114 - struct usb_hcd *hcd;
119 - bus = dev_get_drvdata(buf->dev);
120 - hcd = bus_to_hcd(bus);
121 - ahcd = hcd_to_admhcd(hcd);
124 spin_lock_irqsave(&ahcd->lock, flags);
125 temp = show_list(ahcd, buf->page, PAGE_SIZE, ahcd->ed_head);
126 @@ -516,8 +515,6 @@ static ssize_t fill_async_buffer(struct
128 static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
130 - struct usb_bus *bus;
131 - struct usb_hcd *hcd;
133 struct ed **seen, *ed;
135 @@ -530,9 +527,7 @@ static ssize_t fill_periodic_buffer(stru
139 - bus = dev_get_drvdata(buf->dev);
140 - hcd = bus_to_hcd(bus);
141 - ahcd = hcd_to_admhcd(hcd);
146 @@ -615,7 +610,6 @@ static ssize_t fill_periodic_buffer(stru
148 static ssize_t fill_registers_buffer(struct debug_buffer *buf)
150 - struct usb_bus *bus;
153 struct admhcd_regs __iomem *regs;
154 @@ -624,9 +618,8 @@ static ssize_t fill_registers_buffer(str
158 - bus = dev_get_drvdata(buf->dev);
159 - hcd = bus_to_hcd(bus);
160 - ahcd = hcd_to_admhcd(hcd);
162 + hcd = admhc_to_hcd(ahcd);
166 @@ -638,13 +631,13 @@ static ssize_t fill_registers_buffer(str
167 admhc_dbg_sw(ahcd, &next, &size,
168 "bus %s, device %s\n"
170 - "%s version " DRIVER_VERSION "\n",
172 hcd->self.controller->bus->name,
173 dev_name(hcd->self.controller),
177 - if (bus->controller->power.power_state.event) {
178 + if (!HCD_HW_ACCESSIBLE(hcd)) {
179 size -= scnprintf(next, size,
180 "SUSPENDED (no register access)\n");
182 @@ -691,7 +684,7 @@ done:
186 -static struct debug_buffer *alloc_buffer(struct device *dev,
187 +static struct debug_buffer *alloc_buffer(struct admhcd *ahcd,
188 ssize_t (*fill_func)(struct debug_buffer *))
190 struct debug_buffer *buf;
191 @@ -699,7 +692,7 @@ static struct debug_buffer *alloc_buffer
192 buf = kzalloc(sizeof(struct debug_buffer), GFP_KERNEL);
197 buf->fill_func = fill_func;
198 mutex_init(&buf->mutex);
200 @@ -792,26 +785,25 @@ static int debug_registers_open(struct i
201 static inline void create_debug_files(struct admhcd *ahcd)
203 struct usb_bus *bus = &admhcd_to_hcd(ahcd)->self;
204 - struct device *dev = bus->dev;
206 ahcd->debug_dir = debugfs_create_dir(bus->bus_name, admhc_debug_root);
207 if (!ahcd->debug_dir)
210 ahcd->debug_async = debugfs_create_file("async", S_IRUGO,
211 - ahcd->debug_dir, dev,
212 + ahcd->debug_dir, ahcd,
214 if (!ahcd->debug_async)
217 ahcd->debug_periodic = debugfs_create_file("periodic", S_IRUGO,
218 - ahcd->debug_dir, dev,
219 + ahcd->debug_dir, ahcd,
220 &debug_periodic_fops);
221 if (!ahcd->debug_periodic)
224 ahcd->debug_registers = debugfs_create_file("registers", S_IRUGO,
225 - ahcd->debug_dir, dev,
226 + ahcd->debug_dir, ahcd,
227 &debug_registers_fops);
228 if (!ahcd->debug_registers)
229 goto registers_error;
230 --- a/drivers/usb/host/adm5120-pm.c
231 +++ b/drivers/usb/host/adm5120-pm.c
232 @@ -257,7 +257,7 @@ static int admhc_bus_suspend(struct usb_
234 spin_lock_irq(&ahcd->lock);
236 - if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
237 + if (unlikely(!HCD_HW_ACCESSIBLE(hcd)))
240 rc = admhc_rh_suspend(ahcd, 0);
241 @@ -275,7 +275,7 @@ static int admhc_bus_resume(struct usb_h
243 spin_lock_irq(&ahcd->lock);
245 - if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
246 + if (unlikely(!HCD_HW_ACCESSIBLE(hcd)))
249 rc = admhc_rh_resume(ahcd);
250 --- a/drivers/usb/host/adm5120-hcd.c
251 +++ b/drivers/usb/host/adm5120-hcd.c
253 #include <linux/list.h>
254 #include <linux/usb.h>
255 #include <linux/usb/otg.h>
256 +#include <linux/usb/hcd.h>
257 #include <linux/dma-mapping.h>
258 #include <linux/dmapool.h>
259 -#include <linux/reboot.h>
260 #include <linux/debugfs.h>
261 #include <linux/io.h>
264 #include <asm/unaligned.h>
265 #include <asm/byteorder.h>
267 -#include "../core/hcd.h"
268 -#include "../core/hub.h"
270 #define DRIVER_VERSION "0.27.0"
271 #define DRIVER_AUTHOR "Gabor Juhos <juhosg@openwrt.org>"
272 #define DRIVER_DESC "ADMtek USB 1.1 Host Controller Driver"
273 @@ -117,7 +114,7 @@ static int admhc_urb_enqueue(struct usb_
277 - /* one TD for every 4096 Bytes (can be upto 8K) */
278 + /* one TD for every 4096 Bytes (can be up to 8K) */
279 td_cnt += urb->transfer_buffer_length / TD_DATALEN_MAX;
280 /* ... and for any remaining bytes ... */
281 if ((urb->transfer_buffer_length % TD_DATALEN_MAX) != 0)
282 @@ -153,7 +150,7 @@ static int admhc_urb_enqueue(struct usb_
284 spin_lock_irqsave(&ahcd->lock, flags);
285 /* don't submit to a dead HC */
286 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) {
287 + if (!HCD_HW_ACCESSIBLE(hcd)) {
291 @@ -321,7 +318,6 @@ sanitize:
294 spin_unlock_irqrestore(&ahcd->lock, flags);
298 static int admhc_get_frame_number(struct usb_hcd *hcd)
299 @@ -488,7 +484,7 @@ err:
301 static int admhc_run(struct admhcd *ahcd)
305 int first = ahcd->fminterval == 0;
306 struct usb_hcd *hcd = admhcd_to_hcd(ahcd);
308 @@ -496,8 +492,8 @@ static int admhc_run(struct admhcd *ahcd
310 /* boot firmware should have set this up (5.1.1.3.1) */
312 - temp = admhc_readl(ahcd, &ahcd->regs->fminterval);
313 - ahcd->fminterval = temp & ADMHC_SFI_FI_MASK;
314 + val = admhc_readl(ahcd, &ahcd->regs->fminterval);
315 + ahcd->fminterval = val & ADMHC_SFI_FI_MASK;
316 if (ahcd->fminterval != FI)
317 admhc_dbg(ahcd, "fminterval delta %d\n",
318 ahcd->fminterval - FI);
319 @@ -507,30 +503,30 @@ static int admhc_run(struct admhcd *ahcd
322 #if 0 /* TODO: not applicable */
323 - /* Reset USB nearly "by the book". RemoteWakeupConnected was
324 - * saved if boot firmware (BIOS/SMM/...) told us it's connected,
325 - * or if bus glue did the same (e.g. for PCI add-in cards with
327 + /* Reset USB nearly "by the book". RemoteWakeupConnected has
328 + * to be checked in case boot firmware (BIOS/SMM/...) has set up
329 + * wakeup in a way the bus isn't aware of (e.g., legacy PCI PM).
330 + * If the bus glue detected wakeup capability then it should
331 + * already be enabled; if so we'll just enable it again.
333 - if ((ahcd->hc_control & OHCI_CTRL_RWC) != 0
334 - && !device_may_wakeup(hcd->self.controller))
335 - device_init_wakeup(hcd->self.controller, 1);
336 + if ((ahcd->hc_control & OHCI_CTRL_RWC) != 0)
337 + device_set_wakeup_capable(hcd->self.controller, 1);
340 switch (ahcd->host_control & ADMHC_HC_BUSS) {
341 case ADMHC_BUSS_OPER:
345 case ADMHC_BUSS_SUSPEND:
347 case ADMHC_BUSS_RESUME:
348 ahcd->host_control = ADMHC_BUSS_RESUME;
349 - temp = 10 /* msec wait */;
350 + val = 10 /* msec wait */;
352 /* case ADMHC_BUSS_RESET: */
354 ahcd->host_control = ADMHC_BUSS_RESET;
355 - temp = 50 /* msec wait */;
356 + val = 50 /* msec wait */;
359 admhc_writel(ahcd, ahcd->host_control, &ahcd->regs->host_control);
360 @@ -538,12 +534,12 @@ static int admhc_run(struct admhcd *ahcd
361 /* flush the writes */
362 admhc_writel_flush(ahcd);
365 - temp = admhc_read_rhdesc(ahcd);
366 - if (!(temp & ADMHC_RH_NPS)) {
368 + val = admhc_read_rhdesc(ahcd);
369 + if (!(val & ADMHC_RH_NPS)) {
370 /* power down each port */
371 - for (temp = 0; temp < ahcd->num_ports; temp++)
372 - admhc_write_portstatus(ahcd, temp, ADMHC_PS_CPP);
373 + for (val = 0; val < ahcd->num_ports; val++)
374 + admhc_write_portstatus(ahcd, val, ADMHC_PS_CPP);
376 /* flush those writes */
377 admhc_writel_flush(ahcd);
378 @@ -552,9 +548,9 @@ static int admhc_run(struct admhcd *ahcd
379 spin_lock_irq(&ahcd->lock);
381 admhc_writel(ahcd, ADMHC_CTRL_SR, &ahcd->regs->gencontrol);
382 - temp = 30; /* ... allow extra time */
383 + val = 30; /* ... allow extra time */
384 while ((admhc_readl(ahcd, &ahcd->regs->gencontrol) & ADMHC_CTRL_SR) != 0) {
387 spin_unlock_irq(&ahcd->lock);
388 admhc_err(ahcd, "USB HC reset timed out!\n");
390 @@ -571,7 +567,7 @@ static int admhc_run(struct admhcd *ahcd
391 periodic_reinit(ahcd);
393 /* use rhsc irqs after khubd is fully initialized */
395 + set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
396 hcd->uses_new_polling = 1;
399 @@ -594,10 +590,10 @@ static int admhc_run(struct admhcd *ahcd
400 ahcd->host_control = ADMHC_BUSS_OPER;
401 admhc_writel(ahcd, ahcd->host_control, &ahcd->regs->host_control);
405 while ((admhc_readl(ahcd, &ahcd->regs->host_control)
406 & ADMHC_HC_BUSS) != ADMHC_BUSS_OPER) {
409 spin_unlock_irq(&ahcd->lock);
410 admhc_err(ahcd, "unable to setup operational mode!\n");
412 @@ -613,10 +609,10 @@ static int admhc_run(struct admhcd *ahcd
413 /* FIXME: enabling DMA is always failed here for an unknown reason */
414 admhc_dma_enable(ahcd);
418 while ((admhc_readl(ahcd, &ahcd->regs->host_control)
419 & ADMHC_HC_DMAE) != ADMHC_HC_DMAE) {
422 spin_unlock_irq(&ahcd->lock);
423 admhc_err(ahcd, "unable to enable DMA!\n");
425 @@ -688,7 +684,7 @@ static irqreturn_t admhc_irq(struct usb_
427 admhc_vdbg(ahcd, "Resume Detect\n");
428 admhc_intr_ack(ahcd, ADMHC_INTR_RESI);
430 + set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
431 if (ahcd->autostop) {
432 spin_lock(&ahcd->lock);
433 admhc_rh_resume(ahcd);
434 @@ -799,9 +795,10 @@ static int __init admhc_hcd_mod_init(voi
435 pr_info("%s: " DRIVER_INFO "\n", hcd_name);
436 pr_info("%s: block sizes: ed %Zd td %Zd\n", hcd_name,
437 sizeof(struct ed), sizeof(struct td));
438 + set_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
441 - admhc_debug_root = debugfs_create_dir("admhc", NULL);
442 + admhc_debug_root = debugfs_create_dir("admhc", usb_debug_root);
443 if (!admhc_debug_root) {
446 @@ -826,6 +823,7 @@ error_platform:
447 admhc_debug_root = NULL;
450 + clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
453 module_init(admhc_hcd_mod_init);
454 @@ -836,6 +834,7 @@ static void __exit admhc_hcd_mod_exit(vo
456 debugfs_remove(admhc_debug_root);
458 + clear_bit(USB_OHCI_LOADED, &usb_hcds_loaded);
460 module_exit(admhc_hcd_mod_exit);
462 --- a/drivers/usb/host/adm5120-hub.c
463 +++ b/drivers/usb/host/adm5120-hub.c
464 @@ -75,7 +75,7 @@ admhc_hub_status_data(struct usb_hcd *hc
467 spin_lock_irqsave(&ahcd->lock, flags);
468 - if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags))
469 + if (!HCD_HW_ACCESSIBLE(hcd))
473 @@ -106,8 +106,11 @@ admhc_hub_status_data(struct usb_hcd *hc
477 - hcd->poll_rh = admhc_root_hub_state_changes(ahcd, changed,
479 + if (admhc_root_hub_state_changes(ahcd, changed,
481 + set_bit(HCD_FLAG_POLL_RH, &hcd->flags);
483 + clear_bit(HCD_FLAG_POLL_RH, &hcd->flags);
486 spin_unlock_irqrestore(&ahcd->lock, flags);
487 @@ -143,9 +146,9 @@ static int admhc_get_hub_descriptor(stru
489 desc->wHubCharacteristics = (__force __u16)cpu_to_hc16(ahcd, temp);
491 - /* two bitmaps: ports removable, and usb 1.0 legacy PortPwrCtrlMask */
492 - desc->bitmap[0] = 0;
493 - desc->bitmap[0] = ~0;
494 + /* ports removable, and usb 1.0 legacy PortPwrCtrlMask */
495 + desc->u.hs.DeviceRemovable[0] = 0;
496 + desc->u.hs.DeviceRemovable[0] = ~0;
500 @@ -310,10 +313,10 @@ static int admhc_hub_control(struct usb_
501 u16 wIndex, char *buf, u16 wLength)
503 struct admhcd *ahcd = hcd_to_admhcd(hcd);
504 - int ports = hcd_to_bus(hcd)->root_hub->maxchild;
505 + int ports = ahcd->num_ports;
508 - if (unlikely(!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)))
509 + if (unlikely(!HCD_HW_ACCESSIBLE(hcd)))
513 --- a/drivers/usb/host/adm5120-q.c
514 +++ b/drivers/usb/host/adm5120-q.c
518 #include <linux/irq.h>
519 +#include <linux/slab.h>
521 /*-------------------------------------------------------------------------*/
523 @@ -300,7 +301,7 @@ static struct ed *ed_get(struct admhcd *
526 /* FIXME: usbcore changes dev->devnum before SET_ADDRESS
527 - * suceeds ... otherwise we wouldn't need "pipe".
528 + * succeeds ... otherwise we wouldn't need "pipe".
530 info = usb_pipedevice(pipe);
531 info |= (ep->desc.bEndpointAddress & ~USB_DIR_IN) << ED_EN_SHIFT;
532 @@ -634,8 +635,7 @@ static int td_done(struct admhcd *ahcd,
534 /*-------------------------------------------------------------------------*/
537 -ed_halted(struct admhcd *ahcd, struct td *td, int cc, struct td *rev)
538 +static void ed_halted(struct admhcd *ahcd, struct td *td, int cc)
540 struct urb *urb = td->urb;
541 struct urb_priv *urb_priv = urb->hcpriv;
542 @@ -764,6 +764,7 @@ rescan_this:
544 struct urb_priv *urb_priv;
549 td = list_entry(entry, struct td, td_list);
550 @@ -781,6 +782,16 @@ rescan_this:
551 /* patch pointer hc uses */
552 savebits = *prev & ~cpu_to_hc32(ahcd, TD_MASK);
553 *prev = td->hwNextTD | savebits;
554 + /* If this was unlinked, the TD may not have been
555 + * retired ... so manually save dhe data toggle.
556 + * The controller ignores the value we save for
557 + * control and ISO endpoints.
559 + tdINFO = hc32_to_cpup(ahcd, &td->hwINFO);
560 + if ((tdINFO & TD_T) == TD_T_DATA0)
561 + ed->hwHeadP &= ~cpu_to_hc32(ahcd, ED_C);
562 + else if ((tdINFO & TD_T) == TD_T_DATA1)
563 + ed->hwHeadP |= cpu_to_hc32(ahcd, ED_C);
565 /* HC may have partly processed this TD */
566 #ifdef ADMHC_VERBOSE_DEBUG
567 @@ -816,13 +827,12 @@ rescan_this:
570 /*-------------------------------------------------------------------------*/
573 * Process normal completions (error or success) and clean the schedules.
575 * This is the main path for handing urbs back to drivers. The only other
576 - * path is finish_unlinks(), which unlinks URBs using ed_rm_list, instead of
577 - * scanning the (re-reversed) donelist as this does.
578 + * normal path is finish_unlinks(), which unlinks URBs using ed_rm_list,
579 + * instead of scanning the (re-reversed) donelist as this does.
582 static void ed_unhalt(struct admhcd *ahcd, struct ed *ed, struct urb *urb)