Module Name: src
Committed By: dyoung
Date: Tue Aug 18 17:06:35 UTC 2009
Modified Files:
src/sys/dev/ic: hpet.c hpetvar.h
Log Message:
Add a bus-independent detachment routine. In the attachment routine,
save some device state to restore during detachment.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/hpet.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/hpetvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/ic/hpet.c
diff -u src/sys/dev/ic/hpet.c:1.6 src/sys/dev/ic/hpet.c:1.7
--- src/sys/dev/ic/hpet.c:1.6 Fri Mar 21 13:25:27 2008
+++ src/sys/dev/ic/hpet.c Tue Aug 18 17:06:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: hpet.c,v 1.6 2008/03/21 13:25:27 xtraeme Exp $ */
+/* $NetBSD: hpet.c,v 1.7 2009/08/18 17:06:35 dyoung Exp $ */
/*
* Copyright (c) 2006 Nicolas Joly
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hpet.c,v 1.6 2008/03/21 13:25:27 xtraeme Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpet.c,v 1.7 2009/08/18 17:06:35 dyoung Exp $");
#include <sys/systm.h>
#include <sys/device.h>
@@ -50,6 +50,22 @@
static u_int hpet_get_timecount(struct timecounter *);
static bool hpet_resume(device_t PMF_FN_PROTO);
+int
+hpet_detach(device_t dv, int flags)
+{
+ struct hpet_softc *sc = device_private(dv);
+ int rc;
+
+ if ((rc = tc_detach(&sc->sc_tc)) != 0)
+ return rc;
+
+ pmf_device_deregister(dv);
+
+ bus_space_write_4(sc->sc_memt, sc->sc_memh, HPET_CONFIG, sc->sc_config);
+
+ return 0;
+}
+
void
hpet_attach_subr(device_t dv)
{
@@ -71,6 +87,7 @@
/* Enable timer */
val = bus_space_read_4(sc->sc_memt, sc->sc_memh, HPET_CONFIG);
+ sc->sc_config = val;
if ((val & HPET_CONFIG_ENABLE) == 0) {
val |= HPET_CONFIG_ENABLE;
bus_space_write_4(sc->sc_memt, sc->sc_memh, HPET_CONFIG, val);
Index: src/sys/dev/ic/hpetvar.h
diff -u src/sys/dev/ic/hpetvar.h:1.2 src/sys/dev/ic/hpetvar.h:1.3
--- src/sys/dev/ic/hpetvar.h:1.2 Fri Mar 21 13:25:27 2008
+++ src/sys/dev/ic/hpetvar.h Tue Aug 18 17:06:35 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: hpetvar.h,v 1.2 2008/03/21 13:25:27 xtraeme Exp $ */
+/* $NetBSD: hpetvar.h,v 1.3 2009/08/18 17:06:35 dyoung Exp $ */
/*
* Copyright (c) 2006 Nicolas Joly
@@ -35,9 +35,11 @@
bus_space_tag_t sc_memt;
bus_space_handle_t sc_memh;
+ uint32_t sc_config;
struct timecounter sc_tc;
};
void hpet_attach_subr(device_t);
+int hpet_detach(device_t, int flags);
#endif /* _DEV_IC_HPETVAR_H_ */