pcmcia_cis_quirks.c revision 1.21 1 1.21 mycroft /* $NetBSD: pcmcia_cis_quirks.c,v 1.21 2004/08/10 19:22:10 mycroft Exp $ */
2 1.1 marc
3 1.1 marc /*
4 1.1 marc * Copyright (c) 1998 Marc Horowitz. All rights reserved.
5 1.1 marc *
6 1.1 marc * Redistribution and use in source and binary forms, with or without
7 1.1 marc * modification, are permitted provided that the following conditions
8 1.1 marc * are met:
9 1.1 marc * 1. Redistributions of source code must retain the above copyright
10 1.1 marc * notice, this list of conditions and the following disclaimer.
11 1.1 marc * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 marc * notice, this list of conditions and the following disclaimer in the
13 1.1 marc * documentation and/or other materials provided with the distribution.
14 1.1 marc * 3. All advertising materials mentioning features or use of this software
15 1.1 marc * must display the following acknowledgement:
16 1.1 marc * This product includes software developed by Marc Horowitz.
17 1.1 marc * 4. The name of the author may not be used to endorse or promote products
18 1.1 marc * derived from this software without specific prior written permission.
19 1.1 marc *
20 1.1 marc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.1 marc * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.1 marc * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.1 marc * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.1 marc * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.1 marc * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1 marc * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1 marc * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1 marc * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.1 marc * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 marc */
31 1.13 lukem
32 1.13 lukem #include <sys/cdefs.h>
33 1.21 mycroft __KERNEL_RCSID(0, "$NetBSD: pcmcia_cis_quirks.c,v 1.21 2004/08/10 19:22:10 mycroft Exp $");
34 1.1 marc
35 1.1 marc #include <sys/param.h>
36 1.1 marc #include <sys/systm.h>
37 1.1 marc #include <sys/device.h>
38 1.1 marc #include <sys/mbuf.h>
39 1.1 marc
40 1.1 marc #include <dev/pcmcia/pcmciadevs.h>
41 1.1 marc #include <dev/pcmcia/pcmciareg.h>
42 1.1 marc #include <dev/pcmcia/pcmciachip.h>
43 1.1 marc #include <dev/pcmcia/pcmciavar.h>
44 1.1 marc
45 1.1 marc /* There are cards out there whose CIS flat-out lies. This file
46 1.1 marc contains struct pcmcia_function chains for those devices. */
47 1.1 marc
48 1.1 marc /* these structures are just static templates which are then copied
49 1.1 marc into "live" allocated structures */
50 1.1 marc
51 1.8 jdolecek static const struct pcmcia_function pcmcia_3cxem556_func0 = {
52 1.1 marc 0, /* function number */
53 1.1 marc PCMCIA_FUNCTION_NETWORK,
54 1.1 marc 0x07, /* last cfe number */
55 1.1 marc 0x800, /* ccr_base */
56 1.1 marc 0x63, /* ccr_mask */
57 1.1 marc };
58 1.1 marc
59 1.8 jdolecek static const struct pcmcia_config_entry pcmcia_3cxem556_func0_cfe0 = {
60 1.1 marc 0x07, /* cfe number */
61 1.1 marc PCMCIA_CFE_IO8 | PCMCIA_CFE_IO16 | PCMCIA_CFE_IRQLEVEL,
62 1.1 marc PCMCIA_IFTYPE_IO,
63 1.1 marc 1, /* num_iospace */
64 1.1 marc 4, /* iomask */
65 1.1 marc { { 0x0010, 0 } }, /* iospace */
66 1.1 marc 0xffff, /* irqmask */
67 1.1 marc 0, /* num_memspace */
68 1.11 lukem { { 0 } }, /* memspace */
69 1.1 marc 0, /* maxtwins */
70 1.1 marc };
71 1.1 marc
72 1.8 jdolecek static const struct pcmcia_function pcmcia_3cxem556_func1 = {
73 1.1 marc 1, /* function number */
74 1.1 marc PCMCIA_FUNCTION_SERIAL,
75 1.1 marc 0x27, /* last cfe number */
76 1.1 marc 0x900, /* ccr_base */
77 1.1 marc 0x63, /* ccr_mask */
78 1.1 marc };
79 1.1 marc
80 1.8 jdolecek static const struct pcmcia_config_entry pcmcia_3cxem556_func1_cfe0 = {
81 1.1 marc 0x27, /* cfe number */
82 1.1 marc PCMCIA_CFE_IO8 | PCMCIA_CFE_IRQLEVEL,
83 1.1 marc PCMCIA_IFTYPE_IO,
84 1.1 marc 1, /* num_iospace */
85 1.1 marc 3, /* iomask */
86 1.1 marc { { 0x0008, 0 } }, /* iospace */
87 1.1 marc 0xffff, /* irqmask */
88 1.1 marc 0, /* num_memspace */
89 1.11 lukem { { 0 } }, /* memspace */
90 1.1 marc 0, /* maxtwins */
91 1.1 marc };
92 1.1 marc
93 1.8 jdolecek static const struct pcmcia_function pcmcia_3ccfem556bi_func0 = {
94 1.5 thorpej 0, /* function number */
95 1.5 thorpej PCMCIA_FUNCTION_NETWORK,
96 1.5 thorpej 0x07, /* last cfe number */
97 1.5 thorpej 0x1000, /* ccr_base */
98 1.5 thorpej 0x267, /* ccr_mask */
99 1.5 thorpej };
100 1.5 thorpej
101 1.8 jdolecek static const struct pcmcia_config_entry pcmcia_3ccfem556bi_func0_cfe0 = {
102 1.5 thorpej 0x07, /* cfe number */
103 1.5 thorpej PCMCIA_CFE_IO8 | PCMCIA_CFE_IO16 | PCMCIA_CFE_IRQLEVEL,
104 1.5 thorpej PCMCIA_IFTYPE_IO,
105 1.5 thorpej 1, /* num_iospace */
106 1.5 thorpej 5, /* iomask */
107 1.5 thorpej { { 0x0020, 0 } }, /* iospace */
108 1.5 thorpej 0xffff, /* irqmask */
109 1.5 thorpej 0, /* num_memspace */
110 1.11 lukem { { 0 } }, /* memspace */
111 1.5 thorpej 0, /* maxtwins */
112 1.5 thorpej };
113 1.5 thorpej
114 1.8 jdolecek static const struct pcmcia_function pcmcia_3ccfem556bi_func1 = {
115 1.5 thorpej 1, /* function number */
116 1.5 thorpej PCMCIA_FUNCTION_SERIAL,
117 1.5 thorpej 0x27, /* last cfe number */
118 1.5 thorpej 0x1100, /* ccr_base */
119 1.5 thorpej 0x277, /* ccr_mask */
120 1.5 thorpej };
121 1.5 thorpej
122 1.8 jdolecek static const struct pcmcia_config_entry pcmcia_3ccfem556bi_func1_cfe0 = {
123 1.5 thorpej 0x27, /* cfe number */
124 1.5 thorpej PCMCIA_CFE_IO8 | PCMCIA_CFE_IRQLEVEL,
125 1.5 thorpej PCMCIA_IFTYPE_IO,
126 1.5 thorpej 1, /* num_iospace */
127 1.5 thorpej 3, /* iomask */
128 1.5 thorpej { { 0x0008, 0 } }, /* iospace */
129 1.5 thorpej 0xffff, /* irqmask */
130 1.5 thorpej 0, /* num_memspace */
131 1.11 lukem { { 0 } }, /* memspace */
132 1.5 thorpej 0, /* maxtwins */
133 1.5 thorpej };
134 1.5 thorpej
135 1.8 jdolecek static const struct pcmcia_function pcmcia_sveclancard_func0 = {
136 1.3 marc 0, /* function number */
137 1.3 marc PCMCIA_FUNCTION_NETWORK,
138 1.3 marc 0x1, /* last cfe number */
139 1.3 marc 0x100, /* ccr_base */
140 1.3 marc 0x1, /* ccr_mask */
141 1.3 marc };
142 1.3 marc
143 1.8 jdolecek static const struct pcmcia_config_entry pcmcia_sveclancard_func0_cfe0 = {
144 1.3 marc 0x1, /* cfe number */
145 1.3 marc PCMCIA_CFE_MWAIT_REQUIRED | PCMCIA_CFE_RDYBSY_ACTIVE |
146 1.3 marc PCMCIA_CFE_WP_ACTIVE | PCMCIA_CFE_BVD_ACTIVE | PCMCIA_CFE_IO16,
147 1.3 marc PCMCIA_IFTYPE_IO,
148 1.3 marc 1, /* num_iospace */
149 1.3 marc 5, /* iomask */
150 1.3 marc { { 0x20, 0x300 } }, /* iospace */
151 1.3 marc 0xdeb8, /* irqmask */
152 1.3 marc 0, /* num_memspace */
153 1.11 lukem { { 0 } }, /* memspace */
154 1.3 marc 0, /* maxtwins */
155 1.3 marc };
156 1.3 marc
157 1.8 jdolecek static const struct pcmcia_function pcmcia_ndc_nd5100_func0 = {
158 1.6 scw 0, /* function number */
159 1.6 scw PCMCIA_FUNCTION_NETWORK,
160 1.6 scw 0x23, /* last cfe number */
161 1.6 scw 0x3f8, /* ccr_base */
162 1.6 scw 0x3, /* ccr_mask */
163 1.6 scw };
164 1.6 scw
165 1.8 jdolecek static const struct pcmcia_config_entry pcmcia_ndc_nd5100_func0_cfe0 = {
166 1.6 scw 0x20, /* cfe number */
167 1.6 scw PCMCIA_CFE_MWAIT_REQUIRED | PCMCIA_CFE_IO16 | PCMCIA_CFE_IRQLEVEL,
168 1.6 scw PCMCIA_IFTYPE_IO,
169 1.6 scw 1, /* num_iospace */
170 1.6 scw 5, /* iomask */
171 1.6 scw { { 0x20, 0x300 } }, /* iospace */
172 1.6 scw 0xdeb8, /* irqmask */
173 1.6 scw 0, /* num_memspace */
174 1.11 lukem { { 0 } }, /* memspace */
175 1.6 scw 0, /* maxtwins */
176 1.6 scw };
177 1.6 scw
178 1.12 ichiro static const struct pcmcia_function pcmcia_emtac_a2424i_func0 = {
179 1.12 ichiro 0, /* function number */
180 1.12 ichiro PCMCIA_FUNCTION_NETWORK,
181 1.12 ichiro 0x21, /* last cfe number */
182 1.12 ichiro 0x3e0, /* ccr_base */
183 1.12 ichiro 0x1, /* ccr_mask */
184 1.12 ichiro };
185 1.12 ichiro
186 1.12 ichiro static const struct pcmcia_config_entry pcmcia_emtac_a2424i_func0_cfe0 = {
187 1.12 ichiro 0x21, /* cfe number */
188 1.15 ichiro PCMCIA_CFE_IO16 | PCMCIA_CFE_IRQLEVEL | PCMCIA_CFE_IRQPULSE,
189 1.12 ichiro PCMCIA_IFTYPE_IO,
190 1.12 ichiro 1, /* num_iospace */
191 1.12 ichiro 6, /* iomask */
192 1.12 ichiro { { 0x40, 0x100 } }, /* iospace */
193 1.12 ichiro 0xffff, /* irqmask */
194 1.12 ichiro 0, /* num_memspace */
195 1.12 ichiro { { 0 } }, /* memspace */
196 1.12 ichiro 0, /* maxtwins */
197 1.12 ichiro };
198 1.12 ichiro
199 1.17 ichiro static const struct pcmcia_function pcmcia_fujitsu_j181_func0 = {
200 1.15 ichiro 0, /* function number */
201 1.15 ichiro PCMCIA_FUNCTION_NETWORK,
202 1.17 ichiro 0x21, /* last cfe number */
203 1.17 ichiro 0xfe0, /* ccr_base */
204 1.15 ichiro 0xf, /* ccr_mask */
205 1.17 ichiro };
206 1.15 ichiro
207 1.17 ichiro static const struct pcmcia_config_entry pcmcia_fujitsu_j181_func0_cfe0 = {
208 1.17 ichiro 0xc, /* cfe number */
209 1.17 ichiro PCMCIA_CFE_MWAIT_REQUIRED | PCMCIA_CFE_WP_ACTIVE | PCMCIA_CFE_IO8 |
210 1.17 ichiro PCMCIA_CFE_IO16 | PCMCIA_CFE_IRQLEVEL | PCMCIA_CFE_IRQPULSE,
211 1.15 ichiro PCMCIA_IFTYPE_IO,
212 1.15 ichiro 1, /* num_iospace */
213 1.15 ichiro 10, /* iomask */
214 1.17 ichiro { { 0x20, 0x140 } }, /* iospace */
215 1.15 ichiro 0xffff, /* irqmask */
216 1.15 ichiro 0, /* num_memspace */
217 1.15 ichiro { { 0 } }, /* memspace */
218 1.15 ichiro 0, /* maxtwins */
219 1.15 ichiro };
220 1.15 ichiro
221 1.8 jdolecek static const struct pcmcia_cis_quirk pcmcia_cis_quirks[] = {
222 1.3 marc { PCMCIA_VENDOR_3COM, PCMCIA_PRODUCT_3COM_3CXEM556, PCMCIA_CIS_INVALID,
223 1.1 marc &pcmcia_3cxem556_func0, &pcmcia_3cxem556_func0_cfe0 },
224 1.3 marc { PCMCIA_VENDOR_3COM, PCMCIA_PRODUCT_3COM_3CXEM556, PCMCIA_CIS_INVALID,
225 1.4 tron &pcmcia_3cxem556_func1, &pcmcia_3cxem556_func1_cfe0 },
226 1.4 tron { PCMCIA_VENDOR_3COM, PCMCIA_PRODUCT_3COM_3CXEM556INT, PCMCIA_CIS_INVALID,
227 1.4 tron &pcmcia_3cxem556_func0, &pcmcia_3cxem556_func0_cfe0 },
228 1.4 tron { PCMCIA_VENDOR_3COM, PCMCIA_PRODUCT_3COM_3CXEM556INT, PCMCIA_CIS_INVALID,
229 1.1 marc &pcmcia_3cxem556_func1, &pcmcia_3cxem556_func1_cfe0 },
230 1.5 thorpej { PCMCIA_VENDOR_3COM, PCMCIA_PRODUCT_3COM_3CCFEM556BI,
231 1.5 thorpej PCMCIA_CIS_INVALID,
232 1.5 thorpej &pcmcia_3ccfem556bi_func0, &pcmcia_3ccfem556bi_func0_cfe0 },
233 1.5 thorpej { PCMCIA_VENDOR_3COM, PCMCIA_PRODUCT_3COM_3CCFEM556BI,
234 1.5 thorpej PCMCIA_CIS_INVALID,
235 1.5 thorpej &pcmcia_3ccfem556bi_func1, &pcmcia_3ccfem556bi_func1_cfe0 },
236 1.3 marc { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, PCMCIA_CIS_SVEC_LANCARD,
237 1.3 marc &pcmcia_sveclancard_func0, &pcmcia_sveclancard_func0_cfe0 },
238 1.6 scw { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID, PCMCIA_CIS_NDC_ND5100_E,
239 1.6 scw &pcmcia_ndc_nd5100_func0, &pcmcia_ndc_nd5100_func0_cfe0 },
240 1.12 ichiro { PCMCIA_VENDOR_EMTAC, PCMCIA_PRODUCT_EMTAC_WLAN, PCMCIA_CIS_INVALID,
241 1.12 ichiro &pcmcia_emtac_a2424i_func0, &pcmcia_emtac_a2424i_func0_cfe0 },
242 1.17 ichiro { PCMCIA_VENDOR_INVALID, PCMCIA_PRODUCT_INVALID,
243 1.17 ichiro PCMCIA_CIS_FUJITSU_FMV_J181,
244 1.17 ichiro &pcmcia_fujitsu_j181_func0, &pcmcia_fujitsu_j181_func0_cfe0 },
245 1.1 marc };
246 1.1 marc
247 1.21 mycroft static const int pcmcia_cis_nquirks =
248 1.21 mycroft sizeof(pcmcia_cis_quirks) / sizeof(pcmcia_cis_quirks[0]);
249 1.1 marc
250 1.1 marc void pcmcia_check_cis_quirks(sc)
251 1.1 marc struct pcmcia_softc *sc;
252 1.1 marc {
253 1.1 marc int wiped = 0;
254 1.1 marc int i, j;
255 1.19 lukem struct pcmcia_function *pf;
256 1.8 jdolecek const struct pcmcia_function *pf_last;
257 1.19 lukem struct pcmcia_config_entry *cfe;
258 1.1 marc
259 1.2 marc pf = NULL;
260 1.1 marc pf_last = NULL;
261 1.1 marc
262 1.21 mycroft for (i=0; i<pcmcia_cis_nquirks; i++) {
263 1.3 marc if ((sc->card.manufacturer == pcmcia_cis_quirks[i].manufacturer) &&
264 1.3 marc (sc->card.product == pcmcia_cis_quirks[i].product) &&
265 1.3 marc (((sc->card.manufacturer != PCMCIA_VENDOR_INVALID) &&
266 1.3 marc (sc->card.product != PCMCIA_PRODUCT_INVALID)) ||
267 1.3 marc ((sc->card.manufacturer == PCMCIA_VENDOR_INVALID) &&
268 1.3 marc (sc->card.product == PCMCIA_PRODUCT_INVALID) &&
269 1.3 marc sc->card.cis1_info[0] &&
270 1.3 marc (strcmp(sc->card.cis1_info[0],
271 1.3 marc pcmcia_cis_quirks[i].cis1_info[0]) == 0) &&
272 1.3 marc sc->card.cis1_info[1] &&
273 1.3 marc (strcmp(sc->card.cis1_info[1],
274 1.3 marc pcmcia_cis_quirks[i].cis1_info[1]) == 0)))) {
275 1.1 marc if (!wiped) {
276 1.1 marc if (pcmcia_verbose) {
277 1.1 marc printf("%s: using CIS quirks for ", sc->dev.dv_xname);
278 1.1 marc for (j = 0; j < 4; j++) {
279 1.1 marc if (sc->card.cis1_info[j] == NULL)
280 1.1 marc break;
281 1.1 marc if (j)
282 1.1 marc printf(", ");
283 1.1 marc printf("%s", sc->card.cis1_info[j]);
284 1.1 marc }
285 1.1 marc printf("\n");
286 1.1 marc }
287 1.20 christos pcmcia_free_pf(&sc->card.pf_head);
288 1.1 marc wiped = 1;
289 1.1 marc }
290 1.1 marc
291 1.1 marc if (pf_last == pcmcia_cis_quirks[i].pf) {
292 1.1 marc cfe = malloc(sizeof(*cfe), M_DEVBUF, M_NOWAIT);
293 1.1 marc *cfe = *pcmcia_cis_quirks[i].cfe;
294 1.1 marc
295 1.1 marc SIMPLEQ_INSERT_TAIL(&pf->cfe_head, cfe, cfe_list);
296 1.1 marc } else {
297 1.1 marc pf = malloc(sizeof(*pf), M_DEVBUF, M_NOWAIT);
298 1.1 marc *pf = *pcmcia_cis_quirks[i].pf;
299 1.1 marc SIMPLEQ_INIT(&pf->cfe_head);
300 1.1 marc
301 1.1 marc cfe = malloc(sizeof(*cfe), M_DEVBUF, M_NOWAIT);
302 1.1 marc *cfe = *pcmcia_cis_quirks[i].cfe;
303 1.1 marc
304 1.1 marc SIMPLEQ_INSERT_TAIL(&pf->cfe_head, cfe, cfe_list);
305 1.1 marc SIMPLEQ_INSERT_TAIL(&sc->card.pf_head, pf, pf_list);
306 1.1 marc
307 1.1 marc pf_last = pcmcia_cis_quirks[i].pf;
308 1.1 marc }
309 1.1 marc }
310 1.1 marc }
311 1.1 marc }
312