2 * ADM5120 HCD (Host Controller Driver) for USB
4 * Copyright (C) 2007-2008 Gabor Juhos <juhosg@openwrt.org>
6 * This file was derived from: drivers/usb/host/ohci-hcd.c
7 * (C) Copyright 1999 Roman Weissgaerber <weissg@vienna.at>
8 * (C) Copyright 2000-2004 David Brownell <dbrownell@users.sourceforge.net>
10 * [ Initialisation is based on Linus' ]
11 * [ uhci code and gregs ahcd fragments ]
12 * [ (C) Copyright 1999 Linus Torvalds ]
13 * [ (C) Copyright 1999 Gregory P. Smith]
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License version 2 as published
17 * by the Free Software Foundation.
21 #include <linux/module.h>
22 #include <linux/moduleparam.h>
23 #include <linux/pci.h>
24 #include <linux/kernel.h>
25 #include <linux/delay.h>
26 #include <linux/ioport.h>
27 #include <linux/sched.h>
28 #include <linux/slab.h>
29 #include <linux/errno.h>
30 #include <linux/init.h>
31 #include <linux/timer.h>
32 #include <linux/list.h>
33 #include <linux/usb.h>
34 #include <linux/usb/otg.h>
35 #include <linux/dma-mapping.h>
36 #include <linux/dmapool.h>
37 #include <linux/reboot.h>
38 #include <linux/debugfs.h>
42 #include <asm/system.h>
43 #include <asm/unaligned.h>
44 #include <asm/byteorder.h>
46 #include "../core/hcd.h"
47 #include "../core/hub.h"
49 #define DRIVER_VERSION "0.27.0"
50 #define DRIVER_AUTHOR "Gabor Juhos <juhosg@openwrt.org>"
51 #define DRIVER_DESC "ADMtek USB 1.1 Host Controller Driver"
53 /*-------------------------------------------------------------------------*/
55 #undef ADMHC_VERBOSE_DEBUG /* not always helpful */
57 /* For initializing controller (mask in an HCFS mode too) */
58 #define OHCI_CONTROL_INIT OHCI_CTRL_CBSR
60 #define ADMHC_INTR_INIT \
61 ( ADMHC_INTR_MIE | ADMHC_INTR_INSM | ADMHC_INTR_FATI \
62 | ADMHC_INTR_RESI | ADMHC_INTR_TDC | ADMHC_INTR_BABI )
64 /*-------------------------------------------------------------------------*/
66 static const char hcd_name
[] = "admhc-hcd";
68 #define STATECHANGE_DELAY msecs_to_jiffies(300)
72 static void admhc_dump(struct admhcd
*ahcd
, int verbose
);
73 static int admhc_init(struct admhcd
*ahcd
);
74 static void admhc_stop(struct usb_hcd
*hcd
);
76 #include "adm5120-dbg.c"
77 #include "adm5120-mem.c"
78 #include "adm5120-pm.c"
79 #include "adm5120-hub.c"
80 #include "adm5120-q.c"
82 /*-------------------------------------------------------------------------*/
85 * queue up an urb for anything except the root hub
87 static int admhc_urb_enqueue(struct usb_hcd
*hcd
, struct urb
*urb
,
90 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
92 struct urb_priv
*urb_priv
;
93 unsigned int pipe
= urb
->pipe
;
98 #ifdef ADMHC_VERBOSE_DEBUG
99 spin_lock_irqsave(&ahcd
->lock
, flags
);
100 urb_print(ahcd
, urb
, "ENQEUE", usb_pipein(pipe
), -EINPROGRESS
);
101 spin_unlock_irqrestore(&ahcd
->lock
, flags
);
104 /* every endpoint has an ed, locate and maybe (re)initialize it */
105 ed
= ed_get(ahcd
, urb
->ep
, urb
->dev
, pipe
, urb
->interval
);
109 /* for the private part of the URB we need the number of TDs */
112 if (urb
->transfer_buffer_length
> TD_DATALEN_MAX
)
113 /* td_submit_urb() doesn't yet handle these */
116 /* 1 TD for setup, 1 for ACK, plus ... */
120 /* one TD for every 4096 Bytes (can be upto 8K) */
121 td_cnt
+= urb
->transfer_buffer_length
/ TD_DATALEN_MAX
;
122 /* ... and for any remaining bytes ... */
123 if ((urb
->transfer_buffer_length
% TD_DATALEN_MAX
) != 0)
125 /* ... and maybe a zero length packet to wrap it up */
128 else if ((urb
->transfer_flags
& URB_ZERO_PACKET
) != 0
129 && (urb
->transfer_buffer_length
130 % usb_maxpacket(urb
->dev
, pipe
,
131 usb_pipeout (pipe
))) == 0)
136 * for Interrupt IN/OUT transactions, each ED contains
138 * TODO: check transfer_buffer_length?
142 case PIPE_ISOCHRONOUS
:
143 /* number of packets from URB */
144 td_cnt
= urb
->number_of_packets
;
148 urb_priv
= urb_priv_alloc(ahcd
, td_cnt
, mem_flags
);
154 spin_lock_irqsave(&ahcd
->lock
, flags
);
155 /* don't submit to a dead HC */
156 if (!test_bit(HCD_FLAG_HW_ACCESSIBLE
, &hcd
->flags
)) {
160 if (!HC_IS_RUNNING(hcd
->state
)) {
165 ret
= usb_hcd_link_urb_to_ep(hcd
, urb
);
169 /* schedule the ed if needed */
170 if (ed
->state
== ED_IDLE
) {
171 ret
= ed_schedule(ahcd
, ed
);
173 usb_hcd_unlink_urb_from_ep(hcd
, urb
);
176 if (ed
->type
== PIPE_ISOCHRONOUS
) {
177 u16 frame
= admhc_frame_no(ahcd
);
179 /* delay a few frames before the first TD */
180 frame
+= max_t (u16
, 8, ed
->interval
);
181 frame
&= ~(ed
->interval
- 1);
183 urb
->start_frame
= frame
;
185 /* yes, only URB_ISO_ASAP is supported, and
186 * urb->start_frame is never used as input.
189 } else if (ed
->type
== PIPE_ISOCHRONOUS
)
190 urb
->start_frame
= ed
->last_iso
+ ed
->interval
;
192 /* fill the TDs and link them to the ed; and
193 * enable that part of the schedule, if needed
194 * and update count of queued periodic urbs
196 urb
->hcpriv
= urb_priv
;
197 td_submit_urb(ahcd
, urb
);
199 #ifdef ADMHC_VERBOSE_DEBUG
200 admhc_dump_ed(ahcd
, "admhc_urb_enqueue", urb_priv
->ed
, 1);
205 urb_priv_free(ahcd
, urb_priv
);
207 spin_unlock_irqrestore(&ahcd
->lock
, flags
);
212 * decouple the URB from the HC queues (TDs, urb_priv);
213 * reporting is always done
214 * asynchronously, and we might be dealing with an urb that's
215 * partially transferred, or an ED with other urbs being unlinked.
217 static int admhc_urb_dequeue(struct usb_hcd
*hcd
, struct urb
*urb
,
220 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
224 spin_lock_irqsave(&ahcd
->lock
, flags
);
226 #ifdef ADMHC_VERBOSE_DEBUG
227 urb_print(ahcd
, urb
, "DEQUEUE", 1, status
);
229 ret
= usb_hcd_check_unlink_urb(hcd
, urb
, status
);
233 } else if (HC_IS_RUNNING(hcd
->state
)) {
234 struct urb_priv
*urb_priv
;
236 /* Unless an IRQ completed the unlink while it was being
237 * handed to us, flag it for unlink and giveback, and force
238 * some upcoming INTR_SF to call finish_unlinks()
240 urb_priv
= urb
->hcpriv
;
242 if (urb_priv
->ed
->state
== ED_OPER
)
243 start_ed_unlink(ahcd
, urb_priv
->ed
);
247 * with HC dead, we won't respect hc queue pointers
248 * any more ... just clean up every urb's memory.
251 finish_urb(ahcd
, urb
, status
);
253 spin_unlock_irqrestore(&ahcd
->lock
, flags
);
258 /*-------------------------------------------------------------------------*/
260 /* frees config/altsetting state for endpoints,
261 * including ED memory, dummy TD, and bulk/intr data toggle
264 static void admhc_endpoint_disable(struct usb_hcd
*hcd
,
265 struct usb_host_endpoint
*ep
)
267 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
269 struct ed
*ed
= ep
->hcpriv
;
270 unsigned limit
= 1000;
272 /* ASSERT: any requests/urbs are being unlinked */
273 /* ASSERT: nobody can be submitting urbs for this any more */
278 #ifdef ADMHC_VERBOSE_DEBUG
279 spin_lock_irqsave(&ahcd
->lock
, flags
);
280 admhc_dump_ed(ahcd
, "EP-DISABLE", ed
, 1);
281 spin_unlock_irqrestore(&ahcd
->lock
, flags
);
285 spin_lock_irqsave(&ahcd
->lock
, flags
);
287 if (!HC_IS_RUNNING(hcd
->state
)) {
290 finish_unlinks(ahcd
, 0);
294 case ED_UNLINK
: /* wait for hw to finish? */
295 /* major IRQ delivery trouble loses INTR_SOFI too... */
297 admhc_warn(ahcd
, "IRQ INTR_SOFI lossage\n");
300 spin_unlock_irqrestore(&ahcd
->lock
, flags
);
301 schedule_timeout_uninterruptible(1);
303 case ED_IDLE
: /* fully unlinked */
304 if (list_empty(&ed
->td_list
)) {
305 td_free (ahcd
, ed
->dummy
);
309 /* else FALL THROUGH */
311 /* caller was supposed to have unlinked any requests;
312 * that's not our job. can't recover; must leak ed.
314 admhc_err(ahcd
, "leak ed %p (#%02x) state %d%s\n",
315 ed
, ep
->desc
.bEndpointAddress
, ed
->state
,
316 list_empty(&ed
->td_list
) ? "" : " (has tds)");
317 td_free(ahcd
, ed
->dummy
);
323 spin_unlock_irqrestore(&ahcd
->lock
, flags
);
327 static int admhc_get_frame_number(struct usb_hcd
*hcd
)
329 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
331 return admhc_frame_no(ahcd
);
334 static void admhc_usb_reset(struct admhcd
*ahcd
)
337 ahcd
->hc_control
= admhc_readl(ahcd
, &ahcd
->regs
->control
);
338 ahcd
->hc_control
&= OHCI_CTRL_RWC
;
339 admhc_writel(ahcd
, ahcd
->hc_control
, &ahcd
->regs
->control
);
342 ahcd
->host_control
= ADMHC_BUSS_RESET
;
343 admhc_writel(ahcd
, ahcd
->host_control
,&ahcd
->regs
->host_control
);
347 /* admhc_shutdown forcibly disables IRQs and DMA, helping kexec and
348 * other cases where the next software may expect clean state from the
349 * "firmware". this is bus-neutral, unlike shutdown() methods.
352 admhc_shutdown(struct usb_hcd
*hcd
)
356 ahcd
= hcd_to_admhcd(hcd
);
357 admhc_intr_disable(ahcd
, ADMHC_INTR_MIE
);
358 admhc_dma_disable(ahcd
);
359 admhc_usb_reset(ahcd
);
360 /* flush the writes */
361 admhc_writel_flush(ahcd
);
364 /*-------------------------------------------------------------------------*
366 *-------------------------------------------------------------------------*/
368 static void admhc_eds_cleanup(struct admhcd
*ahcd
)
370 if (ahcd
->ed_tails
[PIPE_INTERRUPT
]) {
371 ed_free(ahcd
, ahcd
->ed_tails
[PIPE_INTERRUPT
]);
372 ahcd
->ed_tails
[PIPE_INTERRUPT
] = NULL
;
375 if (ahcd
->ed_tails
[PIPE_ISOCHRONOUS
]) {
376 ed_free(ahcd
, ahcd
->ed_tails
[PIPE_ISOCHRONOUS
]);
377 ahcd
->ed_tails
[PIPE_ISOCHRONOUS
] = NULL
;
380 if (ahcd
->ed_tails
[PIPE_CONTROL
]) {
381 ed_free(ahcd
, ahcd
->ed_tails
[PIPE_CONTROL
]);
382 ahcd
->ed_tails
[PIPE_CONTROL
] = NULL
;
385 if (ahcd
->ed_tails
[PIPE_BULK
]) {
386 ed_free(ahcd
, ahcd
->ed_tails
[PIPE_BULK
]);
387 ahcd
->ed_tails
[PIPE_BULK
] = NULL
;
390 ahcd
->ed_head
= NULL
;
393 #define ED_DUMMY_INFO (ED_SPEED_FULL | ED_SKIP)
395 static int admhc_eds_init(struct admhcd
*ahcd
)
399 ed
= ed_create(ahcd
, PIPE_INTERRUPT
, ED_DUMMY_INFO
);
403 ahcd
->ed_tails
[PIPE_INTERRUPT
] = ed
;
405 ed
= ed_create(ahcd
, PIPE_ISOCHRONOUS
, ED_DUMMY_INFO
);
409 ahcd
->ed_tails
[PIPE_ISOCHRONOUS
] = ed
;
410 ed
->ed_prev
= ahcd
->ed_tails
[PIPE_INTERRUPT
];
411 ahcd
->ed_tails
[PIPE_INTERRUPT
]->ed_next
= ed
;
412 ahcd
->ed_tails
[PIPE_INTERRUPT
]->hwNextED
= cpu_to_hc32(ahcd
, ed
->dma
);
414 ed
= ed_create(ahcd
, PIPE_CONTROL
, ED_DUMMY_INFO
);
418 ahcd
->ed_tails
[PIPE_CONTROL
] = ed
;
419 ed
->ed_prev
= ahcd
->ed_tails
[PIPE_ISOCHRONOUS
];
420 ahcd
->ed_tails
[PIPE_ISOCHRONOUS
]->ed_next
= ed
;
421 ahcd
->ed_tails
[PIPE_ISOCHRONOUS
]->hwNextED
= cpu_to_hc32(ahcd
, ed
->dma
);
423 ed
= ed_create(ahcd
, PIPE_BULK
, ED_DUMMY_INFO
);
427 ahcd
->ed_tails
[PIPE_BULK
] = ed
;
428 ed
->ed_prev
= ahcd
->ed_tails
[PIPE_CONTROL
];
429 ahcd
->ed_tails
[PIPE_CONTROL
]->ed_next
= ed
;
430 ahcd
->ed_tails
[PIPE_CONTROL
]->hwNextED
= cpu_to_hc32(ahcd
, ed
->dma
);
432 ahcd
->ed_head
= ahcd
->ed_tails
[PIPE_INTERRUPT
];
434 #ifdef ADMHC_VERBOSE_DEBUG
435 admhc_dump_ed(ahcd
, "ed intr", ahcd
->ed_tails
[PIPE_INTERRUPT
], 1);
436 admhc_dump_ed(ahcd
, "ed isoc", ahcd
->ed_tails
[PIPE_ISOCHRONOUS
], 1);
437 admhc_dump_ed(ahcd
, "ed ctrl", ahcd
->ed_tails
[PIPE_CONTROL
], 1);
438 admhc_dump_ed(ahcd
, "ed bulk", ahcd
->ed_tails
[PIPE_BULK
], 1);
444 admhc_eds_cleanup(ahcd
);
448 /* init memory, and kick BIOS/SMM off */
450 static int admhc_init(struct admhcd
*ahcd
)
452 struct usb_hcd
*hcd
= admhcd_to_hcd(ahcd
);
456 ahcd
->regs
= hcd
->regs
;
458 /* Disable HC interrupts */
459 admhc_intr_disable(ahcd
, ADMHC_INTR_MIE
);
461 /* Read the number of ports unless overridden */
462 if (ahcd
->num_ports
== 0)
463 ahcd
->num_ports
= admhc_read_rhdesc(ahcd
) & ADMHC_RH_NUMP
;
465 ret
= admhc_mem_init(ahcd
);
469 /* init dummy endpoints */
470 ret
= admhc_eds_init(ahcd
);
474 create_debug_files(ahcd
);
483 /*-------------------------------------------------------------------------*/
485 /* Start an OHCI controller, set the BUS operational
486 * resets USB and controller
489 static int admhc_run(struct admhcd
*ahcd
)
492 int first
= ahcd
->fminterval
== 0;
493 struct usb_hcd
*hcd
= admhcd_to_hcd(ahcd
);
497 /* boot firmware should have set this up (5.1.1.3.1) */
499 temp
= admhc_readl(ahcd
, &ahcd
->regs
->fminterval
);
500 ahcd
->fminterval
= temp
& ADMHC_SFI_FI_MASK
;
501 if (ahcd
->fminterval
!= FI
)
502 admhc_dbg(ahcd
, "fminterval delta %d\n",
503 ahcd
->fminterval
- FI
);
505 (FSLDP(ahcd
->fminterval
) << ADMHC_SFI_FSLDP_SHIFT
);
506 /* also: power/overcurrent flags in rhdesc */
509 #if 0 /* TODO: not applicable */
510 /* Reset USB nearly "by the book". RemoteWakeupConnected was
511 * saved if boot firmware (BIOS/SMM/...) told us it's connected,
512 * or if bus glue did the same (e.g. for PCI add-in cards with
515 if ((ahcd
->hc_control
& OHCI_CTRL_RWC
) != 0
516 && !device_may_wakeup(hcd
->self
.controller
))
517 device_init_wakeup(hcd
->self
.controller
, 1);
520 switch (ahcd
->host_control
& ADMHC_HC_BUSS
) {
521 case ADMHC_BUSS_OPER
:
524 case ADMHC_BUSS_SUSPEND
:
526 case ADMHC_BUSS_RESUME
:
527 ahcd
->host_control
= ADMHC_BUSS_RESUME
;
528 temp
= 10 /* msec wait */;
530 /* case ADMHC_BUSS_RESET: */
532 ahcd
->host_control
= ADMHC_BUSS_RESET
;
533 temp
= 50 /* msec wait */;
536 admhc_writel(ahcd
, ahcd
->host_control
, &ahcd
->regs
->host_control
);
538 /* flush the writes */
539 admhc_writel_flush(ahcd
);
542 temp
= admhc_read_rhdesc(ahcd
);
543 if (!(temp
& ADMHC_RH_NPS
)) {
544 /* power down each port */
545 for (temp
= 0; temp
< ahcd
->num_ports
; temp
++)
546 admhc_write_portstatus(ahcd
, temp
, ADMHC_PS_CPP
);
548 /* flush those writes */
549 admhc_writel_flush(ahcd
);
551 /* 2msec timelimit here means no irqs/preempt */
552 spin_lock_irq(&ahcd
->lock
);
554 admhc_writel(ahcd
, ADMHC_CTRL_SR
, &ahcd
->regs
->gencontrol
);
555 temp
= 30; /* ... allow extra time */
556 while ((admhc_readl(ahcd
, &ahcd
->regs
->gencontrol
) & ADMHC_CTRL_SR
) != 0) {
558 spin_unlock_irq(&ahcd
->lock
);
559 admhc_err(ahcd
, "USB HC reset timed out!\n");
565 /* enable HOST mode, before access any host specific register */
566 admhc_writel(ahcd
, ADMHC_CTRL_UHFE
, &ahcd
->regs
->gencontrol
);
568 /* Tell the controller where the descriptor list is */
569 admhc_writel(ahcd
, (u32
)ahcd
->ed_head
->dma
, &ahcd
->regs
->hosthead
);
571 periodic_reinit(ahcd
);
573 /* use rhsc irqs after khubd is fully initialized */
575 hcd
->uses_new_polling
= 1;
578 /* wake on ConnectStatusChange, matching external hubs */
579 admhc_writel(ahcd
, RH_HS_DRWE
, &ahcd
->regs
->roothub
.status
);
581 /* FIXME roothub_write_status (ahcd, ADMHC_RH_DRWE); */
584 /* Choose the interrupts we care about now, others later on demand */
585 admhc_intr_ack(ahcd
, ~0);
586 admhc_intr_enable(ahcd
, ADMHC_INTR_INIT
);
588 admhc_writel(ahcd
, ADMHC_RH_NPS
| ADMHC_RH_LPSC
, &ahcd
->regs
->rhdesc
);
590 /* flush those writes */
591 admhc_writel_flush(ahcd
);
593 /* start controller operations */
594 ahcd
->host_control
= ADMHC_BUSS_OPER
;
595 admhc_writel(ahcd
, ahcd
->host_control
, &ahcd
->regs
->host_control
);
598 while ((admhc_readl(ahcd
, &ahcd
->regs
->host_control
)
599 & ADMHC_HC_BUSS
) != ADMHC_BUSS_OPER
) {
601 spin_unlock_irq(&ahcd
->lock
);
602 admhc_err(ahcd
, "unable to setup operational mode!\n");
608 hcd
->state
= HC_STATE_RUNNING
;
610 ahcd
->next_statechange
= jiffies
+ STATECHANGE_DELAY
;
613 /* FIXME: enabling DMA is always failed here for an unknown reason */
614 admhc_dma_enable(ahcd
);
617 while ((admhc_readl(ahcd
, &ahcd
->regs
->host_control
)
618 & ADMHC_HC_DMAE
) != ADMHC_HC_DMAE
) {
620 spin_unlock_irq(&ahcd
->lock
);
621 admhc_err(ahcd
, "unable to enable DMA!\n");
630 spin_unlock_irq(&ahcd
->lock
);
632 mdelay(ADMHC_POTPGT
);
637 /*-------------------------------------------------------------------------*/
639 /* an interrupt happens */
641 static irqreturn_t
admhc_irq(struct usb_hcd
*hcd
)
643 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
644 struct admhcd_regs __iomem
*regs
= ahcd
->regs
;
647 ints
= admhc_readl(ahcd
, ®s
->int_status
);
648 if ((ints
& ADMHC_INTR_INTA
) == 0) {
649 /* no unmasked interrupt status is set */
653 ints
&= admhc_readl(ahcd
, ®s
->int_enable
);
655 if (ints
& ADMHC_INTR_FATI
) {
656 /* e.g. due to PCI Master/Target Abort */
658 admhc_err(ahcd
, "Fatal Error, controller disabled\n");
660 admhc_usb_reset(ahcd
);
663 if (ints
& ADMHC_INTR_BABI
) {
664 admhc_intr_disable(ahcd
, ADMHC_INTR_BABI
);
665 admhc_intr_ack(ahcd
, ADMHC_INTR_BABI
);
666 admhc_err(ahcd
, "Babble Detected\n");
669 if (ints
& ADMHC_INTR_INSM
) {
670 admhc_vdbg(ahcd
, "Root Hub Status Change\n");
671 ahcd
->next_statechange
= jiffies
+ STATECHANGE_DELAY
;
672 admhc_intr_ack(ahcd
, ADMHC_INTR_RESI
| ADMHC_INTR_INSM
);
674 /* NOTE: Vendors didn't always make the same implementation
675 * choices for RHSC. Many followed the spec; RHSC triggers
676 * on an edge, like setting and maybe clearing a port status
677 * change bit. With others it's level-triggered, active
678 * until khubd clears all the port status change bits. We'll
679 * always disable it here and rely on polling until khubd
682 admhc_intr_disable(ahcd
, ADMHC_INTR_INSM
);
683 usb_hcd_poll_rh_status(hcd
);
684 } else if (ints
& ADMHC_INTR_RESI
) {
685 /* For connect and disconnect events, we expect the controller
686 * to turn on RHSC along with RD. But for remote wakeup events
687 * this might not happen.
689 admhc_vdbg(ahcd
, "Resume Detect\n");
690 admhc_intr_ack(ahcd
, ADMHC_INTR_RESI
);
692 if (ahcd
->autostop
) {
693 spin_lock(&ahcd
->lock
);
694 admhc_rh_resume(ahcd
);
695 spin_unlock(&ahcd
->lock
);
697 usb_hcd_resume_root_hub(hcd
);
700 if (ints
& ADMHC_INTR_TDC
) {
701 admhc_vdbg(ahcd
, "Transfer Descriptor Complete\n");
702 admhc_intr_ack(ahcd
, ADMHC_INTR_TDC
);
703 if (HC_IS_RUNNING(hcd
->state
))
704 admhc_intr_disable(ahcd
, ADMHC_INTR_TDC
);
705 spin_lock(&ahcd
->lock
);
706 admhc_td_complete(ahcd
);
707 spin_unlock(&ahcd
->lock
);
708 if (HC_IS_RUNNING(hcd
->state
))
709 admhc_intr_enable(ahcd
, ADMHC_INTR_TDC
);
712 if (ints
& ADMHC_INTR_SO
) {
713 /* could track INTR_SO to reduce available PCI/... bandwidth */
714 admhc_vdbg(ahcd
, "Schedule Overrun\n");
718 spin_lock(&ahcd
->lock
);
719 if (ahcd
->ed_rm_list
)
720 finish_unlinks(ahcd
, admhc_frame_no(ahcd
));
722 if ((ints
& ADMHC_INTR_SOFI
) != 0 && !ahcd
->ed_rm_list
723 && HC_IS_RUNNING(hcd
->state
))
724 admhc_intr_disable(ahcd
, ADMHC_INTR_SOFI
);
725 spin_unlock(&ahcd
->lock
);
727 if (ints
& ADMHC_INTR_SOFI
) {
728 admhc_vdbg(ahcd
, "Start Of Frame\n");
729 spin_lock(&ahcd
->lock
);
731 /* handle any pending ED removes */
732 finish_unlinks(ahcd
, admhc_frameno(ahcd
));
734 /* leaving INTR_SOFI enabled when there's still unlinking
735 * to be done in the (next frame).
737 if ((ahcd
->ed_rm_list
== NULL
) ||
738 HC_IS_RUNNING(hcd
->state
) == 0)
740 * disable INTR_SOFI if there are no unlinking to be
741 * done (in the next frame)
743 admhc_intr_disable(ahcd
, ADMHC_INTR_SOFI
);
745 spin_unlock(&ahcd
->lock
);
749 if (HC_IS_RUNNING(hcd
->state
)) {
750 admhc_intr_ack(ahcd
, ints
);
751 admhc_intr_enable(ahcd
, ADMHC_INTR_MIE
);
752 admhc_writel_flush(ahcd
);
758 /*-------------------------------------------------------------------------*/
760 static void admhc_stop(struct usb_hcd
*hcd
)
762 struct admhcd
*ahcd
= hcd_to_admhcd(hcd
);
766 flush_scheduled_work();
768 admhc_usb_reset(ahcd
);
769 admhc_intr_disable(ahcd
, ADMHC_INTR_MIE
);
771 free_irq(hcd
->irq
, hcd
);
774 remove_debug_files(ahcd
);
775 admhc_eds_cleanup(ahcd
);
776 admhc_mem_cleanup(ahcd
);
779 /*-------------------------------------------------------------------------*/
781 #ifdef CONFIG_ADM5120
782 #include "adm5120-drv.c"
783 #define PLATFORM_DRIVER usb_hcd_adm5120_driver
786 #if !defined(PLATFORM_DRIVER)
787 #error "missing bus glue for admhc-hcd"
790 #define DRIVER_INFO DRIVER_DESC " version " DRIVER_VERSION
792 static int __init
admhc_hcd_mod_init(void)
799 pr_info("%s: " DRIVER_INFO
"\n", hcd_name
);
800 pr_info("%s: block sizes: ed %Zd td %Zd\n", hcd_name
,
801 sizeof (struct ed
), sizeof (struct td
));
804 admhc_debug_root
= debugfs_create_dir("admhc", NULL
);
805 if (!admhc_debug_root
) {
811 #ifdef PLATFORM_DRIVER
812 ret
= platform_driver_register(&PLATFORM_DRIVER
);
819 #ifdef PLATFORM_DRIVER
820 platform_driver_unregister(&PLATFORM_DRIVER
);
825 debugfs_remove(admhc_debug_root
);
826 admhc_debug_root
= NULL
;
831 module_init(admhc_hcd_mod_init
);
833 static void __exit
admhc_hcd_mod_exit(void)
835 platform_driver_unregister(&PLATFORM_DRIVER
);
837 debugfs_remove(admhc_debug_root
);
840 module_exit(admhc_hcd_mod_exit
);
842 MODULE_AUTHOR(DRIVER_AUTHOR
);
843 MODULE_DESCRIPTION(DRIVER_INFO
);
844 MODULE_VERSION(DRIVER_VERSION
);
845 MODULE_LICENSE("GPL v2");
This page took 0.090833 seconds and 5 git commands to generate.