if_fmv_isapnp.c revision 1.2.2.3 1 1.2.2.3 thorpej /* $NetBSD: if_fmv_isapnp.c,v 1.2.2.3 2002/12/11 06:38:12 thorpej Exp $ */
2 1.2.2.2 nathanw
3 1.2.2.3 thorpej /*-
4 1.2.2.3 thorpej * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
5 1.2.2.3 thorpej * All rights reserved.
6 1.2.2.2 nathanw *
7 1.2.2.3 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.2.2.3 thorpej * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 1.2.2.3 thorpej * NASA Ames Research Center and Matt Thomas of the 3am Software Foundry.
10 1.2.2.2 nathanw *
11 1.2.2.3 thorpej * Redistribution and use in source and binary forms, with or without
12 1.2.2.3 thorpej * modification, are permitted provided that the following conditions
13 1.2.2.3 thorpej * are met:
14 1.2.2.3 thorpej * 1. Redistributions of source code must retain the above copyright
15 1.2.2.3 thorpej * notice, this list of conditions and the following disclaimer.
16 1.2.2.3 thorpej * 2. Redistributions in binary form must reproduce the above copyright
17 1.2.2.3 thorpej * notice, this list of conditions and the following disclaimer in the
18 1.2.2.3 thorpej * documentation and/or other materials provided with the distribution.
19 1.2.2.3 thorpej * 3. All advertising materials mentioning features or use of this software
20 1.2.2.3 thorpej * must display the following acknowledgement:
21 1.2.2.3 thorpej * This product includes software developed by the NetBSD
22 1.2.2.3 thorpej * Foundation, Inc. and its contributors.
23 1.2.2.3 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
24 1.2.2.3 thorpej * contributors may be used to endorse or promote products derived
25 1.2.2.3 thorpej * from this software without specific prior written permission.
26 1.2.2.3 thorpej *
27 1.2.2.3 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
28 1.2.2.3 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
29 1.2.2.3 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30 1.2.2.3 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
31 1.2.2.3 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 1.2.2.3 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 1.2.2.3 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 1.2.2.3 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 1.2.2.3 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 1.2.2.3 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 1.2.2.3 thorpej * POSSIBILITY OF SUCH DAMAGE.
38 1.2.2.2 nathanw */
39 1.2.2.2 nathanw
40 1.2.2.2 nathanw #include <sys/cdefs.h>
41 1.2.2.3 thorpej __KERNEL_RCSID(0, "$NetBSD: if_fmv_isapnp.c,v 1.2.2.3 2002/12/11 06:38:12 thorpej Exp $");
42 1.2.2.2 nathanw
43 1.2.2.2 nathanw #include <sys/param.h>
44 1.2.2.2 nathanw #include <sys/systm.h>
45 1.2.2.2 nathanw #include <sys/device.h>
46 1.2.2.2 nathanw
47 1.2.2.2 nathanw #include <net/if.h>
48 1.2.2.2 nathanw #include <net/if_ether.h>
49 1.2.2.2 nathanw #include <net/if_media.h>
50 1.2.2.2 nathanw
51 1.2.2.2 nathanw #include <machine/bus.h>
52 1.2.2.2 nathanw #include <machine/intr.h>
53 1.2.2.2 nathanw
54 1.2.2.2 nathanw #include <dev/ic/mb86960reg.h>
55 1.2.2.2 nathanw #include <dev/ic/mb86960var.h>
56 1.2.2.2 nathanw #include <dev/ic/fmvreg.h>
57 1.2.2.2 nathanw #include <dev/ic/fmvvar.h>
58 1.2.2.2 nathanw
59 1.2.2.2 nathanw #include <dev/isa/isavar.h>
60 1.2.2.2 nathanw
61 1.2.2.2 nathanw #include <dev/isapnp/isapnpreg.h>
62 1.2.2.2 nathanw #include <dev/isapnp/isapnpvar.h>
63 1.2.2.2 nathanw #include <dev/isapnp/isapnpdevs.h>
64 1.2.2.2 nathanw
65 1.2.2.2 nathanw int fmv_isapnp_match __P((struct device *, struct cfdata *, void *));
66 1.2.2.2 nathanw void fmv_isapnp_attach __P((struct device *, struct device *, void *));
67 1.2.2.2 nathanw
68 1.2.2.2 nathanw struct fmv_isapnp_softc {
69 1.2.2.2 nathanw struct mb86960_softc sc_mb86960; /* real "mb86960" softc */
70 1.2.2.2 nathanw
71 1.2.2.2 nathanw /* ISAPnP-specific goo. */
72 1.2.2.2 nathanw void *sc_ih; /* interrupt cookie */
73 1.2.2.2 nathanw };
74 1.2.2.2 nathanw
75 1.2.2.2 nathanw CFATTACH_DECL(fmv_isapnp, sizeof(struct fmv_isapnp_softc),
76 1.2.2.2 nathanw fmv_isapnp_match, fmv_isapnp_attach, NULL, NULL);
77 1.2.2.2 nathanw
78 1.2.2.2 nathanw int
79 1.2.2.2 nathanw fmv_isapnp_match(parent, match, aux)
80 1.2.2.2 nathanw struct device *parent;
81 1.2.2.2 nathanw struct cfdata *match;
82 1.2.2.2 nathanw void *aux;
83 1.2.2.2 nathanw {
84 1.2.2.2 nathanw int pri, variant;
85 1.2.2.2 nathanw
86 1.2.2.2 nathanw pri = isapnp_devmatch(aux, &isapnp_fmv_devinfo, &variant);
87 1.2.2.2 nathanw if (pri && variant > 0)
88 1.2.2.2 nathanw pri = 0;
89 1.2.2.2 nathanw return (pri);
90 1.2.2.2 nathanw }
91 1.2.2.2 nathanw
92 1.2.2.2 nathanw void
93 1.2.2.2 nathanw fmv_isapnp_attach(parent, self, aux)
94 1.2.2.2 nathanw struct device *parent, *self;
95 1.2.2.2 nathanw void *aux;
96 1.2.2.2 nathanw {
97 1.2.2.2 nathanw struct fmv_isapnp_softc *isc = (struct fmv_isapnp_softc *)self;
98 1.2.2.2 nathanw struct mb86960_softc *sc = &isc->sc_mb86960;
99 1.2.2.2 nathanw struct isapnp_attach_args * const ipa = aux;
100 1.2.2.2 nathanw
101 1.2.2.2 nathanw if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
102 1.2.2.2 nathanw printf(": can't configure isapnp resources\n");
103 1.2.2.2 nathanw return;
104 1.2.2.2 nathanw }
105 1.2.2.2 nathanw
106 1.2.2.2 nathanw sc->sc_bst = ipa->ipa_iot;
107 1.2.2.2 nathanw sc->sc_bsh = ipa->ipa_io[0].h;
108 1.2.2.2 nathanw
109 1.2.2.2 nathanw fmv_attach(sc);
110 1.2.2.2 nathanw
111 1.2.2.2 nathanw /* Establish the interrupt handler. */
112 1.2.2.2 nathanw isc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
113 1.2.2.2 nathanw ipa->ipa_irq[0].type, IPL_NET, mb86960_intr, sc);
114 1.2.2.2 nathanw if (isc->sc_ih == NULL)
115 1.2.2.2 nathanw printf("%s: couldn't establish interrupt handler\n",
116 1.2.2.2 nathanw sc->sc_dev.dv_xname);
117 1.2.2.2 nathanw }
118