Date: Mon, 08 May 2000 21:44:13 +0100 (BST) From: Duncan Barclay <dmlb@ragnet.demon.co.uk> To: freebsd-mobile@freebsd.org Subject: Patch to if_xe for RealPorts Message-ID: <XFMail.000508214413.dmlb@computer.my.domain>
next in thread | raw e-mail | index | archive | help
This message is in MIME format --_=XFMail.1.3.p0.FreeBSD:000508214413:85113=_ Content-Type: text/plain; charset=us-ascii Hi all, Patch to if_xe for -current that re-enables RealPorts. You will need to set the configuration entry in /etc/defaults/pccard.conf to card "Xircom" "CreditCard Ethernet 10/100 + Modem 56" config 0x27 "xe0" ? or appropiate IRQ. Apply the patch, recompile the kernel and hopefully all will be well. Can someone who is familiar with NEWBUS work out how to get the reallocation of the ioport range in xe_activate work better with OLDCARD. At present the kernel will assign an io port range when the driver is probed. We then re-assign this on attach - I think that this is "wrong". Enjoy Duncan --- ________________________________________________________________________ Duncan Barclay | God smiles upon the little children, dmlb@ragnet.demon.co.uk | the alcoholics, and the permanently stoned. ________________________________________________________________________ --_=XFMail.1.3.p0.FreeBSD:000508214413:85113=_ Content-Disposition: attachment; filename="if_xe.patch" Content-Transfer-Encoding: 7bit Content-Description: if_xe.patch Content-Type: text/plain; charset=us-ascii; name=if_xe.patch; SizeOnDisk=6030 Index: if_xe.c =================================================================== RCS file: /steer/ncvs/src/sys/dev/xe/if_xe.c,v retrieving revision 1.18 diff -u -r1.18 if_xe.c --- if_xe.c 2000/05/01 04:41:04 1.18 +++ if_xe.c 2000/05/08 20:27:38 @@ -205,6 +205,7 @@ /* * Debug functions */ +#define XE_DEBUG 2 #ifdef XE_DEBUG #define XE_REG_DUMP(scp) xe_reg_dump((scp)) #define XE_MII_DUMP(scp) xe_mii_dump((scp)) @@ -234,73 +235,58 @@ * Hacking for RealPort cards */ static int -xe_cem56fix(struct xe_softc *scp) +xe_cem56fix(device_t dev) { -#if XXX /* Need to revisit */ - int ioport, fail; - - /* allocate a new I/O slot for the ethernet */ - /* XXX: ctrl->mapio() always appears to return 0 (success), so - * this may cause problems if another device is listening - * on 0x300 already. In this case, you should choose a - * known free I/O port address in the kernel config line - * for the driver. It will be picked up here and used - * instead of the autodetected value. - */ - slt->io[1].window = 1; - slt->io[1].flags = IODF_WS|IODF_16BIT|IODF_ZEROWS|IODF_ACTIVE; - slt->io[1].size = 0x10; - -#ifdef XE_IOBASE - - device_printf(scp->dev, "user requested ioport 0x%x\n", XE_IOBASE ); - ioport = XE_IOBASE; - slt->io[1].start = ioport; - fail = ctrl->mapio(slt, 1); - -#else + struct xe_softc *sc = (struct xe_softc *) device_get_softc(dev); + bus_space_tag_t bst; + bus_space_handle_t bsh; + struct resource *r; + int rid; + int ioport; - for (ioport = 0x300; ioport < 0x400; ioport += 0x10) { - slt->io[1].start = ioport; - if ((fail = ctrl->mapio( slt, 1 )) == 0) - break; - } +#ifdef XE_DEBUG + device_printf(dev, "Hacking your Realport, master\n"); +#endif +#if XE_DEBUG > 1 + device_printf(dev, "Realport port 0x%0lx, size 0x%0lx\n", + bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid), + bus_get_resource_count(dev, SYS_RES_IOPORT, sc->port_rid)); #endif - /* did we find one? */ - if (fail) { - device_printf(scp->dev, "xe_cem56fix: no free address space\n"); + rid = 0; + r = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 4 << 10, RF_ACTIVE); + if (!r) { +#if XE_DEBUG > 0 + device_printf(dev, "Can't map in attribute memory\n"); +#endif return -1; } + bsh = rman_get_bushandle(r); + bst = rman_get_bustag(r); - /* munge the id_iobase entry for use by the rest of the driver */ -#if XE_DEBUG > 1 - device_printf(scp->dev, "using 0x%x for RealPort ethernet\n", ioport); -#endif -#if 0 - scp->dev->id_iobase = ioport; -#endif + CARD_SET_RES_FLAGS(device_get_parent(dev), dev, SYS_RES_MEMORY, rid, + PCCARD_A_MEM_ATTR); + + bus_space_write_1(bst, bsh, DINGO_ECOR, DINGO_ECOR_IRQ_LEVEL | + DINGO_ECOR_INT_ENABLE | + DINGO_ECOR_IOB_ENABLE | + DINGO_ECOR_ETH_ENABLE); + ioport = bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid); + bus_space_write_1(bst, bsh, DINGO_EBAR0, ioport & 0xff); + bus_space_write_1(bst, bsh, DINGO_EBAR1, (ioport >> 8) & 0xff); + + bus_space_write_1(bst, bsh, DINGO_DCOR0, DINGO_DCOR0_SF_INT); + bus_space_write_1(bst, bsh, DINGO_DCOR1, DINGO_DCOR1_INT_LEVEL | + DINGO_DCOR1_EEDIO); + bus_space_write_1(bst, bsh, DINGO_DCOR2, 0x00); + bus_space_write_1(bst, bsh, DINGO_DCOR3, 0x00); + bus_space_write_1(bst, bsh, DINGO_DCOR4, 0x00); - /* magic to set up the ethernet */ - xe_memwrite( scp->dev, DINGO_ECOR, DINGO_ECOR_IRQ_LEVEL| - DINGO_ECOR_INT_ENABLE|DINGO_ECOR_IOB_ENABLE| - DINGO_ECOR_ETH_ENABLE ); - xe_memwrite( scp->dev, DINGO_EBAR0, ioport & 0xff ); - xe_memwrite( scp->dev, DINGO_EBAR1, (ioport >> 8) & 0xff ); - - xe_memwrite( scp->dev, DINGO_DCOR0, DINGO_DCOR0_SF_INT ); - xe_memwrite( scp->dev, DINGO_DCOR1, DINGO_DCOR1_INT_LEVEL|DINGO_DCOR1_EEDIO ) ; - xe_memwrite( scp->dev, DINGO_DCOR2, 0x00 ); - xe_memwrite( scp->dev, DINGO_DCOR3, 0x00 ); - xe_memwrite( scp->dev, DINGO_DCOR4, 0x00 ); + bus_release_resource(dev, SYS_RES_MEMORY, rid, r); - /* success! */ return 0; -#else - return -1; -#endif /* XXX */ } /* @@ -532,7 +518,7 @@ scp->autoneg_status = 0; /* Hack RealPorts into submission */ - if (scp->dingo && xe_cem56fix(scp) < 0) { + if (scp->dingo && xe_cem56fix(dev) < 0) { device_printf(dev, "Unable to fix your RealPort\n"); xe_deactivate(dev); return ENODEV; @@ -2210,11 +2196,50 @@ xe_activate(device_t dev) { struct xe_softc *sc = device_get_softc(dev); - int err; + int ioport, err; sc->port_rid = 0; - sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid, - 0, ~0, 16, RF_ACTIVE); + if (!sc->dingo) + sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, + &sc->port_rid, 0, ~0, 16, RF_ACTIVE); + else { + /* + * Find a 16 byte aligned ioport for the card using a hard + * coded range + * + * Adapted from /sys/isa/isa_common.c:isa_find_port() + */ +#if XE_DEBUG > 0 + device_printf(dev, "Finding an aligned ioport for RealPort\n"); +#endif /* XE_DEBUG */ + for (ioport = 0x300; ioport < 0x400; ioport += 0x10) { +#if XE_DEBUG > 1 + device_printf(dev, "checking 0x%0x\n", ioport); +#endif /* XE_DEBUG */ + sc->port_rid = 0; + bus_set_resource(dev, SYS_RES_IOPORT, sc->port_rid, + ioport, 0x10); + sc->port_res = bus_alloc_resource(dev, + SYS_RES_IOPORT, &sc->port_rid, 0, ~0, 1, + 0 /*!RF_ACTIVE*/); + bus_release_resource(dev, SYS_RES_IOPORT, + sc->port_rid, sc->port_res); + if (sc->port_res) { + sc->port_res = bus_alloc_resource(dev, + SYS_RES_IOPORT, &sc->port_rid, 0, ~0, 1, + RF_ACTIVE); +#if XE_DEBUG > 2 + device_printf(dev, "port 0x%0x, + size 0x%0lx\n", + bus_get_resource_start(dev, + SYS_RES_IOPORT, sc->port_rid), + bus_get_resource_count(dev, + SYS_RES_IOPORT, sc->port_rid)); +#endif /* XE_DEBUG */ + break; + } + } + } if (!sc->port_res) { #if XE_DEBUG > 0 device_printf(dev, "Cannot allocate ioport\n"); --_=XFMail.1.3.p0.FreeBSD:000508214413:85113=_-- End of MIME message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.000508214413.dmlb>