2 * Product specific probe and attach routines for:
3 * 3COM 3C579 and 3C509(in eisa config mode) ethernet controllers
5 * Copyright (c) 1996 Justin T. Gibbs
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice immediately at the beginning of the file, without modification,
13 * this list of conditions, and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Absolutely no warranty of function or purpose is made by the author
19 * 4. Modifications may be freely made to this file if the above conditions
22 * $FreeBSD: src/sys/dev/ep/if_ep_eisa.c,v 1.18 2000/01/14 07:14:00 peter Exp $
23 * $DragonFly: src/sys/dev/netif/ep/if_ep_eisa.c,v 1.5 2003/11/20 22:07:27 dillon Exp $
26 #include <sys/param.h>
27 #include <sys/systm.h>
28 #include <sys/kernel.h>
29 #include <sys/socket.h>
31 #include <sys/module.h>
34 #include <machine/bus.h>
35 #include <machine/resource.h>
39 #include <net/if_arp.h>
40 #include <net/if_media.h>
42 #include <machine/clock.h>
44 #include <bus/eisa/eisaconf.h>
49 #define EISA_DEVICE_ID_3COM_3C509_TP 0x506d5090
50 #define EISA_DEVICE_ID_3COM_3C509_BNC 0x506d5091
51 #define EISA_DEVICE_ID_3COM_3C579_TP 0x506d5092
52 #define EISA_DEVICE_ID_3COM_3C579_BNC 0x506d5093
53 #define EISA_DEVICE_ID_3COM_3C509_COMBO 0x506d5094
54 #define EISA_DEVICE_ID_3COM_3C509_TPO 0x506d5095
56 #define EP_EISA_SLOT_OFFSET 0x0c80
57 #define EP_EISA_IOSIZE 0x000a
59 #define EISA_IOCONF 0x0008
60 #define IRQ_CHANNEL 0xf000
69 #define EISA_BPROM_MEDIA_CONF 0x0006
70 #define TRANS_TYPE 0xc000
71 #define TRANS_TP 0x0000
72 #define TRANS_AUI 0x4000
73 #define TRANS_BNC 0xc000
75 static const char *ep_match (eisa_id_t type);
78 ep_match(eisa_id_t type)
81 case EISA_DEVICE_ID_3COM_3C509_TP:
82 return "3Com 3C509-TP Network Adapter";
84 case EISA_DEVICE_ID_3COM_3C509_BNC:
85 return "3Com 3C509-BNC Network Adapter";
87 case EISA_DEVICE_ID_3COM_3C579_TP:
88 return "3Com 3C579-TP EISA Network Adapter";
90 case EISA_DEVICE_ID_3COM_3C579_BNC:
91 return "3Com 3C579-BNC EISA Network Adapter";
93 case EISA_DEVICE_ID_3COM_3C509_COMBO:
94 return "3Com 3C509-Combo Network Adapter";
96 case EISA_DEVICE_ID_3COM_3C509_TPO:
97 return "3Com 3C509-TPO Network Adapter";
106 ep_eisa_probe(device_t dev)
115 desc = ep_match(eisa_get_id(dev));
118 device_set_desc(dev, desc);
120 port = (eisa_get_slot(dev) * EISA_SLOT_SIZE);
121 iobase = port + EP_EISA_SLOT_OFFSET;
123 /* We must be in EISA configuration mode */
124 if ((inw(iobase + EP_W0_ADDRESS_CFG) & 0x1f) != 0x1f)
127 eisa_add_iospace(dev, iobase, EP_EISA_IOSIZE, RESVADDR_NONE);
128 eisa_add_iospace(dev, port, EP_IOSIZE, RESVADDR_NONE);
130 conf = inw(iobase + EISA_IOCONF);
131 /* Determine our IRQ */
132 switch (conf & IRQ_CHANNEL) {
159 printf("ep: 3COM Network Adapter at "
160 "slot %d has its IRQ disabled. "
166 switch(eisa_get_id(dev)) {
167 case EISA_DEVICE_ID_3COM_3C579_BNC:
168 case EISA_DEVICE_ID_3COM_3C579_TP:
169 int_trig = EISA_TRIGGER_LEVEL;
172 int_trig = EISA_TRIGGER_EDGE;
176 eisa_add_intr(dev, irq, int_trig);
182 ep_eisa_attach(device_t dev)
184 struct ep_softc * sc = device_get_softc(dev);
185 struct resource * eisa_io = NULL;
186 u_int32_t eisa_iobase;
192 eisa_io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
193 0, ~0, 1, RF_ACTIVE);
195 device_printf(dev, "No I/O space?!\n");
199 eisa_iobase = rman_get_start(eisa_io);
201 /* Reset and Enable the card */
202 outb(eisa_iobase + EP_W0_CONFIG_CTRL, W0_P4_CMD_RESET_ADAPTER);
203 DELAY(1000); /* we must wait at least 1 ms */
204 outb(eisa_iobase + EP_W0_CONFIG_CTRL, W0_P4_CMD_ENABLE_ADAPTER);
205 /* Now the registers are availible through the lower ioport */
207 if ((error = ep_alloc(dev))) {
208 device_printf(dev, "ep_alloc() failed! (%d)\n", error);
212 switch(eisa_get_id(dev)) {
213 case EISA_DEVICE_ID_3COM_3C579_BNC:
214 case EISA_DEVICE_ID_3COM_3C579_TP:
215 sc->stat = F_ACCESS_32_BITS;
223 irq = rman_get_start(sc->irq);
230 if ((error = ep_attach(sc))) {
231 device_printf(dev, "ep_attach() failed! (%d)\n", error);
235 if ((error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET, ep_intr,
236 sc, &sc->ep_intrhand))) {
237 device_printf(dev, "bus_setup_intr() failed! (%d)\n", error);
245 bus_release_resource(dev, SYS_RES_IOPORT, 0, eisa_io);
251 static device_method_t ep_eisa_methods[] = {
252 /* Device interface */
253 DEVMETHOD(device_probe, ep_eisa_probe),
254 DEVMETHOD(device_attach, ep_eisa_attach),
259 static driver_t ep_eisa_driver = {
262 sizeof(struct ep_softc),
265 extern devclass_t ep_devclass;
267 DRIVER_MODULE(if_ep, eisa, ep_eisa_driver, ep_devclass, 0, 0);