Home | History | Annotate | Line # | Download | only in dev
if_ie_obio.c revision 1.5
      1 /*	$NetBSD: if_ie_obio.c,v 1.5 1996/10/30 00:24:34 gwr Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1994 Gordon W. Ross
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by Gordon Ross
     18  * 4. The name of the Author may not be used to endorse or promote products
     19  *    derived from this software without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31  */
     32 
     33 /*
     34  * Machine-dependent glue for the Intel Ethernet (ie) driver.
     35  */
     36 
     37 #include <sys/param.h>
     38 #include <sys/systm.h>
     39 #include <sys/device.h>
     40 #include <sys/protosw.h>
     41 #include <sys/socket.h>
     42 #include <net/if.h>
     43 
     44 #ifdef INET
     45 #include <netinet/in.h>
     46 #include <netinet/in_systm.h>
     47 #include <netinet/in_var.h>
     48 #include <netinet/ip.h>
     49 #include <netinet/if_ether.h>
     50 #endif
     51 
     52 #include <machine/autoconf.h>
     53 #include <machine/cpu.h>
     54 #include <machine/dvma.h>
     55 #include <machine/isr.h>
     56 #include <machine/obio.h>
     57 #include <machine/idprom.h>
     58 #include <machine/vmparam.h>
     59 
     60 #include "i82586.h"
     61 #include "if_iereg.h"
     62 #include "if_ievar.h"
     63 
     64 static void ie_obreset __P((struct ie_softc *));
     65 static void ie_obattend __P((struct ie_softc *));
     66 static void ie_obrun __P((struct ie_softc *));
     67 
     68 /*
     69  * New-style autoconfig attachment
     70  */
     71 
     72 static int  ie_obio_match __P((struct device *, void *, void *));
     73 static void ie_obio_attach __P((struct device *, struct device *, void *));
     74 
     75 struct cfattach ie_obio_ca = {
     76 	sizeof(struct ie_softc), ie_obio_match, ie_obio_attach
     77 };
     78 
     79 
     80 static int
     81 ie_obio_match(parent, vcf, args)
     82 	struct device *parent;
     83 	void *vcf, *args;
     84 {
     85 	struct cfdata *cf = vcf;
     86 	struct confargs *ca = args;
     87 
     88 	/* Make sure there is something there... */
     89 	if (bus_peek(ca->ca_bustype, ca->ca_paddr, 1) == -1)
     90 		return (0);
     91 
     92 	/* Default interrupt priority. */
     93 	if (ca->ca_intpri == -1)
     94 		ca->ca_intpri = 3;
     95 
     96 	return (1);
     97 }
     98 
     99 void
    100 ie_obio_attach(parent, self, args)
    101 	struct device *parent;
    102 	struct device *self;
    103 	void *args;
    104 {
    105 	struct ie_softc *sc = (void *) self;
    106 	struct cfdata *cf = self->dv_cfdata;
    107 	struct confargs *ca = args;
    108 
    109 	sc->hard_type = IE_OBIO;
    110 	sc->reset_586 = ie_obreset;
    111 	sc->chan_attn = ie_obattend;
    112 	sc->run_586 = ie_obrun;
    113 	sc->sc_bcopy = bcopy;
    114 	sc->sc_bzero = bzero;
    115 
    116 	/*
    117 	 * The on-board "ie" just uses main memory, so
    118 	 * we can choose how much memory to give it.
    119 	 * XXX: Would like to use less than 64K...
    120 	 */
    121 	sc->sc_msize = 0x8000; /* MEMSIZE 32K */
    122 
    123 	/* Map in the control registers. */
    124 	sc->sc_reg = obio_alloc(ca->ca_paddr, OBIO_INTEL_ETHER_SIZE);
    125 
    126 	/* Allocate "shared" memory (in DVMA space). */
    127 	sc->sc_maddr = dvma_malloc(sc->sc_msize);
    128 	if (sc->sc_maddr == NULL)
    129 		panic(": not enough dvma space");
    130 
    131 	/*
    132 	 * The on-board "ie" is wired-up such that its
    133 	 * memory access goes to the high 16 megabytes
    134 	 * of the on-board memory space (on-board DVMA).
    135 	 */
    136 	sc->sc_iobase = (caddr_t)DVMA_OBIO_SLAVE_BASE;
    137 
    138 	/*
    139 	 * Set the System Configuration Pointer (SCP).
    140 	 * Its location is system-dependent because the
    141 	 * i82586 reads it from a fixed physical address.
    142 	 * On this hardware, the i82586 address maps to
    143 	 * a 24-bit offset in on-board DVMA space. The
    144 	 * SCP happens to fall in a page used by the
    145 	 * PROM monitor, which the PROM knows about.
    146 	 */
    147 	sc->scp = (volatile void *) (sc->sc_iobase + IE_SCP_ADDR);
    148 
    149 	/*
    150 	 * The rest of ram is used for buffers.
    151 	 */
    152 	sc->buf_area    = sc->sc_maddr;
    153 	sc->buf_area_sz = sc->sc_msize;
    154 
    155 	/* Set the ethernet address. */
    156 	idprom_etheraddr(sc->sc_addr);
    157 
    158 	/* Do machine-independent parts of attach. */
    159 	ie_attach(sc);
    160 
    161 	/* Install interrupt handler. */
    162 	isr_add_autovect(ie_intr, (void *)sc, ca->ca_intpri);
    163 }
    164 
    165 
    166 /*
    167  * onboard ie support
    168  */
    169 void
    170 ie_obreset(sc)
    171 	struct ie_softc *sc;
    172 {
    173 	volatile struct ieob *ieo = (struct ieob *) sc->sc_reg;
    174 	ieo->obctrl = 0;
    175 	delay(100);			/* XXX could be shorter? */
    176 	ieo->obctrl = IEOB_NORSET;
    177 }
    178 void
    179 ie_obattend(sc)
    180 	struct ie_softc *sc;
    181 {
    182 	volatile struct ieob *ieo = (struct ieob *) sc->sc_reg;
    183 
    184 	ieo->obctrl |= IEOB_ATTEN;	/* flag! */
    185 	ieo->obctrl &= ~IEOB_ATTEN;	/* down. */
    186 }
    187 
    188 void
    189 ie_obrun(sc)
    190 	struct ie_softc *sc;
    191 {
    192 	volatile struct ieob *ieo = (struct ieob *) sc->sc_reg;
    193 
    194 	ieo->obctrl |= (IEOB_ONAIR|IEOB_IENAB|IEOB_NORSET);
    195 }
    196 
    197