Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/xe/if_xe.c
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
struct xe_softc *sc = device_get_softc(dev); | struct xe_softc *sc = device_get_softc(dev); | ||||
int start, i; | int start, i; | ||||
DEVPRINTF(2, (dev, "activate\n")); | DEVPRINTF(2, (dev, "activate\n")); | ||||
if (!sc->modem) { | if (!sc->modem) { | ||||
sc->port_rid = 0; /* 0 is managed by pccard */ | sc->port_rid = 0; /* 0 is managed by pccard */ | ||||
sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, | sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, | ||||
&sc->port_rid, 0ul, ~0ul, 16, RF_ACTIVE); | &sc->port_rid, 0, ~0, 16, RF_ACTIVE); | ||||
} else if (sc->dingo) { | } else if (sc->dingo) { | ||||
/* | /* | ||||
* Find a 16 byte aligned ioport for the card. | * Find a 16 byte aligned ioport for the card. | ||||
*/ | */ | ||||
DEVPRINTF(1, (dev, "Finding an aligned port for RealPort\n")); | DEVPRINTF(1, (dev, "Finding an aligned port for RealPort\n")); | ||||
sc->port_rid = 1; /* 0 is managed by pccard */ | sc->port_rid = 1; /* 0 is managed by pccard */ | ||||
start = 0x100; | start = 0x100; | ||||
do { | do { | ||||
sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, | sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, | ||||
&sc->port_rid, start, 0x3ff, 16, RF_ACTIVE); | &sc->port_rid, start, 0x3ff, 16, RF_ACTIVE); | ||||
if (sc->port_res == NULL) | if (sc->port_res == NULL) | ||||
break; | break; | ||||
if ((rman_get_start(sc->port_res) & 0xf) == 0) | if ((rman_get_start(sc->port_res) & 0xf) == 0) | ||||
break; | break; | ||||
bus_release_resource(dev, SYS_RES_IOPORT, sc->port_rid, | bus_release_resource(dev, SYS_RES_IOPORT, sc->port_rid, | ||||
sc->port_res); | sc->port_res); | ||||
start = (rman_get_start(sc->port_res) + 15) & ~0xf; | start = (rman_get_start(sc->port_res) + 15) & ~0xf; | ||||
} while (1); | } while (1); | ||||
DEVPRINTF(1, (dev, "RealPort port 0x%0lx, size 0x%0lx\n", | DEVPRINTF(1, (dev, "RealPort port 0x%0jx, size 0x%0jx\n", | ||||
bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid), | bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid), | ||||
bus_get_resource_count(dev, SYS_RES_IOPORT, sc->port_rid))); | bus_get_resource_count(dev, SYS_RES_IOPORT, sc->port_rid))); | ||||
} else if (sc->ce2) { | } else if (sc->ce2) { | ||||
/* | /* | ||||
* Find contiguous I/O port for the Ethernet function | * Find contiguous I/O port for the Ethernet function | ||||
* on CEM2 and CEM3 cards. We allocate window 0 | * on CEM2 and CEM3 cards. We allocate window 0 | ||||
* wherever pccard has decided it should be, then find | * wherever pccard has decided it should be, then find | ||||
* an available window adjacent to it for the second | * an available window adjacent to it for the second | ||||
* function. Not sure that both windows are actually | * function. Not sure that both windows are actually | ||||
* needed. | * needed. | ||||
*/ | */ | ||||
DEVPRINTF(1, (dev, "Finding I/O port for CEM2/CEM3\n")); | DEVPRINTF(1, (dev, "Finding I/O port for CEM2/CEM3\n")); | ||||
sc->ce2_port_rid = 0; /* 0 is managed by pccard */ | sc->ce2_port_rid = 0; /* 0 is managed by pccard */ | ||||
sc->ce2_port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, | sc->ce2_port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, | ||||
&sc->ce2_port_rid, 0ul, ~0ul, 8, RF_ACTIVE); | &sc->ce2_port_rid, 0, ~0, 8, RF_ACTIVE); | ||||
if (sc->ce2_port_res == NULL) { | if (sc->ce2_port_res == NULL) { | ||||
DEVPRINTF(1, (dev, | DEVPRINTF(1, (dev, | ||||
"Cannot allocate I/O port for modem\n")); | "Cannot allocate I/O port for modem\n")); | ||||
xe_deactivate(dev); | xe_deactivate(dev); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} | } | ||||
sc->port_rid = 1; | sc->port_rid = 1; | ||||
start = bus_get_resource_start(dev, SYS_RES_IOPORT, | start = bus_get_resource_start(dev, SYS_RES_IOPORT, | ||||
sc->ce2_port_rid); | sc->ce2_port_rid); | ||||
for (i = 0; i < 2; i++) { | for (i = 0; i < 2; i++) { | ||||
start += (i == 0 ? 8 : -24); | start += (i == 0 ? 8 : -24); | ||||
sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, | sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, | ||||
&sc->port_rid, start, start + 15, 16, RF_ACTIVE); | &sc->port_rid, start, start + 15, 16, RF_ACTIVE); | ||||
if (sc->port_res == NULL) | if (sc->port_res == NULL) | ||||
continue; | continue; | ||||
if (bus_get_resource_start(dev, SYS_RES_IOPORT, | if (bus_get_resource_start(dev, SYS_RES_IOPORT, | ||||
sc->port_rid) == start) | sc->port_rid) == start) | ||||
break; | break; | ||||
bus_release_resource(dev, SYS_RES_IOPORT, sc->port_rid, | bus_release_resource(dev, SYS_RES_IOPORT, sc->port_rid, | ||||
sc->port_res); | sc->port_res); | ||||
sc->port_res = NULL; | sc->port_res = NULL; | ||||
} | } | ||||
DEVPRINTF(1, (dev, "CEM2/CEM3 port 0x%0lx, size 0x%0lx\n", | DEVPRINTF(1, (dev, "CEM2/CEM3 port 0x%0jx, size 0x%0jx\n", | ||||
bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid), | bus_get_resource_start(dev, SYS_RES_IOPORT, sc->port_rid), | ||||
bus_get_resource_count(dev, SYS_RES_IOPORT, sc->port_rid))); | bus_get_resource_count(dev, SYS_RES_IOPORT, sc->port_rid))); | ||||
} | } | ||||
if (!sc->port_res) { | if (!sc->port_res) { | ||||
DEVPRINTF(1, (dev, "Cannot allocate ioport\n")); | DEVPRINTF(1, (dev, "Cannot allocate ioport\n")); | ||||
xe_deactivate(dev); | xe_deactivate(dev); | ||||
return (ENOMEM); | return (ENOMEM); | ||||
Show All 39 Lines |