Home | History | Annotate | Line # | Download | only in dev
if_le.c revision 1.24
      1  1.24  mycroft /*	$NetBSD: if_le.c,v 1.24 1995/12/10 08:46:05 mycroft 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 <sun3/dev/if_lereg.h>
     66  1.24  mycroft #include <sun3/dev/if_levar.h>
     67  1.24  mycroft #include <dev/ic/am7990reg.h>
     68  1.24  mycroft #define	LE_NEED_BUF_CONTIG
     69  1.24  mycroft #include <dev/ic/am7990var.h>
     70  1.24  mycroft 
     71  1.24  mycroft #define	LE_SOFTC(unit)	lecd.cd_devs[unit]
     72  1.24  mycroft #define	LE_DELAY(x)	DELAY(x)
     73  1.24  mycroft 
     74  1.24  mycroft int	lematch __P((struct device *, void *, void *));
     75  1.24  mycroft void	leattach __P((struct device *, struct device *, void *));
     76  1.24  mycroft int	leintr __P((void *));
     77  1.10      gwr 
     78  1.10      gwr struct	cfdriver lecd = {
     79  1.24  mycroft 	NULL, "le", lematch, leattach, DV_IFNET, sizeof(struct le_softc)
     80  1.10      gwr };
     81  1.10      gwr 
     82  1.24  mycroft integrate void
     83  1.24  mycroft lewrcsr(sc, port, val)
     84  1.16      gwr 	struct le_softc *sc;
     85  1.24  mycroft 	u_int16_t port, val;
     86  1.16      gwr {
     87  1.24  mycroft 	register struct lereg1 *ler1 = sc->sc_r1;
     88  1.16      gwr 
     89  1.24  mycroft 	ler1->ler1_rap = port;
     90  1.24  mycroft 	ler1->ler1_rdp = val;
     91  1.16      gwr }
     92  1.16      gwr 
     93  1.24  mycroft integrate u_int16_t
     94  1.24  mycroft lerdcsr(sc, port)
     95  1.16      gwr 	struct le_softc *sc;
     96  1.24  mycroft 	u_int16_t port;
     97  1.16      gwr {
     98  1.24  mycroft 	register struct lereg1 *ler1 = sc->sc_r1;
     99  1.24  mycroft 	u_int16_t val;
    100  1.16      gwr 
    101  1.24  mycroft 	ler1->ler1_rap = port;
    102  1.24  mycroft 	val = ler1->ler1_rdp;
    103  1.24  mycroft 	return (val);
    104  1.16      gwr }
    105  1.16      gwr 
    106  1.24  mycroft int
    107  1.24  mycroft lematch(parent, match, aux)
    108  1.24  mycroft 	struct device *parent;
    109  1.24  mycroft 	void *match, *aux;
    110  1.10      gwr {
    111  1.16      gwr 	struct confargs *ca = aux;
    112  1.24  mycroft 	int x;
    113  1.18      gwr 
    114  1.24  mycroft 	if (ca->ca_paddr == -1)
    115  1.24  mycroft 		ca->ca_paddr = OBIO_AMD_ETHER;
    116  1.24  mycroft 	if (ca->ca_intpri == -1)
    117  1.24  mycroft 		ca->ca_intpri = 3;
    118  1.23      gwr 
    119  1.24  mycroft 	/* The peek returns -1 on bus error. */
    120  1.24  mycroft 	x = bus_peek(ca->ca_bustype, ca->ca_paddr, 1);
    121  1.24  mycroft 	return (x != -1);
    122   1.1    glass }
    123   1.1    glass 
    124  1.10      gwr void
    125  1.24  mycroft leattach(parent, self, aux)
    126  1.24  mycroft 	struct device *parent, *self;
    127  1.24  mycroft 	void *aux;
    128  1.10      gwr {
    129  1.24  mycroft 	struct le_softc *sc = (void *)self;
    130  1.24  mycroft 	struct confargs *ca = aux;
    131  1.10      gwr 
    132  1.24  mycroft 	sc->sc_r1 = (struct lereg1 *)
    133  1.24  mycroft 	    obio_alloc(ca->ca_paddr, OBIO_AMD_ETHER_SIZE);
    134  1.24  mycroft 	sc->sc_mem = dvma_malloc(MEMSIZE);
    135  1.24  mycroft 	sc->sc_conf3 = LE_C3_BSWP;
    136  1.24  mycroft 	sc->sc_addr = (u_long)sc->sc_mem & 0xffffff;
    137  1.24  mycroft 	sc->sc_memsize = MEMSIZE;
    138   1.1    glass 
    139  1.24  mycroft 	idprom_etheraddr(sc->sc_arpcom.ac_enaddr);
    140   1.1    glass 
    141  1.24  mycroft 	sc->sc_copytodesc = copytobuf_contig;
    142  1.24  mycroft 	sc->sc_copyfromdesc = copyfrombuf_contig;
    143  1.24  mycroft 	sc->sc_copytobuf = copytobuf_contig;
    144  1.24  mycroft 	sc->sc_copyfrombuf = copyfrombuf_contig;
    145  1.24  mycroft 	sc->sc_zerobuf = zerobuf_contig;
    146   1.1    glass 
    147  1.24  mycroft 	sc->sc_arpcom.ac_if.if_name = lecd.cd_name;
    148  1.24  mycroft 	leconfig(sc);
    149  1.16      gwr 
    150  1.24  mycroft 	/* Install interrupt handler. */
    151  1.24  mycroft 	isr_add_autovect(leintr, (void *)sc, ca->ca_intpri);
    152   1.1    glass }
    153   1.1    glass 
    154  1.24  mycroft #include <dev/ic/am7990.c>
    155