Module Name: src
Committed By: mbalmer
Date: Thu Aug 11 07:33:26 UTC 2011
Modified Files:
src/distrib/sets/lists/man: mi
src/distrib/sets/lists/modules: mi
src/share/man/man4: Makefile
src/sys/dev/pci: files.pci
src/sys/modules: Makefile
Added Files:
src/share/man/man4: pwdog.4
src/sys/dev/pci: pwdog.c
src/sys/modules/pwdog: Makefile pwdog.ioconf
Log Message:
pwdog(4) is a device driver for QUANCOM Electronic PWDOG1 PCI
attached watchdog timers.
To generate a diff of this commit:
cvs rdiff -u -r1.1330 -r1.1331 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.26 -r1.27 src/distrib/sets/lists/modules/mi
cvs rdiff -u -r1.562 -r1.563 src/share/man/man4/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man4/pwdog.4
cvs rdiff -u -r1.343 -r1.344 src/sys/dev/pci/files.pci
cvs rdiff -u -r0 -r1.1 src/sys/dev/pci/pwdog.c
cvs rdiff -u -r1.86 -r1.87 src/sys/modules/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/pwdog/Makefile \
src/sys/modules/pwdog/pwdog.ioconf
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/man/mi
diff -u src/distrib/sets/lists/man/mi:1.1330 src/distrib/sets/lists/man/mi:1.1331
--- src/distrib/sets/lists/man/mi:1.1330 Thu Aug 4 21:59:35 2011
+++ src/distrib/sets/lists/man/mi Thu Aug 11 07:33:25 2011
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1330 2011/08/04 21:59:35 riz Exp $
+# $NetBSD: mi,v 1.1331 2011/08/11 07:33:25 mbalmer Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -1418,6 +1418,7 @@
./usr/share/man/cat4/puc.0 man-sys-catman .cat
./usr/share/man/cat4/pud.0 man-sys-catman .cat
./usr/share/man/cat4/puffs.0 man-puffs-catman .cat
+./usr/share/man/cat4/pwdog.0 man-sys-catman .cat
./usr/share/man/cat4/px.0 man-sys-catman .cat
./usr/share/man/cat4/pxg.0 man-sys-catman .cat
./usr/share/man/cat4/qe.0 man-sys-catman .cat
@@ -4158,6 +4159,7 @@
./usr/share/man/html4/puc.html man-sys-htmlman html
./usr/share/man/html4/pud.html man-sys-htmlman html
./usr/share/man/html4/puffs.html man-sys-htmlman html
+./usr/share/man/html4/pwdog.html man-sys-htmlman html
./usr/share/man/html4/px.html man-sys-htmlman html
./usr/share/man/html4/pxg.html man-sys-htmlman html
./usr/share/man/html4/qe.html man-sys-htmlman html
@@ -6803,6 +6805,7 @@
./usr/share/man/man4/puc.4 man-sys-man .man
./usr/share/man/man4/pud.4 man-sys-man .man
./usr/share/man/man4/puffs.4 man-sys-man .man
+./usr/share/man/man4/pwdog.4 man-sys-man .man
./usr/share/man/man4/px.4 man-sys-man .man
./usr/share/man/man4/pxg.4 man-sys-man .man
./usr/share/man/man4/qe.4 man-sys-man .man
Index: src/distrib/sets/lists/modules/mi
diff -u src/distrib/sets/lists/modules/mi:1.26 src/distrib/sets/lists/modules/mi:1.27
--- src/distrib/sets/lists/modules/mi:1.26 Tue Aug 9 01:42:57 2011
+++ src/distrib/sets/lists/modules/mi Thu Aug 11 07:33:25 2011
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.26 2011/08/09 01:42:57 jmcneill Exp $
+# $NetBSD: mi,v 1.27 2011/08/11 07:33:25 mbalmer Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -110,6 +110,8 @@
./@MODULEDIR@/puffs/puffs.kmod base-kernel-modules kmod
./@MODULEDIR@/putter base-kernel-modules kmod
./@MODULEDIR@/putter/putter.kmod base-kernel-modules kmod
+./@MODULEDIR@/pwdog base-kernel-modules kmod
+./@MODULEDIR@/pwdog/pwdog.kmod base-kernel-modules kmod
./@MODULEDIR@/scsiverbose base-kernel-modules kmod
./@MODULEDIR@/scsiverbose/scsiverbose.kmod base-kernel-modules kmod
./@MODULEDIR@/sdt base-kernel-modules kmod,dtrace
Index: src/share/man/man4/Makefile
diff -u src/share/man/man4/Makefile:1.562 src/share/man/man4/Makefile:1.563
--- src/share/man/man4/Makefile:1.562 Wed Jul 20 20:51:12 2011
+++ src/share/man/man4/Makefile Thu Aug 11 07:33:25 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.562 2011/07/20 20:51:12 jakllsch Exp $
+# $NetBSD: Makefile,v 1.563 2011/08/11 07:33:25 mbalmer Exp $
# @(#)Makefile 8.1 (Berkeley) 6/18/93
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -45,7 +45,7 @@
pad.4 pas.4 pcdisplay.4 pcf8563rtc.4 pciide.4 pckbc.4 pckbd.4 pcn.4 \
pcppi.4 pcscp.4 pcweasel.4 pdcide.4 pdcsata.4 piixide.4 piixpcib.4 \
piixpm.4 pim.4 plip.4 pms.4 pmu.4 pnaphy.4 ppbus.4 ppp.4 pppoe.4 \
- pseye.4 ptm.4 pty.4 puc.4 pud.4 puffs.4 px.4 pxg.4 \
+ pseye.4 ptm.4 pty.4 puc.4 pud.4 puffs.4 pwdog.4 px.4 pxg.4 \
qe.4 qec.4 qsphy.4 \
raid.4 ral.4 ray.4 rcons.4 rdcphy.4 re.4 rgephy.4 rlphy.4 \
rnd.4 route.4 rs5c372rtc.4 rtk.4 rtw.4 rum.4 \
Index: src/sys/dev/pci/files.pci
diff -u src/sys/dev/pci/files.pci:1.343 src/sys/dev/pci/files.pci:1.344
--- src/sys/dev/pci/files.pci:1.343 Thu Aug 4 14:43:55 2011
+++ src/sys/dev/pci/files.pci Thu Aug 11 07:33:24 2011
@@ -1,4 +1,4 @@
-# $NetBSD: files.pci,v 1.343 2011/08/04 14:43:55 jakllsch Exp $
+# $NetBSD: files.pci,v 1.344 2011/08/11 07:33:24 mbalmer Exp $
#
# Config file and device description for machine-independent PCI code.
# Included by ports that need it. Requires that the SCSI files be
@@ -1058,3 +1058,9 @@
device coram: dtvbus, i2cbus, i2cexec, mt2131, cx24227
attach coram at pci
file dev/pci/coram.c coram
+
+# QUANCOM Electronic GmbH PWDOG1
+device pwdog: sysmon_envsys
+attach pwdog at pci
+file dev/pci/pwdog.c pwdog
+
Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.86 src/sys/modules/Makefile:1.87
--- src/sys/modules/Makefile:1.86 Tue Aug 9 12:16:03 2011
+++ src/sys/modules/Makefile Thu Aug 11 07:33:25 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.86 2011/08/09 12:16:03 jruoho Exp $
+# $NetBSD: Makefile,v 1.87 2011/08/11 07:33:25 mbalmer Exp $
.include <bsd.own.mk>
@@ -49,6 +49,7 @@
SUBDIR+= ptyfs
SUBDIR+= puffs
SUBDIR+= putter
+SUBDIR+= pwdog
SUBDIR+= scsiverbose
SUBDIR+= secmodel_bsd44
SUBDIR+= secmodel_overlay
Added files:
Index: src/share/man/man4/pwdog.4
diff -u /dev/null src/share/man/man4/pwdog.4:1.1
--- /dev/null Thu Aug 11 07:33:26 2011
+++ src/share/man/man4/pwdog.4 Thu Aug 11 07:33:25 2011
@@ -0,0 +1,55 @@
+.\" $NetBSD: pwdog.4,v 1.1 2011/08/11 07:33:25 mbalmer Exp $
+.\" $OpenBSD: pwdog.4,v 1.6 2007/12/23 22:16:39 jmc Exp $
+.\"
+.\" Copyright (c) 2011 Marc Balmer <[email protected]>
+.\" Copyright (c) 2006 Marc Balmer <[email protected]>
+.\"
+.\" 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.
+.\"
+.Dd August 11, 2011
+.Dt PWDOG 4
+.Os
+.Sh NAME
+.Nm pwdog
+.Nd Quancom PWDOG1 watchdog timer device
+.Sh SYNOPSIS
+.Cd "pwdog0 at pci?"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for Quancom PWDOG1 boards.
+.Pp
+If the kernel crashes, the watchdog timer is not reset and the system will
+reboot (assuming a proper connection is made between the PWDOG1 and
+the motherboard).
+Alternatively, the watchdog can be reinitialized via a userland process which
+ensures that process scheduling, not just kernel timeout processing, is still
+taking place.
+.Pp
+The timeout period of the PWDOG1 card is set using DIP switches and cannot
+be changed by software.
+.Sh SEE ALSO
+.Xr intro 4 ,
+.Xr pci 4
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Ox 4.1
+and
+.Nx 6.0 .
+.Sh AUTHORS
+The
+.Nm
+driver was written by
+.An Marc Balmer Aq [email protected] .
Index: src/sys/dev/pci/pwdog.c
diff -u /dev/null src/sys/dev/pci/pwdog.c:1.1
--- /dev/null Thu Aug 11 07:33:26 2011
+++ src/sys/dev/pci/pwdog.c Thu Aug 11 07:33:24 2011
@@ -0,0 +1,206 @@
+/* $$NetBSD: pwdog.c,v 1.1 2011/08/11 07:33:24 mbalmer Exp $ */
+/* $OpenBSD: pwdog.c,v 1.7 2010/04/08 00:23:53 tedu Exp $ */
+
+/*
+ * Copyright (c) 2011 Marc Balmer <[email protected]>
+ * Copyright (c) 2006 Marc Balmer <[email protected]>
+ *
+ * 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/types.h>
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#ifdef _MODULE
+#include <sys/module.h>
+#endif
+#include <sys/systm.h>
+
+/* #include <machine/bus.h> */
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pcidevs.h>
+
+#include <dev/sysmon/sysmonvar.h>
+
+struct pwdog_softc {
+ device_t sc_dev;
+
+ bus_space_tag_t sc_iot;
+ bus_space_handle_t sc_ioh;
+ bus_size_t sc_iosize;
+
+ struct sysmon_wdog sc_smw;
+ bool sc_smw_valid;
+};
+
+/* registers */
+#define PWDOG_ACTIVATE 0
+#define PWDOG_DISABLE 1
+
+/* maximum timeout period in seconds */
+#define PWDOG_MAX_PERIOD (12*60) /* 12 minutes */
+
+static int pwdog_match(device_t, cfdata_t, void *);
+static void pwdog_attach(device_t, device_t, void *);
+static int pwdog_detach(device_t, int);
+static bool pwdog_suspend(device_t, const pmf_qual_t *);
+static int pwdog_setmode(struct sysmon_wdog *smw);
+static int pwdog_tickle(struct sysmon_wdog *smw);
+
+CFATTACH_DECL_NEW(
+ pwdog,
+ sizeof(struct pwdog_softc),
+ pwdog_match,
+ pwdog_attach,
+ pwdog_detach,
+ NULL
+);
+
+static int
+pwdog_match(device_t parent, cfdata_t match, void *aux)
+{
+ struct pci_attach_args *pa = (struct pci_attach_args *)aux;
+
+ if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_QUANCOM &&
+ PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_QUANCOM_PWDOG1)
+ return 1;
+ return 0;
+}
+
+void
+pwdog_attach(device_t parent, device_t self, void *aux)
+{
+ struct pwdog_softc *sc = device_private(self);
+ struct pci_attach_args *const pa = (struct pci_attach_args *)aux;
+ pcireg_t memtype;
+
+ memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, PCI_MAPREG_START);
+ if (pci_mapreg_map(pa, PCI_MAPREG_START, memtype, 0, &sc->sc_iot,
+ &sc->sc_ioh, NULL, &sc->sc_iosize)) {
+ aprint_error("\n");
+ aprint_error_dev(self, "PCI %s region not found\n",
+ memtype == PCI_MAPREG_TYPE_IO ? "I/O" : "memory");
+ return;
+ }
+ printf("\n");
+
+ sc->sc_dev = self;
+
+ pmf_device_register(self, pwdog_suspend, NULL);
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, PWDOG_DISABLE, 0);
+
+ sc->sc_smw.smw_name = device_xname(self);
+ sc->sc_smw.smw_cookie = sc;
+ sc->sc_smw.smw_setmode = pwdog_setmode;
+ sc->sc_smw.smw_tickle = pwdog_tickle;
+ sc->sc_smw.smw_period = PWDOG_MAX_PERIOD;
+
+ if (sysmon_wdog_register(&sc->sc_smw))
+ aprint_error_dev(self, "couldn't register with sysmon\n");
+ else
+ sc->sc_smw_valid = true;
+}
+
+static int
+pwdog_detach(device_t self, int flags)
+{
+ struct pwdog_softc *sc = device_private(self);
+
+ if (sc->sc_smw_valid) {
+ if ((sc->sc_smw.smw_mode & WDOG_MODE_MASK)
+ != WDOG_MODE_DISARMED)
+ return EBUSY;
+
+ sysmon_wdog_unregister(&sc->sc_smw);
+ sc->sc_smw_valid = false;
+ }
+
+ pmf_device_deregister(self);
+
+ if (sc->sc_iosize)
+ bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_iosize);
+ return 0;
+}
+
+static bool
+pwdog_suspend(device_t self, const pmf_qual_t *qual)
+{
+ struct pwdog_softc *sc = device_private(self);
+
+ if (sc->sc_smw_valid == false)
+ return true;
+
+ if ((sc->sc_smw.smw_mode & WDOG_MODE_MASK) != WDOG_MODE_DISARMED)
+ return false;
+
+ return true;
+}
+
+static int
+pwdog_setmode(struct sysmon_wdog *smw)
+{
+ struct pwdog_softc *sc = smw->smw_cookie;
+
+ switch (smw->smw_mode & WDOG_MODE_MASK) {
+ case WDOG_MODE_DISARMED:
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, PWDOG_DISABLE, 0);
+ break;
+ default:
+ /* NB: the timer period set by the user is ignored */
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, PWDOG_ACTIVATE, 0);
+ }
+ return 0;
+}
+
+static int
+pwdog_tickle(struct sysmon_wdog *smw)
+{
+ struct pwdog_softc *sc = smw->smw_cookie;
+
+ bus_space_write_1(sc->sc_iot, sc->sc_ioh, PWDOG_ACTIVATE, 0);
+ return 0;
+}
+
+#ifdef _MODULE
+MODULE(MODULE_CLASS_DRIVER, pwdog, NULL);
+
+#include "ioconf.c"
+
+static int
+pwdog_modcmd(modcmd_t cmd, void *opaque)
+{
+ int error;
+
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ error = config_init_component(cfdriver_ioconf_pwdog,
+ cfattach_ioconf_pwdog, cfdata_ioconf_pwdog);
+ if (error) {
+ aprint_error("%s: unable to init component\n",
+ pwdog_cd.cd_name);
+ return error;
+ }
+ return 0;
+ case MODULE_CMD_FINI:
+ config_fini_component(cfdriver_ioconf_pwdog,
+ cfattach_ioconf_pwdog, cfdata_ioconf_pwdog);
+ return 0;
+ default:
+ return ENOTTY;
+ }
+}
+
+#endif /* _MODULE */
Index: src/sys/modules/pwdog/Makefile
diff -u /dev/null src/sys/modules/pwdog/Makefile:1.1
--- /dev/null Thu Aug 11 07:33:26 2011
+++ src/sys/modules/pwdog/Makefile Thu Aug 11 07:33:25 2011
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1 2011/08/11 07:33:25 mbalmer Exp $
+
+.include "../Makefile.inc"
+
+.PATH: ${S}/dev/pci
+
+KMOD= pwdog
+IOCONF= pwdog.ioconf
+SRCS= pwdog.c
+
+CPPFLAGS+= -I${S}/pci
+
+.include <bsd.kmodule.mk>
+
Index: src/sys/modules/pwdog/pwdog.ioconf
diff -u /dev/null src/sys/modules/pwdog/pwdog.ioconf:1.1
--- /dev/null Thu Aug 11 07:33:26 2011
+++ src/sys/modules/pwdog/pwdog.ioconf Thu Aug 11 07:33:25 2011
@@ -0,0 +1,11 @@
+# $NetBSD: pwdog.ioconf,v 1.1 2011/08/11 07:33:25 mbalmer Exp $
+
+ioconf pwdog
+
+include "conf/files"
+include "dev/i2o/files.i2o"
+include "dev/pci/files.pci"
+
+pseudo-root pci*
+pwdog* at pci?
+