Deleted Added
sdiff udiff text old ( 71324 ) new ( 73374 )
full compact
1/*
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
10 * disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/dev/ed/if_ed_pccard.c 71324 2001-01-21 08:20:23Z imp $
28 */
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/socket.h>
33#include <sys/kernel.h>
34#include <sys/conf.h>
35#include <sys/uio.h>
36
37#include <sys/module.h>
38#include <sys/bus.h>
39#include <machine/bus.h>
40#include <sys/rman.h>
41#include <machine/resource.h>
42
43#include <net/ethernet.h>
44#include <net/if.h>
45#include <net/if_arp.h>
46#include <net/if_mib.h>
47
48#include <dev/ed/if_edreg.h>
49#include <dev/ed/if_edvar.h>
50#include <dev/pccard/pccardvar.h>
51#include <dev/pccard/pccarddevs.h>
52
53#include "card_if.h"
54
55/*
56 * PC-Card (PCMCIA) specific code.
57 */
58static int ed_pccard_match(device_t);
59static int ed_pccard_probe(device_t);
60static int ed_pccard_attach(device_t);
61static int ed_pccard_detach(device_t);
62
63static int ed_pccard_Linksys(device_t dev);
64static int ed_pccard_ax88190(device_t dev);
65
66static void ax88190_geteprom(struct ed_softc *);
67static int ed_pccard_memwrite(device_t dev, off_t offset, u_char byte);
68static int linksys;
69
70/*
71 * ed_pccard_detach - unload the driver and clear the table.
72 * XXX TODO:
73 * This is usually called when the card is ejected, but
74 * can be caused by a modunload of a controller driver.
75 * The idea is to reset the driver's view of the device
76 * and ensure that any driver entry points such as
77 * read and write do not hang.
78 */
79static int
80ed_pccard_detach(device_t dev)
81{
82 struct ed_softc *sc = device_get_softc(dev);
83 struct ifnet *ifp = &sc->arpcom.ac_if;
84
85 if (sc->gone) {
86 device_printf(dev, "already unloaded\n");
87 return (0);
88 }
89 ed_stop(sc);
90 ifp->if_flags &= ~IFF_RUNNING;
91 ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
92 sc->gone = 1;
93 bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
94 ed_release_resources(dev);
95 return (0);
96}
97
98static const struct ed_product {
99 struct pccard_product prod;
100 int enet_maddr;
101 unsigned char enet_vendor[3];
102 int flags;
103#define NE2000DVF_DL10019 0x0001 /* chip is D-Link DL10019 */
104#define NE2000DVF_AX88190 0x0002 /* chip is ASIX AX88190 */
105} ed_pccard_products[] = {
106 { { PCCARD_STR_AMBICOM_AMB8002T,
107 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
108 PCCARD_CIS_AMBICOM_AMB8002T },
109 -1, { 0x00, 0x10, 0x7a } },
110
111 { { PCCARD_STR_PREMAX_PE200,
112 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
113 PCCARD_CIS_PREMAX_PE200 },
114 0x07f0, { 0x00, 0x20, 0xe0 } },
115
116 { { PCCARD_STR_DIGITAL_DEPCMXX,
117 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
118 PCCARD_CIS_DIGITAL_DEPCMXX },
119 0x0ff0, { 0x00, 0x00, 0xe8 } },
120
121 { { PCCARD_STR_PLANET_SMARTCOM2000,
122 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
123 PCCARD_CIS_PLANET_SMARTCOM2000 },
124 0xff0, { 0x00, 0x00, 0xe8 } },
125
126 { { PCCARD_STR_DLINK_DE660,
127 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
128 PCCARD_CIS_DLINK_DE660 },
129 -1, { 0x00, 0x80, 0xc8 } },
130
131 { { PCCARD_STR_RPTI_EP400,
132 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
133 PCCARD_CIS_RPTI_EP400 },
134 -1, { 0x00, 0x40, 0x95 } },
135
136 { { PCCARD_STR_RPTI_EP401,
137 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
138 PCCARD_CIS_RPTI_EP401 },
139 -1, { 0x00, 0x40, 0x95 } },
140
141 { { PCCARD_STR_ACCTON_EN2212,
142 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
143 PCCARD_CIS_ACCTON_EN2212 },
144 0x0ff0, { 0x00, 0x00, 0xe8 } },
145
146 { { PCCARD_STR_SVEC_COMBOCARD,
147 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
148 PCCARD_CIS_SVEC_COMBOCARD },
149 -1, { 0x00, 0xe0, 0x98 } },
150
151 { { PCCARD_STR_SVEC_LANCARD,
152 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
153 PCCARD_CIS_SVEC_LANCARD },
154 0x7f0, { 0x00, 0xc0, 0x6c } },
155
156 { { PCCARD_STR_EPSON_EEN10B,
157 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_EPSON_EEN10B, 0,
158 PCCARD_CIS_EPSON_EEN10B },
159 0xff0, { 0x00, 0x00, 0x48 } },
160
161 /*
162 * You have to add new entries which contains
163 * PCCARD_VENDOR_INVALID and/or PCCARD_PRODUCT_INVALID
164 * in front of this comment.
165 *
166 * There are cards which use a generic vendor and product id but needs
167 * a different handling depending on the cis_info, so ne2000_match
168 * needs a table where the exceptions comes first and then the normal
169 * product and vendor entries.
170 */
171
172 { { PCCARD_STR_IBM_INFOMOVER,
173 PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_INFOMOVER, 0,
174 PCCARD_CIS_IBM_INFOMOVER },
175 0x0ff0, { 0x08, 0x00, 0x5a } },
176
177 { { PCCARD_STR_IBM_INFOMOVER,
178 PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_INFOMOVER, 0,
179 PCCARD_CIS_IBM_INFOMOVER },
180 0x0ff0, { 0x00, 0x04, 0xac } },
181
182 { { PCCARD_STR_IBM_INFOMOVER,
183 PCCARD_VENDOR_IBM, PCCARD_PRODUCT_IBM_INFOMOVER, 0,
184 PCCARD_CIS_IBM_INFOMOVER },
185 0x0ff0, { 0x00, 0x06, 0x29 } },
186
187 { { PCCARD_STR_KINGSTON_KNE2, PCCARD_VENDOR_KINGSTON,
188 PCCARD_PRODUCT_KINGSTON_KNE2, 0,
189 PCCARD_CIS_KINGSTON_KNE2 },
190 -1, { 0, 0, 0 }, 0 }, /* XXX */
191
192 { { PCCARD_STR_LINKSYS_ECARD_1,
193 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_ECARD_1, 0,
194 PCCARD_CIS_LINKSYS_ECARD_1 },
195 -1, { 0x00, 0x80, 0xc8 } },
196
197 { { PCCARD_STR_PLANEX_FNW3600T,
198 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_COMBO_ECARD, 0,
199 PCCARD_CIS_PLANEX_FNW3600T },
200 -1, { 0x00, 0x90, 0xcc }, NE2000DVF_DL10019 },
201
202 { { PCCARD_STR_SVEC_PN650TX,
203 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_COMBO_ECARD, 0,
204 PCCARD_CIS_SVEC_PN650TX },
205 -1, { 0x00, 0xe0, 0x98 }, NE2000DVF_DL10019 },
206
207 /*
208 * This entry should be here so that above two cards doesn't
209 * match with this. FNW-3700T won't match above entries due to
210 * MAC address check.
211 */
212 { { PCCARD_STR_PLANEX_FNW3700T,
213 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_COMBO_ECARD, 0,
214 PCCARD_CIS_PLANEX_FNW3700T },
215 -1, { 0x00, 0x90, 0xcc }, NE2000DVF_AX88190 },
216
217 { { PCCARD_STR_LINKSYS_ETHERFAST,
218 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_ETHERFAST, 0,
219 PCCARD_CIS_LINKSYS_ETHERFAST },
220 -1, { 0x00, 0x80, 0xc8 }, NE2000DVF_DL10019 },
221
222 { { PCCARD_STR_DLINK_DE650,
223 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_ETHERFAST, 0,
224 PCCARD_CIS_DLINK_DE650 },
225 -1, { 0x00, 0xe0, 0x98 }, NE2000DVF_DL10019 },
226
227 { { PCCARD_STR_MELCO_LPC2_TX,
228 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_ETHERFAST, 0,
229 PCCARD_CIS_MELCO_LPC2_TX },
230 -1, { 0x00, 0x40, 0x26 }, NE2000DVF_DL10019 },
231
232 { { PCCARD_STR_LINKSYS_COMBO_ECARD,
233 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_COMBO_ECARD, 0,
234 PCCARD_CIS_LINKSYS_COMBO_ECARD },
235 -1, { 0x00, 0x80, 0xc8 } },
236
237 { { PCCARD_STR_LINKSYS_TRUST_COMBO_ECARD,
238 PCCARD_VENDOR_LINKSYS, PCCARD_PRODUCT_LINKSYS_TRUST_COMBO_ECARD, 0,
239 PCCARD_CIS_LINKSYS_TRUST_COMBO_ECARD },
240 0x0120, { 0x20, 0x04, 0x49 } },
241
242 /*
243 * Although the comments above say to put VENDOR/PRODUCT
244 * INVALID IDs above this list, we need to keep this one below
245 * the ECARD_1, or else both will match the same more-generic
246 * entry rather than the more specific one above with proper
247 * vendor and product IDs.
248 */
249 { { PCCARD_STR_LINKSYS_ECARD_2,
250 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
251 PCCARD_CIS_LINKSYS_ECARD_2 },
252 -1, { 0x00, 0x80, 0xc8 } },
253
254 /*
255 * D-Link DE-650 has many minor versions:
256 *
257 * CIS information Manufacturer Product Note
258 * 1 "D-Link, DE-650" INVALID INVALID white card
259 * 2 "D-Link, DE-650, Ver 01.00" INVALID INVALID became bare metal
260 * 3 "D-Link, DE-650, Ver 01.00" 0x149 0x265 minor changed look
261 * 4 "D-Link, DE-650, Ver 01.00" 0x149 0x265 collision LED added
262 *
263 * While the 1st and the 2nd types should use the "D-Link DE-650"
264 * entry, the 3rd and the 4th types should use the "Linksys
265 * EtherCard" entry. Therefore, this enty must be below the
266 * LINKSYS_ECARD_1. --itohy
267 */
268 { { PCCARD_STR_DLINK_DE650,
269 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
270 PCCARD_CIS_DLINK_DE650 },
271 0x0040, { 0x00, 0x80, 0xc8 } },
272
273 /*
274 * IO-DATA PCLA/TE and later version of PCLA/T has valid
275 * vendor/product ID and it is possible to read MAC address
276 * using standard I/O ports. It also read from CIS offset 0x01c0.
277 * On the other hand, earlier version of PCLA/T doesn't have valid
278 * vendor/product ID and MAC address must be read from CIS offset
279 * 0x0ff0 (i.e., usual ne2000 way to read it doesn't work).
280 * And CIS information of earlier and later version of PCLA/T are
281 * same except fourth element. So, for now, we place the entry for
282 * PCLA/TE (and later version of PCLA/T) followed by entry
283 * for the earlier version of PCLA/T (or, modify to match all CIS
284 * information and have three or more individual entries).
285 */
286 { { PCCARD_STR_IODATA_PCLATE,
287 PCCARD_VENDOR_IODATA, PCCARD_PRODUCT_IODATA_PCLATE, 0,
288 PCCARD_CIS_IODATA_PCLATE },
289 -1, { 0x00, 0xa0, 0xb0 } },
290
291 /*
292 * This entry should be placed after above PCLA-TE entry.
293 * See above comments for detail.
294 */
295 { { PCCARD_STR_IODATA_PCLAT,
296 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
297 PCCARD_CIS_IODATA_PCLAT },
298 0x0ff0, { 0x00, 0xa0, 0xb0 } },
299
300 { { PCCARD_STR_DAYNA_COMMUNICARD_E_1,
301 PCCARD_VENDOR_DAYNA, PCCARD_PRODUCT_DAYNA_COMMUNICARD_E_1, 0,
302 PCCARD_CIS_DAYNA_COMMUNICARD_E_1 },
303 0x0110, { 0x00, 0x80, 0x19 } },
304
305 { { PCCARD_STR_DAYNA_COMMUNICARD_E_2,
306 PCCARD_VENDOR_DAYNA, PCCARD_PRODUCT_DAYNA_COMMUNICARD_E_2, 0,
307 PCCARD_CIS_DAYNA_COMMUNICARD_E_2 },
308 -1, { 0x00, 0x80, 0x19 } },
309
310 { { PCCARD_STR_COREGA_ETHER_PCC_T,
311 PCCARD_VENDOR_COREGA, PCCARD_PRODUCT_COREGA_ETHER_PCC_T, 0,
312 PCCARD_CIS_COREGA_ETHER_PCC_T },
313 -1, { 0x00, 0x00, 0xf4 } },
314
315 { { PCCARD_STR_COREGA_ETHER_II_PCC_T,
316 PCCARD_VENDOR_COREGA, PCCARD_PRODUCT_COREGA_ETHER_II_PCC_T, 0,
317 PCCARD_CIS_COREGA_ETHER_II_PCC_T },
318 -1, { 0x00, 0x00, 0xf4 } },
319
320 { { PCCARD_STR_COREGA_FAST_ETHER_PCC_TX,
321 PCCARD_VENDOR_COREGA, PCCARD_PRODUCT_COREGA_FAST_ETHER_PCC_TX, 0,
322 PCCARD_CIS_COREGA_FAST_ETHER_PCC_TX },
323 -1, { 0x00, 0x00, 0xf4 }, NE2000DVF_DL10019 },
324
325 { { PCCARD_STR_COMPEX_LINKPORT_ENET_B,
326 PCCARD_VENDOR_COMPEX, PCCARD_PRODUCT_COMPEX_LINKPORT_ENET_B, 0,
327 PCCARD_CIS_COMPEX_LINKPORT_ENET_B },
328 0x01c0, { 0x00, 0xa0, 0x0c } },
329
330 { { PCCARD_STR_SMC_EZCARD,
331 PCCARD_VENDOR_SMC, PCCARD_PRODUCT_SMC_EZCARD, 0,
332 PCCARD_CIS_SMC_EZCARD },
333 0x01c0, { 0x00, 0xe0, 0x29 } },
334
335 { { PCCARD_STR_SOCKET_LP_ETHER_CF,
336 PCCARD_VENDOR_SOCKET, PCCARD_PRODUCT_SOCKET_LP_ETHER_CF, 0,
337 PCCARD_CIS_SOCKET_LP_ETHER_CF },
338 -1, { 0x00, 0xc0, 0x1b } },
339
340 { { PCCARD_STR_SOCKET_LP_ETHER,
341 PCCARD_VENDOR_SOCKET, PCCARD_PRODUCT_SOCKET_LP_ETHER, 0,
342 PCCARD_CIS_SOCKET_LP_ETHER },
343 -1, { 0x00, 0xc0, 0x1b } },
344
345 { { PCCARD_STR_XIRCOM_CFE_10,
346 PCCARD_VENDOR_XIRCOM, PCCARD_PRODUCT_XIRCOM_CFE_10, 0,
347 PCCARD_CIS_XIRCOM_CFE_10 },
348 -1, { 0x00, 0x10, 0xa4 } },
349
350 { { PCCARD_STR_MELCO_LPC3_TX,
351 PCCARD_VENDOR_MELCO, PCCARD_PRODUCT_MELCO_LPC3_TX, 0,
352 PCCARD_CIS_MELCO_LPC3_TX },
353 -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 },
354
355 { { PCCARD_STR_BILLIONTON_LNT10TN,
356 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
357 PCCARD_CIS_BILLIONTON_LNT10TN },
358 -1, { 0x00, 0x00, 0x00 } },
359
360 { { PCCARD_STR_NDC_ND5100_E,
361 PCCARD_VENDOR_INVALID, PCCARD_PRODUCT_INVALID, 0,
362 PCCARD_CIS_NDC_ND5100_E },
363 -1, { 0x00, 0x80, 0xc6 } },
364
365 { { PCCARD_STR_TELECOMDEVICE_TCD_HPC100,
366 PCCARD_VENDOR_TELECOMDEVICE, PCCARD_PRODUCT_TELECOMDEVICE_TCD_HPC100, 0,
367 PCCARD_CIS_TELECOMDEVICE_TCD_HPC100 },
368 -1, { 0x00, 0x40, 0x26 }, NE2000DVF_AX88190 },
369
370 { { PCCARD_STR_MACNICA_ME1_JEIDA,
371 PCCARD_VENDOR_MACNICA, PCCARD_PRODUCT_MACNICA_ME1_JEIDA, 0,
372 PCCARD_CIS_MACNICA_ME1_JEIDA },
373 0x00b8, { 0x08, 0x00, 0x42 } },
374
375#if 0
376 /* the rest of these are stolen from the linux pcnet pcmcia device
377 driver. Since I don't know the manfid or cis info strings for
378 any of them, they're not compiled in until I do. */
379 { "APEX MultiCard",
380 0x0000, 0x0000, NULL, NULL, 0,
381 0x03f4, { 0x00, 0x20, 0xe5 } },
382 { "ASANTE FriendlyNet",
383 0x0000, 0x0000, NULL, NULL, 0,
384 0x4910, { 0x00, 0x00, 0x94 } },
385 { "Danpex EN-6200P2",
386 0x0000, 0x0000, NULL, NULL, 0,
387 0x0110, { 0x00, 0x40, 0xc7 } },
388 { "DataTrek NetCard",
389 0x0000, 0x0000, NULL, NULL, 0,
390 0x0ff0, { 0x00, 0x20, 0xe8 } },
391 { "Dayna CommuniCard E",
392 0x0000, 0x0000, NULL, NULL, 0,
393 0x0110, { 0x00, 0x80, 0x19 } },
394 { "EP-210 Ethernet",
395 0x0000, 0x0000, NULL, NULL, 0,
396 0x0110, { 0x00, 0x40, 0x33 } },
397 { "ELECOM Laneed LD-CDWA",
398 0x0000, 0x0000, NULL, NULL, 0,
399 0x00b8, { 0x08, 0x00, 0x42 } },
400 { "Grey Cell GCS2220",
401 0x0000, 0x0000, NULL, NULL, 0,
402 0x0000, { 0x00, 0x47, 0x43 } },
403 { "Hypertec Ethernet",
404 0x0000, 0x0000, NULL, NULL, 0,
405 0x01c0, { 0x00, 0x40, 0x4c } },
406 { "IBM CCAE",
407 0x0000, 0x0000, NULL, NULL, 0,
408 0x0ff0, { 0x08, 0x00, 0x5a } },
409 { "IBM CCAE",
410 0x0000, 0x0000, NULL, NULL, 0,
411 0x0ff0, { 0x00, 0x04, 0xac } },
412 { "IBM CCAE",
413 0x0000, 0x0000, NULL, NULL, 0,
414 0x0ff0, { 0x00, 0x06, 0x29 } },
415 { "IBM FME",
416 0x0000, 0x0000, NULL, NULL, 0,
417 0x0374, { 0x00, 0x04, 0xac } },
418 { "IBM FME",
419 0x0000, 0x0000, NULL, NULL, 0,
420 0x0374, { 0x08, 0x00, 0x5a } },
421 { "Katron PE-520",
422 0x0000, 0x0000, NULL, NULL, 0,
423 0x0110, { 0x00, 0x40, 0xf6 } },
424 { "Kingston KNE-PCM/x",
425 0x0000, 0x0000, NULL, NULL, 0,
426 0x0ff0, { 0x00, 0xc0, 0xf0 } },
427 { "Kingston KNE-PCM/x",
428 0x0000, 0x0000, NULL, NULL, 0,
429 0x0ff0, { 0xe2, 0x0c, 0x0f } },
430 { "Kingston KNE-PC2",
431 0x0000, 0x0000, NULL, NULL, 0,
432 0x0180, { 0x00, 0xc0, 0xf0 } },
433 { "Longshine LCS-8534",
434 0x0000, 0x0000, NULL, NULL, 0,
435 0x0000, { 0x08, 0x00, 0x00 } },
436 { "Maxtech PCN2000",
437 0x0000, 0x0000, NULL, NULL, 0,
438 0x5000, { 0x00, 0x00, 0xe8 } },
439 { "NDC Instant-Link",
440 0x0000, 0x0000, NULL, NULL, 0,
441 0x003a, { 0x00, 0x80, 0xc6 } },
442 { "NE2000 Compatible",
443 0x0000, 0x0000, NULL, NULL, 0,
444 0x0ff0, { 0x00, 0xa0, 0x0c } },
445 { "Network General Sniffer",
446 0x0000, 0x0000, NULL, NULL, 0,
447 0x0ff0, { 0x00, 0x00, 0x65 } },
448 { "Panasonic VEL211",
449 0x0000, 0x0000, NULL, NULL, 0,
450 0x0ff0, { 0x00, 0x80, 0x45 } },
451 { "SCM Ethernet",
452 0x0000, 0x0000, NULL, NULL, 0,
453 0x0ff0, { 0x00, 0x20, 0xcb } },
454 { "Socket EA",
455 0x0000, 0x0000, NULL, NULL, 0,
456 0x4000, { 0x00, 0xc0, 0x1b } },
457 { "Volktek NPL-402CT",
458 0x0000, 0x0000, NULL, NULL, 0,
459 0x0060, { 0x00, 0x40, 0x05 } },
460#endif
461
462 { { PCCARD_STR_ALLIEDTELESIS_LA_PCM,
463 PCCARD_VENDOR_ALLIEDTELESIS, PCCARD_PRODUCT_ALLIEDTELESIS_LA_PCM, 0,
464 PCCARD_CIS_ALLIEDTELESIS_LA_PCM },
465 0x0ff0, { 0x00, 0x00, 0xf4 } },
466
467};
468
469static int
470ed_pccard_match(device_t dev)
471{
472 const struct pccard_product *pp;
473
474 if ((pp = pccard_product_lookup(dev,
475 (const struct pccard_product *) ed_pccard_products,
476 sizeof(ed_pccard_products[0]), NULL)) != NULL) {
477 device_set_desc(dev, pp->pp_name);
478 return 0;
479 }
480 return EIO;
481}
482
483/*
484 * Probe framework for pccards. Replicates the standard framework,
485 * minus the pccard driver registration and ignores the ether address
486 * supplied (from the CIS), relying on the probe to find it instead.
487 */
488static int
489ed_pccard_probe(device_t dev)
490{
491 int error;
492 int flags = device_get_flags(dev);
493
494 if (ED_FLAGS_GETTYPE(flags) == ED_FLAGS_AX88190) {
495 error = ed_pccard_ax88190(dev);
496 goto end2;
497 }
498
499 error = ed_probe_Novell(dev, 0, flags);
500 if (error == 0)
501 goto end;
502 ed_release_resources(dev);
503
504 error = ed_probe_WD80x3(dev, 0, flags);
505 if (error == 0)
506 goto end;
507 ed_release_resources(dev);
508 goto end2;
509
510end:
511 if (ED_FLAGS_GETTYPE(flags) & ED_FLAGS_LINKSYS) {
512 linksys = ed_pccard_Linksys(dev);
513 } else {
514 linksys = 0;
515 }
516end2:
517 if (error == 0)
518 error = ed_alloc_irq(dev, 0, 0);
519
520 ed_release_resources(dev);
521 return (error);
522}
523
524static int
525ed_pccard_attach(device_t dev)
526{
527 int error;
528 int flags = device_get_flags(dev);
529 int i;
530 struct ed_softc *sc = device_get_softc(dev);
531 u_char sum;
532 u_char ether_addr[ETHER_ADDR_LEN];
533
534 if (sc->port_used > 0)
535 ed_alloc_port(dev, sc->port_rid, sc->port_used);
536 if (sc->mem_used)
537 ed_alloc_memory(dev, sc->mem_rid, sc->mem_used);
538 ed_alloc_irq(dev, sc->irq_rid, 0);
539
540 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
541 edintr, sc, &sc->irq_handle);
542 if (error) {
543 printf("setup intr failed %d \n", error);
544 ed_release_resources(dev);
545 return (error);
546 }
547
548 if (linksys == 0) {
549 pccard_get_ether(dev, ether_addr);
550 for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++)
551 sum |= ether_addr[i];
552 if (sum)
553 bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
554 }
555
556 error = ed_attach(sc, device_get_unit(dev), flags);
557 return (error);
558}
559
560static void
561ax88190_geteprom(struct ed_softc *sc)
562{
563 int prom[16],i;
564 u_char tmp;
565 struct {
566 unsigned char offset, value;
567 } pg_seq[] = {
568 {ED_P0_CR, ED_CR_RD2|ED_CR_STP},/* Select Page0 */
569 {ED_P0_DCR, 0x01},
570 {ED_P0_RBCR0, 0x00}, /* Clear the count regs. */
571 {ED_P0_RBCR1, 0x00},
572 {ED_P0_IMR, 0x00}, /* Mask completion irq. */
573 {ED_P0_ISR, 0xff},
574 {ED_P0_RCR, ED_RCR_MON | ED_RCR_INTT}, /* Set To Monitor */
575 {ED_P0_TCR, ED_TCR_LB0}, /* loopback mode. */
576 {ED_P0_RBCR0, 32},
577 {ED_P0_RBCR1, 0x00},
578 {ED_P0_RSAR0, 0x00},
579 {ED_P0_RSAR1, 0x04},
580 {ED_P0_CR ,ED_CR_RD0 | ED_CR_STA},
581 };
582
583 /* Reset Card */
584 tmp = ed_asic_inb(sc, ED_NOVELL_RESET);
585 ed_asic_outb(sc, ED_NOVELL_RESET, tmp);
586 DELAY(5000);
587 ed_asic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STP);
588 DELAY(5000);
589
590 /* Card Settings */
591 for (i = 0; i < sizeof(pg_seq) / sizeof(pg_seq[0]); i++)
592 ed_nic_outb(sc, pg_seq[i].offset, pg_seq[i].value);
593
594 /* Get Data */
595 for (i = 0; i < 16; i++)
596 prom[i] = ed_asic_inb(sc, 0);
597 sc->arpcom.ac_enaddr[0] = prom[0] & 0xff;
598 sc->arpcom.ac_enaddr[1] = prom[0] >> 8;
599 sc->arpcom.ac_enaddr[2] = prom[1] & 0xff;
600 sc->arpcom.ac_enaddr[3] = prom[1] >> 8;
601 sc->arpcom.ac_enaddr[4] = prom[2] & 0xff;
602 sc->arpcom.ac_enaddr[5] = prom[2] >> 8;
603}
604
605static int
606ed_pccard_memwrite(device_t dev, off_t offset, u_char byte)
607{
608 int cis_rid;
609 struct resource *cis;
610
611 cis_rid = 0;
612 cis = bus_alloc_resource(dev, SYS_RES_MEMORY, &cis_rid, 0, ~0,
613 4 << 10, RF_ACTIVE | RF_SHAREABLE);
614 if (cis == NULL)
615 return (ENXIO);
616 CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY,
617 cis_rid, PCCARD_A_MEM_ATTR);
618
619 bus_space_write_1(rman_get_bustag(cis), rman_get_bushandle(cis),
620 offset, byte);
621
622 bus_deactivate_resource(dev, SYS_RES_MEMORY, cis_rid, cis);
623 bus_release_resource(dev, SYS_RES_MEMORY, cis_rid, cis);
624
625 return (0);
626}
627
628/*
629 * Probe the Ethernet MAC addrees for PCMCIA Linksys EtherFast 10/100
630 * and compatible cards (DL10019C Ethernet controller).
631 *
632 * Note: The PAO patches try to use more memory for the card, but that
633 * seems to fail for my card. A future optimization would add this back
634 * conditionally.
635 */
636static int
637ed_pccard_Linksys(device_t dev)
638{
639 struct ed_softc *sc = device_get_softc(dev);
640 u_char sum;
641 int i;
642
643 /*
644 * Linksys registers(offset from ASIC base)
645 *
646 * 0x04-0x09 : Physical Address Register 0-5 (PAR0-PAR5)
647 * 0x0A : Card ID Register (CIR)
648 * 0x0B : Check Sum Register (SR)
649 */
650 for (sum = 0, i = 0x04; i < 0x0c; i++)
651 sum += ed_asic_inb(sc, i);
652 if (sum != 0xff)
653 return (0); /* invalid DL10019C */
654 for (i = 0; i < ETHER_ADDR_LEN; i++) {
655 sc->arpcom.ac_enaddr[i] = ed_asic_inb(sc, 0x04 + i);
656 }
657
658 ed_nic_outb(sc, ED_P0_DCR, ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
659 sc->isa16bit = 1;
660 sc->type = ED_TYPE_NE2000;
661 sc->type_str = "Linksys";
662 return (1);
663}
664
665/*
666 * Special setup for AX88190
667 */
668static int
669ed_pccard_ax88190(device_t dev)
670{
671 int error;
672 int flags = device_get_flags(dev);
673 int iobase;
674 struct ed_softc *sc = device_get_softc(dev);
675
676 /* Allocate the port resource during setup. */
677 error = ed_alloc_port(dev, 0, ED_NOVELL_IO_PORTS);
678 if (error)
679 return (error);
680
681 sc->asic_offset = ED_NOVELL_ASIC_OFFSET;
682 sc->nic_offset = ED_NOVELL_NIC_OFFSET;
683 sc->chip_type = ED_CHIP_TYPE_AX88190;
684
685 /*
686 * Set Attribute Memory IOBASE Register
687 */
688 iobase = rman_get_start(sc->port_res);
689 ed_pccard_memwrite(dev, ED_AX88190_IOBASE0, iobase & 0xff);
690 ed_pccard_memwrite(dev, ED_AX88190_IOBASE1, (iobase >> 8) & 0xff);
691 ax88190_geteprom(sc);
692 ed_release_resources(dev);
693 error = ed_probe_Novell(dev, 0, flags);
694 return (error);
695}
696
697static device_method_t ed_pccard_methods[] = {
698 /* Device interface */
699 DEVMETHOD(device_probe, pccard_compat_probe),
700 DEVMETHOD(device_attach, pccard_compat_attach),
701 DEVMETHOD(device_detach, ed_pccard_detach),
702
703 /* Card interface */
704 DEVMETHOD(card_compat_match, ed_pccard_match),
705 DEVMETHOD(card_compat_probe, ed_pccard_probe),
706 DEVMETHOD(card_compat_attach, ed_pccard_attach),
707 { 0, 0 }
708};
709
710static driver_t ed_pccard_driver = {
711 "ed",
712 ed_pccard_methods,
713 sizeof(struct ed_softc)
714};
715
716DRIVER_MODULE(if_ed, pccard, ed_pccard_driver, ed_devclass, 0, 0);