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