summaryrefslogtreecommitdiffstats
path: root/sys/dev/xe
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2000-05-30 05:42:57 +0000
committerimp <imp@FreeBSD.org>2000-05-30 05:42:57 +0000
commitd394ba6e95cb9023c51273378852ed333d4a014f (patch)
tree324df460c80123c2ad180efe009f13275a675da6 /sys/dev/xe
parent3f253b00b84dcc4be6585d4fb5ed461e608eef35 (diff)
downloadFreeBSD-src-d394ba6e95cb9023c51273378852ed333d4a014f.zip
FreeBSD-src-d394ba6e95cb9023c51273378852ed333d4a014f.tar.gz
Add support for the modem side of the 56k combo card.
Submitted by: Duncan Barclay <dmlb@ragnet.demon.co.uk>
Diffstat (limited to 'sys/dev/xe')
-rw-r--r--sys/dev/xe/if_xe.c154
1 files changed, 77 insertions, 77 deletions
diff --git a/sys/dev/xe/if_xe.c b/sys/dev/xe/if_xe.c
index d5160ed..63cbb76 100644
--- a/sys/dev/xe/if_xe.c
+++ b/sys/dev/xe/if_xe.c
@@ -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 @@ static void xe_phy_writereg (struct xe_softc *scp, u_int16_t reg, u_int16_t
/*
* 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,63 @@ static void xe_mii_dump (struct xe_softc *scp);
#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
-
- for (ioport = 0x300; ioport < 0x400; ioport += 0x10) {
- slt->io[1].start = ioport;
- if ((fail = ctrl->mapio( slt, 1 )) == 0)
- break;
- }
+ 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;
+#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);
- /* 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 );
+ 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);
- 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 +504,7 @@ xe_attach (device_t dev) {
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;
@@ -2188,11 +2160,39 @@ int
xe_activate(device_t dev)
{
struct xe_softc *sc = device_get_softc(dev);
- int err;
-
- sc->port_rid = 0;
- sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid,
- 0, ~0, 16, RF_ACTIVE);
+ int start, err;
+
+ 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");
OpenPOWER on IntegriCloud