From 6384b0f1bb77cfc4f79d471e78178023017afc68 Mon Sep 17 00:00:00 2001 From: Julian Elischer Date: Mon, 14 Dec 1998 21:14:11 +0000 Subject: [PATCH] The OHCI interfaces I have access to map their control regs etc. into memory address space rather than IO space.. reflect this when looking for the interface revision register. If this is not true for them all then we probably need some smarter code. --- sys/dev/pci/ohci_pci.c | 11 ++++++++--- sys/dev/usb/ohci.c | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/sys/dev/pci/ohci_pci.c b/sys/dev/pci/ohci_pci.c index 0d3e325e19b2..30aa1585af98 100644 --- a/sys/dev/pci/ohci_pci.c +++ b/sys/dev/pci/ohci_pci.c @@ -1,5 +1,5 @@ /* $NetBSD: ohci_pci.c,v 1.5 1998/11/25 22:32:04 augustss Exp $ */ -/* FreeBSD $Id$ */ +/* FreeBSD $Id: ohci_pci.c,v 1.5 1998/12/14 09:40:14 n_hibma Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -226,6 +226,7 @@ ohci_pci_attach(pcici_t config_id, int unit) usbd_status r; ohci_softc_t *sc = NULL; int rev; + vm_offset_t pbase; sc = malloc(sizeof(ohci_softc_t), M_DEVBUF, M_NOWAIT); /* Do not free it below, intr might use the sc */ @@ -235,7 +236,11 @@ ohci_pci_attach(pcici_t config_id, int unit) } memset(sc, 0, sizeof(ohci_softc_t)); - sc->sc_iobase = pci_conf_read(config_id,PCI_OHCI_BASE_REG) & 0xfffff000; + if(!pci_map_mem(config_id, PCI_CBMEM, + (vm_offset_t *)&sc->sc_iobase, &pbase)) { + printf("usb%d: couldn't map memory\n", unit); + return; + } sc->unit = unit; if ( !pci_map_int(config_id, (pci_inthand_t *)ohci_intr, @@ -249,7 +254,7 @@ ohci_pci_attach(pcici_t config_id, int unit) #endif { /* XXX is this correct? Does the correct version show up? */ - rev = inw(sc->sc_iobase+OHCI_REVISION); + rev = *((unsigned int *)(sc->sc_iobase+OHCI_REVISION)); printf("usb%d: OHCI version %d%d, interrupting at %d\n", unit, OHCI_REV_HI(rev), OHCI_REV_LO(rev), (int)pci_conf_read(config_id,PCI_INTERRUPT_REG) & 0xff); diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index ec4973dedb92..90f638a05d7e 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1,5 +1,5 @@ /* $NetBSD: ohci.c,v 1.12 1998/11/30 21:39:20 augustss Exp $ */ -/* FreeBSD $Id$ */ +/* FreeBSD $Id: ohci.c,v 1.4 1998/12/14 09:32:23 n_hibma Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -144,9 +144,9 @@ void ohci_dump_ed __P((ohci_soft_ed_t *)); #define OREAD4(sc, r) bus_space_read_4((sc)->iot, (sc)->ioh, (r)) #define OREAD2(sc, r) bus_space_read_2((sc)->iot, (sc)->ioh, (r)) #elif defined(__FreeBSD__) -#define OWRITE4(sc, r, x) outl((sc)->sc_iobase + (r), (x)) -#define OREAD4(sc, r) inl((sc)->sc_iobase + (r)) -#define OREAD2(sc, r) inw((sc)->sc_iobase + (r)) +#define OWRITE4(sc, r, x) *(unsigned int *) ((sc)->sc_iobase + (r)) = x +#define OREAD4(sc, r) (*(unsigned int *) ((sc)->sc_iobase + (r))) +#define OREAD2(sc, r) (*(unsigned short *) ((sc)->sc_iobase + (r))) #endif /* Reverse the bits in a value 0 .. 31 */