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