Home | History | Annotate | Line # | Download | only in dev
if_le.c revision 1.32
      1  1.32      gwr /*	$NetBSD: if_le.c,v 1.32 1996/10/30 00:24:36 gwr Exp $	*/
      2  1.12      cgd 
      3  1.24  mycroft /*-
      4  1.24  mycroft  * Copyright (c) 1995 Charles M. Hannum.  All rights reserved.
      5  1.24  mycroft  * Copyright (c) 1992, 1993
      6  1.24  mycroft  *	The Regents of the University of California.  All rights reserved.
      7   1.1    glass  *
      8  1.24  mycroft  * This code is derived from software contributed to Berkeley by
      9  1.24  mycroft  * Ralph Campbell and Rick Macklem.
     10   1.1    glass  *
     11  1.24  mycroft  * Redistribution and use in source and binary forms, with or without
     12  1.24  mycroft  * modification, are permitted provided that the following conditions
     13  1.24  mycroft  * are met:
     14  1.24  mycroft  * 1. Redistributions of source code must retain the above copyright
     15  1.24  mycroft  *    notice, this list of conditions and the following disclaimer.
     16  1.24  mycroft  * 2. Redistributions in binary form must reproduce the above copyright
     17  1.24  mycroft  *    notice, this list of conditions and the following disclaimer in the
     18  1.24  mycroft  *    documentation and/or other materials provided with the distribution.
     19  1.24  mycroft  * 3. All advertising materials mentioning features or use of this software
     20  1.24  mycroft  *    must display the following acknowledgement:
     21  1.24  mycroft  *	This product includes software developed by the University of
     22  1.24  mycroft  *	California, Berkeley and its contributors.
     23  1.24  mycroft  * 4. Neither the name of the University nor the names of its contributors
     24  1.24  mycroft  *    may be used to endorse or promote products derived from this software
     25  1.24  mycroft  *    without specific prior written permission.
     26  1.24  mycroft  *
     27  1.24  mycroft  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     28  1.24  mycroft  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     29  1.24  mycroft  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     30  1.24  mycroft  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     31  1.24  mycroft  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     32  1.24  mycroft  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     33  1.24  mycroft  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     34  1.24  mycroft  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     35  1.24  mycroft  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     36  1.24  mycroft  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     37  1.24  mycroft  * SUCH DAMAGE.
     38  1.24  mycroft  *
     39  1.24  mycroft  *	@(#)if_le.c	8.2 (Berkeley) 11/16/93
     40   1.1    glass  */
     41   1.1    glass 
     42   1.1    glass #include "bpfilter.h"
     43   1.1    glass 
     44   1.8    glass #include <sys/param.h>
     45   1.8    glass #include <sys/systm.h>
     46   1.8    glass #include <sys/mbuf.h>
     47  1.24  mycroft #include <sys/syslog.h>
     48   1.8    glass #include <sys/socket.h>
     49  1.16      gwr #include <sys/device.h>
     50   1.8    glass 
     51   1.8    glass #include <net/if.h>
     52  1.10      gwr 
     53   1.1    glass #ifdef INET
     54   1.8    glass #include <netinet/in.h>
     55   1.8    glass #include <netinet/if_ether.h>
     56   1.1    glass #endif
     57   1.1    glass 
     58   1.8    glass #include <machine/autoconf.h>
     59  1.10      gwr #include <machine/cpu.h>
     60  1.24  mycroft #include <machine/dvma.h>
     61  1.24  mycroft #include <machine/isr.h>
     62  1.24  mycroft #include <machine/obio.h>
     63  1.24  mycroft #include <machine/idprom.h>
     64  1.24  mycroft 
     65  1.24  mycroft #include <dev/ic/am7990reg.h>
     66  1.24  mycroft #include <dev/ic/am7990var.h>
     67  1.24  mycroft 
     68  1.29  thorpej #include <sun3/dev/if_lereg.h>
     69  1.29  thorpej #include <sun3/dev/if_levar.h>
     70  1.24  mycroft 
     71  1.26      gwr static int	le_match __P((struct device *, void *, void *));
     72  1.26      gwr static void	le_attach __P((struct device *, struct device *, void *));
     73  1.10      gwr 
     74  1.25  thorpej struct cfattach le_ca = {
     75  1.26      gwr 	sizeof(struct le_softc), le_match, le_attach
     76  1.25  thorpej };
     77  1.25  thorpej 
     78  1.29  thorpej hide void lewrcsr __P((struct am7990_softc *, u_int16_t, u_int16_t));
     79  1.29  thorpej hide u_int16_t lerdcsr __P((struct am7990_softc *, u_int16_t));
     80  1.10      gwr 
     81  1.29  thorpej hide void
     82  1.24  mycroft lewrcsr(sc, port, val)
     83  1.29  thorpej 	struct am7990_softc *sc;
     84  1.24  mycroft 	u_int16_t port, val;
     85  1.16      gwr {
     86  1.29  thorpej 	register struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
     87  1.16      gwr 
     88  1.24  mycroft 	ler1->ler1_rap = port;
     89  1.24  mycroft 	ler1->ler1_rdp = val;
     90  1.16      gwr }
     91  1.16      gwr 
     92  1.29  thorpej hide u_int16_t
     93  1.24  mycroft lerdcsr(sc, port)
     94  1.29  thorpej 	struct am7990_softc *sc;
     95  1.24  mycroft 	u_int16_t port;
     96  1.16      gwr {
     97  1.29  thorpej 	register struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
     98  1.24  mycroft 	u_int16_t val;
     99  1.16      gwr 
    100  1.24  mycroft 	ler1->ler1_rap = port;
    101  1.24  mycroft 	val = ler1->ler1_rdp;
    102  1.24  mycroft 	return (val);
    103  1.16      gwr }
    104  1.16      gwr 
    105  1.24  mycroft int
    106  1.26      gwr le_match(parent, vcf, aux)
    107  1.24  mycroft 	struct device *parent;
    108  1.26      gwr 	void *vcf, *aux;
    109  1.10      gwr {
    110  1.26      gwr 	struct cfdata *cf = vcf;
    111  1.16      gwr 	struct confargs *ca = aux;
    112  1.18      gwr 
    113  1.32      gwr 	/* Make sure there is something there... */
    114  1.32      gwr 	if (bus_peek(ca->ca_bustype, ca->ca_paddr, 1) == -1)
    115  1.26      gwr 		return (0);
    116  1.23      gwr 
    117  1.32      gwr 	/* Default interrupt priority. */
    118  1.32      gwr 	if (ca->ca_intpri == -1)
    119  1.32      gwr 		ca->ca_intpri = 3;
    120  1.32      gwr 
    121  1.32      gwr 	return (1);
    122   1.1    glass }
    123   1.1    glass 
    124  1.10      gwr void
    125  1.26      gwr le_attach(parent, self, aux)
    126  1.24  mycroft 	struct device *parent, *self;
    127  1.24  mycroft 	void *aux;
    128  1.10      gwr {
    129  1.29  thorpej 	struct le_softc *lesc = (struct le_softc *)self;
    130  1.29  thorpej 	struct am7990_softc *sc = &lesc->sc_am7990;
    131  1.26      gwr 	struct cfdata *cf = self->dv_cfdata;
    132  1.24  mycroft 	struct confargs *ca = aux;
    133  1.10      gwr 
    134  1.29  thorpej 	lesc->sc_r1 = (struct lereg1 *)
    135  1.24  mycroft 	    obio_alloc(ca->ca_paddr, OBIO_AMD_ETHER_SIZE);
    136  1.26      gwr 
    137  1.26      gwr 	sc->sc_memsize = 0x4000;	/* 16K */
    138  1.26      gwr 	sc->sc_mem = dvma_malloc(sc->sc_memsize);
    139  1.26      gwr 	sc->sc_addr = (u_long)sc->sc_mem & 0xffffff;
    140  1.24  mycroft 	sc->sc_conf3 = LE_C3_BSWP;
    141   1.1    glass 
    142  1.24  mycroft 	idprom_etheraddr(sc->sc_arpcom.ac_enaddr);
    143   1.1    glass 
    144  1.27      cgd 	sc->sc_copytodesc = am7990_copytobuf_contig;
    145  1.27      cgd 	sc->sc_copyfromdesc = am7990_copyfrombuf_contig;
    146  1.27      cgd 	sc->sc_copytobuf = am7990_copytobuf_contig;
    147  1.27      cgd 	sc->sc_copyfrombuf = am7990_copyfrombuf_contig;
    148  1.27      cgd 	sc->sc_zerobuf = am7990_zerobuf_contig;
    149   1.1    glass 
    150  1.29  thorpej 	sc->sc_rdcsr = lerdcsr;
    151  1.29  thorpej 	sc->sc_wrcsr = lewrcsr;
    152  1.29  thorpej 	sc->sc_hwinit = NULL;
    153  1.29  thorpej 
    154  1.29  thorpej 	am7990_config(sc);
    155  1.16      gwr 
    156  1.24  mycroft 	/* Install interrupt handler. */
    157  1.32      gwr 	isr_add_autovect(am7990_intr, (void *)sc, ca->ca_intpri);
    158   1.1    glass }
    159