summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2009-12-25 21:53:20 +0000
committermarius <marius@FreeBSD.org>2009-12-25 21:53:20 +0000
commit48852d86534cd2b219bc13c43a14aac693c1abd0 (patch)
tree2c904dd130b1c9996ce5cc113fe4639233ebe087
parenta77d48014c469c8ddd44668c6e5b4874f0c87d4d (diff)
downloadFreeBSD-src-48852d86534cd2b219bc13c43a14aac693c1abd0.zip
FreeBSD-src-48852d86534cd2b219bc13c43a14aac693c1abd0.tar.gz
- Take advantage of bus_{read,write}_*(9).
- Set dow = -1 in mk48txx_gettime() because some drivers (for example the NetBSD and OpenBSD mk48txx(4)) don't set it correctly.
-rw-r--r--sys/dev/mk48txx/mk48txx.c13
-rw-r--r--sys/dev/mk48txx/mk48txxvar.h3
-rw-r--r--sys/sparc64/sparc64/eeprom.c4
3 files changed, 13 insertions, 7 deletions
diff --git a/sys/dev/mk48txx/mk48txx.c b/sys/dev/mk48txx/mk48txx.c
index ec8a1e9..ae3f16a 100644
--- a/sys/dev/mk48txx/mk48txx.c
+++ b/sys/dev/mk48txx/mk48txx.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
#include <sys/eventhandler.h>
#include <sys/lock.h>
#include <sys/mutex.h>
+#include <sys/rman.h>
#include <sys/watchdog.h>
#include <machine/bus.h>
@@ -175,8 +176,16 @@ mk48txx_gettime(device_t dev, struct timespec *ts)
ct.min = FROMBCD(FROMREG(MK48TXX_IMIN, MK48TXX_MIN_MASK));
ct.hour = FROMBCD(FROMREG(MK48TXX_IHOUR, MK48TXX_HOUR_MASK));
ct.day = FROMBCD(FROMREG(MK48TXX_IDAY, MK48TXX_DAY_MASK));
+#if 0
/* Map dow from 1 - 7 to 0 - 6; FROMBCD() isn't necessary here. */
ct.dow = FROMREG(MK48TXX_IWDAY, MK48TXX_WDAY_MASK) - 1;
+#else
+ /*
+ * Set dow = -1 because some drivers (for example the NetBSD and
+ * OpenBSD mk48txx(4)) don't set it correctly.
+ */
+ ct.dow = - 1;
+#endif
ct.mon = FROMBCD(FROMREG(MK48TXX_IMON, MK48TXX_MON_MASK));
year = FROMBCD(FROMREG(MK48TXX_IYEAR, MK48TXX_YEAR_MASK));
year += sc->sc_year0;
@@ -266,7 +275,7 @@ mk48txx_def_nvrd(device_t dev, int off)
struct mk48txx_softc *sc;
sc = device_get_softc(dev);
- return (bus_space_read_1(sc->sc_bst, sc->sc_bsh, off));
+ return (bus_read_1(sc->sc_res, off));
}
static void
@@ -275,7 +284,7 @@ mk48txx_def_nvwr(device_t dev, int off, uint8_t v)
struct mk48txx_softc *sc;
sc = device_get_softc(dev);
- bus_space_write_1(sc->sc_bst, sc->sc_bsh, off, v);
+ bus_write_1(sc->sc_res, off, v);
}
static void
diff --git a/sys/dev/mk48txx/mk48txxvar.h b/sys/dev/mk48txx/mk48txxvar.h
index 5bb92da..9706d8d 100644
--- a/sys/dev/mk48txx/mk48txxvar.h
+++ b/sys/dev/mk48txx/mk48txxvar.h
@@ -35,8 +35,7 @@ typedef uint8_t (*mk48txx_nvrd_t)(device_t dev, int off);
typedef void (*mk48txx_nvwr_t)(device_t dev, int off, uint8_t v);
struct mk48txx_softc {
- bus_space_tag_t sc_bst; /* bus space tag */
- bus_space_handle_t sc_bsh; /* bus space handle */
+ struct resource *sc_res;/* bus resource */
struct mtx sc_mtx; /* hardware mutex */
eventhandler_tag sc_wet; /* watchdog event handler tag */
diff --git a/sys/sparc64/sparc64/eeprom.c b/sys/sparc64/sparc64/eeprom.c
index 223b96c..6a4b1aa 100644
--- a/sys/sparc64/sparc64/eeprom.c
+++ b/sys/sparc64/sparc64/eeprom.c
@@ -107,7 +107,7 @@ DRIVER_MODULE(eeprom, sbus, eeprom_driver, eeprom_devclass, 0, 0);
static int
eeprom_probe(device_t dev)
{
-
+
if (strcmp("eeprom", ofw_bus_get_name(dev)) == 0) {
device_set_desc(dev, "EEPROM/clock");
return (0);
@@ -134,8 +134,6 @@ eeprom_attach(device_t dev)
error = ENXIO;
goto fail_mtx;
}
- sc->sc_bst = rman_get_bustag(res);
- sc->sc_bsh = rman_get_bushandle(res);
if ((sc->sc_model = ofw_bus_get_model(dev)) == NULL) {
device_printf(dev, "cannot determine model\n");
OpenPOWER on IntegriCloud