summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/ohci_pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb/ohci_pci.c')
-rw-r--r--sys/dev/usb/ohci_pci.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/sys/dev/usb/ohci_pci.c b/sys/dev/usb/ohci_pci.c
index 1afd9bc..1401a4b 100644
--- a/sys/dev/usb/ohci_pci.c
+++ b/sys/dev/usb/ohci_pci.c
@@ -55,6 +55,8 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/module.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
#include <sys/bus.h>
#include <sys/queue.h>
#include <machine/bus.h>
@@ -303,6 +305,30 @@ ohci_pci_attach(device_t self)
ohci_pci_detach(self);
return ENXIO;
}
+
+ /* Allocate a parent dma tag for DMA maps */
+ err = bus_dma_tag_create(NULL, 1, 0, BUS_SPACE_MAXADDR_32BIT,
+ BUS_SPACE_MAXADDR, NULL, NULL, BUS_SPACE_MAXSIZE_32BIT,
+ USB_DMA_NSEG, BUS_SPACE_MAXSIZE_32BIT, 0, NULL, NULL,
+ &sc->sc_bus.parent_dmatag);
+ if (err) {
+ device_printf(self, "Could not allocate parent DMA tag (%d)\n",
+ err);
+ ohci_pci_detach(self);
+ return ENXIO;
+ }
+ /* Allocate a dma tag for transfer buffers */
+ err = bus_dma_tag_create(sc->sc_bus.parent_dmatag, 1, 0,
+ BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+ BUS_SPACE_MAXSIZE_32BIT, USB_DMA_NSEG, BUS_SPACE_MAXSIZE_32BIT, 0,
+ busdma_lock_mutex, &Giant, &sc->sc_bus.buffer_dmatag);
+ if (err) {
+ device_printf(self, "Could not allocate transfer tag (%d)\n",
+ err);
+ ohci_pci_detach(self);
+ return ENXIO;
+ }
+
err = ohci_init(sc);
if (!err) {
sc->sc_flags |= OHCI_SCFLG_DONEINIT;
@@ -327,6 +353,11 @@ ohci_pci_detach(device_t self)
sc->sc_flags &= ~OHCI_SCFLG_DONEINIT;
}
+ if (sc->sc_bus.parent_dmatag != NULL)
+ bus_dma_tag_destroy(sc->sc_bus.parent_dmatag);
+ if (sc->sc_bus.buffer_dmatag != NULL)
+ bus_dma_tag_destroy(sc->sc_bus.buffer_dmatag);
+
if (sc->irq_res && sc->ih) {
int err = bus_teardown_intr(self, sc->irq_res, sc->ih);
@@ -345,7 +376,8 @@ ohci_pci_detach(device_t self)
sc->irq_res = NULL;
}
if (sc->io_res) {
- bus_release_resource(self, SYS_RES_MEMORY, PCI_CBMEM, sc->io_res);
+ bus_release_resource(self, SYS_RES_MEMORY, PCI_CBMEM,
+ sc->io_res);
sc->io_res = NULL;
sc->iot = 0;
sc->ioh = 0;
OpenPOWER on IntegriCloud