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()
416 ed = ed_alloc (ohci, GFP_ATOMIC); in ed_get()
423 td = td_alloc (ohci, GFP_ATOMIC); in ed_get()
426 ed_free (ohci, ed); in ed_get()
431 ed->hwTailP = cpu_to_hc32 (ohci, td->td_dma); in ed_get()
464 ed->hwINFO = cpu_to_hc32(ohci, info); in ed_get()
470 spin_unlock_irqrestore (&ohci->lock, flags); in ed_get()
482 static void start_ed_unlink (struct ohci_hcd *ohci, struct ed *ed) in start_ed_unlink() argument
484 ed->hwINFO |= cpu_to_hc32 (ohci, ED_DEQUEUE); in start_ed_unlink()
485 ed_deschedule (ohci, ed); in start_ed_unlink()
488 ed->ed_next = ohci->ed_rm_list; in start_ed_unlink()
490 ohci->ed_rm_list = ed; in start_ed_unlink()
493 ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrstatus); in start_ed_unlink()
494 ohci_writel (ohci, OHCI_INTR_SF, &ohci->regs->intrenable); in start_ed_unlink()
496 (void) ohci_readl (ohci, &ohci->regs->control); in start_ed_unlink()
503 ed->tick = ohci_frame_no(ohci) + 1; in start_ed_unlink()
514 td_fill (struct ohci_hcd *ohci, u32 info, in td_fill() argument
555 td->hwINFO = cpu_to_hc32 (ohci, info); in td_fill()
557 td->hwCBP = cpu_to_hc32 (ohci, data & 0xFFFFF000); in td_fill()
558 *ohci_hwPSWp(ohci, td, 0) = cpu_to_hc16 (ohci, in td_fill()
561 td->hwCBP = cpu_to_hc32 (ohci, data); in td_fill()
564 td->hwBE = cpu_to_hc32 (ohci, data + len - 1); in td_fill()
567 td->hwNextTD = cpu_to_hc32 (ohci, td_pt->td_dma); in td_fill()
574 td->td_hash = ohci->td_hash [hash]; in td_fill()
575 ohci->td_hash [hash] = td; in td_fill()
590 struct ohci_hcd *ohci, in td_submit_urb() argument
594 struct device *dev = ohci_to_hcd(ohci)->self.controller; in td_submit_urb()
611 urb_priv->ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_C); in td_submit_urb()
614 list_add (&urb_priv->pending, &ohci->pending); in td_submit_urb()
646 periodic = ohci_to_hcd(ohci)->self.bandwidth_int_reqs++ == 0 in td_submit_urb()
647 && ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0; in td_submit_urb()
662 td_fill(ohci, info, data, n, urb, cnt); in td_submit_urb()
679 td_fill (ohci, info, 0, 0, urb, cnt); in td_submit_urb()
685 ohci_writel (ohci, OHCI_BLF, &ohci->regs->cmdstatus); in td_submit_urb()
694 td_fill (ohci, info, urb->setup_dma, 8, urb, cnt++); in td_submit_urb()
699 td_fill (ohci, info, data, data_len, urb, cnt++); in td_submit_urb()
704 td_fill (ohci, info, data, 0, urb, cnt++); in td_submit_urb()
707 ohci_writel (ohci, OHCI_CLF, &ohci->regs->cmdstatus); in td_submit_urb()
724 td_fill (ohci, TD_CC | TD_ISO | frame, in td_submit_urb()
728 if (ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs == 0) { in td_submit_urb()
729 if (quirk_amdiso(ohci)) in td_submit_urb()
731 if (quirk_amdprefetch(ohci)) in td_submit_urb()
734 periodic = ohci_to_hcd(ohci)->self.bandwidth_isoc_reqs++ == 0 in td_submit_urb()
735 && ohci_to_hcd(ohci)->self.bandwidth_int_reqs == 0; in td_submit_urb()
742 ohci->hc_control |= OHCI_CTRL_PLE|OHCI_CTRL_IE; in td_submit_urb()
743 ohci_writel (ohci, ohci->hc_control, &ohci->regs->control); in td_submit_urb()
754 static int td_done(struct ohci_hcd *ohci, struct urb *urb, struct td *td) in td_done() argument
756 u32 tdINFO = hc32_to_cpup (ohci, &td->hwINFO); in td_done()
764 u16 tdPSW = ohci_hwPSW(ohci, td, 0); in td_done()
788 ohci_dbg(ohci, in td_done()
798 u32 tdBE = hc32_to_cpup (ohci, &td->hwBE); in td_done()
815 hc32_to_cpup (ohci, &td->hwCBP) in td_done()
820 ohci_dbg(ohci, in td_done()
831 static void ed_halted(struct ohci_hcd *ohci, struct td *td, int cc) in ed_halted() argument
837 __hc32 toggle = ed->hwHeadP & cpu_to_hc32 (ohci, ED_C); in ed_halted()
842 ed->hwINFO |= cpu_to_hc32 (ohci, ED_SKIP); in ed_halted()
844 ed->hwHeadP &= ~cpu_to_hc32 (ohci, ED_H); in ed_halted()
886 ohci_dbg (ohci, in ed_halted()
891 hc32_to_cpu (ohci, td->hwINFO), in ed_halted()
897 static void add_to_done_list(struct ohci_hcd *ohci, struct td *td) in add_to_done_list() argument
915 if (ohci->dl_end) in add_to_done_list()
916 ohci->dl_end->next_dl_td = td_prev; in add_to_done_list()
918 ohci->dl_start = td_prev; in add_to_done_list()
924 ohci->dl_end = td->next_dl_td = td; in add_to_done_list()
933 static void update_done_list(struct ohci_hcd *ohci) in update_done_list() argument
938 td_dma = hc32_to_cpup (ohci, &ohci->hcca->done_head); in update_done_list()
939 ohci->hcca->done_head = 0; in update_done_list()
948 td = dma_to_td (ohci, td_dma); in update_done_list()
950 ohci_err (ohci, "bad entry %8x\n", td_dma); in update_done_list()
954 td->hwINFO |= cpu_to_hc32 (ohci, TD_DONE); in update_done_list()
955 cc = TD_CC_GET (hc32_to_cpup (ohci, &td->hwINFO)); in update_done_list()
962 && (td->ed->hwHeadP & cpu_to_hc32 (ohci, ED_H))) in update_done_list()
963 ed_halted(ohci, td, cc); in update_done_list()
965 td_dma = hc32_to_cpup (ohci, &td->hwNextTD); in update_done_list()
966 add_to_done_list(ohci, td); in update_done_list()
973 static void finish_unlinks(struct ohci_hcd *ohci) in finish_unlinks() argument
975 unsigned tick = ohci_frame_no(ohci); in finish_unlinks()
979 for (last = &ohci->ed_rm_list, ed = *last; ed != NULL; ed = *last) { in finish_unlinks()
987 if (likely(ohci->rh_state == OHCI_RH_RUNNING) && in finish_unlinks()
1000 head = hc32_to_cpu(ohci, ed->hwHeadP) & TD_MASK; in finish_unlinks()
1002 ohci->rh_state == OHCI_RH_RUNNING) in finish_unlinks()
1011 ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_H); in finish_unlinks()
1014 ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE); in finish_unlinks()
1050 savebits = *prev & ~cpu_to_hc32 (ohci, TD_MASK); in finish_unlinks()
1058 tdINFO = hc32_to_cpup(ohci, &td->hwINFO); in finish_unlinks()
1060 ed->hwHeadP &= ~cpu_to_hc32(ohci, ED_C); in finish_unlinks()
1062 ed->hwHeadP |= cpu_to_hc32(ohci, ED_C); in finish_unlinks()
1065 td_done (ohci, urb, td); in finish_unlinks()
1071 finish_urb(ohci, urb, 0); in finish_unlinks()
1087 } else if (ohci->rh_state == OHCI_RH_RUNNING) { in finish_unlinks()
1090 ed_schedule(ohci, ed); in finish_unlinks()
1100 if (ohci->rh_state == OHCI_RH_RUNNING && !ohci->ed_rm_list) { in finish_unlinks()
1103 if (ohci->ed_controltail) { in finish_unlinks()
1105 if (quirk_zfmicro(ohci)) in finish_unlinks()
1107 if (!(ohci->hc_control & OHCI_CTRL_CLE)) { in finish_unlinks()
1109 ohci_writel (ohci, 0, in finish_unlinks()
1110 &ohci->regs->ed_controlcurrent); in finish_unlinks()
1113 if (ohci->ed_bulktail) { in finish_unlinks()
1115 if (quirk_zfmicro(ohci)) in finish_unlinks()
1117 if (!(ohci->hc_control & OHCI_CTRL_BLE)) { in finish_unlinks()
1119 ohci_writel (ohci, 0, in finish_unlinks()
1120 &ohci->regs->ed_bulkcurrent); in finish_unlinks()
1126 ohci->hc_control |= control; in finish_unlinks()
1127 if (quirk_zfmicro(ohci)) in finish_unlinks()
1129 ohci_writel (ohci, ohci->hc_control, in finish_unlinks()
1130 &ohci->regs->control); in finish_unlinks()
1133 if (quirk_zfmicro(ohci)) in finish_unlinks()
1135 ohci_writel (ohci, command, &ohci->regs->cmdstatus); in finish_unlinks()
1145 static void takeback_td(struct ohci_hcd *ohci, struct td *td) in takeback_td() argument
1153 status = td_done(ohci, urb, td); in takeback_td()
1158 finish_urb(ohci, urb, status); in takeback_td()
1163 start_ed_unlink(ohci, ed); in takeback_td()
1166 } else if ((ed->hwINFO & cpu_to_hc32(ohci, ED_SKIP | ED_DEQUEUE)) in takeback_td()
1167 == cpu_to_hc32(ohci, ED_SKIP)) { in takeback_td()
1169 if (!(td->hwINFO & cpu_to_hc32(ohci, TD_DONE))) { in takeback_td()
1170 ed->hwINFO &= ~cpu_to_hc32(ohci, ED_SKIP); in takeback_td()
1174 ohci_writel(ohci, OHCI_CLF, in takeback_td()
1175 &ohci->regs->cmdstatus); in takeback_td()
1178 ohci_writel(ohci, OHCI_BLF, in takeback_td()
1179 &ohci->regs->cmdstatus); in takeback_td()
1193 static void process_done_list(struct ohci_hcd *ohci) in process_done_list() argument
1197 while (ohci->dl_start) { in process_done_list()
1198 td = ohci->dl_start; in process_done_list()
1199 if (td == ohci->dl_end) in process_done_list()
1200 ohci->dl_start = ohci->dl_end = NULL; in process_done_list()
1202 ohci->dl_start = td->next_dl_td; in process_done_list()
1204 takeback_td(ohci, td); in process_done_list()
1212 static void ohci_work(struct ohci_hcd *ohci) in ohci_work() argument
1214 if (ohci->working) { in ohci_work()
1215 ohci->restart_work = 1; in ohci_work()
1218 ohci->working = 1; in ohci_work()
1221 process_done_list(ohci); in ohci_work()
1222 if (ohci->ed_rm_list) in ohci_work()
1223 finish_unlinks(ohci); in ohci_work()
1225 if (ohci->restart_work) { in ohci_work()
1226 ohci->restart_work = 0; in ohci_work()
1229 ohci->working = 0; in ohci_work()