xref: /openbsd/sys/dev/isa/if_ep_isapnp.c (revision 76d0caae)
1 /*	$OpenBSD: if_ep_isapnp.c,v 1.16 2015/11/24 17:11:39 mpi Exp $	*/
2 /*	$NetBSD: if_ep_isapnp.c,v 1.5 1996/05/12 23:52:36 mycroft Exp $	*/
3 
4 /*
5  * Copyright (c) 1996 Jason R. Thorpe <thorpej@beer.org>
6  * Copyright (c) 1994 Herb Peyerl <hpeyerl@beer.org>
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by Herb Peyerl.
20  * 4. The name of Herb Peyerl may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * Note: Most of the code here was written by Theo de Raadt originally,
35  * ie. all the mechanics of probing for all cards on first call and then
36  * searching for matching devices on subsequent calls.
37  */
38 
39 #include "bpfilter.h"
40 
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/mbuf.h>
44 #include <sys/socket.h>
45 #include <sys/ioctl.h>
46 #include <sys/errno.h>
47 #include <sys/syslog.h>
48 #include <sys/selinfo.h>
49 #include <sys/device.h>
50 #include <sys/timeout.h>
51 #include <sys/queue.h>
52 
53 #include <net/if.h>
54 #include <net/if_media.h>
55 
56 #include <netinet/in.h>
57 #include <netinet/if_ether.h>
58 
59 #if NBPFILTER > 0
60 #include <net/bpf.h>
61 #endif
62 
63 #include <machine/cpu.h>
64 #include <machine/bus.h>
65 #include <machine/intr.h>
66 
67 #include <dev/mii/mii.h>
68 #include <dev/mii/miivar.h>
69 
70 #include <dev/ic/elink3var.h>
71 #include <dev/ic/elink3reg.h>
72 
73 #include <dev/isa/isavar.h>
74 #include <dev/isa/elink.h>
75 
76 int ep_isapnp_match(struct device *, void *, void *);
77 void ep_isapnp_attach(struct device *, struct device *, void *);
78 
79 struct cfattach ep_isapnp_ca = {
80 	sizeof(struct ep_softc), ep_isapnp_match, ep_isapnp_attach
81 };
82 
83 /*
84  * 3c509 cards on the ISA bus are probed in ethernet address order.
85  * The probe sequence requires careful orchestration, and we'd like
86  * to allow the irq and base address to be wildcarded. So, we
87  * probe all the cards the first time epprobe() is called. On subsequent
88  * calls we look for matching cards.
89  */
90 int
91 ep_isapnp_match(struct device *parent, void *match, void *aux)
92 {
93 	/* XXX This should be more intelligent */
94 	return 1;
95 }
96 
97 void
98 ep_isapnp_attach(struct device *parent, struct device *self, void *aux)
99 {
100 	struct ep_softc *sc = (void *)self;
101 	struct isa_attach_args *ia = aux;
102 	bus_space_tag_t iot = ia->ia_iot;
103 	bus_space_handle_t ioh;
104 
105 	sc->sc_iot = iot = ia->ia_iot;
106 	sc->sc_ioh = ioh = ia->ipa_io[0].h;
107 	sc->bustype = EP_BUS_ISA;
108 
109 	printf(":");
110 
111 	/* Should look at ia->ia_devident... */
112 	epconfig(sc, EP_CHIPSET_3C509, NULL);
113 
114 	sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
115 	    IPL_NET, epintr, sc, sc->sc_dev.dv_xname);
116 }
117