From owner-freebsd-mobile Mon May 8 14:25:57 2000 Delivered-To: freebsd-mobile@freebsd.org Received: from anchor-post-32.mail.demon.net (anchor-post-32.mail.demon.net [194.217.242.90]) by hub.freebsd.org (Postfix) with ESMTP id F2BAE37C029 for ; Mon, 8 May 2000 14:25:46 -0700 (PDT) (envelope-from dmlb@ragnet.demon.co.uk) Received: from ragnet.demon.co.uk ([158.152.46.40]) by anchor-post-32.mail.demon.net with esmtp (Exim 2.12 #1) id 12ov28-000NdC-0W for freebsd-mobile@freebsd.org; Mon, 8 May 2000 22:25:45 +0100 Received: from dmlb by ragnet.demon.co.uk with local (Exim 3.03 #1) id 12ouzt-000Meh-00 for freebsd-mobile@freebsd.org; Mon, 08 May 2000 22:23:25 +0100 Content-Length: 8177 Message-ID: X-Mailer: XFMail 1.3 [p0] on FreeBSD X-Priority: 3 (Normal) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="_=XFMail.1.3.p0.FreeBSD:000508222325:85572=_" Date: Mon, 08 May 2000 22:23:25 +0100 (BST) From: Duncan Barclay To: freebsd-mobile@freebsd.org Subject: Updated patch to if_xe for RealPorts Sender: owner-freebsd-mobile@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org This message is in MIME format --_=XFMail.1.3.p0.FreeBSD:000508222325:85572=_ Content-Type: text/plain; charset=us-ascii Hi again, Updated patch - no functional change, just a slightly better way of doing something. Duncan On 08-May-00 Duncan Barclay wrote: > 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 Barclay | God smiles upon the little children, dmlb@ragnet.demon.co.uk | the alcoholics, and the permanently stoned. ________________________________________________________________________ --_=XFMail.1.3.p0.FreeBSD:000508222325:85572=_ 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=6655 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 21:15:19 @@ -33,7 +33,6 @@ * I've pushed this fairly far, but there are some things that need to be * done here. I'm documenting them here in case I get destracted. -- imp * - * xe_memwrite -- maybe better handled pccard layer? * xe_cem56fix -- need to figure out how to map the extra stuff. */ @@ -205,6 +204,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)) @@ -216,91 +216,62 @@ #endif /* - * Two routines to read from/write to the attribute memory - * the write portion is used only for fixing up the RealPort cards, - * the reader portion was needed for debugging info, and duplicated some - * code in xe_card_init(), so it appears here instead with suitable - * modifications to xe_card_init() - * -aDe Lovett + * Fixing for RealPort cards - they need a little furtling to get the + * ethernet working */ static int -xe_memwrite(device_t dev, off_t offset, u_char byte) +xe_cem56fix(device_t dev) { - /* XXX */ - return (-1); -} - -/* - * Hacking for RealPort cards - */ -static int -xe_cem56fix(struct xe_softc *scp) -{ -#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 +503,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 +2181,39 @@ xe_activate(device_t dev) { struct xe_softc *sc = device_get_softc(dev); - int err; + int start, 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_rid = 0; /* 0 is managed by pccard */ + 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. + */ +#if XE_DEBUG > 0 + device_printf(dev, "Finding an aligned port for RealPort\n"); +#endif /* XE_DEBUG */ + sc->port_rid = 1; /* 0 is managed by pccard */ + start = 0x100; + do { + sc->port_res = bus_alloc_resource(dev, + SYS_RES_IOPORT, &sc->port_rid, start, 0x3ff, 16, + RF_ACTIVE); + if (sc->port_res == 0) + break; /* we failed */ + if ((rman_get_start(sc->port_res) & 0xf) == 0) + break; /* good */ + bus_release_resource(dev, SYS_RES_IOPORT, sc->port_rid, + sc->port_res); + start = (rman_get_start(sc->port_res) + 15) & ~0xf; + } while (1); +#if XE_DEBUG > 2 + device_printf(dev, "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 /* XE_DEBUG */ + } if (!sc->port_res) { #if XE_DEBUG > 0 device_printf(dev, "Cannot allocate ioport\n"); --_=XFMail.1.3.p0.FreeBSD:000508222325:85572=_-- End of MIME message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message