catch up with r189306; handle delayed activation of resources
Submitted by: jhb
This commit is contained in:
parent
f9ec06aba7
commit
5ee23799eb
@ -362,8 +362,10 @@ ixp425_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
|||||||
struct rman *rmanp;
|
struct rman *rmanp;
|
||||||
struct resource *rv;
|
struct resource *rv;
|
||||||
uint32_t vbase, addr;
|
uint32_t vbase, addr;
|
||||||
|
int needactivate = flags & RF_ACTIVE;
|
||||||
int irq;
|
int irq;
|
||||||
|
|
||||||
|
flags &= ~RF_ACTIVE;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SYS_RES_IRQ:
|
case SYS_RES_IRQ:
|
||||||
rmanp = &sc->sc_irq_rman;
|
rmanp = &sc->sc_irq_rman;
|
||||||
@ -382,6 +384,7 @@ ixp425_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
|||||||
if (BUS_READ_IVAR(dev, child, IXP425_IVAR_ADDR, &addr) == 0) {
|
if (BUS_READ_IVAR(dev, child, IXP425_IVAR_ADDR, &addr) == 0) {
|
||||||
start = addr;
|
start = addr;
|
||||||
end = start + 0x1000; /* XXX */
|
end = start + 0x1000; /* XXX */
|
||||||
|
count = end - start;
|
||||||
}
|
}
|
||||||
if (getvbase(start, end - start, &vbase) != 0) {
|
if (getvbase(start, end - start, &vbase) != 0) {
|
||||||
/* likely means above table needs to be updated */
|
/* likely means above table needs to be updated */
|
||||||
@ -391,20 +394,41 @@ ixp425_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
|||||||
}
|
}
|
||||||
rv = rman_reserve_resource(rmanp, start, end, count,
|
rv = rman_reserve_resource(rmanp, start, end, count,
|
||||||
flags, child);
|
flags, child);
|
||||||
if (rv != NULL) {
|
if (rv != NULL)
|
||||||
rman_set_rid(rv, *rid);
|
rman_set_rid(rv, *rid);
|
||||||
if (strcmp(device_get_name(child), "uart") == 0)
|
|
||||||
rman_set_bustag(rv, &ixp425_a4x_bs_tag);
|
|
||||||
else
|
|
||||||
rman_set_bustag(rv, sc->sc_iot);
|
|
||||||
rman_set_bushandle(rv, vbase);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
rv = NULL;
|
rv = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return rv;
|
if (rv != NULL && needactivate) {
|
||||||
|
if (bus_activate_resource(child, type, *rid, rv)) {
|
||||||
|
rman_release_resource(rv);
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (rv);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
ixp425_activate_resource(device_t dev, device_t child, int type, int rid,
|
||||||
|
struct resource *r)
|
||||||
|
{
|
||||||
|
struct ixp425_softc *sc = device_get_softc(dev);
|
||||||
|
int error;
|
||||||
|
uint32_t vbase;
|
||||||
|
|
||||||
|
if (type == SYS_RES_MEMORY) {
|
||||||
|
error = getvbase(rman_get_start(r), rman_get_size(r), &vbase);
|
||||||
|
if (error)
|
||||||
|
return (error);
|
||||||
|
if (strcmp(device_get_name(child), "uart") == 0)
|
||||||
|
rman_set_bustag(r, &ixp425_a4x_bs_tag);
|
||||||
|
else
|
||||||
|
rman_set_bustag(r, sc->sc_iot);
|
||||||
|
rman_set_bushandle(r, vbase);
|
||||||
|
}
|
||||||
|
return (rman_activate_resource(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline void
|
static __inline void
|
||||||
@ -472,6 +496,7 @@ static device_method_t ixp425_methods[] = {
|
|||||||
DEVMETHOD(bus_read_ivar, ixp425_read_ivar),
|
DEVMETHOD(bus_read_ivar, ixp425_read_ivar),
|
||||||
|
|
||||||
DEVMETHOD(bus_alloc_resource, ixp425_alloc_resource),
|
DEVMETHOD(bus_alloc_resource, ixp425_alloc_resource),
|
||||||
|
DEVMETHOD(bus_activate_resource, ixp425_activate_resource),
|
||||||
DEVMETHOD(bus_setup_intr, ixp425_setup_intr),
|
DEVMETHOD(bus_setup_intr, ixp425_setup_intr),
|
||||||
DEVMETHOD(bus_teardown_intr, ixp425_teardown_intr),
|
DEVMETHOD(bus_teardown_intr, ixp425_teardown_intr),
|
||||||
|
|
||||||
|
@ -276,12 +276,10 @@ static struct resource *
|
|||||||
ixppcib_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
ixppcib_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
||||||
u_long start, u_long end, u_long count, u_int flags)
|
u_long start, u_long end, u_long count, u_int flags)
|
||||||
{
|
{
|
||||||
bus_space_tag_t tag;
|
|
||||||
struct ixppcib_softc *sc = device_get_softc(bus);
|
struct ixppcib_softc *sc = device_get_softc(bus);
|
||||||
struct rman *rmanp;
|
struct rman *rmanp;
|
||||||
struct resource *rv;
|
struct resource *rv;
|
||||||
|
|
||||||
tag = NULL; /* shut up stupid gcc */
|
|
||||||
rv = NULL;
|
rv = NULL;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SYS_RES_IRQ:
|
case SYS_RES_IRQ:
|
||||||
@ -290,28 +288,25 @@ ixppcib_alloc_resource(device_t bus, device_t child, int type, int *rid,
|
|||||||
|
|
||||||
case SYS_RES_IOPORT:
|
case SYS_RES_IOPORT:
|
||||||
rmanp = &sc->sc_io_rman;
|
rmanp = &sc->sc_io_rman;
|
||||||
tag = &sc->sc_pci_iot;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SYS_RES_MEMORY:
|
case SYS_RES_MEMORY:
|
||||||
rmanp = &sc->sc_mem_rman;
|
rmanp = &sc->sc_mem_rman;
|
||||||
tag = &sc->sc_pci_memt;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return (rv);
|
return (rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
rv = rman_reserve_resource(rmanp, start, end, count, flags, child);
|
rv = rman_reserve_resource(rmanp, start, end, count, flags & ~RF_ACTIVE,
|
||||||
if (rv != NULL) {
|
child);
|
||||||
rman_set_rid(rv, *rid);
|
if (rv == NULL)
|
||||||
if (type == SYS_RES_IOPORT) {
|
return (NULL);
|
||||||
rman_set_bustag(rv, tag);
|
rman_set_rid(rv, *rid);
|
||||||
rman_set_bushandle(rv, rman_get_start(rv));
|
if (flags & RF_ACTIVE) {
|
||||||
} else if (type == SYS_RES_MEMORY) {
|
if (bus_activate_resource(child, type, *rid, rv)) {
|
||||||
rman_set_bustag(rv, tag);
|
rman_release_resource(rv);
|
||||||
rman_set_bushandle(rv, rman_get_bushandle(sc->sc_mem) +
|
return (NULL);
|
||||||
(rman_get_start(rv) - IXP425_PCI_MEM_HWBASE));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,9 +318,21 @@ ixppcib_activate_resource(device_t bus, device_t child, int type, int rid,
|
|||||||
struct resource *r)
|
struct resource *r)
|
||||||
{
|
{
|
||||||
|
|
||||||
device_printf(bus, "%s called activate_resource (unexpected)\n",
|
struct ixppcib_softc *sc = device_get_softc(bus);
|
||||||
device_get_nameunit(child));
|
|
||||||
return (ENXIO);
|
switch (type) {
|
||||||
|
case SYS_RES_IOPORT:
|
||||||
|
rman_set_bustag(r, &sc->sc_pci_iot);
|
||||||
|
rman_set_bushandle(r, rman_get_start(r));
|
||||||
|
break;
|
||||||
|
case SYS_RES_MEMORY:
|
||||||
|
rman_set_bustag(r, &sc->sc_pci_memt);
|
||||||
|
rman_set_bushandle(r, rman_get_bushandle(sc->sc_mem) +
|
||||||
|
(rman_get_start(r) - IXP425_PCI_MEM_HWBASE));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (rman_activate_resource(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user