Deleted Added
sdiff udiff text old ( 227461 ) new ( 228483 )
full compact
1/*-
2 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
3 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
4 * Copyright (c) 1998 Lennart Augustsson. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/dev/usb/controller/ohci.c 228483 2011-12-14 00:28:54Z hselasky $");
30
31/*
32 * USB Open Host Controller driver.
33 *
34 * OHCI spec: http://www.compaq.com/productinfo/development/openhci.html
35 * USB spec: http://www.usb.org/developers/docs/usbspec.zip
36 */
37

--- 123 unchanged lines hidden (view full) ---

161
162 for (i = 0; i != OHCI_NO_EDS; i++) {
163 cb(bus, sc->sc_hw.intr_start_pc + i, sc->sc_hw.intr_start_pg + i,
164 sizeof(ohci_ed_t), OHCI_ED_ALIGN);
165 }
166}
167
168static usb_error_t
169ohci_controller_init(ohci_softc_t *sc, int do_suspend)
170{
171 struct usb_page_search buf_res;
172 uint32_t i;
173 uint32_t ctl;
174 uint32_t ival;
175 uint32_t hcr;
176 uint32_t fm;
177 uint32_t per;

--- 50 unchanged lines hidden (view full) ---

228 return (USB_ERR_IOERROR);
229 }
230#ifdef USB_DEBUG
231 if (ohcidebug > 15) {
232 ohci_dumpregs(sc);
233 }
234#endif
235
236 if (do_suspend) {
237 OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_SUSPEND);
238 return (USB_ERR_NORMAL_COMPLETION);
239 }
240
241 /* The controller is now in SUSPEND state, we have 2ms to finish. */
242
243 /* set up HC registers */
244 usbd_get_page(&sc->sc_hw.hcca_pc, 0, &buf_res);
245 OWRITE4(sc, OHCI_HCCA, buf_res.physaddr);
246
247 usbd_get_page(&sc->sc_hw.ctrl_start_pc, 0, &buf_res);
248 OWRITE4(sc, OHCI_CONTROL_HEAD_ED, buf_res.physaddr);

--- 166 unchanged lines hidden (view full) ---

415 }
416 printf("iso ");
417 ohci_dump_ed(sc->sc_isoc_p_last);
418 }
419#endif
420
421 sc->sc_bus.usbrev = USB_REV_1_0;
422
423 if (ohci_controller_init(sc, 0) != 0)
424 return (USB_ERR_INVAL);
425
426 /* catch any lost interrupts */
427 ohci_do_poll(&sc->sc_bus);
428 return (USB_ERR_NORMAL_COMPLETION);
429}
430
431/*
432 * shut down the controller when the system is going down
433 */
434void
435ohci_detach(struct ohci_softc *sc)
436{

--- 7 unchanged lines hidden (view full) ---

444 USB_BUS_UNLOCK(&sc->sc_bus);
445
446 /* XXX let stray task complete */
447 usb_pause_mtx(NULL, hz / 20);
448
449 usb_callout_drain(&sc->sc_tmo_rhsc);
450}
451
452static void
453ohci_suspend(ohci_softc_t *sc)
454{
455 DPRINTF("\n");
456
457#ifdef USB_DEBUG
458 if (ohcidebug > 2)
459 ohci_dumpregs(sc);
460#endif
461
462 /* reset HC and leave it suspended */
463 ohci_controller_init(sc, 1);
464}
465
466static void
467ohci_resume(ohci_softc_t *sc)
468{
469 DPRINTF("\n");
470
471#ifdef USB_DEBUG
472 if (ohcidebug > 2)
473 ohci_dumpregs(sc);
474#endif
475
476 /* some broken BIOSes never initialize the Controller chip */
477 ohci_controller_init(sc, 0);
478
479 /* catch any lost interrupts */
480 ohci_do_poll(&sc->sc_bus);
481}
482
483#ifdef USB_DEBUG
484static void
485ohci_dumpregs(ohci_softc_t *sc)
486{

--- 2182 unchanged lines hidden (view full) ---

2669 }
2670
2671 USB_BUS_UNLOCK(udev->bus);
2672
2673 return;
2674}
2675
2676static void
2677ohci_set_hw_power_sleep(struct usb_bus *bus, uint32_t state)
2678{
2679 struct ohci_softc *sc = OHCI_BUS2SC(bus);
2680
2681 switch (state) {
2682 case USB_HW_POWER_SUSPEND:
2683 case USB_HW_POWER_SHUTDOWN:
2684 ohci_suspend(sc);
2685 break;
2686 case USB_HW_POWER_RESUME:
2687 ohci_resume(sc);
2688 break;
2689 default:
2690 break;
2691 }
2692}
2693
2694static void
2695ohci_set_hw_power(struct usb_bus *bus)
2696{
2697 struct ohci_softc *sc = OHCI_BUS2SC(bus);
2698 uint32_t temp;
2699 uint32_t flags;
2700
2701 DPRINTF("\n");
2702

--- 27 unchanged lines hidden (view full) ---

2730{
2731 .endpoint_init = ohci_ep_init,
2732 .xfer_setup = ohci_xfer_setup,
2733 .xfer_unsetup = ohci_xfer_unsetup,
2734 .get_dma_delay = ohci_get_dma_delay,
2735 .device_resume = ohci_device_resume,
2736 .device_suspend = ohci_device_suspend,
2737 .set_hw_power = ohci_set_hw_power,
2738 .set_hw_power_sleep = ohci_set_hw_power_sleep,
2739 .roothub_exec = ohci_roothub_exec,
2740 .xfer_poll = ohci_do_poll,
2741};