• Home
  • Raw
  • Download

Lines Matching refs:uhci

92 static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state);
93 static void wakeup_rh(struct uhci_hcd *uhci);
94 static void uhci_get_current_frame_number(struct uhci_hcd *uhci);
99 static __hc32 uhci_frame_skel_link(struct uhci_hcd *uhci, int frame) in uhci_frame_skel_link() argument
121 return LINK_TO_QH(uhci, uhci->skelqh[skelnum]); in uhci_frame_skel_link()
131 static void finish_reset(struct uhci_hcd *uhci) in finish_reset() argument
139 for (port = 0; port < uhci->rh_numports; ++port) in finish_reset()
140 uhci_writew(uhci, 0, USBPORTSC1 + (port * 2)); in finish_reset()
142 uhci->port_c_suspend = uhci->resuming_ports = 0; in finish_reset()
143 uhci->rh_state = UHCI_RH_RESET; in finish_reset()
144 uhci->is_stopped = UHCI_IS_STOPPED; in finish_reset()
145 clear_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); in finish_reset()
152 static void uhci_hc_died(struct uhci_hcd *uhci) in uhci_hc_died() argument
154 uhci_get_current_frame_number(uhci); in uhci_hc_died()
155 uhci->reset_hc(uhci); in uhci_hc_died()
156 finish_reset(uhci); in uhci_hc_died()
157 uhci->dead = 1; in uhci_hc_died()
160 ++uhci->frame_number; in uhci_hc_died()
168 static void check_and_reset_hc(struct uhci_hcd *uhci) in check_and_reset_hc() argument
170 if (uhci->check_and_reset_hc(uhci)) in check_and_reset_hc()
171 finish_reset(uhci); in check_and_reset_hc()
185 static void uhci_generic_reset_hc(struct uhci_hcd *uhci) in uhci_generic_reset_hc() argument
192 uhci_writew(uhci, USBCMD_HCRESET, USBCMD); in uhci_generic_reset_hc()
195 if (uhci_readw(uhci, USBCMD) & USBCMD_HCRESET) in uhci_generic_reset_hc()
196 dev_warn(uhci_dev(uhci), "HCRESET not completed yet!\n"); in uhci_generic_reset_hc()
201 uhci_writew(uhci, 0, USBINTR); in uhci_generic_reset_hc()
202 uhci_writew(uhci, 0, USBCMD); in uhci_generic_reset_hc()
211 static int uhci_generic_check_and_reset_hc(struct uhci_hcd *uhci) in uhci_generic_check_and_reset_hc() argument
225 cmd = uhci_readw(uhci, USBCMD); in uhci_generic_check_and_reset_hc()
227 dev_dbg(uhci_dev(uhci), "%s: cmd = 0x%04x\n", in uhci_generic_check_and_reset_hc()
232 intr = uhci_readw(uhci, USBINTR); in uhci_generic_check_and_reset_hc()
234 dev_dbg(uhci_dev(uhci), "%s: intr = 0x%04x\n", in uhci_generic_check_and_reset_hc()
241 dev_dbg(uhci_dev(uhci), "Performing full reset\n"); in uhci_generic_check_and_reset_hc()
242 uhci_generic_reset_hc(uhci); in uhci_generic_check_and_reset_hc()
250 static void configure_hc(struct uhci_hcd *uhci) in configure_hc() argument
253 uhci_writeb(uhci, USBSOF_DEFAULT, USBSOF); in configure_hc()
256 uhci_writel(uhci, uhci->frame_dma_handle, USBFLBASEADD); in configure_hc()
259 uhci_writew(uhci, uhci->frame_number & UHCI_MAX_SOF_NUMBER, in configure_hc()
263 if (uhci->configure_hc) in configure_hc()
264 uhci->configure_hc(uhci); in configure_hc()
267 static int resume_detect_interrupts_are_broken(struct uhci_hcd *uhci) in resume_detect_interrupts_are_broken() argument
275 if (ignore_oc || uhci_is_aspeed(uhci)) in resume_detect_interrupts_are_broken()
278 return uhci->resume_detect_interrupts_are_broken ? in resume_detect_interrupts_are_broken()
279 uhci->resume_detect_interrupts_are_broken(uhci) : 0; in resume_detect_interrupts_are_broken()
282 static int global_suspend_mode_is_broken(struct uhci_hcd *uhci) in global_suspend_mode_is_broken() argument
284 return uhci->global_suspend_mode_is_broken ? in global_suspend_mode_is_broken()
285 uhci->global_suspend_mode_is_broken(uhci) : 0; in global_suspend_mode_is_broken()
288 static void suspend_rh(struct uhci_hcd *uhci, enum uhci_rh_state new_state) in suspend_rh() argument
289 __releases(uhci->lock) in suspend_rh()
290 __acquires(uhci->lock) in suspend_rh()
294 struct usb_device *rhdev = uhci_to_hcd(uhci)->self.root_hub; in suspend_rh()
343 if (!wakeup_enable || global_suspend_mode_is_broken(uhci) || in suspend_rh()
344 resume_detect_interrupts_are_broken(uhci)) in suspend_rh()
347 uhci->RD_enable = !!int_enable; in suspend_rh()
348 uhci_writew(uhci, int_enable, USBINTR); in suspend_rh()
349 uhci_writew(uhci, egsm_enable | USBCMD_CF, USBCMD); in suspend_rh()
358 if (!auto_stop && !(uhci_readw(uhci, USBSTS) & USBSTS_HCH)) { in suspend_rh()
359 uhci->rh_state = UHCI_RH_SUSPENDING; in suspend_rh()
360 spin_unlock_irq(&uhci->lock); in suspend_rh()
362 spin_lock_irq(&uhci->lock); in suspend_rh()
363 if (uhci->dead) in suspend_rh()
366 if (!(uhci_readw(uhci, USBSTS) & USBSTS_HCH)) in suspend_rh()
367 dev_warn(uhci_dev(uhci), "Controller not stopped yet!\n"); in suspend_rh()
369 uhci_get_current_frame_number(uhci); in suspend_rh()
371 uhci->rh_state = new_state; in suspend_rh()
372 uhci->is_stopped = UHCI_IS_STOPPED; in suspend_rh()
380 set_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); in suspend_rh()
382 clear_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); in suspend_rh()
384 uhci_scan_schedule(uhci); in suspend_rh()
385 uhci_fsbr_off(uhci); in suspend_rh()
388 static void start_rh(struct uhci_hcd *uhci) in start_rh() argument
390 uhci->is_stopped = 0; in start_rh()
396 if (uhci_is_aspeed(uhci)) in start_rh()
397 uhci_writew(uhci, uhci_readw(uhci, USBSTS), USBSTS); in start_rh()
402 uhci_writew(uhci, USBCMD_RS | USBCMD_CF | USBCMD_MAXP, USBCMD); in start_rh()
403 uhci_writew(uhci, USBINTR_TIMEOUT | USBINTR_RESUME | in start_rh()
406 uhci->rh_state = UHCI_RH_RUNNING; in start_rh()
407 set_bit(HCD_FLAG_POLL_RH, &uhci_to_hcd(uhci)->flags); in start_rh()
410 static void wakeup_rh(struct uhci_hcd *uhci) in wakeup_rh() argument
411 __releases(uhci->lock) in wakeup_rh()
412 __acquires(uhci->lock) in wakeup_rh()
414 dev_dbg(&uhci_to_hcd(uhci)->self.root_hub->dev, in wakeup_rh()
416 uhci->rh_state == UHCI_RH_AUTO_STOPPED ? in wakeup_rh()
423 if (uhci->rh_state == UHCI_RH_SUSPENDED) { in wakeup_rh()
427 egsm = uhci_readw(uhci, USBCMD) & USBCMD_EGSM; in wakeup_rh()
428 uhci->rh_state = UHCI_RH_RESUMING; in wakeup_rh()
429 uhci_writew(uhci, USBCMD_FGR | USBCMD_CF | egsm, USBCMD); in wakeup_rh()
430 spin_unlock_irq(&uhci->lock); in wakeup_rh()
432 spin_lock_irq(&uhci->lock); in wakeup_rh()
433 if (uhci->dead) in wakeup_rh()
437 uhci_writew(uhci, USBCMD_CF, USBCMD); in wakeup_rh()
440 if (uhci_readw(uhci, USBCMD) & USBCMD_FGR) in wakeup_rh()
441 dev_warn(uhci_dev(uhci), "FGR not stopped yet!\n"); in wakeup_rh()
444 start_rh(uhci); in wakeup_rh()
447 mod_timer(&uhci_to_hcd(uhci)->rh_timer, jiffies); in wakeup_rh()
452 struct uhci_hcd *uhci = hcd_to_uhci(hcd); in uhci_irq() local
460 status = uhci_readw(uhci, USBSTS); in uhci_irq()
463 uhci_writew(uhci, status, USBSTS); /* Clear it */ in uhci_irq()
465 spin_lock(&uhci->lock); in uhci_irq()
466 if (unlikely(!uhci->is_initialized)) /* not yet configured */ in uhci_irq()
471 dev_err(uhci_dev(uhci), in uhci_irq()
474 dev_err(uhci_dev(uhci), in uhci_irq()
477 if (uhci->rh_state >= UHCI_RH_RUNNING) { in uhci_irq()
478 dev_err(uhci_dev(uhci), in uhci_irq()
482 uhci_sprint_schedule(uhci, errbuf, in uhci_irq()
486 uhci_hc_died(uhci); in uhci_irq()
497 spin_unlock(&uhci->lock); in uhci_irq()
500 uhci_scan_schedule(uhci); in uhci_irq()
502 spin_unlock(&uhci->lock); in uhci_irq()
516 static void uhci_get_current_frame_number(struct uhci_hcd *uhci) in uhci_get_current_frame_number() argument
518 if (!uhci->is_stopped) { in uhci_get_current_frame_number()
521 delta = (uhci_readw(uhci, USBFRNUM) - uhci->frame_number) & in uhci_get_current_frame_number()
523 uhci->frame_number += delta; in uhci_get_current_frame_number()
530 static void release_uhci(struct uhci_hcd *uhci) in release_uhci() argument
535 spin_lock_irq(&uhci->lock); in release_uhci()
536 uhci->is_initialized = 0; in release_uhci()
537 spin_unlock_irq(&uhci->lock); in release_uhci()
539 debugfs_lookup_and_remove(uhci_to_hcd(uhci)->self.bus_name, in release_uhci()
543 uhci_free_qh(uhci, uhci->skelqh[i]); in release_uhci()
545 uhci_free_td(uhci, uhci->term_td); in release_uhci()
547 dma_pool_destroy(uhci->qh_pool); in release_uhci()
549 dma_pool_destroy(uhci->td_pool); in release_uhci()
551 kfree(uhci->frame_cpu); in release_uhci()
553 dma_free_coherent(uhci_dev(uhci), in release_uhci()
554 UHCI_NUMFRAMES * sizeof(*uhci->frame), in release_uhci()
555 uhci->frame, uhci->frame_dma_handle); in release_uhci()
578 struct uhci_hcd *uhci = hcd_to_uhci(hcd); in uhci_start() local
587 spin_lock_init(&uhci->lock); in uhci_start()
588 timer_setup(&uhci->fsbr_timer, uhci_fsbr_timeout, 0); in uhci_start()
589 INIT_LIST_HEAD(&uhci->idle_qh_list); in uhci_start()
590 init_waitqueue_head(&uhci->waitqh); in uhci_start()
594 uhci_debugfs_root, uhci, &uhci_debug_operations); in uhci_start()
597 uhci->frame = dma_alloc_coherent(uhci_dev(uhci), in uhci_start()
598 UHCI_NUMFRAMES * sizeof(*uhci->frame), in uhci_start()
599 &uhci->frame_dma_handle, GFP_KERNEL); in uhci_start()
600 if (!uhci->frame) { in uhci_start()
601 dev_err(uhci_dev(uhci), in uhci_start()
606 uhci->frame_cpu = kcalloc(UHCI_NUMFRAMES, sizeof(*uhci->frame_cpu), in uhci_start()
608 if (!uhci->frame_cpu) in uhci_start()
611 uhci->td_pool = dma_pool_create("uhci_td", uhci_dev(uhci), in uhci_start()
613 if (!uhci->td_pool) { in uhci_start()
614 dev_err(uhci_dev(uhci), "unable to create td dma_pool\n"); in uhci_start()
618 uhci->qh_pool = dma_pool_create("uhci_qh", uhci_dev(uhci), in uhci_start()
620 if (!uhci->qh_pool) { in uhci_start()
621 dev_err(uhci_dev(uhci), "unable to create qh dma_pool\n"); in uhci_start()
625 uhci->term_td = uhci_alloc_td(uhci); in uhci_start()
626 if (!uhci->term_td) { in uhci_start()
627 dev_err(uhci_dev(uhci), "unable to allocate terminating TD\n"); in uhci_start()
632 uhci->skelqh[i] = uhci_alloc_qh(uhci, NULL, NULL); in uhci_start()
633 if (!uhci->skelqh[i]) { in uhci_start()
634 dev_err(uhci_dev(uhci), "unable to allocate QH\n"); in uhci_start()
643 uhci->skelqh[i]->link = LINK_TO_QH(uhci, uhci->skel_async_qh); in uhci_start()
644 uhci->skel_async_qh->link = UHCI_PTR_TERM(uhci); in uhci_start()
645 uhci->skel_term_qh->link = LINK_TO_QH(uhci, uhci->skel_term_qh); in uhci_start()
648 uhci_fill_td(uhci, uhci->term_td, 0, uhci_explen(0) | in uhci_start()
650 uhci->term_td->link = UHCI_PTR_TERM(uhci); in uhci_start()
651 uhci->skel_async_qh->element = uhci->skel_term_qh->element = in uhci_start()
652 LINK_TO_TD(uhci, uhci->term_td); in uhci_start()
661 uhci->frame[i] = uhci_frame_skel_link(uhci, i); in uhci_start()
670 spin_lock_irq(&uhci->lock); in uhci_start()
671 configure_hc(uhci); in uhci_start()
672 uhci->is_initialized = 1; in uhci_start()
673 start_rh(uhci); in uhci_start()
674 spin_unlock_irq(&uhci->lock); in uhci_start()
682 if (uhci->skelqh[i]) in uhci_start()
683 uhci_free_qh(uhci, uhci->skelqh[i]); in uhci_start()
686 uhci_free_td(uhci, uhci->term_td); in uhci_start()
689 dma_pool_destroy(uhci->qh_pool); in uhci_start()
692 dma_pool_destroy(uhci->td_pool); in uhci_start()
695 kfree(uhci->frame_cpu); in uhci_start()
698 dma_free_coherent(uhci_dev(uhci), in uhci_start()
699 UHCI_NUMFRAMES * sizeof(*uhci->frame), in uhci_start()
700 uhci->frame, uhci->frame_dma_handle); in uhci_start()
710 struct uhci_hcd *uhci = hcd_to_uhci(hcd); in uhci_stop() local
712 spin_lock_irq(&uhci->lock); in uhci_stop()
713 if (HCD_HW_ACCESSIBLE(hcd) && !uhci->dead) in uhci_stop()
714 uhci_hc_died(uhci); in uhci_stop()
715 uhci_scan_schedule(uhci); in uhci_stop()
716 spin_unlock_irq(&uhci->lock); in uhci_stop()
719 del_timer_sync(&uhci->fsbr_timer); in uhci_stop()
720 release_uhci(uhci); in uhci_stop()
726 struct uhci_hcd *uhci = hcd_to_uhci(hcd); in uhci_rh_suspend() local
729 spin_lock_irq(&uhci->lock); in uhci_rh_suspend()
732 else if (uhci->dead) in uhci_rh_suspend()
741 uhci->resuming_ports) { in uhci_rh_suspend()
742 dev_dbg(uhci_dev(uhci), in uhci_rh_suspend()
746 suspend_rh(uhci, UHCI_RH_SUSPENDED); in uhci_rh_suspend()
747 spin_unlock_irq(&uhci->lock); in uhci_rh_suspend()
753 struct uhci_hcd *uhci = hcd_to_uhci(hcd); in uhci_rh_resume() local
756 spin_lock_irq(&uhci->lock); in uhci_rh_resume()
759 else if (!uhci->dead) in uhci_rh_resume()
760 wakeup_rh(uhci); in uhci_rh_resume()
761 spin_unlock_irq(&uhci->lock); in uhci_rh_resume()
771 struct uhci_hcd *uhci = hcd_to_uhci(hcd); in uhci_hcd_endpoint_disable() local
774 spin_lock_irq(&uhci->lock); in uhci_hcd_endpoint_disable()
780 ++uhci->num_waiting; in uhci_hcd_endpoint_disable()
781 spin_unlock_irq(&uhci->lock); in uhci_hcd_endpoint_disable()
782 wait_event_interruptible(uhci->waitqh, in uhci_hcd_endpoint_disable()
784 spin_lock_irq(&uhci->lock); in uhci_hcd_endpoint_disable()
785 --uhci->num_waiting; in uhci_hcd_endpoint_disable()
788 uhci_free_qh(uhci, qh); in uhci_hcd_endpoint_disable()
790 spin_unlock_irq(&uhci->lock); in uhci_hcd_endpoint_disable()
795 struct uhci_hcd *uhci = hcd_to_uhci(hcd); in uhci_hcd_get_frame_number() local
800 frame_number = uhci->frame_number; in uhci_hcd_get_frame_number()
802 delta = (uhci_readw(uhci, USBFRNUM) - frame_number) & in uhci_hcd_get_frame_number()
810 struct uhci_hcd *uhci = hcd_to_uhci(hcd); in uhci_count_ports() local
825 portstatus = uhci_readw(uhci, USBPORTSC1 + (port * 2)); in uhci_count_ports()
830 dev_info(uhci_dev(uhci), "detected %d ports\n", port); in uhci_count_ports()
834 dev_info(uhci_dev(uhci), in uhci_count_ports()