Home | History | Annotate | Line # | Download | only in dev
if_le.c revision 1.17
      1 /*	$NetBSD: if_le.c,v 1.17 1998/07/21 17:36:02 drochner Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1995 Charles M. Hannum.  All rights reserved.
      5  * Copyright (c) 1992, 1993
      6  *	The Regents of the University of California.  All rights reserved.
      7  *
      8  * This code is derived from software contributed to Berkeley by
      9  * Ralph Campbell and Rick Macklem.
     10  *
     11  * Redistribution and use in source and binary forms, with or without
     12  * modification, are permitted provided that the following conditions
     13  * are met:
     14  * 1. Redistributions of source code must retain the above copyright
     15  *    notice, this list of conditions and the following disclaimer.
     16  * 2. Redistributions in binary form must reproduce the above copyright
     17  *    notice, this list of conditions and the following disclaimer in the
     18  *    documentation and/or other materials provided with the distribution.
     19  * 3. All advertising materials mentioning features or use of this software
     20  *    must display the following acknowledgement:
     21  *	This product includes software developed by the University of
     22  *	California, Berkeley and its contributors.
     23  * 4. Neither the name of the University nor the names of its contributors
     24  *    may be used to endorse or promote products derived from this software
     25  *    without specific prior written permission.
     26  *
     27  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     28  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     30  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     31  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     32  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     33  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     34  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     35  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     36  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     37  * SUCH DAMAGE.
     38  *
     39  *	@(#)if_le.c	8.2 (Berkeley) 11/16/93
     40  */
     41 
     42 #include "opt_inet.h"
     43 #include "bpfilter.h"
     44 
     45 #include <sys/param.h>
     46 #include <sys/systm.h>
     47 #include <sys/mbuf.h>
     48 #include <sys/syslog.h>
     49 #include <sys/socket.h>
     50 #include <sys/device.h>
     51 
     52 #include <net/if.h>
     53 #include <net/if_ether.h>
     54 #include <net/if_media.h>
     55 
     56 #ifdef INET
     57 #include <netinet/in.h>
     58 #include <netinet/if_inarp.h>
     59 #endif
     60 
     61 #include <vm/vm.h>
     62 
     63 #include <machine/autoconf.h>
     64 #include <machine/cpu.h>
     65 #include <machine/pmap.h>
     66 
     67 #include <mvme68k/dev/pccreg.h>
     68 #include <mvme68k/dev/pccvar.h>
     69 
     70 #include <dev/ic/lancereg.h>
     71 #include <dev/ic/lancevar.h>
     72 #include <dev/ic/am7990reg.h>
     73 #include <dev/ic/am7990var.h>
     74 
     75 #include <mvme68k/dev/if_lereg.h>
     76 #include <mvme68k/dev/if_levar.h>
     77 
     78 int 	le_pcc_match __P((struct device *, struct cfdata  *, void *));
     79 void	le_pcc_attach __P((struct device *, struct device *, void *));
     80 
     81 struct cfattach le_pcc_ca = {
     82 	sizeof(struct le_softc), le_pcc_match, le_pcc_attach
     83 };
     84 
     85 extern struct cfdriver le_cd;
     86 
     87 #if defined(_KERNEL) && !defined(_LKM)
     88 #include "opt_ddb.h"
     89 #endif
     90 
     91 #ifdef DDB
     92 #define	integrate
     93 #define hide
     94 #else
     95 #define	integrate	static __inline
     96 #define hide		static
     97 #endif
     98 
     99 hide void le_pcc_wrcsr __P((struct lance_softc *, u_int16_t, u_int16_t));
    100 hide u_int16_t le_pcc_rdcsr __P((struct lance_softc *, u_int16_t));
    101 
    102 void *ledatabuf; /* XXXCDC hack from pmap bootstrap */
    103 
    104 hide void
    105 le_pcc_wrcsr(sc, port, val)
    106 	struct lance_softc *sc;
    107 	u_int16_t port, val;
    108 {
    109 	register struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
    110 
    111 	ler1->ler1_rap = port;
    112 	ler1->ler1_rdp = val;
    113 }
    114 
    115 hide u_int16_t
    116 le_pcc_rdcsr(sc, port)
    117 	struct lance_softc *sc;
    118 	u_int16_t port;
    119 {
    120 	register struct lereg1 *ler1 = ((struct le_softc *)sc)->sc_r1;
    121 	u_int16_t val;
    122 
    123 	ler1->ler1_rap = port;
    124 	val = ler1->ler1_rdp;
    125 	return (val);
    126 }
    127 
    128 int
    129 le_pcc_match(parent, cf, aux)
    130 	struct device *parent;
    131 	struct cfdata *cf;
    132 	void *aux;
    133 {
    134 	struct pcc_attach_args *pa = aux;
    135 
    136 	if (strcmp(pa->pa_name, le_cd.cd_name))
    137 		return (0);
    138 
    139 	pa->pa_ipl = cf->pcccf_ipl;
    140 	return (1);
    141 }
    142 
    143 void
    144 le_pcc_attach(parent, self, aux)
    145 	struct device *parent, *self;
    146 	void *aux;
    147 {
    148 	struct le_softc *lesc = (void *)self;
    149 	struct lance_softc *sc = &lesc->sc_am7990.lsc;
    150 	struct pcc_attach_args *pa = aux;
    151 
    152 	/* XXX the following declarations should be elsewhere */
    153 	extern void myetheraddr __P((u_char *));
    154 
    155 	/* Map control registers. */
    156 	lesc->sc_r1 = (struct lereg1 *)PCC_VADDR(pa->pa_offset);
    157 
    158 	sc->sc_mem = ledatabuf;		/* XXX */
    159 	sc->sc_conf3 = LE_C3_BSWP;
    160 	sc->sc_addr = (u_long)sc->sc_mem;
    161 	sc->sc_memsize = 4 * NBPG;	/* XXX */
    162 
    163 	myetheraddr(sc->sc_enaddr);
    164 
    165 	sc->sc_copytodesc = lance_copytobuf_contig;
    166 	sc->sc_copyfromdesc = lance_copyfrombuf_contig;
    167 	sc->sc_copytobuf = lance_copytobuf_contig;
    168 	sc->sc_copyfrombuf = lance_copyfrombuf_contig;
    169 	sc->sc_zerobuf = lance_zerobuf_contig;
    170 
    171 	sc->sc_rdcsr = le_pcc_rdcsr;
    172 	sc->sc_wrcsr = le_pcc_wrcsr;
    173 	sc->sc_hwinit = NULL;
    174 
    175 	am7990_config(&lesc->sc_am7990);
    176 
    177 	/* Are we the boot device? */
    178 	if (PCC_PADDR(pa->pa_offset) == bootaddr)
    179 		booted_device = self;
    180 
    181 	pccintr_establish(PCCV_LE, am7990_intr, pa->pa_ipl, sc);
    182 	sys_pcc->le_int = pa->pa_ipl | PCC_IENABLE;
    183 }
    184