Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / isapnp / if_fmv_isapnp.c
blobf859fa1383dcf1c3086b974154a205285c4da641
1 /* $NetBSD: if_fmv_isapnp.c,v 1.11 2008/04/12 06:27:01 tsutsui Exp $ */
3 /*-
4 * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center and Matt Thomas of the 3am Software Foundry.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: if_fmv_isapnp.c,v 1.11 2008/04/12 06:27:01 tsutsui Exp $");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/device.h>
40 #include <net/if.h>
41 #include <net/if_ether.h>
42 #include <net/if_media.h>
44 #include <sys/bus.h>
45 #include <sys/intr.h>
47 #include <dev/ic/mb86960reg.h>
48 #include <dev/ic/mb86960var.h>
49 #include <dev/ic/fmvreg.h>
50 #include <dev/ic/fmvvar.h>
52 #include <dev/isa/isavar.h>
54 #include <dev/isapnp/isapnpreg.h>
55 #include <dev/isapnp/isapnpvar.h>
56 #include <dev/isapnp/isapnpdevs.h>
58 int fmv_isapnp_match(device_t, cfdata_t, void *);
59 void fmv_isapnp_attach(device_t, device_t, void *);
61 struct fmv_isapnp_softc {
62 struct mb86960_softc sc_mb86960; /* real "mb86960" softc */
64 /* ISAPnP-specific goo. */
65 void *sc_ih; /* interrupt cookie */
68 CFATTACH_DECL_NEW(fmv_isapnp, sizeof(struct fmv_isapnp_softc),
69 fmv_isapnp_match, fmv_isapnp_attach, NULL, NULL);
71 int
72 fmv_isapnp_match(device_t parent, cfdata_t cf, void *aux)
74 int pri, variant;
76 pri = isapnp_devmatch(aux, &isapnp_fmv_devinfo, &variant);
77 if (pri && variant > 0)
78 pri = 0;
79 return pri;
82 void
83 fmv_isapnp_attach(device_t parent, device_t self, void *aux)
85 struct fmv_isapnp_softc *isc = device_private(self);
86 struct mb86960_softc *sc = &isc->sc_mb86960;
87 struct isapnp_attach_args * const ipa = aux;
89 sc->sc_dev = self;
91 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
92 aprint_error(": can't configure isapnp resources\n");
93 return;
96 sc->sc_bst = ipa->ipa_iot;
97 sc->sc_bsh = ipa->ipa_io[0].h;
99 fmv_attach(sc);
101 /* Establish the interrupt handler. */
102 isc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
103 ipa->ipa_irq[0].type, IPL_NET, mb86960_intr, sc);
104 if (isc->sc_ih == NULL)
105 aprint_error_dev(sc->sc_dev,
106 "couldn't establish interrupt handler\n");