diff options
author | Jason Wright <jason@cvs.openbsd.org> | 1999-11-17 05:21:20 +0000 |
---|---|---|
committer | Jason Wright <jason@cvs.openbsd.org> | 1999-11-17 05:21:20 +0000 |
commit | 65e317faa1755553c19003a9789b12bfe4b2d7fc (patch) | |
tree | 7c2758c9dbf2a2bf7094c5219f7234c15f9c8fbf | |
parent | d0ac82c3a4f18433a1847ff846429e64a1e3dc2c (diff) |
merge with freebsd:
o make sure busmaster/io/mem bits are set appropriately
o make sure the card powers up correctly
-rw-r--r-- | sys/dev/pci/if_tx.c | 72 | ||||
-rw-r--r-- | sys/dev/pci/if_txvar.h | 11 |
2 files changed, 67 insertions, 16 deletions
diff --git a/sys/dev/pci/if_tx.c b/sys/dev/pci/if_tx.c index 0b126007e8e..be40b322069 100644 --- a/sys/dev/pci/if_tx.c +++ b/sys/dev/pci/if_tx.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_tx.c,v 1.8 1999/09/30 00:12:21 jason Exp $ */ -/* $FreeBSD: if_tx.c,v 1.27 1999/05/10 00:20:46 peter Exp $ */ +/* $OpenBSD: if_tx.c,v 1.9 1999/11/17 05:21:18 jason Exp $ */ +/* $FreeBSD: src/sys/pci/if_tx.c,v 1.33 1999/10/29 09:56:51 semenu Exp $ */ /*- * Copyright (c) 1997 Semen Ustimenko (semen@iclub.nsu.ru) @@ -25,9 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD: if_tx.c,v 1.21 1999/03/09 17:30:12 andreas Exp $ - * */ /* @@ -37,8 +34,6 @@ * Thanks are going to Steve Bauer and Jason Wright. * * todo: - * Deal with bus mastering, i.e. i realy don't know what to do with - * it and how it can improve performance. * Implement FULL IFF_MULTICAST support. * Test, test and test again:-( * @@ -250,23 +245,50 @@ epic_openbsd_attach( pci_intr_handle_t ih; const char *intrstr = NULL; struct ifnet *ifp; - bus_space_tag_t iot = pa->pa_iot; bus_addr_t iobase; bus_size_t iosize; int i; + u_int32_t command; #if !defined(EPIC_NOIFMEDIA) int tmp; #endif + command = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); + command |= PCI_COMMAND_IO_ENABLE | + PCI_COMMAND_MEM_ENABLE | + PCI_COMMAND_MASTER_ENABLE; + pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, command); + command = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); + +#ifdef EPIC_USEIOSPACE + if (!(command & PCI_COMMAND_IO_ENABLE)) { + printf(": failed to enable memory mapping\n"); + return; + } if( pci_io_find(pc, pa->pa_tag, PCI_CBIO, &iobase, &iosize)) { printf(": can't find i/o space\n"); return; } - if( bus_space_map(iot, iobase, iosize, 0, &sc->sc_sh)) { + if( bus_space_map(pa->pa_iot, iobase, iosize, 0, &sc->sc_sh)) { + printf(": can't map i/o space\n"); + return; + } + sc->sc_st = pa->pa_iot; +#else + if (!(command & PCI_COMMAND_MEM_ENABLE)) { + printf(": failed to enable memory mapping\n"); + return; + } + if( pci_mem_find(pc, pa->pa_tag, PCI_CBMA, &iobase, &iosize, NULL)) { + printf(": can't find mem space\n"); + return; + } + if( bus_space_map(pa->pa_memt, iobase, iosize, 0, &sc->sc_sh)) { printf(": can't map i/o space\n"); return; } - sc->sc_st = iot; + sc->sc_st = pa->pa_memt; +#endif ifp = &sc->sc_if; bcopy(sc->sc_dev.dv_xname, ifp->if_xname,IFNAMSIZ); @@ -424,6 +446,7 @@ epic_freebsd_attach( #else caddr_t pmembase; #endif + u_int32_t command; int i,s,tmp; printf("tx%d",unit); @@ -452,12 +475,34 @@ epic_freebsd_attach( /* Get iobase or membase */ #if defined(EPIC_USEIOSPACE) + command = PCI_CONF_READ(PCI_CFCS); + command |= PCI_CFCS_IOEN; + PCI_CONF_WRITE(PCI_CFCS, command); + command = PCI_CONF_READ(PCI_CFCS); + + if (!(command & PCI_CFCS_IOEN)) { + printf(": failed to enable memory mapping!\n"); + free(sc, M_DEVBUF); + return; + } + if (!pci_map_port(config_id, PCI_CBIO,(u_short *) &(sc->iobase))) { printf(": cannot map port\n"); free(sc, M_DEVBUF); return; } #else + command = PCI_CONF_READ(PCI_CFCS); + command |= PCI_CFCS_MAEN; + PCI_CONF_WRITE(PCI_CFCS, command); + command = PCI_CONF_READ(PCI_CFCS); + + if (!(command & PCI_CFCS_MAEN)) { + printf(": failed to enable memory mapping!\n"); + free(sc, M_DEVBUF); + return; + } + if (!pci_map_mem(config_id, PCI_CBMA,(vm_offset_t *) &(sc->csr),(vm_offset_t *) &pmembase)) { printf(": cannot map memory\n"); free(sc, M_DEVBUF); @@ -465,8 +510,13 @@ epic_freebsd_attach( } #endif + /* Do OS independent part, including chip wakeup and reset */ if( epic_common_attach(sc) ) return; + command = PCI_CONF_READ(PCI_CFCS); + command |= PCI_CFCS_BMEN; + PCI_CONF_WRITE(PCI_CFCS, command); + /* Display ethernet address ,... */ printf(": address %02x:%02x:%02x:%02x:%02x:%02x,", sc->sc_macaddr[0],sc->sc_macaddr[1],sc->sc_macaddr[2], @@ -733,7 +783,7 @@ epic_common_attach( sc->tx_desc = (void *)pool; /* Bring the chip out of low-power mode. */ - CSR_WRITE_4( sc, GENCTL, 0x0000 ); + CSR_WRITE_4( sc, GENCTL, GENCTL_SOFT_RESET); /* Workaround for Application Note 7-15 */ for (i=0; i<16; i++) CSR_WRITE_4(sc, TEST1, TEST1_CLOCK_TEST); diff --git a/sys/dev/pci/if_txvar.h b/sys/dev/pci/if_txvar.h index dabd650b76b..7fd538ae248 100644 --- a/sys/dev/pci/if_txvar.h +++ b/sys/dev/pci/if_txvar.h @@ -1,5 +1,5 @@ -/* $OpenBSD: if_txvar.h,v 1.6 1999/06/29 17:13:40 jason Exp $ */ -/* $FreeBSD: if_txvar.h,v 1.3 1999/05/22 06:10:14 semenu Exp $ */ +/* $OpenBSD: if_txvar.h,v 1.7 1999/11/17 05:21:19 jason Exp $ */ +/* $FreeBSD: src/sys/pci/if_txvar.h,v 1.5 1999/10/29 09:56:52 semenu Exp $ */ /*- * Copyright (c) 1997 Semen Ustimenko @@ -25,9 +25,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD: if_txvar.h,v 1.2 1999/03/14 08:30:23 semenu Exp $ - * */ /* @@ -68,6 +65,10 @@ #define PCI_CFIT 0x3c /* Configuration Interrupt */ #define PCI_CFDA 0x40 /* Configuration Driver Area */ +#define PCI_CFCS_IOEN 0x0001 /* IO Space Enable */ +#define PCI_CFCS_MAEN 0x0002 /* Memory Space Enable */ +#define PCI_CFCS_BMEN 0x0004 /* Bus Master Enable */ + #define PCI_CONF_WRITE(r, v) pci_conf_write(config_id, (r), (v)) #define PCI_CONF_READ(r) pci_conf_read(config_id, (r)) |