diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2009-08-29 21:30:49 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2009-08-29 21:30:49 +0000 |
commit | 47350a290a93e2f2d5160b6bb03114cfc45ef637 (patch) | |
tree | d46294788962cd37f35c4276d7b8dde1329dd3eb /sys/arch | |
parent | 6bed2bd2bebb3bc2213623236ef2874fc2fb9141 (diff) |
Glue for the SBus version of the Sun Vector Gigabit Ethernet card.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/sparc/conf/GENERIC | 3 | ||||
-rw-r--r-- | sys/arch/sparc/conf/files.sparc | 5 | ||||
-rw-r--r-- | sys/arch/sparc/dev/if_ti_sbus.c | 118 |
3 files changed, 124 insertions, 2 deletions
diff --git a/sys/arch/sparc/conf/GENERIC b/sys/arch/sparc/conf/GENERIC index ae863260221..bbd13e6473a 100644 --- a/sys/arch/sparc/conf/GENERIC +++ b/sys/arch/sparc/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.93 2009/07/13 19:53:58 kettenis Exp $ +# $OpenBSD: GENERIC,v 1.94 2009/08/29 21:30:48 kettenis Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -200,6 +200,7 @@ be* at qec? # Gigabit ethernet gem* at sbus? +ti* at sbus? # Xylogics 753 or 7053 VME SMD disk controllers and disks, found # on sun4 systems. diff --git a/sys/arch/sparc/conf/files.sparc b/sys/arch/sparc/conf/files.sparc index cc96c86613d..272f90a4968 100644 --- a/sys/arch/sparc/conf/files.sparc +++ b/sys/arch/sparc/conf/files.sparc @@ -1,4 +1,4 @@ -# $OpenBSD: files.sparc,v 1.84 2009/07/13 19:53:58 kettenis Exp $ +# $OpenBSD: files.sparc,v 1.85 2009/08/29 21:30:48 kettenis Exp $ # $NetBSD: files.sparc,v 1.44 1997/08/31 21:29:16 pk Exp $ # @(#)files.sparc 8.1 (Berkeley) 7/19/93 @@ -133,6 +133,9 @@ file arch/sparc/dev/qe.c qe attach gem at sbus with gem_sbus file arch/sparc/dev/if_gem_sbus.c gem_sbus +attach ti at sbus with ti_sbus +file arch/sparc/dev/if_ti_sbus.c ti_sbus + # HappyMeal (hme) ethernet device hme: ifnet, ether, mii, ifmedia attach hme at sbus diff --git a/sys/arch/sparc/dev/if_ti_sbus.c b/sys/arch/sparc/dev/if_ti_sbus.c new file mode 100644 index 00000000000..fefd0987969 --- /dev/null +++ b/sys/arch/sparc/dev/if_ti_sbus.c @@ -0,0 +1,118 @@ +/* $OpenBSD: if_ti_sbus.c,v 1.1 2009/08/29 21:30:48 kettenis Exp $ */ +/* + * Copyright (c) 2009 Mark Kettenis + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/param.h> +#include <sys/device.h> +#include <sys/socket.h> + +#include <net/if.h> +#include <net/if_dl.h> +#include <net/if_media.h> + +#ifdef INET +#include <netinet/in.h> +#include <netinet/in_systm.h> +#include <netinet/in_var.h> +#include <netinet/ip.h> +#include <netinet/if_ether.h> +#endif + +#include <machine/autoconf.h> +#include <machine/bus.h> +extern struct sparc_bus_dma_tag *iommu_dmatag; + +#include <dev/pci/pcireg.h> + +#include <dev/ic/tireg.h> +#include <dev/ic/tivar.h> + +struct ti_sbus_softc { + struct ti_softc tsc_sc; + struct intrhand tsc_ih; + struct rom_reg tsc_rr; +}; + +int ti_sbus_match(struct device *, void *, void *); +void ti_sbus_attach(struct device *, struct device *, void *); + +struct cfattach ti_sbus_ca = { + sizeof(struct ti_sbus_softc), ti_sbus_match, ti_sbus_attach +}; + +int +ti_sbus_match(struct device *parent, void *match, void *aux) +{ + struct confargs *ca = aux; + struct romaux *ra = &ca->ca_ra; + + return (strcmp("SUNW,vge", ra->ra_name) == 0); +} + +void +ti_sbus_attach(struct device *parent, struct device *self, void *aux) +{ + struct confargs *ca = aux; + struct ti_sbus_softc *tsc = (void *)self; + struct ti_softc *sc = &tsc->tsc_sc; + bus_space_handle_t ioh; + + /* Pass on the bus tags */ + tsc->tsc_rr = ca->ca_ra.ra_reg[1]; + sc->ti_btag = &tsc->tsc_rr; + sc->sc_dmatag = iommu_dmatag; + + if (ca->ca_ra.ra_nintr < 1) { + printf(": no interrupt\n"); + return; + } + + if (ca->ca_ra.ra_nreg < 2) { + printf(": only %d register sets\n", ca->ca_ra.ra_nreg); + return; + } + + if (bus_space_map(&ca->ca_ra.ra_reg[1], 0, + ca->ca_ra.ra_reg[1].rr_len, 0, &sc->ti_bhandle)) { + printf(": can't map registers\n"); + return; + } + + if (bus_space_map(&ca->ca_ra.ra_reg[0], 0, + ca->ca_ra.ra_reg[0].rr_len, 0, &ioh)) { + printf(": can't map registers\n"); + goto fail; + } + + tsc->tsc_ih.ih_fun = ti_intr; + tsc->tsc_ih.ih_arg = sc; + intr_establish(ca->ca_ra.ra_intr[0].int_pri, &tsc->tsc_ih, + IPL_NET, self->dv_xname); + + bus_space_write_4(sc->ti_btag, ioh, TI_PCI_CMDSTAT, 0x02000006); + bus_space_write_4(sc->ti_btag, ioh, TI_PCI_BIST, 0xffffffff); + bus_space_write_4(sc->ti_btag, ioh, TI_PCI_LOMEM, 0x00000400); + + bus_space_unmap(&ca->ca_ra.ra_reg[0], ioh, ca->ca_ra.ra_reg[0].rr_len); + + sc->ti_sbus = 1; + if (ti_attach(sc) == 0) + return; + +fail: + bus_space_unmap(&ca->ca_ra.ra_reg[1], sc->ti_bhandle, + ca->ca_ra.ra_reg[1].rr_len); +} |