if_ep_isapnp.c revision 1.21 1 /* $NetBSD: if_ep_isapnp.c,v 1.21 2001/07/27 02:13:26 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1997 Jonathan Stone <jonathan (at) NetBSD.org>
5 * Copyright (c) 1997 Charles M. Hannum. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Charles M. Hannum.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/mbuf.h>
36 #include <sys/socket.h>
37 #include <sys/ioctl.h>
38 #include <sys/errno.h>
39 #include <sys/syslog.h>
40 #include <sys/select.h>
41 #include <sys/device.h>
42
43 #include <net/if.h>
44 #include <net/if_dl.h>
45 #include <net/if_ether.h>
46 #include <net/if_media.h>
47
48 #include <machine/cpu.h>
49 #include <machine/bus.h>
50 #include <machine/intr.h>
51
52 #include <dev/isa/isavar.h>
53
54 #include <dev/isapnp/isapnpreg.h>
55 #include <dev/isapnp/isapnpvar.h>
56 #include <dev/isapnp/isapnpdevs.h>
57
58 #include <dev/mii/miivar.h>
59
60 #include <dev/ic/elink3var.h>
61 #include <dev/ic/elink3reg.h>
62
63 int ep_isapnp_match __P((struct device *, struct cfdata *, void *));
64 void ep_isapnp_attach __P((struct device *, struct device *, void *));
65
66 struct cfattach ep_isapnp_ca = {
67 sizeof(struct ep_softc), ep_isapnp_match, ep_isapnp_attach
68 };
69
70 int
71 ep_isapnp_match(parent, match, aux)
72 struct device *parent;
73 struct cfdata *match;
74 void *aux;
75 {
76 int pri, variant;
77
78 pri = isapnp_devmatch(aux, &isapnp_ep_devinfo, &variant);
79 if (pri && variant > 0)
80 pri = 0;
81 return (pri);
82 }
83
84 void
85 ep_isapnp_attach(parent, self, aux)
86 struct device *parent, *self;
87 void *aux;
88 {
89 struct ep_softc *sc = (void *)self;
90 struct isapnp_attach_args *ipa = aux;
91 int chipset;
92
93 printf("\n");
94
95 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
96 printf("%s: error in region allocation\n", sc->sc_dev.dv_xname);
97 return;
98 }
99
100 printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident,
101 ipa->ipa_devclass);
102
103 sc->sc_iot = ipa->ipa_iot;
104 sc->sc_ioh = ipa->ipa_io[0].h;
105 sc->bustype = ELINK_BUS_ISA;
106
107 sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
108 ipa->ipa_irq[0].type, IPL_NET, epintr, sc);
109
110 sc->enable = NULL;
111 sc->disable = NULL;
112 sc->enabled = 1;
113
114 if (strcmp(ipa->ipa_devlogic, "TCM5051") == 0) {
115 /* 3c515 */
116 chipset = ELINK_CHIPSET_CORKSCREW;
117 } else {
118 /* 3c509 */
119 chipset = ELINK_CHIPSET_3C509;
120 }
121
122 epconfig(sc, chipset, NULL);
123 }
124