1 /* $NetBSD: if_tr_isapnp.c,v 1.9 2002/10/02 16:34:02 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Onno van der Linden.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by The NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: if_tr_isapnp.c,v 1.9 2002/10/02 16:34:02 thorpej Exp $");
41
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/callout.h>
45 #include <sys/mbuf.h>
46 #include <sys/socket.h>
47 #include <sys/ioctl.h>
48 #include <sys/errno.h>
49 #include <sys/syslog.h>
50 #include <sys/select.h>
51 #include <sys/device.h>
52
53 #include <net/if.h>
54 #include <net/if_dl.h>
55 #include <net/if_ether.h>
56 #include <net/if_media.h>
57
58 #include <machine/cpu.h>
59 #include <machine/bus.h>
60 #include <machine/intr.h>
61
62 #include <dev/ic/tropicreg.h>
63 #include <dev/ic/tropicvar.h>
64
65 #include <dev/isa/isavar.h>
66
67 #include <dev/isapnp/isapnpreg.h>
68 #include <dev/isapnp/isapnpvar.h>
69 #include <dev/isapnp/isapnpdevs.h>
70
71 int tr_isapnp_match __P((struct device *, struct cfdata *, void *));
72 void tr_isapnp_attach __P((struct device *, struct device *, void *));
73
74 CFATTACH_DECL(tr_isapnp, sizeof(struct tr_softc),
75 tr_isapnp_match, tr_isapnp_attach, NULL, NULL);
76
77 int
78 tr_isapnp_match(parent, match, aux)
79 struct device *parent;
80 struct cfdata *match;
81 void *aux;
82 {
83 int pri, variant;
84
85 pri = isapnp_devmatch(aux, &isapnp_tr_devinfo, &variant);
86 if (pri && variant > 0)
87 pri = 0;
88 return pri;
89 }
90
91
92 void
93 tr_isapnp_attach(parent, self, aux)
94 struct device *parent, *self;
95 void *aux;
96 {
97 struct tr_softc *sc = (void *)self;
98 struct isapnp_attach_args *ipa = aux;
99 int mmioidx, sramidx;
100
101 printf("\n");
102
103 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
104 printf("%s: error in region allocation\n", sc->sc_dev.dv_xname);
105 return;
106 }
107
108 printf("%s: %s %s\n", sc->sc_dev.dv_xname, ipa->ipa_devident,
109 ipa->ipa_devclass);
110
111 sc->sc_piot = ipa->ipa_iot;
112 sc->sc_pioh = ipa->ipa_io[0].h;
113
114 if (strcmp(ipa->ipa_devlogic, "TCM3190") == 0) {
115 mmioidx = 0;
116 sramidx = 1;
117 }
118 else { /* Default */
119 mmioidx = 1;
120 sramidx = 0;
121 }
122 sc->sc_memt = ipa->ipa_memt;
123 sc->sc_mmioh = ipa->ipa_mem[mmioidx].h;
124 sc->sc_sramh = ipa->ipa_mem[sramidx].h;
125 sc->sc_memwinsz = ipa->ipa_mem[sramidx].length;
126 /*
127 * Determine total RAM on adapter and decide how much to use.
128 * XXX Since we don't use RAM paging, use sc_memwinsz for now.
129 */
130 sc->sc_memsize = sc->sc_memwinsz;
131 sc->sc_memreserved = 0;
132
133 sc->sc_aca = TR_ACA_OFFSET;
134 sc->sc_maddr = ipa->ipa_mem[sramidx].base;
135 /*
136 * Reset the card.
137 */
138 if (tr_reset(sc))
139 return;
140
141 sc->sc_mediastatus = NULL;
142 sc->sc_mediachange = NULL;
143
144 if (tr_attach(sc))
145 return;
146
147 sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
148 ipa->ipa_irq[0].type, IPL_NET, tr_intr, sc);
149 }
Cache object: cea15a07bb8044e30b72a6b4c3d150c6
|