summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2006-03-06 03:13:43 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2006-03-06 03:13:43 +0000
commit50e4354e596283140e602b29da43d441ad981651 (patch)
tree6bffc24d9375343be87a8260ff8fa48b686b67d0 /sys
parent61c7ba14e20c8d045f94a8a045d586484f8eea14 (diff)
Rename hpet to acpihpet so that all devices use the same naming convention.
discussed with jordan.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/conf/GENERIC16
-rw-r--r--sys/arch/i386/conf/GENERIC16
-rw-r--r--sys/dev/acpi/acpihpet.c144
-rw-r--r--sys/dev/acpi/files.acpi9
4 files changed, 164 insertions, 21 deletions
diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC
index 5fef33b2614..898c0bae9f6 100644
--- a/sys/arch/amd64/conf/GENERIC
+++ b/sys/arch/amd64/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.115 2006/03/05 09:12:57 jmc Exp $
+# $OpenBSD: GENERIC,v 1.116 2006/03/06 03:13:42 marco Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -45,13 +45,13 @@ pci* at mainbus0
#option ACPIVERBOSE
#option ACPI_ENABLE
-#acpi0 at mainbus?
-#acpitimer* at acpi?
-#hpet* at acpi?
-#acpiac* at acpi?
-#acpibat* at acpi?
-#acpibtn* at acpi?
-#acpicpu* at acpi?
+#acpi0 at mainbus?
+#acpitimer* at acpi?
+#acpihpet* at acpi?
+#acpiac* at acpi?
+#acpibat* at acpi?
+#acpibtn* at acpi?
+#acpicpu* at acpi?
ipmi0 at mainbus? # IPMI
diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC
index 02096997e4c..492544b7724 100644
--- a/sys/arch/i386/conf/GENERIC
+++ b/sys/arch/i386/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.474 2006/03/04 16:27:03 grange Exp $
+# $OpenBSD: GENERIC,v 1.475 2006/03/06 03:13:42 marco Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -62,13 +62,13 @@ pci* at mainbus0
option ACPIVERBOSE
#option ACPI_ENABLE
-#acpi0 at mainbus?
-#acpitimer* at acpi?
-#hpet* at acpi?
-#acpiac* at acpi?
-#acpibat* at acpi?
-#acpibtn* at acpi?
-#acpicpu* at acpi?
+#acpi0 at mainbus?
+#acpitimer* at acpi?
+#acpihpet* at acpi?
+#acpiac* at acpi?
+#acpibat* at acpi?
+#acpibtn* at acpi?
+#acpicpu* at acpi?
option PCIVERBOSE
option EISAVERBOSE
diff --git a/sys/dev/acpi/acpihpet.c b/sys/dev/acpi/acpihpet.c
new file mode 100644
index 00000000000..4c1e3c2b009
--- /dev/null
+++ b/sys/dev/acpi/acpihpet.c
@@ -0,0 +1,144 @@
+/* $OpenBSD: acpihpet.c,v 1.1 2006/03/06 03:13:42 marco Exp $ */
+/*
+ * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#ifdef __HAVE_TIMECOUNTER
+#include <sys/timetc.h>
+#endif
+
+#include <machine/bus.h>
+
+#include <dev/acpi/acpireg.h>
+#include <dev/acpi/acpivar.h>
+#include <dev/acpi/acpidev.h>
+
+int acpihpet_match(struct device *, void *, void *);
+void acpihpet_attach(struct device *, struct device *, void *);
+
+#ifdef __HAVE_TIMECOUNTER
+u_int acpihpet_gettime(struct timecounter *tc);
+
+static struct timecounter hpet_timecounter = {
+ acpihpet_gettime, /* get_timecount */
+ 0, /* no poll_pps */
+ 0xffffffff, /* counter_mask (24 bits) */
+ 0, /* frequency */
+ 0, /* name */
+ 1000 /* quality */
+};
+#endif
+
+struct acpihpet_softc {
+ struct device sc_dev;
+
+ bus_space_tag_t sc_iot;
+ bus_space_handle_t sc_ioh;
+};
+
+struct cfattach acpihpet_ca = {
+ sizeof(struct acpihpet_softc), acpihpet_match, acpihpet_attach
+};
+
+struct cfdriver acpihpet_cd = {
+ NULL, "acpihpet", DV_DULL
+};
+
+int
+acpihpet_match(struct device *parent, void *match, void *aux)
+{
+ struct acpi_attach_args *aaa = aux;
+ struct acpi_table_header *hdr;
+
+ /*
+ * If we do not have a table, it is not us
+ */
+ if (aaa->aaa_table == NULL)
+ return (0);
+
+ /*
+ * If it is an HPET table, we can attach
+ */
+ hdr = (struct acpi_table_header *)aaa->aaa_table;
+ if (memcmp(hdr->signature, HPET_SIG, sizeof(HPET_SIG) - 1) != 0)
+ return (0);
+
+ return (1);
+}
+
+void
+acpihpet_attach(struct device *parent, struct device *self, void *aux)
+{
+ struct acpihpet_softc *sc = (struct acpihpet_softc *) self;
+ struct acpi_attach_args *aa = aux;
+ struct acpi_hpet *hpet = (struct acpi_hpet *)aa->aaa_table;
+ u_int64_t period, freq; /* timer period in femtoseconds (10^-15) */
+
+ switch (hpet->base_address.address_space_id) {
+ case GAS_SYSTEM_MEMORY:
+ sc->sc_iot = aa->aaa_memt;
+ break;
+
+ case GAS_SYSTEM_IOSPACE:
+ sc->sc_iot = aa->aaa_iot;
+ break;
+
+#if 0
+ case GAS_SYSTEM_PCI_CFG_SPACE:
+ sc->sc_iot = aa->aaa_pcit;
+ break;
+
+ case GAS_SYSTEM_SMBUS:
+ sc->sc_iot = aa->aaa_smbust;
+ break;
+#endif
+
+ default:
+ printf(": can't identify bus\n");
+ return;
+ }
+
+ if (bus_space_map(sc->sc_iot, hpet->base_address.address,
+ HPET_REG_SIZE, 0, &sc->sc_ioh)) {
+ printf(": can't map i/o space\n");
+ return;
+ }
+
+ period = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
+ HPET_CAPABILITIES + sizeof(u_int32_t));
+ freq = 1000000000000000ull / period;
+ printf(": %lld Hz\n", freq);
+
+#ifdef __HAVE_TIMECOUNTER
+ hpet_timecounter.tc_frequency = (u_int32_t)freq;
+ hpet_timecounter.tc_priv = sc;
+ hpet_timecounter.tc_name = sc->sc_dev.dv_xname;
+ tc_init(&hpet_timecounter);
+#endif
+}
+
+#ifdef __HAVE_TIMECOUNTER
+u_int
+acpihpet_gettime(struct timecounter *tc)
+{
+ struct acpihpet_softc *sc = tc->tc_priv;
+
+ return (bus_space_read_4(sc->sc_iot, sc->sc_ioh, HPET_MAIN_COUNTER));
+}
+#endif
diff --git a/sys/dev/acpi/files.acpi b/sys/dev/acpi/files.acpi
index 10dd854347a..56e4d00cb4e 100644
--- a/sys/dev/acpi/files.acpi
+++ b/sys/dev/acpi/files.acpi
@@ -1,4 +1,4 @@
-# $OpenBSD: files.acpi,v 1.9 2006/03/05 14:46:46 marco Exp $
+# $OpenBSD: files.acpi,v 1.10 2006/03/06 03:13:42 marco Exp $
#
# Config file and device description for machine-independent ACPI code.
# Included by ports that need it.
@@ -37,7 +37,6 @@ attach acpicpu at acpi
file dev/acpi/acpicpu.c acpicpu
# High Precision Event Timer
-device hpet
-attach hpet at acpi
-file dev/acpi/hpet.c hpet
-
+device acpihpet
+attach acpihpet at acpi
+file dev/acpi/acpihpet.c acpihpet