summaryrefslogtreecommitdiffstats
path: root/sys/alpha/tlsb/mcclock_tlsb.c
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1998-06-14 13:46:10 +0000
committerdfr <dfr@FreeBSD.org>1998-06-14 13:46:10 +0000
commitdc295ed278eb0235154462b23615e89213bc591c (patch)
tree0734d180ccb27bfdde5cd04d1961394e2e0ac94f /sys/alpha/tlsb/mcclock_tlsb.c
parenta7d3dec6df55d42bcb12806631798932380ce34b (diff)
downloadFreeBSD-src-dc295ed278eb0235154462b23615e89213bc591c.zip
FreeBSD-src-dc295ed278eb0235154462b23615e89213bc591c.tar.gz
Major changes to the generic device framework for FreeBSD/alpha:
* Eliminate bus_t and make it possible for all devices to have attached children. * Support dynamically extendable interfaces for drivers to replace both the function pointers in driver_t and bus_ops_t (which has been removed entirely. Two system defined interfaces have been defined, 'device' which is mandatory for all devices and 'bus' which is recommended for all devices which support attached children. * In addition, the alpha port defines two simple interfaces 'clock' for attaching various real time clocks to the system and 'mcclock' for the many different variations of mc146818 clocks which can be attached to different alpha platforms. This eliminates two more function pointer tables in favour of the generic method dispatch system provided by the device framework. Future device interfaces may include: * cdev and bdev interfaces for devfs to use in replacement for specfs and the fixed interfaces bdevsw and cdevsw. * scsi interface to replace struct scsi_adapter (not sure how this works in CAM but I imagine there is something similar there). * various tailored interfaces for different bus types such as pci, isa, pccard etc.
Diffstat (limited to 'sys/alpha/tlsb/mcclock_tlsb.c')
-rw-r--r--sys/alpha/tlsb/mcclock_tlsb.c62
1 files changed, 32 insertions, 30 deletions
diff --git a/sys/alpha/tlsb/mcclock_tlsb.c b/sys/alpha/tlsb/mcclock_tlsb.c
index 15974fc..593b00f 100644
--- a/sys/alpha/tlsb/mcclock_tlsb.c
+++ b/sys/alpha/tlsb/mcclock_tlsb.c
@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $Id: mcclock_tlsb.c,v 1.1 1998/06/10 10:55:52 dfr Exp $ */
/* $NetBSD: mcclock_tlsb.c,v 1.8 1998/05/13 02:50:29 thorpej Exp $ */
/*
@@ -37,7 +37,7 @@
#include <sys/module.h>
#include <sys/bus.h>
-#include <dev/dec/clockvar.h>
+#include <machine/clockvar.h>
#include <dev/dec/mcclockvar.h>
#include <alpha/tlsb/gbusvar.h>
@@ -53,71 +53,73 @@
#define REGSHIFT 6
struct mcclock_tlsb_softc {
- struct mcclock_softc sc_mcclock;
unsigned long regbase;
};
-static int mcclock_tlsb_probe(bus_t, device_t);
-static int mcclock_tlsb_attach(bus_t, device_t);
+static int mcclock_tlsb_probe(device_t dev);
+static int mcclock_tlsb_attach(device_t dev);
+static void mcclock_tlsb_write(device_t, u_int, u_int);
+static u_int mcclock_tlsb_read(device_t, u_int);
-static devclass_t mcclock_devclass;
+static device_method_t mcclock_tlsb_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, mcclock_tlsb_probe),
+ DEVMETHOD(device_attach, mcclock_tlsb_attach),
+
+ /* mcclock interface */
+ DEVMETHOD(mcclock_write, mcclock_tlsb_write),
+ DEVMETHOD(mcclock_read, mcclock_tlsb_read),
+
+ /* clock interface */
+ DEVMETHOD(clock_init, mcclock_init),
+ DEVMETHOD(clock_get, mcclock_get),
+ DEVMETHOD(clock_set, mcclock_set),
+
+ { 0, 0 }
+};
-driver_t mcclock_tlsb_driver = {
+static driver_t mcclock_tlsb_driver = {
"mcclock",
- mcclock_tlsb_probe,
- mcclock_tlsb_attach,
- NULL,
- NULL,
+ mcclock_tlsb_methods,
DRIVER_TYPE_MISC,
sizeof(struct mcclock_tlsb_softc),
- NULL,
};
-static void mcclock_tlsb_write __P((struct mcclock_softc *, u_int, u_int));
-static u_int mcclock_tlsb_read __P((struct mcclock_softc *, u_int));
-
-const struct mcclock_busfns mcclock_tlsb_busfns = {
- mcclock_tlsb_write, mcclock_tlsb_read,
-};
+static devclass_t mcclock_devclass;
int
-mcclock_tlsb_probe(bus_t bus, device_t dev)
+mcclock_tlsb_probe(device_t dev)
{
device_set_desc(dev, "MC146818A real time clock");
return 0;
}
int
-mcclock_tlsb_attach(bus_t bus, device_t dev)
+mcclock_tlsb_attach(device_t dev)
{
struct mcclock_tlsb_softc *sc = device_get_softc(dev);
/* XXX Should be bus.h'd, so we can accomodate the kn7aa. */
- sc->sc_mcclock.sc_dev = dev;
sc->regbase = TLSB_GBUS_BASE + gbus_get_offset(dev);
- mcclock_attach(&sc->sc_mcclock, &mcclock_tlsb_busfns);
+ mcclock_attach(dev);
return 0;
}
static void
-mcclock_tlsb_write(mcsc, reg, val)
- struct mcclock_softc *mcsc;
- u_int reg, val;
+mcclock_tlsb_write(device_t dev, u_int reg, u_int val)
{
- struct mcclock_tlsb_softc *sc = (struct mcclock_tlsb_softc *)mcsc;
+ struct mcclock_tlsb_softc *sc = device_get_softc(dev);
unsigned char *ptr = (unsigned char *)
KV(sc->regbase + (reg << REGSHIFT));
*ptr = val;
}
static u_int
-mcclock_tlsb_read(mcsc, reg)
- struct mcclock_softc *mcsc;
- u_int reg;
+mcclock_tlsb_read(device_t dev, u_int reg)
{
- struct mcclock_tlsb_softc *sc = (struct mcclock_tlsb_softc *)mcsc;
+ struct mcclock_tlsb_softc *sc = device_get_softc(dev);
unsigned char *ptr = (unsigned char *)
KV(sc->regbase + (reg << REGSHIFT));
return *ptr;
OpenPOWER on IntegriCloud