Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / isapnp / if_ep_isapnp.c
blob6479fa3d4d3f9bb59ab6d6500c23e68153e893a8
1 /* $NetBSD: if_ep_isapnp.c,v 1.33 2008/04/08 20:09:27 cegger Exp $ */
3 /*
4 * Copyright (c) 1997 Jonathan Stone <jonathan@NetBSD.org>
5 * Copyright (c) 1997 Charles M. Hannum. All rights reserved.
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.
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.
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: if_ep_isapnp.c,v 1.33 2008/04/08 20:09:27 cegger Exp $");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/mbuf.h>
39 #include <sys/socket.h>
40 #include <sys/ioctl.h>
41 #include <sys/errno.h>
42 #include <sys/syslog.h>
43 #include <sys/select.h>
44 #include <sys/device.h>
46 #include <net/if.h>
47 #include <net/if_dl.h>
48 #include <net/if_ether.h>
49 #include <net/if_media.h>
51 #include <sys/cpu.h>
52 #include <sys/bus.h>
53 #include <sys/intr.h>
55 #include <dev/isa/isavar.h>
57 #include <dev/isapnp/isapnpreg.h>
58 #include <dev/isapnp/isapnpvar.h>
59 #include <dev/isapnp/isapnpdevs.h>
61 #include <dev/mii/miivar.h>
63 #include <dev/ic/elink3var.h>
64 #include <dev/ic/elink3reg.h>
66 int ep_isapnp_match(device_t , cfdata_t , void *);
67 void ep_isapnp_attach(device_t , device_t , void *);
69 CFATTACH_DECL_NEW(ep_isapnp, sizeof(struct ep_softc),
70 ep_isapnp_match, ep_isapnp_attach, NULL, NULL);
72 int
73 ep_isapnp_match(device_t parent, cfdata_t match, void *aux)
75 int pri, variant;
77 pri = isapnp_devmatch(aux, &isapnp_ep_devinfo, &variant);
78 if (pri && variant > 0)
79 pri = 0;
80 return (pri);
83 void
84 ep_isapnp_attach(device_t parent, device_t self, void *aux)
86 struct ep_softc *sc = device_private(self);
87 struct isapnp_attach_args *ipa = aux;
88 int chipset;
90 printf("\n");
92 sc->sc_dev = self;
93 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
94 aprint_error_dev(sc->sc_dev, "error in region allocation\n");
95 return;
98 printf("%s: %s %s\n", device_xname(sc->sc_dev), ipa->ipa_devident,
99 ipa->ipa_devclass);
101 sc->sc_iot = ipa->ipa_iot;
102 sc->sc_ioh = ipa->ipa_io[0].h;
103 sc->bustype = ELINK_BUS_ISA;
105 sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
106 ipa->ipa_irq[0].type, IPL_NET, epintr, sc);
108 sc->enable = NULL;
109 sc->disable = NULL;
110 sc->enabled = 1;
112 if (strcmp(ipa->ipa_devlogic, "TCM5051") == 0) {
113 /* 3c515 */
114 chipset = ELINK_CHIPSET_CORKSCREW;
115 } else {
116 /* 3c509 */
117 chipset = ELINK_CHIPSET_3C509;
120 epconfig(sc, chipset, NULL);