Lines Matching refs:ohci

40 finish_urb(struct ohci_hcd *ohci, struct urb *urb, int status)  in finish_urb()  argument
41 __releases(ohci->lock) in finish_urb()
42 __acquires(ohci->lock) in finish_urb()
44 struct device *dev = ohci_to_hcd(ohci)->self.controller; in finish_urb()
51 urb_free_priv (ohci, urb->hcpriv); in finish_urb()
58 ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs--; in finish_urb()
59 if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0) { in finish_urb()
60 if (quirk_amdiso(ohci)) in finish_urb()
62 if (quirk_amdprefetch(ohci)) in finish_urb()
67 ohci_to_hcd(ohci)->self.bandwidth_int_reqs--; in finish_urb()
72 usb_hcd_unlink_urb_from_ep(ohci_to_hcd(ohci), urb); in finish_urb()
73 spin_unlock (&ohci->lock); in finish_urb()
74 usb_hcd_giveback_urb(ohci_to_hcd(ohci), urb, status); in finish_urb()
75 spin_lock (&ohci->lock); in finish_urb()
78 if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0 in finish_urb()
79 && ohci_to_hcd(ohci)->self.bandwidth_int_reqs == 0) { in finish_urb()
80 ohci->hc_control &= ~(OHCI_CTRL_PLE|OHCI_CTRL_IE); in finish_urb()
81 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in finish_urb()
108 static int balance (struct ohci_hcd *ohci, int interval, int load) in balance() argument
120 if (branch < 0 || ohci->load [branch] > ohci->load [i]) { in balance()
125 if ((ohci->load [j] + load) > 900) in balance()
142 static void periodic_link (struct ohci_hcd *ohci, struct ed *ed) in periodic_link() argument
146 ohci_dbg(ohci, "link %sed %p branch %d [%dus.], interval %d\n", in periodic_link()
147 (ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "", in periodic_link()
151 struct ed **prev = &ohci->periodic [i]; in periodic_link()
152 __hc32 *prev_p = &ohci->hcca->int_table [i]; in periodic_link()
172 *prev_p = cpu_to_hc32(ohci, ed->dma); in periodic_link()
175 ohci->load [i] += ed->load; in periodic_link()
177 ohci_to_hcd(ohci)->self.bandwidth_allocated += ed->load / ed->interval; in periodic_link()
182 static int ed_schedule (struct ohci_hcd *ohci, struct ed *ed) in ed_schedule() argument
204 if (ohci->ed_controltail == NULL) { in ed_schedule()
205 WARN_ON (ohci->hc_control & OHCI_CTRL_CLE); in ed_schedule()
206 ohci_writel (ohci, ed->dma, in ed_schedule()
207 &ohci->regs->ed_controlhead); in ed_schedule()
209 ohci->ed_controltail->ed_next = ed; in ed_schedule()
210 ohci->ed_controltail->hwNextED = cpu_to_hc32 (ohci, in ed_schedule()
213 ed->ed_prev = ohci->ed_controltail; in ed_schedule()
214 if (!ohci->ed_controltail && !ohci->ed_rm_list) { in ed_schedule()
216 ohci->hc_control |= OHCI_CTRL_CLE; in ed_schedule()
217 ohci_writel (ohci, 0, &ohci->regs->ed_controlcurrent); in ed_schedule()
218 ohci_writel (ohci, ohci->hc_control, in ed_schedule()
219 &ohci->regs->control); in ed_schedule()
221 ohci->ed_controltail = ed; in ed_schedule()
225 if (ohci->ed_bulktail == NULL) { in ed_schedule()
226 WARN_ON (ohci->hc_control & OHCI_CTRL_BLE); in ed_schedule()
227 ohci_writel (ohci, ed->dma, &ohci->regs->ed_bulkhead); in ed_schedule()
229 ohci->ed_bulktail->ed_next = ed; in ed_schedule()
230 ohci->ed_bulktail->hwNextED = cpu_to_hc32 (ohci, in ed_schedule()
233 ed->ed_prev = ohci->ed_bulktail; in ed_schedule()
234 if (!ohci->ed_bulktail && !ohci->ed_rm_list) { in ed_schedule()
236 ohci->hc_control |= OHCI_CTRL_BLE; in ed_schedule()
237 ohci_writel (ohci, 0, &ohci->regs->ed_bulkcurrent); in ed_schedule()
238 ohci_writel (ohci, ohci->hc_control, in ed_schedule()
239 &ohci->regs->control); in ed_schedule()
241 ohci->ed_bulktail = ed; in ed_schedule()
247 branch = balance (ohci, ed->interval, ed->load); in ed_schedule()
249 ohci_dbg (ohci, in ed_schedule()
256 periodic_link (ohci, ed); in ed_schedule()
268 static void periodic_unlink (struct ohci_hcd *ohci, struct ed *ed) in periodic_unlink() argument
274 struct ed **prev = &ohci->periodic [i]; in periodic_unlink()
275 __hc32 *prev_p = &ohci->hcca->int_table [i]; in periodic_unlink()
285 ohci->load [i] -= ed->load; in periodic_unlink()
287 ohci_to_hcd(ohci)->self.bandwidth_allocated -= ed->load / ed->interval; in periodic_unlink()
289 ohci_dbg(ohci, "unlink %sed %p branch %d [%dus.], interval %d\n", in periodic_unlink()
290 (ed->hwINFO & cpu_to_hc32 (ohci, ED_ISO)) ? "iso " : "", in periodic_unlink()
315 static void ed_deschedule (struct ohci_hcd *ohci, struct ed *ed) in ed_deschedule() argument
317 ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP); in ed_deschedule()
336 ohci->hc_control &= ~OHCI_CTRL_CLE; in ed_deschedule()
337 ohci_writel (ohci, ohci->hc_control, in ed_deschedule()
338 &ohci->regs->control); in ed_deschedule()
341 ohci_writel (ohci, in ed_deschedule()
342 hc32_to_cpup (ohci, &ed->hwNextED), in ed_deschedule()
343 &ohci->regs->ed_controlhead); in ed_deschedule()
349 if (ohci->ed_controltail == ed) { in ed_deschedule()
350 ohci->ed_controltail = ed->ed_prev; in ed_deschedule()
351 if (ohci->ed_controltail) in ed_deschedule()
352 ohci->ed_controltail->ed_next = NULL; in ed_deschedule()
362 ohci->hc_control &= ~OHCI_CTRL_BLE; in ed_deschedule()
363 ohci_writel (ohci, ohci->hc_control, in ed_deschedule()
364 &ohci->regs->control); in ed_deschedule()
367 ohci_writel (ohci, in ed_deschedule()
368 hc32_to_cpup (ohci, &ed->hwNextED), in ed_deschedule()
369 &ohci->regs->ed_bulkhead); in ed_deschedule()
375 if (ohci->ed_bulktail == ed) { in ed_deschedule()
376 ohci->ed_bulktail = ed->ed_prev; in ed_deschedule()
377 if (ohci->ed_bulktail) in ed_deschedule()
378 ohci->ed_bulktail->ed_next = NULL; in ed_deschedule()
387 periodic_unlink (ohci, ed); in ed_deschedule()
399 struct ohci_hcd *ohci, in ed_get() argument
408 spin_lock_irqsave (&ohci->lock, flags); in ed_get()
415 ed = ed_alloc (ohci, GFP_ATOMIC); in ed_get()
422 td = td_alloc (ohci, GFP_ATOMIC); in ed_get()
425 ed_free (ohci, ed); in ed_get()
430 ed->hwTailP = cpu_to_hc32 (ohci, td->td_dma); in ed_get()
463 ed->hwINFO = cpu_to_hc32(ohci, info); in ed_get()
469 spin_unlock_irqrestore (&ohci->lock, flags); in ed_get()
481 static void start_ed_unlink (struct ohci_hcd *ohci, struct ed *ed) in start_ed_unlink() argument
483 ed->hwINFO |= cpu_to_hc32 (ohci, ED_DEQUEUE); in start_ed_unlink()
484 ed_deschedule (ohci, ed); in start_ed_unlink()
487 ed->ed_next = ohci->ed_rm_list; in start_ed_unlink()
489 ohci->ed_rm_list = ed; in start_ed_unlink()
492 ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrstatus); in start_ed_unlink()
493 ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable); in start_ed_unlink()
495 (void) ohci_readl (ohci, &ohci->regs->control); in start_ed_unlink()
502 ed->tick = ohci_frame_no(ohci) + 1; in start_ed_unlink()
513 td_fill (struct ohci_hcd *ohci, u32 info, in td_fill() argument
554 td->hwINFO = cpu_to_hc32 (ohci, info); in td_fill()
556 td->hwCBP = cpu_to_hc32 (ohci, data & 0xFFFFF000); in td_fill()
557 *ohci_hwPSWp(ohci, td, 0) = cpu_to_hc16 (ohci, in td_fill()
560 td->hwCBP = cpu_to_hc32 (ohci, data); in td_fill()
563 td->hwBE = cpu_to_hc32 (ohci, data + len - 1); in td_fill()
566 td->hwNextTD = cpu_to_hc32 (ohci, td_pt->td_dma); in td_fill()
573 td->td_hash = ohci->td_hash [hash]; in td_fill()
574 ohci->td_hash [hash] = td; in td_fill()
589 struct ohci_hcd *ohci, in td_submit_urb() argument
593 struct device *dev = ohci_to_hcd(ohci)->self.controller; in td_submit_urb()
610 urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C); in td_submit_urb()
613 list_add (&urb_priv->pending, &ohci->pending); in td_submit_urb()
645 periodic = ohci_to_hcd(ohci)->self.bandwidth_int_reqs++ == 0 in td_submit_urb()
646 && ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0; in td_submit_urb()
661 td_fill(ohci, info, data, n, urb, cnt); in td_submit_urb()
678 td_fill (ohci, info, 0, 0, urb, cnt); in td_submit_urb()
684 ohci_writel (ohci, OHCI_BLF, &ohci->regs->cmdstatus); in td_submit_urb()
693 td_fill (ohci, info, urb->setup_dma, 8, urb, cnt++); in td_submit_urb()
698 td_fill (ohci, info, data, data_len, urb, cnt++); in td_submit_urb()
703 td_fill (ohci, info, data, 0, urb, cnt++); in td_submit_urb()
706 ohci_writel (ohci, OHCI_CLF, &ohci->regs->cmdstatus); in td_submit_urb()
723 td_fill (ohci, TD_CC | TD_ISO | frame, in td_submit_urb()
727 if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0) { in td_submit_urb()
728 if (quirk_amdiso(ohci)) in td_submit_urb()
730 if (quirk_amdprefetch(ohci)) in td_submit_urb()
733 periodic = ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs++ == 0 in td_submit_urb()
734 && ohci_to_hcd(ohci)->self.bandwidth_int_reqs == 0; in td_submit_urb()
741 ohci->hc_control |= OHCI_CTRL_PLE|OHCI_CTRL_IE; in td_submit_urb()
742 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in td_submit_urb()
753 static int td_done(struct ohci_hcd *ohci, struct urb *urb, struct td *td) in td_done() argument
755 u32 tdINFO = hc32_to_cpup (ohci, &td->hwINFO); in td_done()
763 u16 tdPSW = ohci_hwPSW(ohci, td, 0); in td_done()
787 ohci_dbg(ohci, in td_done()
797 u32 tdBE = hc32_to_cpup (ohci, &td->hwBE); in td_done()
814 hc32_to_cpup (ohci, &td->hwCBP) in td_done()
819 ohci_dbg(ohci, in td_done()
830 static void ed_halted(struct ohci_hcd *ohci, struct td *td, int cc) in ed_halted() argument
836 __hc32 toggle = ed->hwHeadP & cpu_to_hc32 (ohci, ED_C); in ed_halted()
841 ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP); in ed_halted()
843 ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_H); in ed_halted()
885 ohci_dbg (ohci, in ed_halted()
890 hc32_to_cpu (ohci, td->hwINFO), in ed_halted()
896 static void add_to_done_list(struct ohci_hcd *ohci, struct td *td) in add_to_done_list() argument
914 if (ohci->dl_end) in add_to_done_list()
915 ohci->dl_end->next_dl_td = td_prev; in add_to_done_list()
917 ohci->dl_start = td_prev; in add_to_done_list()
923 ohci->dl_end = td->next_dl_td = td; in add_to_done_list()
932 static void update_done_list(struct ohci_hcd *ohci) in update_done_list() argument
937 td_dma = hc32_to_cpup (ohci, &ohci->hcca->done_head); in update_done_list()
938 ohci->hcca->done_head = 0; in update_done_list()
947 td = dma_to_td (ohci, td_dma); in update_done_list()
949 ohci_err (ohci, "bad entry %8x\n", td_dma); in update_done_list()
953 td->hwINFO |= cpu_to_hc32 (ohci, TD_DONE); in update_done_list()
954 cc = TD_CC_GET (hc32_to_cpup (ohci, &td->hwINFO)); in update_done_list()
961 && (td->ed->hwHeadP & cpu_to_hc32 (ohci, ED_H))) in update_done_list()
962 ed_halted(ohci, td, cc); in update_done_list()
964 td_dma = hc32_to_cpup (ohci, &td->hwNextTD); in update_done_list()
965 add_to_done_list(ohci, td); in update_done_list()
972 static void finish_unlinks(struct ohci_hcd *ohci) in finish_unlinks() argument
974 unsigned tick = ohci_frame_no(ohci); in finish_unlinks()
978 for (last = &ohci->ed_rm_list, ed = *last; ed != NULL; ed = *last) { in finish_unlinks()
986 if (likely(ohci->rh_state == OHCI_RH_RUNNING) && in finish_unlinks()
999 head = hc32_to_cpu(ohci, ed->hwHeadP) & TD_MASK; in finish_unlinks()
1001 ohci->rh_state == OHCI_RH_RUNNING) in finish_unlinks()
1010 ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H); in finish_unlinks()
1013 ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE); in finish_unlinks()
1049 savebits = *prev & ~cpu_to_hc32 (ohci, TD_MASK); in finish_unlinks()
1057 tdINFO = hc32_to_cpup(ohci, &td->hwINFO); in finish_unlinks()
1059 ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_C); in finish_unlinks()
1061 ed->hwHeadP |= cpu_to_hc32(ohci, ED_C); in finish_unlinks()
1064 td_done (ohci, urb, td); in finish_unlinks()
1070 finish_urb(ohci, urb, 0); in finish_unlinks()
1086 } else if (ohci->rh_state == OHCI_RH_RUNNING) { in finish_unlinks()
1089 ed_schedule(ohci, ed); in finish_unlinks()
1099 if (ohci->rh_state == OHCI_RH_RUNNING && !ohci->ed_rm_list) { in finish_unlinks()
1102 if (ohci->ed_controltail) { in finish_unlinks()
1104 if (quirk_zfmicro(ohci)) in finish_unlinks()
1106 if (!(ohci->hc_control & OHCI_CTRL_CLE)) { in finish_unlinks()
1108 ohci_writel (ohci, 0, in finish_unlinks()
1109 &ohci->regs->ed_controlcurrent); in finish_unlinks()
1112 if (ohci->ed_bulktail) { in finish_unlinks()
1114 if (quirk_zfmicro(ohci)) in finish_unlinks()
1116 if (!(ohci->hc_control & OHCI_CTRL_BLE)) { in finish_unlinks()
1118 ohci_writel (ohci, 0, in finish_unlinks()
1119 &ohci->regs->ed_bulkcurrent); in finish_unlinks()
1125 ohci->hc_control |= control; in finish_unlinks()
1126 if (quirk_zfmicro(ohci)) in finish_unlinks()
1128 ohci_writel (ohci, ohci->hc_control, in finish_unlinks()
1129 &ohci->regs->control); in finish_unlinks()
1132 if (quirk_zfmicro(ohci)) in finish_unlinks()
1134 ohci_writel (ohci, command, &ohci->regs->cmdstatus); in finish_unlinks()
1144 static void takeback_td(struct ohci_hcd *ohci, struct td *td) in takeback_td() argument
1152 status = td_done(ohci, urb, td); in takeback_td()
1157 finish_urb(ohci, urb, status); in takeback_td()
1162 start_ed_unlink(ohci, ed); in takeback_td()
1165 } else if ((ed->hwINFO & cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE)) in takeback_td()
1166 == cpu_to_hc32(ohci, ED_SKIP)) { in takeback_td()
1168 if (!(td->hwINFO & cpu_to_hc32(ohci, TD_DONE))) { in takeback_td()
1169 ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP); in takeback_td()
1173 ohci_writel(ohci, OHCI_CLF, in takeback_td()
1174 &ohci->regs->cmdstatus); in takeback_td()
1177 ohci_writel(ohci, OHCI_BLF, in takeback_td()
1178 &ohci->regs->cmdstatus); in takeback_td()
1192 static void process_done_list(struct ohci_hcd *ohci) in process_done_list() argument
1196 while (ohci->dl_start) { in process_done_list()
1197 td = ohci->dl_start; in process_done_list()
1198 if (td == ohci->dl_end) in process_done_list()
1199 ohci->dl_start = ohci->dl_end = NULL; in process_done_list()
1201 ohci->dl_start = td->next_dl_td; in process_done_list()
1203 takeback_td(ohci, td); in process_done_list()
1211 static void ohci_work(struct ohci_hcd *ohci) in ohci_work() argument
1213 if (ohci->working) { in ohci_work()
1214 ohci->restart_work = 1; in ohci_work()
1217 ohci->working = 1; in ohci_work()
1220 process_done_list(ohci); in ohci_work()
1221 if (ohci->ed_rm_list) in ohci_work()
1222 finish_unlinks(ohci); in ohci_work()
1224 if (ohci->restart_work) { in ohci_work()
1225 ohci->restart_work = 0; in ohci_work()
1228 ohci->working = 0; in ohci_work()