summaryrefslogtreecommitdiffstats
path: root/sys/sparc64
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2005-05-19 21:16:50 +0000
committermarius <marius@FreeBSD.org>2005-05-19 21:16:50 +0000
commitbedc4e05717f5dabf8d7fab67cee6819f1b93358 (patch)
tree2cc09e97a4f5281f80ee84f17efa48f6183f015d /sys/sparc64
parent3a5fc7dc75e619408c9f7ce037a57772e9685af5 (diff)
downloadFreeBSD-src-bedc4e05717f5dabf8d7fab67cee6819f1b93358.zip
FreeBSD-src-bedc4e05717f5dabf8d7fab67cee6819f1b93358.tar.gz
- Add locking.
- Add support for storing the century in MK48TXX_WDAY_CB on MK48Txx with extended registers when the MK48TXX_NO_CENT_ADJUST flag is set (and which is termed somewhat confusing as it actually means don't manually adjust the century in the driver). - Add the MI part of interfacing the watchdog functionality of MK48Txx with extended registers with watchdog(9). This is inspired by the SunOS/Solaris drivers for the 'eeprom' devices also having watchdog support. I actually expected this to work out of the box on Sun Exx00 machines with 'eeprom' devices which have a 'watchdog-enable' property. On terminal count of the the watchdog timer however only the MK48TXX_FLAGS_WDF bit rises but the reset signal and the interrupt respectively (depending on whether the MK48TXX_WDOG_WDS bit of the chip and the MK48TXX_WDOG_ENABLE_WDS flag of the driver respectively is set) goes nowhere. Apparently passing the reset signal on to the WDR line of the CPUs has to be enabled somewhere else but we don't have documentation for the Exx00 specific controllers. I decided to commit this nevertheless so it can be enabled in the eeprom(4) front-end later in e.g. 6.0-STABLE without breaking the API. Besides the Exx00 the watchdog part of the MK48Txx should also work on E250 and E450. Possibly also without extra fiddling on these machines but I haven't found someone willing to give it a try on such a machine so far. - Use uintXX_t instead of u_intXX_t, use __func__ instead of hardcoded function names in error strings.
Diffstat (limited to 'sys/sparc64')
-rw-r--r--sys/sparc64/sparc64/eeprom.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/sparc64/sparc64/eeprom.c b/sys/sparc64/sparc64/eeprom.c
index 1c9b989..e6b8955 100644
--- a/sys/sparc64/sparc64/eeprom.c
+++ b/sys/sparc64/sparc64/eeprom.c
@@ -58,8 +58,11 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
+#include <sys/eventhandler.h>
#include <sys/kernel.h>
+#include <sys/lock.h>
#include <sys/module.h>
+#include <sys/mutex.h>
#include <sys/resource.h>
#include <dev/ofw/ofw_bus.h>
@@ -126,11 +129,14 @@ eeprom_attach(device_t dev)
sc = device_get_softc(dev);
bzero(sc, sizeof(struct mk48txx_softc));
+ mtx_init(&sc->sc_mtx, "eeprom_mtx", NULL, MTX_DEF);
+
rid = 0;
res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
if (res == NULL) {
device_printf(dev, "cannot allocate resources\n");
- return (ENXIO);
+ error = ENXIO;
+ goto fail_mtx;
}
sc->sc_bst = rman_get_bustag(res);
sc->sc_bsh = rman_get_bushandle(res);
@@ -158,6 +164,7 @@ eeprom_attach(device_t dev)
* on the latter models. A generic way to retrieve the hostid is to
* use the `idprom' node.
*/
+ mtx_lock(&sc->sc_mtx);
h = bus_space_read_1(sc->sc_bst, sc->sc_bsh, sc->sc_nvramsz -
IDPROM_OFFSET + offsetof(struct idprom, id_machine)) << 24;
for (i = 0; i < 3; i++) {
@@ -165,6 +172,7 @@ eeprom_attach(device_t dev)
IDPROM_OFFSET + offsetof(struct idprom, id_hostid[i])) <<
((2 - i) * 8);
}
+ mtx_unlock(&sc->sc_mtx);
if (h != 0)
device_printf(dev, "hostid %x\n", (u_int)h);
@@ -178,6 +186,8 @@ eeprom_attach(device_t dev)
fail_res:
bus_release_resource(dev, SYS_RES_MEMORY, rid, res);
+ fail_mtx:
+ mtx_destroy(&sc->sc_mtx);
return (error);
}
OpenPOWER on IntegriCloud