From 3d583874d52b8fd407af22d491f81ae07ece2070 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 10 Jun 2005 18:33:04 +0000 Subject: [PATCH] Another terrible hack to leave interrupts disabled until the USB bus has completed initialization. --- sys/bus/usb/ohci.c | 17 ++++++++++++++--- sys/bus/usb/ohci_pci.c | 4 ++-- sys/bus/usb/ohcivar.h | 3 ++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/sys/bus/usb/ohci.c b/sys/bus/usb/ohci.c index fcc2565f8d..4db13ad0dc 100644 --- a/sys/bus/usb/ohci.c +++ b/sys/bus/usb/ohci.c @@ -1,7 +1,7 @@ /* * $NetBSD: ohci.c,v 1.138 2003/02/08 03:32:50 ichiro Exp $ * $FreeBSD: src/sys/dev/usb/ohci.c,v 1.141 2003/12/22 15:40:10 shiba Exp $ - * $DragonFly: src/sys/bus/usb/ohci.c,v 1.10 2005/06/02 20:40:40 dillon Exp $ + * $DragonFly: src/sys/bus/usb/ohci.c,v 1.11 2005/06/10 18:33:04 dillon Exp $ */ /* Also, already ported: * $NetBSD: ohci.c,v 1.140 2003/05/13 04:42:00 gson Exp $ @@ -829,6 +829,12 @@ ohci_init(ohci_softc_t *sc) return (err); } +void +ohci_init_intrs(ohci_softc_t *sc) +{ + OWRITE4(sc, OHCI_INTERRUPT_ENABLE, sc->sc_eintrs | OHCI_MIE); +} + Static usbd_status ohci_controller_init(ohci_softc_t *sc) { @@ -903,9 +909,12 @@ ohci_controller_init(ohci_softc_t *sc) OWRITE4(sc, OHCI_HCCA, DMAADDR(&sc->sc_hccadma, 0)); OWRITE4(sc, OHCI_CONTROL_HEAD_ED, sc->sc_ctrl_head->physaddr); OWRITE4(sc, OHCI_BULK_HEAD_ED, sc->sc_bulk_head->physaddr); - /* disable all interrupts and then switch on all desired interrupts */ + + /* + * disable all interrupts to avoid events while we are initializing + * the device. + */ OWRITE4(sc, OHCI_INTERRUPT_DISABLE, OHCI_ALL_INTRS); - OWRITE4(sc, OHCI_INTERRUPT_ENABLE, sc->sc_eintrs | OHCI_MIE); /* switch on desired functional features */ ctl = OREAD4(sc, OHCI_CONTROL); ctl &= ~(OHCI_CBSR_MASK | OHCI_LES | OHCI_HCFS_MASK | OHCI_IR); @@ -1079,6 +1088,8 @@ ohci_power(int why, void *v) usb_delay_ms(&sc->sc_bus, USB_RESUME_RECOVERY); sc->sc_control = sc->sc_intre = 0; sc->sc_bus.use_polling--; + ohci_init_intrs(sc); + } crit_exit(); } diff --git a/sys/bus/usb/ohci_pci.c b/sys/bus/usb/ohci_pci.c index ef6aaef0f8..adc35a7f80 100644 --- a/sys/bus/usb/ohci_pci.c +++ b/sys/bus/usb/ohci_pci.c @@ -35,7 +35,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/usb/ohci_pci.c,v 1.38 2003/12/22 15:18:46 shiba Exp $ - * $DragonFly: src/sys/bus/usb/ohci_pci.c,v 1.2 2005/05/24 20:58:54 dillon Exp $ + * $DragonFly: src/sys/bus/usb/ohci_pci.c,v 1.3 2005/06/10 18:33:04 dillon Exp $ */ /* @@ -292,12 +292,12 @@ ohci_pci_attach(device_t self) err = ohci_init(sc); if (!err) err = device_probe_and_attach(sc->sc_bus.bdev); - if (err) { device_printf(self, "USB init failed\n"); ohci_pci_detach(self); return EIO; } + ohci_init_intrs(sc); return 0; } diff --git a/sys/bus/usb/ohcivar.h b/sys/bus/usb/ohcivar.h index 08d96694d9..2896002422 100644 --- a/sys/bus/usb/ohcivar.h +++ b/sys/bus/usb/ohcivar.h @@ -1,7 +1,7 @@ /* * $NetBSD: ohcivar.h,v 1.30 2001/12/31 12:20:35 augustss Exp $ * $FreeBSD: src/sys/dev/usb/ohcivar.h,v 1.36 2003/12/22 15:18:46 shiba Exp $ - * $DragonFly: src/sys/bus/usb/ohcivar.h,v 1.4 2004/02/11 15:17:26 joerg Exp $ + * $DragonFly: src/sys/bus/usb/ohcivar.h,v 1.5 2005/06/10 18:33:04 dillon Exp $ */ /* @@ -161,6 +161,7 @@ struct ohci_xfer { #define OXFER(xfer) ((struct ohci_xfer *)(xfer)) usbd_status ohci_init(ohci_softc_t *); +void ohci_init_intrs(ohci_softc_t *); int ohci_intr(void *); #if defined(__NetBSD__) || defined(__OpenBSD__) int ohci_detach(ohci_softc_t *, int); -- 2.41.0