Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src pwdog(4) is a device driver for QUANCOM Electronic PWDOG1 PCI



details:   https://anonhg.NetBSD.org/src/rev/23c4943f2f73
branches:  trunk
changeset: 768183:23c4943f2f73
user:      mbalmer <mbalmer%NetBSD.org@localhost>
date:      Thu Aug 11 07:33:24 2011 +0000

description:
pwdog(4) is a device driver for QUANCOM Electronic PWDOG1 PCI
attached watchdog timers.

diffstat:

 distrib/sets/lists/man/mi      |    5 +-
 distrib/sets/lists/modules/mi  |    4 +-
 share/man/man4/Makefile        |    4 +-
 share/man/man4/pwdog.4         |   55 ++++++++++
 sys/dev/pci/files.pci          |    8 +-
 sys/dev/pci/pwdog.c            |  206 +++++++++++++++++++++++++++++++++++++++++
 sys/modules/Makefile           |    3 +-
 sys/modules/pwdog/Makefile     |   14 ++
 sys/modules/pwdog/pwdog.ioconf |   11 ++
 9 files changed, 304 insertions(+), 6 deletions(-)

diffs (truncated from 407 to 300 lines):

diff -r 2b443977a9da -r 23c4943f2f73 distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Wed Aug 10 21:46:02 2011 +0000
+++ b/distrib/sets/lists/man/mi Thu Aug 11 07:33:24 2011 +0000
@@ -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
diff -r 2b443977a9da -r 23c4943f2f73 distrib/sets/lists/modules/mi
--- a/distrib/sets/lists/modules/mi     Wed Aug 10 21:46:02 2011 +0000
+++ b/distrib/sets/lists/modules/mi     Thu Aug 11 07:33:24 2011 +0000
@@ -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
diff -r 2b443977a9da -r 23c4943f2f73 share/man/man4/Makefile
--- a/share/man/man4/Makefile   Wed Aug 10 21:46:02 2011 +0000
+++ b/share/man/man4/Makefile   Thu Aug 11 07:33:24 2011 +0000
@@ -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 \
diff -r 2b443977a9da -r 23c4943f2f73 share/man/man4/pwdog.4
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man4/pwdog.4    Thu Aug 11 07:33:24 2011 +0000
@@ -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 <mbalmer%NetBSD.org@localhost>
+.\" Copyright (c) 2006 Marc Balmer <mbalmer%openbsd.org@localhost>
+.\"
+.\" 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 mbalmer%NetBSD.org@localhost .
diff -r 2b443977a9da -r 23c4943f2f73 sys/dev/pci/files.pci
--- a/sys/dev/pci/files.pci     Wed Aug 10 21:46:02 2011 +0000
+++ b/sys/dev/pci/files.pci     Thu Aug 11 07:33:24 2011 +0000
@@ -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
+
diff -r 2b443977a9da -r 23c4943f2f73 sys/dev/pci/pwdog.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/pci/pwdog.c       Thu Aug 11 07:33:24 2011 +0000
@@ -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 <mbalmer%NetBSD.org@localhost>
+ * Copyright (c) 2006 Marc Balmer <mbalmer%openbsd.org@localhost>
+ *
+ * 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;



Home | Main Index | Thread Index | Old Index