Home | History | Annotate | Line # | Download | only in podulebus
if_eb.c revision 1.8
      1  1.8    perry /* $NetBSD: if_eb.c,v 1.8 2005/02/27 00:27:44 perry Exp $ */
      2  1.1    bjh21 
      3  1.1    bjh21 /*
      4  1.1    bjh21  * Copyright (c) 2000, 2001 Ben Harris
      5  1.1    bjh21  * Copyright (c) 1995 Mark Brinicombe
      6  1.1    bjh21  * All rights reserved.
      7  1.1    bjh21  *
      8  1.1    bjh21  * Redistribution and use in source and binary forms, with or without
      9  1.1    bjh21  * modification, are permitted provided that the following conditions
     10  1.1    bjh21  * are met:
     11  1.1    bjh21  * 1. Redistributions of source code must retain the above copyright
     12  1.1    bjh21  *    notice, this list of conditions and the following disclaimer.
     13  1.1    bjh21  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1    bjh21  *    notice, this list of conditions and the following disclaimer in the
     15  1.1    bjh21  *    documentation and/or other materials provided with the distribution.
     16  1.1    bjh21  * 3. All advertising materials mentioning features or use of this software
     17  1.1    bjh21  *    must display the following acknowledgement:
     18  1.1    bjh21  *	This product includes software developed by Mark Brinicombe.
     19  1.1    bjh21  * 4. The name of the company nor the name of the author may be used to
     20  1.1    bjh21  *    endorse or promote products derived from this software without specific
     21  1.1    bjh21  *    prior written permission.
     22  1.1    bjh21  *
     23  1.1    bjh21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
     24  1.1    bjh21  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     25  1.1    bjh21  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26  1.1    bjh21  * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     27  1.1    bjh21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     28  1.1    bjh21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     29  1.1    bjh21  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.1    bjh21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.1    bjh21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.1    bjh21  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.1    bjh21  * SUCH DAMAGE.
     34  1.1    bjh21  */
     35  1.1    bjh21 /*
     36  1.1    bjh21  * if_eb.c - EtherB device driver
     37  1.1    bjh21  */
     38  1.1    bjh21 
     39  1.2    lukem #include <sys/cdefs.h>
     40  1.8    perry __KERNEL_RCSID(0, "$NetBSD: if_eb.c,v 1.8 2005/02/27 00:27:44 perry Exp $");
     41  1.2    lukem 
     42  1.1    bjh21 #include <sys/param.h>
     43  1.1    bjh21 
     44  1.1    bjh21 #include <sys/device.h>
     45  1.1    bjh21 #include <sys/socket.h>
     46  1.1    bjh21 #include <sys/systm.h>
     47  1.1    bjh21 
     48  1.1    bjh21 #include <machine/bus.h>
     49  1.1    bjh21 #include <machine/intr.h>
     50  1.1    bjh21 
     51  1.1    bjh21 #include <net/if.h>
     52  1.1    bjh21 #include <net/if_ether.h>
     53  1.1    bjh21 
     54  1.1    bjh21 #include <dev/podulebus/podulebus.h>
     55  1.1    bjh21 #include <dev/podulebus/podules.h>
     56  1.1    bjh21 
     57  1.1    bjh21 #include <dev/podulebus/if_ebreg.h>
     58  1.1    bjh21 #include <dev/ic/seeq8005var.h>
     59  1.1    bjh21 
     60  1.1    bjh21 /*
     61  1.1    bjh21  * per-line info and status
     62  1.1    bjh21  */
     63  1.1    bjh21 
     64  1.1    bjh21 struct eb_softc {
     65  1.1    bjh21 	struct seeq8005_softc	sc_8005;
     66  1.1    bjh21 	void	*sc_ih;
     67  1.1    bjh21 	struct evcnt sc_intrcnt;
     68  1.1    bjh21 };
     69  1.1    bjh21 
     70  1.1    bjh21 /*
     71  1.1    bjh21  * prototypes
     72  1.1    bjh21  */
     73  1.1    bjh21 
     74  1.1    bjh21 int ebprobe(struct device *, struct cfdata *, void *);
     75  1.1    bjh21 void ebattach(struct device *, struct device *, void *);
     76  1.1    bjh21 
     77  1.1    bjh21 /* driver structure for autoconf */
     78  1.1    bjh21 
     79  1.6  thorpej CFATTACH_DECL(eb, sizeof(struct eb_softc),
     80  1.7  thorpej     ebprobe, ebattach, NULL, NULL);
     81  1.1    bjh21 
     82  1.1    bjh21 /*
     83  1.1    bjh21  * Probe routine.
     84  1.1    bjh21  */
     85  1.1    bjh21 
     86  1.1    bjh21 /*
     87  1.1    bjh21  * Probe for the ether3 podule.
     88  1.1    bjh21  */
     89  1.1    bjh21 
     90  1.1    bjh21 int
     91  1.1    bjh21 ebprobe(struct device *parent, struct cfdata *cf, void *aux)
     92  1.1    bjh21 {
     93  1.1    bjh21 	struct podulebus_attach_args *pa = aux;
     94  1.8    perry 
     95  1.4    bjh21 	return pa->pa_product == PODULE_ETHERB;
     96  1.1    bjh21 }
     97  1.1    bjh21 
     98  1.1    bjh21 
     99  1.1    bjh21 /*
    100  1.1    bjh21  * Attach podule.
    101  1.1    bjh21  */
    102  1.1    bjh21 
    103  1.1    bjh21 void
    104  1.1    bjh21 ebattach(struct device *parent, struct device *self, void *aux)
    105  1.1    bjh21 {
    106  1.1    bjh21 	struct eb_softc *sc = (void *)self;
    107  1.1    bjh21 	struct podulebus_attach_args *pa = aux;
    108  1.1    bjh21 	u_int8_t myaddr[ETHER_ADDR_LEN];
    109  1.8    perry 
    110  1.1    bjh21 /*	dprintf(("Attaching %s...\n", sc->sc_dev.dv_xname));*/
    111  1.1    bjh21 
    112  1.1    bjh21 	/* Set the address of the controller for easy access */
    113  1.1    bjh21 	podulebus_shift_tag(pa->pa_mod_t, EB_8004_SHIFT, &sc->sc_8005.sc_iot);
    114  1.1    bjh21 	bus_space_map(sc->sc_8005.sc_iot, pa->pa_mod_base + EB_8004_BASE,
    115  1.1    bjh21 	    /* XXX */ 0, 0, &sc->sc_8005.sc_ioh);
    116  1.1    bjh21 
    117  1.1    bjh21 	/*
    118  1.1    bjh21 	 * Build the address from the machine id.
    119  1.1    bjh21 	 */
    120  1.1    bjh21 	netslot_ea(myaddr);
    121  1.1    bjh21 
    122  1.1    bjh21 	printf(":");
    123  1.1    bjh21 	seeq8005_attach(&sc->sc_8005, myaddr, NULL, 0, 0);
    124  1.1    bjh21 
    125  1.1    bjh21 	/* Claim a podule interrupt */
    126  1.1    bjh21 
    127  1.1    bjh21 	evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, NULL,
    128  1.1    bjh21 	    self->dv_xname, "intr");
    129  1.1    bjh21 	sc->sc_ih = podulebus_irq_establish(pa->pa_ih, IPL_NET, seeq8005intr,
    130  1.1    bjh21 	    sc, &sc->sc_intrcnt);
    131  1.1    bjh21 }
    132  1.1    bjh21 
    133  1.1    bjh21 /* End of if_eb.c */
    134