if_ed_pccard.c revision 151225
1/*-
2 * Copyright (c) 2005, M. Warner Losh
3 * Copyright (c) 1995, David Greenman
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice unmodified, this list of conditions, and the following
11 *    disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/dev/ed/if_ed_pccard.c 151225 2005-10-11 01:04:16Z imp $
29 */
30
31/*
32 * Notes for adding media support.  Each chipset is somewhat different
33 * from the others.  Linux has a table of OIDs that it uses to see what
34 * supports the misc register of the NS83903.  But a sampling of datasheets
35 * I could dig up on cards I own paints a different picture.
36 *
37 * Chipset specific details:
38 * NS 83903/902A paired
39 *    ccr base 0x1020
40 *    id register at 0x1000: 7-3 = 0, 2-0 = 1.
41 *	(maybe this test is too week)
42 *    misc register at 0x018:
43 *	6 WAIT_TOUTENABLE enable watchdog timeout
44 *	3 AUI/TPI 1 AUX, 0 TPI
45 *	2 loopback
46 *      1 gdlink (tpi mode only) 1 tp good, 0 tp bad
47 *	0 0-no mam, 1 mam connected
48 * NS83926 appears to be a NS pcmcia glue chip used on the IBM Ethernet II
49 * and the NEC PC9801N-J12 ccr base 0x2000!
50 *
51 * winbond 289c926
52 *    ccr base 0xfd0
53 *    cfb (am 0xff2):
54 *	0-1 PHY01	00 TPI, 01 10B2, 10 10B5, 11 TPI (reduced squ)
55 *	2 LNKEN		0 - enable link and auto switch, 1 disable
56 *	3 LNKSTS	TPI + LNKEN=0 + link good == 1, else 0
57 *    sr (am 0xff4)
58 *	88 00 88 00 88 00, etc
59 *
60 * TMI tc3299a (cr PHY01 == 0)
61 *    ccr base 0x3f8
62 *    cra (io 0xa)
63 *    crb (io 0xb)
64 *	0-1 PHY01	00 auto, 01 res, 10 10B5, 11 TPI
65 *	2 GDLINK	1 disable checking of link
66 *	6 LINK		0 bad link, 1 good link
67 * TMI tc5299 10/100 chip, has a different MII interaction than
68 * dl100xx and ax88x90.
69 *
70 * EN5017A, EN5020	no data, but very popular
71 * Other chips?
72 * NetBSD supports RTL8019, but none have surfaced that I can see
73 */
74
75#include <sys/param.h>
76#include <sys/systm.h>
77#include <sys/socket.h>
78#include <sys/kernel.h>
79#include <sys/conf.h>
80#include <sys/uio.h>
81
82#include <sys/module.h>
83#include <sys/bus.h>
84#include <machine/bus.h>
85#include <sys/rman.h>
86#include <machine/resource.h>
87
88#include <net/ethernet.h>
89#include <net/if.h>
90#include <net/if_arp.h>
91#include <net/if_mib.h>
92#include <net/if_media.h>
93
94#include <dev/ed/if_edreg.h>
95#include <dev/ed/if_edvar.h>
96#include <dev/ed/ax88x90reg.h>
97#include <dev/ed/dl100xxreg.h>
98#include <dev/ed/tc5299jreg.h>
99#include <dev/pccard/pccardvar.h>
100#include <dev/pccard/pccardreg.h>
101#include <dev/pccard/pccard_cis.h>
102#include <dev/mii/mii.h>
103#include <dev/mii/miivar.h>
104
105#include "card_if.h"
106/* "device miibus" required.  See GENERIC if you get errors here. */
107#include "miibus_if.h"
108#include "pccarddevs.h"
109
110/*
111 * NE-2000 based PC Cards have a number of ways to get the MAC address.
112 * Some cards encode this as a FUNCE.  Others have this in the ROMs the
113 * same way that ISA cards do.  Some have it encoded in the attribute
114 * memory somewhere that isn't in the CIS.  Some new chipsets have it
115 * in special registers in the ASIC part of the chip.
116 *
117 * For those cards that have the MAC adress stored in attribute memory,
118 * nearly all of them have it at a fixed offset (0xff0).  We use that
119 * offset as a source of last resource if other offsets have failed.
120 */
121#define ED_DEFAULT_MAC_OFFSET	0xff0
122
123static const struct ed_product {
124	struct pccard_product	prod;
125	int flags;
126#define	NE2000DVF_DL100XX	0x0001		/* chip is D-Link DL10019/22 */
127#define	NE2000DVF_AX88X90	0x0002		/* chip is ASIX AX88[17]90 */
128#define NE2000DVF_TC5299J	0x0004		/* chip is Tamarack TC5299J */
129#define NE2000DVF_ENADDR	0x0100		/* Get MAC from attr mem */
130#define NE2000DVF_ANYFUNC	0x0200		/* Allow any function type */
131#define NE2000DVF_MODEM		0x0400		/* Has a modem/serial */
132	int enoff;
133} ed_pccard_products[] = {
134	{ PCMCIA_CARD(ACCTON, EN2212), 0},
135	{ PCMCIA_CARD(ACCTON, EN2216), 0},
136	{ PCMCIA_CARD(ALLIEDTELESIS, LA_PCM), 0},
137	{ PCMCIA_CARD(AMBICOM, AMB8002T), 0},
138	{ PCMCIA_CARD(BILLIONTON, LNT10TN), 0},
139	{ PCMCIA_CARD(BILLIONTON, CFLT10N), 0},
140	{ PCMCIA_CARD(BROMAX, IPORT), 0},
141	{ PCMCIA_CARD(BROMAX, IPORT2), 0},
142	{ PCMCIA_CARD(BUFFALO, LPC2_CLT), 0},
143	{ PCMCIA_CARD(BUFFALO, LPC3_CLT), 0},
144	{ PCMCIA_CARD(BUFFALO, LPC3_CLX), NE2000DVF_AX88X90},
145	{ PCMCIA_CARD(BUFFALO, LPC4_TX), NE2000DVF_AX88X90},
146	{ PCMCIA_CARD(BUFFALO, LPC4_CLX), NE2000DVF_AX88X90},
147	{ PCMCIA_CARD(BUFFALO, LPC_CF_CLT), 0},
148	{ PCMCIA_CARD(CNET, NE2000), 0},
149	{ PCMCIA_CARD(COMPEX, AX88190), NE2000DVF_AX88X90},
150	{ PCMCIA_CARD(COMPEX, LANMODEM), 0},
151	{ PCMCIA_CARD(COMPEX, LINKPORT_ENET_B), 0},
152	{ PCMCIA_CARD(COREGA, ETHER_II_PCC_T), 0},
153	{ PCMCIA_CARD(COREGA, ETHER_II_PCC_TD), 0},
154	{ PCMCIA_CARD(COREGA, ETHER_PCC_T), 0},
155	{ PCMCIA_CARD(COREGA, ETHER_PCC_TD), 0},
156	{ PCMCIA_CARD(COREGA, FAST_ETHER_PCC_TX), NE2000DVF_DL100XX},
157	{ PCMCIA_CARD(COREGA, FETHER_PCC_TXD), NE2000DVF_AX88X90},
158	{ PCMCIA_CARD(COREGA, FETHER_PCC_TXF), NE2000DVF_DL100XX},
159	{ PCMCIA_CARD(DAYNA, COMMUNICARD_E_1), 0},
160	{ PCMCIA_CARD(DAYNA, COMMUNICARD_E_2), 0},
161	{ PCMCIA_CARD(DLINK, DE660), 0 },
162	{ PCMCIA_CARD(DLINK, DE660PLUS), 0},
163	{ PCMCIA_CARD(DYNALINK, L10C), 0},
164	{ PCMCIA_CARD(EDIMAX, EP4000A), 0},
165	{ PCMCIA_CARD(EPSON, EEN10B), NE2000DVF_ENADDR, 0xff0},
166	{ PCMCIA_CARD(EXP, THINLANCOMBO), 0},
167	{ PCMCIA_CARD(GREY_CELL, TDK3000), 0},
168	{ PCMCIA_CARD(GREY_CELL, DMF650TX),
169	    NE2000DVF_ANYFUNC | NE2000DVF_DL100XX | NE2000DVF_MODEM},
170	{ PCMCIA_CARD(IBM, HOME_AND_AWAY), 0},
171	{ PCMCIA_CARD(IBM, INFOMOVER), NE2000DVF_ENADDR, 0xff0},
172	{ PCMCIA_CARD(IODATA3, PCLAT), 0},
173	{ PCMCIA_CARD(KINGSTON, CIO10T), 0},
174	{ PCMCIA_CARD(KINGSTON, KNE2), 0},
175	{ PCMCIA_CARD(LANTECH, FASTNETTX), NE2000DVF_AX88X90},
176	{ PCMCIA_CARD(LINKSYS, COMBO_ECARD),
177	    NE2000DVF_DL100XX | NE2000DVF_AX88X90},
178	{ PCMCIA_CARD(LINKSYS, ECARD_1), 0},
179	{ PCMCIA_CARD(LINKSYS, ECARD_2), 0},
180	{ PCMCIA_CARD(LINKSYS, ETHERFAST), NE2000DVF_DL100XX},
181	{ PCMCIA_CARD(LINKSYS, TRUST_COMBO_ECARD), 0},
182	{ PCMCIA_CARD(MACNICA, ME1_JEIDA), 0},
183	{ PCMCIA_CARD(MAGICRAM, ETHER), 0},
184	{ PCMCIA_CARD(MELCO, LPC3_CLX), NE2000DVF_AX88X90},
185	{ PCMCIA_CARD(MELCO, LPC3_TX), NE2000DVF_AX88X90},
186	{ PCMCIA_CARD(NDC, ND5100_E), 0},
187	{ PCMCIA_CARD(NETGEAR, FA410TXC), NE2000DVF_DL100XX},
188	/* Same ID as DLINK DFE-670TXD.  670 has DL10022, fa411 has ax88790 */
189	{ PCMCIA_CARD(NETGEAR, FA411), NE2000DVF_AX88X90 | NE2000DVF_DL100XX},
190	{ PCMCIA_CARD(NEXTCOM, NEXTHAWK), 0},
191	{ PCMCIA_CARD(NEWMEDIA, LANSURFER), 0},
192	{ PCMCIA_CARD(OEM2, ETHERNET), 0},
193	{ PCMCIA_CARD(OEM2, FAST_ETHERNET), NE2000DVF_AX88X90 },
194	{ PCMCIA_CARD(OEM2, NE2000), 0},
195	{ PCMCIA_CARD(PLANET, SMARTCOM2000), 0 },
196	{ PCMCIA_CARD(PREMAX, PE200), 0},
197	{ PCMCIA_CARD(PSION, LANGLOBAL),
198	    NE2000DVF_ANYFUNC | NE2000DVF_AX88X90 | NE2000DVF_MODEM},
199	{ PCMCIA_CARD(RACORE, ETHERNET), 0},
200	{ PCMCIA_CARD(RACORE, FASTENET), NE2000DVF_AX88X90},
201	{ PCMCIA_CARD(RACORE, 8041TX), NE2000DVF_AX88X90 | NE2000DVF_TC5299J},
202	{ PCMCIA_CARD(RELIA, COMBO), 0},
203	{ PCMCIA_CARD(RPTI, EP400), 0},
204	{ PCMCIA_CARD(RPTI, EP401), 0},
205	{ PCMCIA_CARD(SMC, EZCARD), 0},
206	{ PCMCIA_CARD(SOCKET, EA_ETHER), 0},
207	{ PCMCIA_CARD(SOCKET, ES_1000), 0},
208	{ PCMCIA_CARD(SOCKET, LP_ETHER), 0},
209	{ PCMCIA_CARD(SOCKET, LP_ETHER_CF), 0},
210	{ PCMCIA_CARD(SOCKET, LP_ETH_10_100_CF), NE2000DVF_DL100XX},
211	{ PCMCIA_CARD(SVEC, COMBOCARD), 0},
212	{ PCMCIA_CARD(SVEC, LANCARD), 0},
213	{ PCMCIA_CARD(TAMARACK, ETHERNET), 0},
214	{ PCMCIA_CARD(TDK, CFE_10), 0},
215	{ PCMCIA_CARD(TDK, LAK_CD031), 0},
216	{ PCMCIA_CARD(TDK, DFL5610WS), 0},
217	{ PCMCIA_CARD(TELECOMDEVICE, LM5LT), 0 },
218	{ PCMCIA_CARD(TELECOMDEVICE, TCD_HPC100), NE2000DVF_AX88X90},
219	{ PCMCIA_CARD(ZONET, ZEN), 0},
220	{ { NULL } }
221};
222
223/*
224 *      PC Card (PCMCIA) specific code.
225 */
226static int	ed_pccard_probe(device_t);
227static int	ed_pccard_attach(device_t);
228
229static int	ed_pccard_dl100xx(device_t dev, const struct ed_product *);
230static void	ed_pccard_dl100xx_mii_reset(struct ed_softc *sc);
231static u_int	ed_pccard_dl100xx_mii_readbits(struct ed_softc *sc, int nbits);
232static void	ed_pccard_dl100xx_mii_writebits(struct ed_softc *sc, u_int val,
233    int nbits);
234
235static int	ed_pccard_ax88x90(device_t dev, const struct ed_product *);
236static void	ed_pccard_ax88x90_mii_reset(struct ed_softc *sc);
237static u_int	ed_pccard_ax88x90_mii_readbits(struct ed_softc *sc, int nbits);
238static void	ed_pccard_ax88x90_mii_writebits(struct ed_softc *sc, u_int val,
239    int nbits);
240
241static int	ed_miibus_readreg(device_t dev, int phy, int reg);
242static int	ed_ifmedia_upd(struct ifnet *);
243static void	ed_ifmedia_sts(struct ifnet *, struct ifmediareq *);
244
245static int	ed_pccard_tc5299j(device_t dev, const struct ed_product *);
246static void	ed_pccard_tc5299j_mii_reset(struct ed_softc *sc);
247static u_int	ed_pccard_tc5299j_mii_readbits(struct ed_softc *sc, int nbits);
248static void	ed_pccard_tc5299j_mii_writebits(struct ed_softc *sc, u_int val,
249    int nbits);
250
251static void
252ed_pccard_print_entry(const struct ed_product *pp)
253{
254	int i;
255
256	printf("Product entry: ");
257	if (pp->prod.pp_name)
258		printf("name='%s',", pp->prod.pp_name);
259	printf("vendor=%#x,product=%#x", pp->prod.pp_vendor,
260	    pp->prod.pp_product);
261	for (i = 0; i < 4; i++)
262		if (pp->prod.pp_cis[i])
263			printf(",CIS%d='%s'", i, pp->prod.pp_cis[i]);
264	printf("\n");
265}
266
267static int
268ed_pccard_probe(device_t dev)
269{
270	const struct ed_product *pp, *pp2;
271	int		error, first = 1;
272	uint32_t	fcn = PCCARD_FUNCTION_UNSPEC;
273
274	/* Make sure we're a network function */
275	error = pccard_get_function(dev, &fcn);
276	if (error != 0)
277		return (error);
278
279	if ((pp = (const struct ed_product *) pccard_product_lookup(dev,
280	    (const struct pccard_product *) ed_pccard_products,
281	    sizeof(ed_pccard_products[0]), NULL)) != NULL) {
282		if (pp->prod.pp_name != NULL)
283			device_set_desc(dev, pp->prod.pp_name);
284		/*
285		 * Some devices don't ID themselves as network, but
286		 * that's OK if the flags say so.
287		 */
288		if (!(pp->flags & NE2000DVF_ANYFUNC) &&
289		    fcn != PCCARD_FUNCTION_NETWORK)
290			return (ENXIO);
291		/*
292		 * Some devices match multiple entries.  Report that
293		 * as a warning to help cull the table
294		 */
295		pp2 = pp;
296		while ((pp2 = (const struct ed_product *)pccard_product_lookup(
297		    dev, (const struct pccard_product *)(pp2 + 1),
298		    sizeof(ed_pccard_products[0]), NULL)) != NULL) {
299			if (first) {
300				device_printf(dev,
301    "Warning: card matches multiple entries.  Report to imp@freebsd.org\n");
302				ed_pccard_print_entry(pp);
303				first = 0;
304			}
305			ed_pccard_print_entry(pp2);
306		}
307
308		return (0);
309	}
310	return (ENXIO);
311}
312
313static int
314ed_pccard_rom_mac(device_t dev, uint8_t *enaddr)
315{
316	struct ed_softc *sc = device_get_softc(dev);
317	uint8_t romdata[32];
318	int i;
319
320	/*
321	 * Read in the rom data at location 0.  Since there are no
322	 * NE-1000 based PC Card devices, we'll assume we're 16-bit.
323	 *
324	 * In researching what format this takes, I've found that the
325	 * following appears to be true for multiple cards based on
326	 * observation as well as datasheet digging.
327	 *
328	 * Data is stored in some ROM and is copied out 8 bits at a time
329	 * into 16-bit wide locations.  This means that the odd locations
330	 * of the ROM are not used (and can be either 0 or ff).
331	 *
332	 * The contents appears to be as follows:
333	 * PROM   RAM
334	 * Offset Offset	What
335	 *  0      0	ENETADDR 0
336	 *  1      2	ENETADDR 1
337	 *  2      4	ENETADDR 2
338	 *  3      6	ENETADDR 3
339	 *  4      8	ENETADDR 4
340	 *  5     10	ENETADDR 5
341	 *  6-13  12-26 Reserved (varies by manufacturer)
342	 * 14     28	0x57
343	 * 15     30    0x57
344	 *
345	 * Some manufacturers have another image of enetaddr from
346	 * PROM offset 0x10 to 0x15 with 0x42 in 0x1e and 0x1f, but
347	 * this doesn't appear to be universally documented in the
348	 * datasheets.  Some manufactuers have a card type, card config
349	 * checksums, etc encoded into PROM offset 6-13, but deciphering it
350	 * requires more knowledge about the exact underlying chipset than
351	 * we possess (and maybe can possess).
352	 */
353	ed_pio_readmem(sc, 0, romdata, 32);
354	if (bootverbose)
355		printf("ROM DATA: %32D\n", romdata, " ");
356	if (romdata[28] != 0x57 || romdata[30] != 0x57)
357		return (0);
358	for (i = 0; i < ETHER_ADDR_LEN; i++)
359		enaddr[i] = romdata[i * 2];
360	return (1);
361}
362
363static int
364ed_pccard_add_modem(device_t dev)
365{
366	struct ed_softc *sc = device_get_softc(dev);
367
368	device_printf(dev, "Need to write this code: modem rid is %d\n",
369	    sc->modem_rid);
370	return 0;
371}
372
373static int
374ed_pccard_media_ioctl(struct ed_softc *sc, struct ifreq *ifr, u_long command)
375{
376	struct mii_data *mii;
377
378	if (sc->miibus == NULL)
379		return (EINVAL);
380	mii = device_get_softc(sc->miibus);
381	return (ifmedia_ioctl(sc->ifp, ifr, &mii->mii_media, command));
382}
383
384
385static void
386ed_pccard_mediachg(struct ed_softc *sc)
387{
388	struct mii_data *mii;
389
390	if (sc->miibus == NULL)
391		return;
392	mii = device_get_softc(sc->miibus);
393	mii_mediachg(mii);
394}
395
396static void
397ed_pccard_tick(void *arg)
398{
399	struct ed_softc *sc = arg;
400	struct mii_data *mii;
401	int media = 0;
402
403	ED_ASSERT_LOCKED(sc);
404	if (sc->miibus != NULL) {
405		mii = device_get_softc(sc->miibus);
406		media = mii->mii_media_status;
407		mii_tick(mii);
408		if (mii->mii_media_status & IFM_ACTIVE &&
409		    media != mii->mii_media_status && 0 &&
410		    sc->chip_type == ED_CHIP_TYPE_DL10022) {
411			ed_asic_outb(sc, ED_DL100XX_DIAG,
412			    (mii->mii_media_active & IFM_FDX) ?
413			    ED_DL100XX_COLLISON_DIS : 0);
414		}
415
416	}
417	callout_reset(&sc->tick_ch, hz, ed_pccard_tick, sc);
418}
419
420static int
421ed_pccard_attach(device_t dev)
422{
423	u_char sum;
424	u_char enaddr[ETHER_ADDR_LEN];
425	const struct ed_product *pp;
426	int	error, i;
427	struct ed_softc *sc = device_get_softc(dev);
428	u_long size;
429
430	if ((pp = (const struct ed_product *) pccard_product_lookup(dev,
431	    (const struct pccard_product *) ed_pccard_products,
432	    sizeof(ed_pccard_products[0]), NULL)) == NULL)
433		return (ENXIO);
434	sc->modem_rid = -1;
435	if (pp->flags & NE2000DVF_MODEM) {
436		sc->port_rid = -1;
437		for (i = 0; i < 4; i++) {
438			size = bus_get_resource_count(dev, SYS_RES_IOPORT, i);
439			if (size == ED_NOVELL_IO_PORTS)
440				sc->port_rid = i;
441			else if (size == 8)
442				sc->modem_rid = i;
443		}
444		if (sc->port_rid == -1) {
445			device_printf(dev, "Cannot locate my ports!\n");
446			return (ENXIO);
447		}
448	} else {
449		sc->port_rid = 0;
450	}
451	/* Allocate the port resource during setup. */
452	error = ed_alloc_port(dev, sc->port_rid, ED_NOVELL_IO_PORTS);
453	if (error)
454		return (error);
455	error = ed_alloc_irq(dev, 0, 0);
456	if (error)
457		goto bad;
458
459	/*
460	 * Determine which chipset we are.  All the PC Card chipsets have the
461	 * ASIC and NIC offsets in the same place.
462	 */
463	sc->asic_offset = ED_NOVELL_ASIC_OFFSET;
464	sc->nic_offset  = ED_NOVELL_NIC_OFFSET;
465	error = ENXIO;
466	if (error != 0)
467		error = ed_pccard_dl100xx(dev, pp);
468	if (error != 0)
469		error = ed_pccard_ax88x90(dev, pp);
470	if (error != 0)
471		error = ed_pccard_tc5299j(dev, pp);
472	if (error != 0)
473		error = ed_probe_Novell_generic(dev, device_get_flags(dev));
474	if (error)
475		goto bad;
476
477	error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET | INTR_MPSAFE,
478	    edintr, sc, &sc->irq_handle);
479	if (error) {
480		device_printf(dev, "setup intr failed %d \n", error);
481		goto bad;
482	}
483
484	/*
485	 * For the older cards, we have to get the MAC address from
486	 * the card in some way.  Let's try the standard PCMCIA way
487	 * first.  If that fails, then check to see if we have valid
488	 * data from the standard NE-2000 data roms.  If that fails,
489	 * check to see if the card has a hint about where to look in
490	 * its CIS.  If that fails, maybe we should look at some
491	 * default value.  In all fails, we should fail the attach,
492	 * but don't right now.
493	 */
494	if (sc->chip_type == ED_CHIP_TYPE_DP8390) {
495		pccard_get_ether(dev, enaddr);
496		if (bootverbose)
497			device_printf(dev, "CIS MAC %6D\n", enaddr, ":");
498		for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++)
499			sum |= enaddr[i];
500		if (sum == 0 && ed_pccard_rom_mac(dev, enaddr)) {
501			if (bootverbose)
502				device_printf(dev, "ROM mac %6D\n", enaddr,
503				    ":");
504			sum++;
505		}
506		if (sum == 0 && pp->flags & NE2000DVF_ENADDR) {
507			for (i = 0; i < ETHER_ADDR_LEN; i++) {
508				pccard_attr_read_1(dev, pp->enoff + i * 2,
509				    enaddr + i);
510				sum |= enaddr[i];
511			}
512			if (bootverbose)
513				device_printf(dev, "Hint %x MAC %6D\n",
514				    pp->enoff, enaddr, ":");
515		}
516		if (sum == 0) {
517			for (i = 0; i < ETHER_ADDR_LEN; i++) {
518				pccard_attr_read_1(dev, ED_DEFAULT_MAC_OFFSET +
519				    i * 2, enaddr + i);
520				sum |= enaddr[i];
521			}
522			if (bootverbose)
523				device_printf(dev, "Fallback MAC %6D\n",
524				    enaddr, ":");
525		}
526		if (sum == 0) {
527			device_printf(dev, "Cannot extract MAC address.\n");
528			ed_release_resources(dev);
529			return (ENXIO);
530		}
531		bcopy(enaddr, sc->enaddr, ETHER_ADDR_LEN);
532	}
533
534	error = ed_attach(dev);
535	if (error)
536		goto bad;
537 	if (sc->chip_type == ED_CHIP_TYPE_DL10019 ||
538	    sc->chip_type == ED_CHIP_TYPE_DL10022) {
539		/* Probe for an MII bus, but ignore errors. */
540		ed_pccard_dl100xx_mii_reset(sc);
541		mii_phy_probe(dev, &sc->miibus, ed_ifmedia_upd,
542		    ed_ifmedia_sts);
543	} else if (sc->chip_type == ED_CHIP_TYPE_AX88190) {
544		ed_pccard_ax88x90_mii_reset(sc);
545		if ((error = mii_phy_probe(dev, &sc->miibus, ed_ifmedia_upd,
546		     ed_ifmedia_sts)) != 0) {
547			device_printf(dev, "Missing mii!\n");
548			goto bad;
549		}
550
551	} else if (sc->chip_type == ED_CHIP_TYPE_TC5299J) {
552		ed_pccard_tc5299j_mii_reset(sc);
553		if ((error = mii_phy_probe(dev, &sc->miibus, ed_ifmedia_upd,
554		     ed_ifmedia_sts)) != 0) {
555			device_printf(dev, "Missing mii!\n");
556			goto bad;
557		}
558
559	}
560	if (sc->miibus != NULL) {
561		sc->sc_tick = ed_pccard_tick;
562		sc->sc_mediachg = ed_pccard_mediachg;
563		sc->sc_media_ioctl = ed_pccard_media_ioctl;
564	}
565	if (sc->modem_rid != -1)
566		ed_pccard_add_modem(dev);
567	return (0);
568bad:
569	ed_release_resources(dev);
570	return (error);
571}
572
573/*
574 * Probe the Ethernet MAC addrees for PCMCIA Linksys EtherFast 10/100
575 * and compatible cards (DL10019C Ethernet controller).
576 *
577 * Note: The PAO patches try to use more memory for the card, but that
578 * seems to fail for my card.  A future optimization would add this back
579 * conditionally.
580 */
581static int
582ed_pccard_dl100xx(device_t dev, const struct ed_product *pp)
583{
584	struct ed_softc *sc = device_get_softc(dev);
585	u_char sum;
586	uint8_t id;
587	int i, error;
588
589	if (!(pp->flags & NE2000DVF_DL100XX))
590		return (ENXIO);
591	if (bootverbose)
592		device_printf(dev, "Trying DL100xx probing\n");
593	error = ed_probe_Novell_generic(dev, device_get_flags(dev));
594	if (bootverbose && error)
595		device_printf(dev, "Novell generic probe failed: %d\n", error);
596	if (error != 0)
597		return (error);
598
599	/*
600	 * Linksys registers(offset from ASIC base)
601	 *
602	 * 0x04-0x09 : Physical Address Register 0-5 (PAR0-PAR5)
603	 * 0x0A      : Card ID Register (CIR)
604	 * 0x0B      : Check Sum Register (SR)
605	 */
606	for (sum = 0, i = 0x04; i < 0x0c; i++)
607		sum += ed_asic_inb(sc, i);
608	if (sum != 0xff) {
609		if (bootverbose)
610			device_printf(dev, "Bad checksum %#x\n", sum);
611		return (ENXIO);		/* invalid DL10019C */
612	}
613	if (bootverbose)
614		device_printf(dev, "CIR is %d\n", ed_asic_inb(sc, 0xa));
615	for (i = 0; i < ETHER_ADDR_LEN; i++)
616		sc->enaddr[i] = ed_asic_inb(sc, 0x04 + i);
617	ed_nic_outb(sc, ED_P0_DCR, ED_DCR_WTS | ED_DCR_FT1 | ED_DCR_LS);
618	id = ed_asic_inb(sc, 0xf);
619	sc->isa16bit = 1;
620	sc->vendor = ED_VENDOR_NOVELL;
621	sc->type = ED_TYPE_NE2000;
622	sc->chip_type = (id & 0x90) == 0x90 ?
623	    ED_CHIP_TYPE_DL10022 : ED_CHIP_TYPE_DL10019;
624	sc->type_str = ((id & 0x90) == 0x90) ? "DL10022" : "DL10019";
625	sc->mii_readbits = ed_pccard_dl100xx_mii_readbits;
626	sc->mii_writebits = ed_pccard_dl100xx_mii_writebits;
627	return (0);
628}
629
630/* MII bit-twiddling routines for cards using Dlink chipset */
631#define DL100XX_MIISET(sc, x) ed_asic_outb(sc, ED_DL100XX_MIIBUS, \
632    ed_asic_inb(sc, ED_DL100XX_MIIBUS) | (x))
633#define DL100XX_MIICLR(sc, x) ed_asic_outb(sc, ED_DL100XX_MIIBUS, \
634    ed_asic_inb(sc, ED_DL100XX_MIIBUS) & ~(x))
635
636static void
637ed_pccard_dl100xx_mii_reset(struct ed_softc *sc)
638{
639	if (sc->chip_type != ED_CHIP_TYPE_DL10022)
640		return;
641
642	ed_asic_outb(sc, ED_DL100XX_MIIBUS, ED_DL100XX_MII_RESET2);
643	DELAY(10);
644	ed_asic_outb(sc, ED_DL100XX_MIIBUS,
645	    ED_DL100XX_MII_RESET2 | ED_DL100XX_MII_RESET1);
646	DELAY(10);
647	ed_asic_outb(sc, ED_DL100XX_MIIBUS, ED_DL100XX_MII_RESET2);
648	DELAY(10);
649	ed_asic_outb(sc, ED_DL100XX_MIIBUS,
650	    ED_DL100XX_MII_RESET2 | ED_DL100XX_MII_RESET1);
651	DELAY(10);
652	ed_asic_outb(sc, ED_DL100XX_MIIBUS, 0);
653}
654
655static void
656ed_pccard_dl100xx_mii_writebits(struct ed_softc *sc, u_int val, int nbits)
657{
658	int i;
659
660	if (sc->chip_type == ED_CHIP_TYPE_DL10022)
661		DL100XX_MIISET(sc, ED_DL100XX_MII_DIROUT_22);
662	else
663		DL100XX_MIISET(sc, ED_DL100XX_MII_DIROUT_19);
664
665	for (i = nbits - 1; i >= 0; i--) {
666		if ((val >> i) & 1)
667			DL100XX_MIISET(sc, ED_DL100XX_MII_DATAOUT);
668		else
669			DL100XX_MIICLR(sc, ED_DL100XX_MII_DATAOUT);
670		DELAY(10);
671		DL100XX_MIISET(sc, ED_DL100XX_MII_CLK);
672		DELAY(10);
673		DL100XX_MIICLR(sc, ED_DL100XX_MII_CLK);
674		DELAY(10);
675	}
676}
677
678static u_int
679ed_pccard_dl100xx_mii_readbits(struct ed_softc *sc, int nbits)
680{
681	int i;
682	u_int val = 0;
683
684	if (sc->chip_type == ED_CHIP_TYPE_DL10022)
685		DL100XX_MIICLR(sc, ED_DL100XX_MII_DIROUT_22);
686	else
687		DL100XX_MIICLR(sc, ED_DL100XX_MII_DIROUT_19);
688
689	for (i = nbits - 1; i >= 0; i--) {
690		DL100XX_MIISET(sc, ED_DL100XX_MII_CLK);
691		DELAY(10);
692		val <<= 1;
693		if (ed_asic_inb(sc, ED_DL100XX_MIIBUS) & ED_DL100XX_MII_DATAIN)
694			val++;
695		DL100XX_MIICLR(sc, ED_DL100XX_MII_CLK);
696		DELAY(10);
697	}
698	return val;
699}
700
701static int
702ed_pccard_ax88x90_geteprom(struct ed_softc *sc)
703{
704	int prom[16],i;
705	u_char tmp;
706	struct {
707		unsigned char offset, value;
708	} pg_seq[] = {
709						/* Select Page0 */
710		{ED_P0_CR, ED_CR_RD2 | ED_CR_STP | ED_CR_PAGE_0},
711		{ED_P0_DCR, 0x01},
712		{ED_P0_RBCR0, 0x00},		/* Clear the count regs. */
713		{ED_P0_RBCR1, 0x00},
714		{ED_P0_IMR, 0x00},		/* Mask completion irq. */
715		{ED_P0_ISR, 0xff},
716		{ED_P0_RCR, ED_RCR_MON | ED_RCR_INTT}, /* Set To Monitor */
717		{ED_P0_TCR, ED_TCR_LB0},	/* loopback mode. */
718		{ED_P0_RBCR0, 32},
719		{ED_P0_RBCR1, 0x00},
720		{ED_P0_RSAR0, 0x00},
721		{ED_P0_RSAR1, 0x04},
722		{ED_P0_CR, ED_CR_RD0 | ED_CR_STA | ED_CR_PAGE_0},
723	};
724
725	/* Reset Card */
726	tmp = ed_asic_inb(sc, ED_NOVELL_RESET);
727	ed_asic_outb(sc, ED_NOVELL_RESET, tmp);
728	DELAY(5000);
729	ed_nic_outb(sc, ED_P0_CR, ED_CR_RD2 | ED_CR_STP | ED_CR_PAGE_0);
730	DELAY(5000);
731
732	/* Card Settings */
733	for (i = 0; i < sizeof(pg_seq) / sizeof(pg_seq[0]); i++)
734		ed_nic_outb(sc, pg_seq[i].offset, pg_seq[i].value);
735
736	/* Get Data */
737	for (i = 0; i < ETHER_ADDR_LEN / 2; i++)
738		prom[i] = ed_asic_inw(sc, 0);
739	for (i = 0; i < ETHER_ADDR_LEN; i += 2) {
740		sc->enaddr[i] = prom[i / 2] & 0xff;
741		sc->enaddr[i + 1] = (prom[i / 2] >> 8) & 0xff;
742	}
743	return (0);
744}
745
746/*
747 * Special setup for AX88[17]90
748 */
749static int
750ed_pccard_ax88x90(device_t dev, const struct ed_product *pp)
751{
752	int	error, iobase, i, id;
753	char *ts;
754	struct	ed_softc *sc = device_get_softc(dev);
755
756	if (!(pp->flags & NE2000DVF_AX88X90))
757		return (ENXIO);
758
759	if (bootverbose)
760		device_printf(dev, "Checking AX88x90\n");
761
762	/*
763	 * Set the IOBASE Register.  The AX88x90 cards are potentially
764	 * multifunction cards, and thus requires a slight workaround.
765	 * We write the address the card is at.
766	 */
767	iobase = rman_get_start(sc->port_res);
768	pccard_ccr_write_1(dev, PCCARD_CCR_IOBASE0, iobase & 0xff);
769	pccard_ccr_write_1(dev, PCCARD_CCR_IOBASE1, (iobase >> 8) & 0xff);
770
771	ts = "AX88190";
772	if (ed_asic_inb(sc, ED_AX88X90_TEST) != 0) {
773		/*
774		 * AX88790 (and I think AX88190A) chips need to be
775		 * powered down.  There's an erratum that says we should
776		 * power down the PHY for 2.5s, but this seems to power
777		 * down the whole card.  I'm unsure why this was done, but
778		 * appears to be required for proper operation.
779		 */
780		pccard_ccr_write_1(dev, PCCARD_CCR_STATUS,
781		    PCCARD_CCR_STATUS_PWRDWN);
782		/*
783		 * Linux axnet driver selects the internal phy for the ax88790
784		 */
785		ed_asic_outb(sc, ED_AX88X90_GPIO, ED_AX88X90_GPIO_INT_PHY);
786		ts = "AX88790";
787	}
788
789	/*
790	 * Check to see if we have a MII PHY ID at any of the first 17
791	 * locations.  All AX88x90 devices have MII and a PHY, so we use
792	 * this to weed out chips that would otherwise make it through
793	 * the tests we have after this point.
794	 */
795	sc->mii_readbits = ed_pccard_ax88x90_mii_readbits;
796	sc->mii_writebits = ed_pccard_ax88x90_mii_writebits;
797	for (i = 0; i < 17; i++) {
798		id = ed_miibus_readreg(dev, i, MII_PHYIDR1);
799		if (id != 0 && id != 0xffff)
800			break;
801	}
802	if (i == 17) {
803		sc->mii_readbits = 0;
804		sc->mii_writebits = 0;
805		return (ENXIO);
806	}
807
808	sc->chip_type = ED_CHIP_TYPE_AX88190;
809	error = ed_pccard_ax88x90_geteprom(sc);
810	if (error)
811		return (error);
812	error = ed_probe_Novell_generic(dev, device_get_flags(dev));
813	if (bootverbose)
814		device_printf(dev, "probe novel returns %d\n", error);
815	if (error == 0) {
816		sc->vendor = ED_VENDOR_NOVELL;
817		sc->type = ED_TYPE_NE2000;
818		sc->chip_type = ED_CHIP_TYPE_AX88190;
819		sc->type_str = ts;
820	}
821	return (error);
822}
823
824/* MII bit-twiddling routines for cards using AX88x90 chipset */
825#define AX88X90_MIISET(sc, x) ed_asic_outb(sc, ED_AX88X90_MIIBUS, \
826    ed_asic_inb(sc, ED_AX88X90_MIIBUS) | (x))
827#define AX88X90_MIICLR(sc, x) ed_asic_outb(sc, ED_AX88X90_MIIBUS, \
828    ed_asic_inb(sc, ED_AX88X90_MIIBUS) & ~(x))
829
830static void
831ed_pccard_ax88x90_mii_reset(struct ed_softc *sc)
832{
833	/* Do nothing! */
834}
835
836static void
837ed_pccard_ax88x90_mii_writebits(struct ed_softc *sc, u_int val, int nbits)
838{
839	int i;
840
841	AX88X90_MIICLR(sc, ED_AX88X90_MII_DIROUT);
842	for (i = nbits - 1; i >= 0; i--) {
843		if ((val >> i) & 1)
844			AX88X90_MIISET(sc, ED_AX88X90_MII_DATAOUT);
845		else
846			AX88X90_MIICLR(sc, ED_AX88X90_MII_DATAOUT);
847		DELAY(10);
848		AX88X90_MIISET(sc, ED_AX88X90_MII_CLK);
849		DELAY(10);
850		AX88X90_MIICLR(sc, ED_AX88X90_MII_CLK);
851		DELAY(10);
852	}
853}
854
855static u_int
856ed_pccard_ax88x90_mii_readbits(struct ed_softc *sc, int nbits)
857{
858	int i;
859	u_int val = 0;
860
861	AX88X90_MIISET(sc, ED_AX88X90_MII_DIROUT);
862	for (i = nbits - 1; i >= 0; i--) {
863		AX88X90_MIISET(sc, ED_AX88X90_MII_CLK);
864		DELAY(10);
865		val <<= 1;
866		if (ed_asic_inb(sc, ED_AX88X90_MIIBUS) & ED_AX88X90_MII_DATAIN)
867			val++;
868		AX88X90_MIICLR(sc, ED_AX88X90_MII_CLK);
869		DELAY(10);
870	}
871	return val;
872}
873
874/*
875 * Special setup for TC5299J
876 */
877static int
878ed_pccard_tc5299j(device_t dev, const struct ed_product *pp)
879{
880	int	error, i, id;
881	char *ts;
882	struct	ed_softc *sc = device_get_softc(dev);
883
884	if (!(pp->flags & NE2000DVF_TC5299J))
885		return (ENXIO);
886
887	if (bootverbose)
888		device_printf(dev, "Checking Tc5299j\n");
889
890	/*
891	 * Check to see if we have a MII PHY ID at any of the first 32
892	 * locations.  All TC5299J devices have MII and a PHY, so we use
893	 * this to weed out chips that would otherwise make it through
894	 * the tests we have after this point.
895	 */
896	sc->mii_readbits = ed_pccard_tc5299j_mii_readbits;
897	sc->mii_writebits = ed_pccard_tc5299j_mii_writebits;
898	for (i = 0; i < 32; i++) {
899		id = ed_miibus_readreg(dev, i, MII_PHYIDR1);
900		if (id != 0 && id != 0xffff)
901			break;
902	}
903	if (i == 32) {
904		sc->mii_readbits = 0;
905		sc->mii_writebits = 0;
906		return (ENXIO);
907	}
908
909	ts = "TC5299J";
910	error = ed_probe_Novell_generic(dev, device_get_flags(dev));
911	if (bootverbose)
912		device_printf(dev, "probe novel returns %d\n", error);
913	if (error != 0) {
914		sc->mii_readbits = 0;
915		sc->mii_writebits = 0;
916		return (error);
917	}
918	if (ed_pccard_rom_mac(dev, sc->enaddr) == 0) {
919		sc->mii_readbits = 0;
920		sc->mii_writebits = 0;
921		return (ENXIO);
922	}
923	sc->vendor = ED_VENDOR_NOVELL;
924	sc->type = ED_TYPE_NE2000;
925	sc->chip_type = ED_CHIP_TYPE_TC5299J;
926	sc->type_str = ts;
927	return (0);
928}
929
930/* MII bit-twiddling routines for cards using TC5299J chipset */
931#define TC5299J_MIISET(sc, x) ed_nic_outb(sc, ED_TC5299J_MIIBUS, \
932    ed_nic_inb(sc, ED_TC5299J_MIIBUS) | (x))
933#define TC5299J_MIICLR(sc, x) ed_nic_outb(sc, ED_TC5299J_MIIBUS, \
934    ed_nic_inb(sc, ED_TC5299J_MIIBUS) & ~(x))
935
936static void
937ed_pccard_tc5299j_mii_reset(struct ed_softc *sc)
938{
939	/* Do nothing! */
940}
941
942static void
943ed_pccard_tc5299j_mii_writebits(struct ed_softc *sc, u_int val, int nbits)
944{
945	int i;
946	uint8_t cr;
947
948	cr = ed_nic_inb(sc, ED_P0_CR);
949	ed_nic_outb(sc, ED_P0_CR, cr | ED_CR_PAGE_3);
950
951	TC5299J_MIICLR(sc, ED_TC5299J_MII_DIROUT);
952	for (i = nbits - 1; i >= 0; i--) {
953		if ((val >> i) & 1)
954			TC5299J_MIISET(sc, ED_TC5299J_MII_DATAOUT);
955		else
956			TC5299J_MIICLR(sc, ED_TC5299J_MII_DATAOUT);
957		TC5299J_MIISET(sc, ED_TC5299J_MII_CLK);
958		TC5299J_MIICLR(sc, ED_TC5299J_MII_CLK);
959	}
960	ed_nic_outb(sc, ED_P0_CR, cr);
961}
962
963static u_int
964ed_pccard_tc5299j_mii_readbits(struct ed_softc *sc, int nbits)
965{
966	int i;
967	u_int val = 0;
968	uint8_t cr;
969
970	cr = ed_nic_inb(sc, ED_P0_CR);
971	ed_nic_outb(sc, ED_P0_CR, cr | ED_CR_PAGE_3);
972
973	TC5299J_MIISET(sc, ED_TC5299J_MII_DIROUT);
974	for (i = nbits - 1; i >= 0; i--) {
975		TC5299J_MIISET(sc, ED_TC5299J_MII_CLK);
976		val <<= 1;
977		if (ed_nic_inb(sc, ED_TC5299J_MIIBUS) & ED_TC5299J_MII_DATAIN)
978			val++;
979		TC5299J_MIICLR(sc, ED_TC5299J_MII_CLK);
980	}
981	ed_nic_outb(sc, ED_P0_CR, cr);
982	return val;
983}
984
985/*
986 * MII bus support routines.
987 */
988static int
989ed_miibus_readreg(device_t dev, int phy, int reg)
990{
991	struct ed_softc *sc;
992	int failed, val;
993
994	/*
995	 * The AX88790 seem to have phy 0..f external, and 0x10 internal.
996	 * but they also seem to have a bogus one that shows up at phy
997	 * 0x11 through 0x1f.
998	 */
999	if (phy >= 0x11)
1000		return (0);
1001
1002	sc = device_get_softc(dev);
1003	(*sc->mii_writebits)(sc, 0xffffffff, 32);
1004	(*sc->mii_writebits)(sc, ED_MII_STARTDELIM, ED_MII_STARTDELIM_BITS);
1005	(*sc->mii_writebits)(sc, ED_MII_READOP, ED_MII_OP_BITS);
1006	(*sc->mii_writebits)(sc, phy, ED_MII_PHY_BITS);
1007	(*sc->mii_writebits)(sc, reg, ED_MII_REG_BITS);
1008	failed = (*sc->mii_readbits)(sc, ED_MII_ACK_BITS);
1009	val = (*sc->mii_readbits)(sc, ED_MII_DATA_BITS);
1010	(*sc->mii_writebits)(sc, ED_MII_IDLE, ED_MII_IDLE_BITS);
1011	return (failed ? 0 : val);
1012}
1013
1014static void
1015ed_miibus_writereg(device_t dev, int phy, int reg, int data)
1016{
1017	struct ed_softc *sc;
1018
1019	/*
1020	 * The AX88790 seem to have phy 0..f external, and 0x10 internal.
1021	 * but they also seem to have a bogus one that shows up at phy
1022	 * 0x11 through 0x1f.
1023	 */
1024	if (phy >= 0x11)
1025		return;
1026
1027	sc = device_get_softc(dev);
1028	(*sc->mii_writebits)(sc, 0xffffffff, 32);
1029	(*sc->mii_writebits)(sc, ED_MII_STARTDELIM, ED_MII_STARTDELIM_BITS);
1030	(*sc->mii_writebits)(sc, ED_MII_WRITEOP, ED_MII_OP_BITS);
1031	(*sc->mii_writebits)(sc, phy, ED_MII_PHY_BITS);
1032	(*sc->mii_writebits)(sc, reg, ED_MII_REG_BITS);
1033	(*sc->mii_writebits)(sc, ED_MII_TURNAROUND, ED_MII_TURNAROUND_BITS);
1034	(*sc->mii_writebits)(sc, data, ED_MII_DATA_BITS);
1035	(*sc->mii_writebits)(sc, ED_MII_IDLE, ED_MII_IDLE_BITS);
1036}
1037
1038static int
1039ed_ifmedia_upd(struct ifnet *ifp)
1040{
1041	struct ed_softc *sc;
1042	struct mii_data *mii;
1043
1044	sc = ifp->if_softc;
1045	if (sc->miibus == NULL)
1046		return (ENXIO);
1047
1048	mii = device_get_softc(sc->miibus);
1049	return mii_mediachg(mii);
1050}
1051
1052static void
1053ed_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
1054{
1055	struct ed_softc *sc;
1056	struct mii_data *mii;
1057
1058	sc = ifp->if_softc;
1059	if (sc->miibus == NULL)
1060		return;
1061
1062	mii = device_get_softc(sc->miibus);
1063	mii_pollstat(mii);
1064	ifmr->ifm_active = mii->mii_media_active;
1065	ifmr->ifm_status = mii->mii_media_status;
1066}
1067
1068static void
1069ed_child_detached(device_t dev, device_t child)
1070{
1071	struct ed_softc *sc;
1072
1073	sc = device_get_softc(dev);
1074	if (child == sc->miibus)
1075		sc->miibus = NULL;
1076}
1077
1078static device_method_t ed_pccard_methods[] = {
1079	/* Device interface */
1080	DEVMETHOD(device_probe,		ed_pccard_probe),
1081	DEVMETHOD(device_attach,	ed_pccard_attach),
1082	DEVMETHOD(device_detach,	ed_detach),
1083
1084	/* Bus interface */
1085	DEVMETHOD(bus_child_detached,	ed_child_detached),
1086
1087	/* MII interface */
1088	DEVMETHOD(miibus_readreg,	ed_miibus_readreg),
1089	DEVMETHOD(miibus_writereg,	ed_miibus_writereg),
1090
1091	{ 0, 0 }
1092};
1093
1094static driver_t ed_pccard_driver = {
1095	"ed",
1096	ed_pccard_methods,
1097	sizeof(struct ed_softc)
1098};
1099
1100DRIVER_MODULE(ed, pccard, ed_pccard_driver, ed_devclass, 0, 0);
1101DRIVER_MODULE(miibus, ed, miibus_driver, miibus_devclass, 0, 0);
1102MODULE_DEPEND(ed, miibus, 1, 1, 1);
1103MODULE_DEPEND(ed, ether, 1, 1, 1);
1104