Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Factor out hpet(4) from ichlpcib(4).
details: https://anonhg.NetBSD.org/src/rev/17938963f5dc
branches: trunk
changeset: 766086:17938963f5dc
user: jruoho <jruoho%NetBSD.org@localhost>
date: Wed Jun 15 06:43:20 2011 +0000
description:
Factor out hpet(4) from ichlpcib(4).
diffstat:
sys/arch/x86/pci/files.pci | 7 +-
sys/arch/x86/pci/ichlpcib.c | 91 +-----------------------------
sys/arch/x86/pci/ichlpcib_hpet.c | 114 +++++++++++++++++++++++++++++++++++++++
sys/dev/ic/i82801lpcvar.h | 39 +++++++++++++
4 files changed, 161 insertions(+), 90 deletions(-)
diffs (truncated from 390 to 300 lines):
diff -r b934c5a1e7f8 -r 17938963f5dc sys/arch/x86/pci/files.pci
--- a/sys/arch/x86/pci/files.pci Wed Jun 15 06:28:39 2011 +0000
+++ b/sys/arch/x86/pci/files.pci Wed Jun 15 06:43:20 2011 +0000
@@ -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,9 +39,10 @@
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
-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
diff -r b934c5a1e7f8 -r 17938963f5dc sys/arch/x86/pci/ichlpcib.c
--- a/sys/arch/x86/pci/ichlpcib.c Wed Jun 15 06:28:39 2011 +0000
+++ b/sys/arch/x86/pci/ichlpcib.c Wed Jun 15 06:43:20 2011 +0000
@@ -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
diff -r b934c5a1e7f8 -r 17938963f5dc sys/arch/x86/pci/ichlpcib_hpet.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/x86/pci/ichlpcib_hpet.c Wed Jun 15 06:43:20 2011 +0000
@@ -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);
Home |
Main Index |
Thread Index |
Old Index