Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Add a bus-independent detachment routine. In the...
details: https://anonhg.NetBSD.org/src/rev/5fed56eed60e
branches: trunk
changeset: 746704:5fed56eed60e
user: dyoung <dyoung%NetBSD.org@localhost>
date: Tue Aug 18 17:06:35 2009 +0000
description:
Add a bus-independent detachment routine. In the attachment routine,
save some device state to restore during detachment.
diffstat:
sys/dev/ic/hpet.c | 21 +++++++++++++++++++--
sys/dev/ic/hpetvar.h | 4 +++-
2 files changed, 22 insertions(+), 3 deletions(-)
diffs (70 lines):
diff -r 4ab0e7a36490 -r 5fed56eed60e sys/dev/ic/hpet.c
--- a/sys/dev/ic/hpet.c Tue Aug 18 17:02:00 2009 +0000
+++ b/sys/dev/ic/hpet.c Tue Aug 18 17:06:35 2009 +0000
@@ -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);
diff -r 4ab0e7a36490 -r 5fed56eed60e sys/dev/ic/hpetvar.h
--- a/sys/dev/ic/hpetvar.h Tue Aug 18 17:02:00 2009 +0000
+++ b/sys/dev/ic/hpetvar.h Tue Aug 18 17:06:35 2009 +0000
@@ -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_ */
Home |
Main Index |
Thread Index |
Old Index