Fix viawd(4) that was only working as a module.

Obtained from:	jhb
MFC after: 3 days
This commit is contained in:
Fabien Thomas 2012-06-20 09:01:44 +00:00
parent 7ed5b3afa2
commit 940853dd84
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=237295

View File

@ -168,14 +168,18 @@ viawd_attach(device_t dev)
}
/* Allocate I/O register space. */
sc->wd_rid = 0;
sc->wd_res = bus_alloc_resource(dev, SYS_RES_MEMORY, &sc->wd_rid,
pmbase, pmbase + VIAWD_MEM_LEN - 1, VIAWD_MEM_LEN,
sc->wd_rid = VIAWD_CONFIG_BASE;
sc->wd_res = bus_alloc_resource_any(sb_dev, SYS_RES_MEMORY, &sc->wd_rid,
RF_ACTIVE | RF_SHAREABLE);
if (sc->wd_res == NULL) {
device_printf(dev, "Unable to map watchdog memory\n");
goto fail;
}
if (rman_get_size(sc->wd_res) < VIAWD_MEM_LEN) {
device_printf(dev, "Bad size for watchdog memory: %#x\n",
(unsigned)rman_get_size(sc->wd_res));
goto fail;
}
/* Check if watchdog fired last boot. */
reg = viawd_read_4(sc, VIAWD_MEM_CTRL);
@ -192,7 +196,7 @@ viawd_attach(device_t dev)
return (0);
fail:
if (sc->wd_res != NULL)
bus_release_resource(dev, SYS_RES_MEMORY,
bus_release_resource(sb_dev, SYS_RES_MEMORY,
sc->wd_rid, sc->wd_res);
return (ENXIO);
}
@ -224,7 +228,7 @@ viawd_detach(device_t dev)
}
if (sc->wd_res != NULL)
bus_release_resource(sc->dev, SYS_RES_MEMORY,
bus_release_resource(sc->sb_dev, SYS_RES_MEMORY,
sc->wd_rid, sc->wd_res);
return (0);