Subject: kern/35381: Support for High Precision Event Timer (HPET)
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <njoly@pasteur.fr>
List: netbsd-bugs
Date: 01/08/2007 13:10:01
>Number:         35381
>Category:       kern
>Synopsis:       Support for High Precision Event Timer (HPET)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jan 08 13:10:01 +0000 2007
>Originator:     Nicolas Joly
>Release:        NetBSD 4.99.7
>Organization:
Institut Pasteur, Paris.
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 4.99.7 NetBSD 4.99.7 (LANFEUST_DEVEL) #11: Mon Jan 8 10:56:02 CET 2007 njoly@lanfeust.sis.pasteur.fr:/local/src/NetBSD/obj/amd64/sys/arch/amd64/compile/LANFEUST_DEVEL amd64
Architecture: x86_64
Machine: amd64
>Description:
Here is a set of patches to add support for Intel compatible High Precision
Event Timer (HPET). Both ACPI and/or PCI (AMD8111 LPC controller) are
supported.

ACPI:
hpet* at acpi?

hpet0 at acpi0 (PNP0103)
hpet0: mem 0xfec01000-0xfec013ff irq 0,8
timecounter: Timecounter "hpet0" frequency 14318179 Hz quality 2000

AMD8111 LPC controller:
amdpcib* at pci? dev ? function ?
hpet*   at amdpcib?
isa0    at amdpcib?

amdpcib0 at pci0 dev 7 function 0
amdpcib0: Advanced Micro Devices AMD8111 LPC Controller (rev. 0x05)
hpet0 at amdpcib0: HPET timer
timecounter: Timecounter "hpet0" frequency 14318179 Hz quality 2000
isa0 at amdpcib0

>How-To-Repeat:
n/a
>Fix:
Index: sys/arch/amd64/conf/files.amd64
===================================================================
RCS file: /cvsroot/src/sys/arch/amd64/conf/files.amd64,v
retrieving revision 1.29
diff -u -r1.29 files.amd64
--- sys/arch/amd64/conf/files.amd64	10 Sep 2006 19:50:48 -0000	1.29
+++ sys/arch/amd64/conf/files.amd64	5 Dec 2006 19:18:31 -0000
@@ -114,7 +117,14 @@
 # PCI-ISA bridges
 device	pcib: isabus
 attach	pcib at pci
-file	arch/amd64/pci/pcib.c			pcib
+file	arch/amd64/pci/pcib.c			pcib | amdpcib
+
+device 	amdpcib {} : isabus
+attach 	amdpcib at pci
+file 	arch/amd64/pci/amdpcib.c		amdpcib
+
+attach 	hpet at amdpcib with amdpcib_hpet
+file 	arch/amd64/pci/amdpcib_hpet.c		amdpcib_hpet
 
 device 	aapic
 attach 	aapic at pci
Index: sys/arch/amd64/pci/amdpcib.c
===================================================================
RCS file: sys/arch/amd64/pci/amdpcib.c
diff -N sys/arch/amd64/pci/amdpcib.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sys/arch/amd64/pci/amdpcib.c	5 Dec 2006 19:18:31 -0000
@@ -0,0 +1,89 @@
+/* $NetBSD$ */
+
+/*
+ * Copyright (c) 2006 Nicolas Joly
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD$");
+
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcidevs.h>
+
+struct amdpcib_softc {
+	struct device		sc_dev;
+
+	bus_space_tag_t		sc_memt;
+	bus_space_handle_t	sc_memh;
+};
+
+static int	amdpcib_match(struct device *, struct cfdata *, void *);
+static void	amdpcib_attach(struct device *, struct device *, void *);
+static int	amdpcib_search(device_t, cfdata_t, const int *, void *);
+
+
+extern void	pcibattach(struct device *, struct device *, void *);
+
+CFATTACH_DECL(amdpcib, sizeof(struct amdpcib_softc), amdpcib_match,
+    amdpcib_attach, NULL, NULL);
+
+static int
+amdpcib_match(struct device *parent, struct cfdata *match, void *aux) {
+	struct pci_attach_args *pa = aux;
+
+	if ((PCI_VENDOR(pa->pa_id) == PCI_VENDOR_AMD) &&
+	    (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_AMD_PBC8111_LPC))
+		return 2;
+
+	return 0;
+}
+
+static void
+amdpcib_attach(struct device *parent, struct device *self, void *aux) {
+	struct amdpcib_softc *sc;
+	struct pci_attach_args *pa;
+
+	sc = (struct amdpcib_softc *)self;
+	pa = (struct pci_attach_args *)aux;
+
+	pcibattach(parent, self, aux);
+
+	config_search_loc(amdpcib_search, &sc->sc_dev, "amdpcib", NULL, pa);
+}
+
+static int
+amdpcib_search(device_t parent, cfdata_t cf, const int *locs, void *aux) {
+
+	if (config_match(parent, cf, aux))
+		config_attach_loc(parent, cf, locs, aux, NULL);
+
+	return 0;
+}
Index: sys/arch/amd64/pci/amdpcib_hpet.c
===================================================================
RCS file: sys/arch/amd64/pci/amdpcib_hpet.c
diff -N sys/arch/amd64/pci/amdpcib_hpet.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sys/arch/amd64/pci/amdpcib_hpet.c	5 Dec 2006 19:18:31 -0000
@@ -0,0 +1,90 @@
+/* $NetBSD$ */
+
+/*
+ * Copyright (c) 2006 Nicolas Joly
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD$");
+
+#include <sys/systm.h>
+#include <sys/device.h>
+
+#include <sys/time.h>
+#include <sys/timetc.h>
+
+#include <machine/bus.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcidevs.h>
+
+#include <dev/ic/hpetvar.h>
+
+
+static int	amdpcib_hpet_match(struct device *, struct cfdata *, void *);
+static void	amdpcib_hpet_attach(struct device *, struct device *, void *);
+
+CFATTACH_DECL(amdpcib_hpet, sizeof(struct hpet_softc), amdpcib_hpet_match,
+    amdpcib_hpet_attach, NULL, NULL);
+
+static int
+amdpcib_hpet_match(struct device *parent, struct cfdata *match, void *aux) {
+	return 1;
+}
+
+static void
+amdpcib_hpet_attach(struct device *parent, struct device *self, void *aux) {
+	struct hpet_softc *sc;
+	struct pci_attach_args *pa;
+	pcireg_t conf, addr;
+
+	sc = (struct hpet_softc *)self;
+	pa = (struct pci_attach_args *)aux;
+
+	aprint_naive("\n");
+	aprint_normal(": HPET timer\n");
+
+	conf = pci_conf_read(pa->pa_pc, pa->pa_tag, 0xa0);
+	if ((conf & 1) == 0) {
+		printf("%s: HPET timer is disabled\n", sc->sc_dev.dv_xname);
+		return;
+	}
+
+	sc->sc_memt = pa->pa_memt;
+
+	addr = conf & 0xfffffc00;
+	if (bus_space_map(sc->sc_memt, addr, 1024, 0,
+	    &sc->sc_memh)) {
+		printf("%s: failed to map mem\n", sc->sc_dev.dv_xname);
+		return;
+	}
+
+#ifdef __HAVE_TIMECOUNTER
+	hpet_attach_subr(sc);
+#endif
+}
Index: sys/conf/files
===================================================================
RCS file: /cvsroot/src/sys/conf/files,v
retrieving revision 1.819
diff -u -r1.819 files
--- sys/conf/files	24 Nov 2006 22:04:25 -0000	1.819
+++ sys/conf/files	5 Dec 2006 19:18:32 -0000
@@ -958,6 +958,9 @@
 define acpipmtimer
 file	dev/ic/acpipmtimer.c	acpipmtimer
 
+device 	hpet
+file 	dev/ic/hpet.c		hpet			needs-flag
+
 # Definitions for wscons
 # device attributes: display, display with emulator, keyboard, and mouse
 #
Index: sys/dev/acpi/files.acpi
===================================================================
RCS file: /cvsroot/src/sys/dev/acpi/files.acpi,v
retrieving revision 1.40
diff -u -r1.40 files.acpi
--- sys/dev/acpi/files.acpi	14 Aug 2006 09:34:43 -0000	1.40
+++ sys/dev/acpi/files.acpi	5 Dec 2006 19:18:32 -0000
@@ -95,3 +95,8 @@
 # Yamaha OPL3-SAx
 attach	ym at acpinodebus with ym_acpi
 file	dev/acpi/ym_acpi.c		ym_acpi
+
+# HPET Timer
+attach 	hpet at acpinodebus with hpet_acpi
+file 	dev/acpi/hpet_acpi.c		hpet_acpi
+
Index: sys/dev/acpi/hpet_acpi.c
===================================================================
RCS file: sys/dev/acpi/hpet_acpi.c
diff -N sys/dev/acpi/hpet_acpi.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sys/dev/acpi/hpet_acpi.c	5 Dec 2006 19:18:32 -0000
@@ -0,0 +1,118 @@
+/* $NetBSD$ */
+
+/*
+ * Copyright (c) 2006 Nicolas Joly
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+
+#include <machine/bus.h>
+
+#include <dev/acpi/acpica.h>
+#include <dev/acpi/acpireg.h>
+#include <dev/acpi/acpivar.h>
+
+#include <sys/time.h>
+#include <sys/timetc.h>
+
+#include <dev/ic/hpetvar.h>
+
+static int	hpet_acpi_match(struct device *, struct cfdata *, void *);
+static void	hpet_acpi_attach(struct device *, struct device *, void *);
+
+
+CFATTACH_DECL(hpet_acpi, sizeof(struct hpet_softc), hpet_acpi_match,
+    hpet_acpi_attach, NULL, NULL);
+
+/*
+ * Supported device IDs
+ */
+
+static const char * const hpet_acpi_ids[] = {
+	"PNP0103",
+	NULL
+};
+
+/*
+ * hpet_acpi_match: autoconf(9) match routine
+ */
+static int
+hpet_acpi_match(struct device *parent, struct cfdata *match,
+    void *aux)
+{
+	struct acpi_attach_args *aa = aux;
+
+	if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE)
+		return 0;
+
+	return acpi_match_hid(aa->aa_node->ad_devinfo, hpet_acpi_ids);
+}
+
+static void
+hpet_acpi_attach(struct device *parent, struct device *self, void *aux)
+{
+	struct hpet_softc *sc = (struct hpet_softc *)self;
+	struct acpi_attach_args *aa = aux;
+	struct acpi_resources res;
+	struct acpi_mem *mem;
+	ACPI_STATUS rv;
+
+	aprint_naive("\n");
+	aprint_normal("\n");
+
+	/* parse resources */
+	rv = acpi_resource_parse(&sc->sc_dev, aa->aa_node->ad_handle, "_CRS",
+	    &res, &acpi_resource_parse_ops_default);
+	if (ACPI_FAILURE(rv))
+		return;
+
+	/* find our mem registers */
+	mem = acpi_res_mem(&res, 0);
+	if (mem == NULL) {
+		aprint_error("%s: unable to find mem register resource\n",
+		    sc->sc_dev.dv_xname);
+		goto out;
+	}
+
+	sc->sc_memt = aa->aa_memt;
+	if (bus_space_map(sc->sc_memt, mem->ar_base, mem->ar_length,
+		    0, &sc->sc_memh)) {
+		aprint_error("%s: can't map mem space\n", sc->sc_dev.dv_xname);
+		goto out;
+	}
+
+	hpet_attach_subr(sc);
+
+ out:
+	acpi_resource_cleanup(&res);
+}
Index: sys/dev/ic/hpet.c
===================================================================
RCS file: sys/dev/ic/hpet.c
diff -N sys/dev/ic/hpet.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sys/dev/ic/hpet.c	5 Dec 2006 19:18:32 -0000
@@ -0,0 +1,92 @@
+/* $NetBSD$ */
+
+/*
+ * Copyright (c) 2006 Nicolas Joly
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * High Precision Event Timer.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD$");
+
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+
+#include <sys/time.h>
+#include <sys/timetc.h>
+
+#include <machine/bus.h>
+
+#include <dev/ic/hpetreg.h>
+#include <dev/ic/hpetvar.h>
+
+static u_int	hpet_get_timecount(struct timecounter *);
+
+void
+hpet_attach_subr(struct hpet_softc *sc) {
+	struct timecounter *tc;
+	uint32_t val;
+
+	tc = &sc->sc_tc;
+
+	tc->tc_name = sc->sc_dev.dv_xname;
+	tc->tc_get_timecount = hpet_get_timecount;
+	tc->tc_quality = 2000;
+
+	/* XXX Only 32-bit supported for now */
+	val = bus_space_read_4(sc->sc_memt, sc->sc_memh, HPET_INFO);
+	if ((val & HPET_INFO_64BIT) != 0) {
+		aprint_normal("%s: Found 64-bit HPET, will only use lowest"
+		    "32-bits\n", sc->sc_dev.dv_xname);
+	}
+	tc->tc_counter_mask = 0xffffffff;
+
+	/* Get frequency */
+	val = bus_space_read_4(sc->sc_memt, sc->sc_memh, HPET_PERIOD);
+	tc->tc_frequency = 1000000000000000ULL / val;
+
+	/* Enable timer */
+	val = bus_space_read_4(sc->sc_memt, sc->sc_memh, HPET_CONFIG);
+	if ((val & HPET_CONFIG_ENABLE) == 0) {
+		val |= HPET_CONFIG_ENABLE;
+		bus_space_write_4(sc->sc_memt, sc->sc_memh, HPET_CONFIG, val);
+	}
+
+	tc->tc_priv = sc;
+	tc_init(tc);
+}
+
+static u_int
+hpet_get_timecount(struct timecounter *tc) {
+	struct hpet_softc *sc = tc->tc_priv;
+
+	return bus_space_read_4(sc->sc_memt, sc->sc_memh, HPET_MCOUNT);
+}
+
Index: sys/dev/ic/hpetreg.h
===================================================================
RCS file: sys/dev/ic/hpetreg.h
diff -N sys/dev/ic/hpetreg.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sys/dev/ic/hpetreg.h	5 Dec 2006 19:18:32 -0000
@@ -0,0 +1,41 @@
+/* $NetBSD$ */
+
+/*
+ * Copyright (c) 2006 Nicolas Joly
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _DEV_IC_HPETREG_H_
+#define _DEV_IC_HPETREG_H_
+
+#define HPET_INFO	0x00
+#define HPET_INFO_64BIT		0x2000
+#define HPET_PERIOD	0x04
+#define HPET_CONFIG	0x10
+#define HPET_CONFIG_ENABLE	0x0001
+#define HPET_MCOUNT	0xf0
+
+#endif /* _DEV_IC_HPETREG_H_ */
Index: sys/dev/ic/hpetvar.h
===================================================================
RCS file: sys/dev/ic/hpetvar.h
diff -N sys/dev/ic/hpetvar.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ sys/dev/ic/hpetvar.h	5 Dec 2006 19:18:32 -0000
@@ -0,0 +1,45 @@
+/* $NetBSD$ */
+
+/*
+ * Copyright (c) 2006 Nicolas Joly
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _DEV_IC_HPETVAR_H_
+#define _DEV_IC_HPETVAR_H_
+
+struct hpet_softc {
+	struct device	sc_dev;
+
+	bus_space_tag_t	sc_memt;
+	bus_space_handle_t sc_memh;
+
+	struct timecounter sc_tc;
+};
+
+void	hpet_attach_subr(struct hpet_softc *);
+
+#endif /* _DEV_IC_HPETVAR_H_ */