summaryrefslogtreecommitdiffstats
path: root/sys/dev/ep/if_ep_mca.c
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>1999-10-27 06:25:16 +0000
committermdodd <mdodd@FreeBSD.org>1999-10-27 06:25:16 +0000
commit5b7d331b4dc9d7b8fd701fbb5328ef1b7fcd5dfb (patch)
treee829fbdae4384eba77df0f37236cbb52bd7bb73c /sys/dev/ep/if_ep_mca.c
parent21f0026c8502ee6b99ec2b4554601965e4ff56c4 (diff)
downloadFreeBSD-src-5b7d331b4dc9d7b8fd701fbb5328ef1b7fcd5dfb.zip
FreeBSD-src-5b7d331b4dc9d7b8fd701fbb5328ef1b7fcd5dfb.tar.gz
HEADS UP! All 3c5x9 users!
- Rip out all the static softc stuff and do softc allocation the right way. - Rewrite most of the ISA code so that it provides a DEVICE_IDENTIFY method to enumerate all non-PnP ISA devices. This has the following consequences: - No 'ep' devices may be hardwired. - All hardwired devices will probably be detected twice. By hardwired I mean: device ep0 at isa? port 0x300 irq 10 - 'ep' devices are ordered by bus, slot, and then MAC address. - Make 3c509B cards work in PnP mode. Yes, they really work. - Convert over to using ifmedia for media selection. No more of this lame 'linkX' stuff. - Consolidate a lot of duplicated code. - Make a stab at not breaking MII based PCCARD devices. I doubt that the PCCARD stuff works any more than it did before my changes but theres hope. My PCCARD hardware should arrive in a week or so. - Retreive the media settings from the card EEPROM rather than guessing. I've got a 3c509-TPO that thinks its got an AUI port and if others can report similar problems I'll write a bit of clever code that will fix this but right now it works correctly on all but 1 card. - Clean up a few things and make some cosmetic changes. - Add myself as the MAINTAINER since nobody else wants to. I'm in the best position to do this as I've got an example of most of the cards: EISA 3c579 bnc/aui MCA 3c529 tp/aui ISA 3c509 tpo ISA-PnP 3c509B combo If someone wants to send me a any cards I don't have I'd appriciate it. Also welcome are 3c59x boards since I'll be folding if_vx and if_ep at some point.
Diffstat (limited to 'sys/dev/ep/if_ep_mca.c')
-rw-r--r--sys/dev/ep/if_ep_mca.c98
1 files changed, 22 insertions, 76 deletions
diff --git a/sys/dev/ep/if_ep_mca.c b/sys/dev/ep/if_ep_mca.c
index 6e0b9e3..778b42b 100644
--- a/sys/dev/ep/if_ep_mca.c
+++ b/sys/dev/ep/if_ep_mca.c
@@ -26,31 +26,21 @@
* $FreeBSD$
*/
-#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/socket.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-
-#include <machine/clock.h>
-#include <machine/cpufunc.h>
-#include <machine/md_var.h>
-
#include <sys/module.h>
#include <sys/bus.h>
+
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
#include <net/if.h>
-#include <net/if_mib.h>
-
-#include <netinet/in.h>
-#include <netinet/if_ether.h>
+#include <net/if_arp.h>
+#include <net/if_media.h>
#include <dev/mca/mca_busreg.h>
#include <dev/mca/mca_busvar.h>
@@ -85,7 +75,7 @@ static struct mca_ident ep_mca_devs[] = {
#define EP_MCA_IOPORT_POS MCA_ADP_POS(MCA_POS2)
#define EP_MCA_IOPORT_MASK 0xfc
-#define EP_MCA_IOPORT_SIZE 0x0f
+#define EP_MCA_IOPORT_SIZE EP_IOSIZE
#define EP_MCA_IOPORT(pos) ((((u_int32_t)pos & EP_MCA_IOPORT_MASK) \
| 0x02) << 8)
@@ -125,79 +115,35 @@ ep_mca_probe (device_t dev)
static int
ep_mca_attach (device_t dev)
{
- struct ep_softc * sc;
- struct ep_board * epb;
- struct resource * io = 0;
- struct resource * irq = 0;
- u_int8_t pos;
- int unit = device_get_unit(dev);
- int i, rid;
- void * ih;
-
- rid = 0;
- io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
- 0, ~0, 1, RF_ACTIVE);
- if (!io) {
- device_printf(dev, "No I/O space?!\n");
- goto bad;
- }
+ struct ep_softc * sc = device_get_softc(dev);
+ int error = 0;
- rid = 0;
- irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
- 0, ~0, 1, RF_ACTIVE);
- if (!irq) {
- device_printf(dev, "No irq?!\n");
+ if ((error = ep_alloc(dev))) {
+ device_printf(dev, "ep_alloc() failed! (%d)\n", error);
goto bad;
}
-
- epb = &ep_board[ep_boards];
-
- epb->epb_addr = rman_get_start(io);
- epb->epb_used = 1;
-
- if(!(sc = ep_alloc(unit, epb)))
- goto bad;
-
- ep_boards++;
-
sc->stat = F_ACCESS_32_BITS;
- switch(mca_get_id(dev)) {
- case EP_MCA_627C:
- sc->ep_connectors = BNC|AUI;
- break;
- case EP_MCA_627D:
- sc->ep_connectors = UTP|AUI;
- break;
- default:
- break;
- }
- pos = mca_pos_read(dev, EP_MCA_MEDIA_POS);
- sc->ep_connector = EP_MCA_MEDIA(pos);
-
- /*
- * Retrieve our ethernet address
- */
- GO_WINDOW(0);
- for(i = 0; i < 3; i++)
- sc->epb->eth_addr[i] = get_e(sc, i);
+ ep_get_media(sc);
GO_WINDOW(0);
- SET_IRQ(BASE, rman_get_start(irq));
+ SET_IRQ(BASE, rman_get_start(sc->irq));
- ep_attach(sc);
+ if ((error = ep_attach(sc))) {
+ device_printf(dev, "ep_attach() failed! (%d)\n", error);
+ goto bad;
+ }
- bus_setup_intr(dev, irq, INTR_TYPE_NET, ep_intr, sc, &ih);
+ if ((error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET, ep_intr,
+ sc, &sc->ep_intrhand))) {
+ device_printf(dev, "bus_setup_intr() failed! (%d)\n", error);
+ goto bad;
+ }
return (0);
-
bad:
- if (io)
- bus_release_resource(dev, SYS_RES_IOPORT, 0, io);
- if (irq)
- bus_release_resource(dev, SYS_RES_IRQ, 0, irq);
-
- return (-1);
+ ep_free(dev);
+ return (error);
}
static device_method_t ep_mca_methods[] = {
@@ -211,7 +157,7 @@ static device_method_t ep_mca_methods[] = {
static driver_t ep_mca_driver = {
"ep",
ep_mca_methods,
- 1, /* unusep */
+ sizeof(struct ep_softc),
};
static devclass_t ep_devclass;
OpenPOWER on IntegriCloud