Module Name:    src
Committed By:   jruoho
Date:           Wed Jun 15 06:43:21 UTC 2011

Modified Files:
        src/sys/arch/x86/pci: files.pci ichlpcib.c
Added Files:
        src/sys/arch/x86/pci: ichlpcib_hpet.c
        src/sys/dev/ic: i82801lpcvar.h

Log Message:
Factor out hpet(4) from ichlpcib(4).


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x86/pci/files.pci
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/x86/pci/ichlpcib.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/pci/ichlpcib_hpet.c
cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/i82801lpcvar.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/arch/x86/pci/files.pci
diff -u src/sys/arch/x86/pci/files.pci:1.11 src/sys/arch/x86/pci/files.pci:1.12
--- src/sys/arch/x86/pci/files.pci:1.11	Mon Apr  4 17:09:39 2011
+++ src/sys/arch/x86/pci/files.pci	Wed Jun 15 06:43:20 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: files.pci,v 1.11 2011/04/04 17:09:39 bouyer Exp $
+#	$NetBSD: files.pci,v 1.12 2011/06/15 06:43:20 jruoho Exp $
 
 device 	aapic
 attach 	aapic at pci
@@ -39,10 +39,11 @@
 define	hpetichbus {}
 device	ichlpcib: acpipmtimer, isabus, sysmon_wdog, fwhichbus, hpetichbus, gpiobus
 attach	ichlpcib at pci
-attach	hpet at hpetichbus with ichlpcib_hpet
-
 file 	arch/x86/pci/ichlpcib.c 	ichlpcib
 
+attach	hpet at hpetichbus with ichlpcib_hpet
+file    arch/x86/pci/ichlpcib_hpet.c	ichlpcib_hpet
+
 device	fwhrng
 attach	fwhrng at fwhichbus
 file	arch/x86/pci/fwhrng.c		fwhrng needs-flag

Index: src/sys/arch/x86/pci/ichlpcib.c
diff -u src/sys/arch/x86/pci/ichlpcib.c:1.30 src/sys/arch/x86/pci/ichlpcib.c:1.31
--- src/sys/arch/x86/pci/ichlpcib.c:1.30	Mon Jun  6 14:33:31 2011
+++ src/sys/arch/x86/pci/ichlpcib.c	Wed Jun 15 06:43:20 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ichlpcib.c,v 1.30 2011/06/06 14:33:31 msaitoh Exp $	*/
+/*	$NetBSD: ichlpcib.c,v 1.31 2011/06/15 06:43:20 jruoho Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ichlpcib.c,v 1.30 2011/06/06 14:33:31 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ichlpcib.c,v 1.31 2011/06/15 06:43:20 jruoho Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -59,10 +59,10 @@
 
 #include <dev/ic/acpipmtimer.h>
 #include <dev/ic/i82801lpcreg.h>
+#include <dev/ic/i82801lpcvar.h>
 #include <dev/ic/hpetreg.h>
 #include <dev/ic/hpetvar.h>
 
-#include "hpet.h"
 #include "pcibvar.h"
 #include "gpio.h"
 #include "fwhrng.h"
@@ -88,10 +88,8 @@
 	bus_space_handle_t	sc_ioh;
 	bus_size_t		sc_iosize;
 
-#if NHPET > 0
 	/* HPET variables. */
 	uint32_t		sc_hpet_reg;
-#endif
 
 #if NGPIO > 0
 	device_t		sc_gpiobus;
@@ -148,10 +146,8 @@
 static void speedstep_unconfigure(device_t);
 static int speedstep_sysctl_helper(SYSCTLFN_ARGS);
 
-#if NHPET > 0
 static void lpcib_hpet_configure(device_t);
 static int lpcib_hpet_unconfigure(device_t, int);
-#endif
 
 #if NGPIO > 0
 static void lpcib_gpio_configure(device_t);
@@ -292,10 +288,8 @@
 	/* Set up SpeedStep. */
 	speedstep_configure(self);
 
-#if NHPET > 0
 	/* Set up HPET. */
 	lpcib_hpet_configure(self);
-#endif
 
 #if NGPIO > 0
 	/* Set up GPIO */
@@ -371,19 +365,15 @@
 static int
 lpcibrescan(device_t self, const char *ifattr, const int *locators)
 {
-#if NHPET > 0 || NGPIO > 0 || NFWHRNG > 0
 	struct lpcib_softc *sc = device_private(self);
-#endif
 
 #if NFWHRNG > 0
 	if (ifattr_match(ifattr, "fwhichbus") && sc->sc_fwhbus == NULL)
 		lpcib_fwh_configure(self);
 #endif
 
-#if NHPET > 0
 	if (ifattr_match(ifattr, "hpetichbus") && sc->sc_hpetbus == NULL)
 		lpcib_hpet_configure(self);
-#endif
 
 #if NGPIO > 0
 	if (ifattr_match(ifattr, "gpiobus") && sc->sc_gpiobus == NULL)
@@ -406,10 +396,8 @@
 		return rc;
 #endif
 
-#if NHPET > 0
 	if ((rc = lpcib_hpet_unconfigure(self, flags)) != 0)
 		return rc;
-#endif
 
 #if NGPIO > 0
 	if ((rc = lpcib_gpio_unconfigure(self, flags)) != 0)
@@ -460,14 +448,10 @@
 
 	if (sc->sc_has_rcba) {
 		sc->sc_rcba_reg = pci_conf_read(pc, tag, LPCIB_RCBA);
-#if NHPET > 0
 		sc->sc_hpet_reg = bus_space_read_4(sc->sc_rcbat, sc->sc_rcbah,
 		    LPCIB_RCBA_HPTC);
-#endif
 	} else if (sc->sc_has_ich5_hpet) {
-#if NHPET > 0
 		sc->sc_hpet_reg = pci_conf_read(pc, tag, LPCIB_PCI_GEN_CNTL);
-#endif
 	}
 
 	return true;
@@ -489,14 +473,10 @@
 
 	if (sc->sc_has_rcba) {
 		pci_conf_write(pc, tag, LPCIB_RCBA, sc->sc_rcba_reg);
-#if NHPET > 0
 		bus_space_write_4(sc->sc_rcbat, sc->sc_rcbah, LPCIB_RCBA_HPTC,
 		    sc->sc_hpet_reg);
-#endif
 	} else if (sc->sc_has_ich5_hpet) {
-#if NHPET > 0
 		pci_conf_write(pc, tag, LPCIB_PCI_GEN_CNTL, sc->sc_hpet_reg);
-#endif
 	}
 
 	return true;
@@ -920,73 +900,11 @@
 	return error;
 }
 
-#if NHPET > 0
-struct lpcib_hpet_attach_arg {
-	bus_space_tag_t hpet_mem_t;
-	uint32_t hpet_reg;
-};
-
-static int
-lpcib_hpet_match(device_t parent, cfdata_t match, void *aux)
-{
-	struct lpcib_hpet_attach_arg *arg = aux;
-	bus_space_tag_t tag;
-	bus_space_handle_t handle;
-
-	tag = arg->hpet_mem_t;
-
-	if (bus_space_map(tag, arg->hpet_reg, HPET_WINDOW_SIZE, 0, &handle)) {
-		aprint_verbose_dev(parent, "HPET window not mapped, skipping\n");
-		return 0;
-	}
-	bus_space_unmap(tag, handle, HPET_WINDOW_SIZE);
-
-	return 1;
-}
-
-static int
-lpcib_hpet_detach(device_t self, int flags)
-{
-	struct hpet_softc *sc = device_private(self);
-	int rc;
-
-	if ((rc = hpet_detach(self, flags)) != 0)
-		return rc;
-
-	bus_space_unmap(sc->sc_memt, sc->sc_memh, HPET_WINDOW_SIZE);
-
-	return 0;
-}
-
-static void
-lpcib_hpet_attach(device_t parent, device_t self, void *aux)
-{
-	struct hpet_softc *sc = device_private(self);
-	struct lpcib_hpet_attach_arg *arg = aux;
-
-	aprint_naive("\n");
-	aprint_normal("\n");
-
-	sc->sc_memt = arg->hpet_mem_t;
-
-	if (bus_space_map(sc->sc_memt, arg->hpet_reg, HPET_WINDOW_SIZE, 0,
-			  &sc->sc_memh)) {
-		aprint_error_dev(self,
-		    "HPET memory window could not be mapped");
-		return;
-	}
-
-	hpet_attach_subr(self);
-}
-
-CFATTACH_DECL_NEW(ichlpcib_hpet, sizeof(struct hpet_softc), lpcib_hpet_match,
-    lpcib_hpet_attach, lpcib_hpet_detach, NULL);
-
 static void
 lpcib_hpet_configure(device_t self)
 {
 	struct lpcib_softc *sc = device_private(self);
-	struct lpcib_hpet_attach_arg arg;
+	struct lpcib_hpet_attach_args arg;
 	uint32_t hpet_reg, val;
 
 	if (sc->sc_has_ich5_hpet) {
@@ -1056,7 +974,6 @@
 
 	return 0;
 }
-#endif
 
 #if NGPIO > 0
 static void

Added files:

Index: src/sys/arch/x86/pci/ichlpcib_hpet.c
diff -u /dev/null src/sys/arch/x86/pci/ichlpcib_hpet.c:1.1
--- /dev/null	Wed Jun 15 06:43:21 2011
+++ src/sys/arch/x86/pci/ichlpcib_hpet.c	Wed Jun 15 06:43:21 2011
@@ -0,0 +1,114 @@
+/* $NetBSD: ichlpcib_hpet.c,v 1.1 2011/06/15 06:43:21 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Minoura Makoto and Matthew R. Green.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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: ichlpcib_hpet.c,v 1.1 2011/06/15 06:43:21 jruoho Exp $");
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/time.h>
+#include <sys/timetc.h>
+
+#include <machine/bus.h>
+
+#include <dev/ic/hpetreg.h>
+#include <dev/ic/hpetvar.h>
+#include <dev/ic/i82801lpcreg.h>
+#include <dev/ic/i82801lpcvar.h>
+
+static int	lpcib_hpet_match(device_t , cfdata_t , void *);
+static void	lpcib_hpet_attach(device_t, device_t, void *);
+static int	lpcib_hpet_detach(device_t, int);
+
+CFATTACH_DECL_NEW(ichlpcib_hpet, sizeof(struct hpet_softc),
+    lpcib_hpet_match, lpcib_hpet_attach, lpcib_hpet_detach, NULL);
+
+static int
+lpcib_hpet_match(device_t parent, cfdata_t match, void *aux)
+{
+	struct lpcib_hpet_attach_args *arg = aux;
+	bus_space_handle_t bh;
+	bus_space_tag_t bt;
+
+	bt = arg->hpet_mem_t;
+
+	if (bus_space_map(bt, arg->hpet_reg, HPET_WINDOW_SIZE, 0, &bh) != 0) {
+		aprint_verbose_dev(parent, "mem space not mapped, skipping\n");
+		return 0;
+	}
+
+	bus_space_unmap(bt, bh, HPET_WINDOW_SIZE);
+
+	return 1;
+}
+
+
+static void
+lpcib_hpet_attach(device_t parent, device_t self, void *aux)
+{
+	struct hpet_softc *sc = device_private(self);
+	struct lpcib_hpet_attach_args *arg = aux;
+
+	sc->sc_mapped = false;
+	sc->sc_memt = arg->hpet_mem_t;
+	sc->sc_mems = HPET_WINDOW_SIZE;
+
+	aprint_naive("\n");
+	aprint_normal(": mem 0x%08x-0x%08x\n",
+	    arg->hpet_reg, arg->hpet_reg + HPET_WINDOW_SIZE);
+
+	if (bus_space_map(sc->sc_memt, arg->hpet_reg,
+		sc->sc_mems, 0, &sc->sc_memh) != 0) {
+		aprint_error_dev(self, "failed to map mem space\n");
+		return;
+	}
+
+	sc->sc_mapped = true;
+	hpet_attach_subr(self);
+}
+
+static int
+lpcib_hpet_detach(device_t self, int flags)
+{
+	struct hpet_softc *sc = device_private(self);
+	int rv;
+
+	if (sc->sc_mapped != true)
+		return 0;
+
+	rv = hpet_detach(self, flags);
+
+	if (rv != 0)
+		return rv;
+
+	bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_mems);
+
+	return 0;
+}

Index: src/sys/dev/ic/i82801lpcvar.h
diff -u /dev/null src/sys/dev/ic/i82801lpcvar.h:1.1
--- /dev/null	Wed Jun 15 06:43:21 2011
+++ src/sys/dev/ic/i82801lpcvar.h	Wed Jun 15 06:43:21 2011
@@ -0,0 +1,39 @@
+/*	$NetBSD: i82801lpcvar.h,v 1.1 2011/06/15 06:43:21 jruoho Exp $	*/
+
+/*-
+ * Copyright (c) 2004 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Minoura Makoto and Matthew R. Green.
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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_I82801LPCVAR_H_
+#define	_DEV_IC_I82801LPCVAR_H_
+
+struct lpcib_hpet_attach_args {
+	bus_space_tag_t		hpet_mem_t;
+	uint32_t		hpet_reg;
+};
+
+#endif	/* !_DEV_IC_I82801LPCVAR_H_ */

Reply via email to