Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jan 2012 08:41:10 +0000 (UTC)
From:      Fabien Thomas <fabient@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r229928 - in stable/8: share/man/man4 sys/amd64/conf sys/conf sys/dev/viawd sys/i386/conf sys/modules sys/modules/viawd
Message-ID:  <201201100841.q0A8fAH9098207@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: fabient
Date: Tue Jan 10 08:41:10 2012
New Revision: 229928
URL: http://svn.freebsd.org/changeset/base/229928

Log:
  MFC r228431, r228502, r228802:
  Add watchdog support for VIA south bridge chipset.
  Tested on VT8251, VX900 but CX700, VX800, VX855 should works.

Added:
  stable/8/share/man/man4/viawd.4
     - copied unchanged from r228431, head/share/man/man4/viawd.4
  stable/8/sys/dev/viawd/
     - copied from r228431, head/sys/dev/viawd/
  stable/8/sys/modules/viawd/
     - copied from r228431, head/sys/modules/viawd/
Modified:
  stable/8/share/man/man4/Makefile
  stable/8/sys/amd64/conf/NOTES
  stable/8/sys/conf/files.amd64
  stable/8/sys/conf/files.i386
  stable/8/sys/dev/viawd/viawd.c
  stable/8/sys/dev/viawd/viawd.h
  stable/8/sys/i386/conf/NOTES
  stable/8/sys/modules/Makefile
Directory Properties:
  stable/8/share/man/man4/   (props changed)
  stable/8/sys/   (props changed)

Modified: stable/8/share/man/man4/Makefile
==============================================================================
--- stable/8/share/man/man4/Makefile	Tue Jan 10 08:16:28 2012	(r229927)
+++ stable/8/share/man/man4/Makefile	Tue Jan 10 08:41:10 2012	(r229928)
@@ -482,6 +482,7 @@ MAN=	aac.4 \
 	vga.4 \
 	vge.4 \
 	viapm.4 \
+	${_viawd.4} \
 	vinum.4 \
 	vkbd.4 \
 	vlan.4 \
@@ -688,6 +689,7 @@ _speaker.4=	speaker.4
 _spkr.4=	spkr.4
 _tpm.4=		tpm.4
 _urtw.4=	urtw.4
+_viawd.4=	viawd.4
 _wpi.4=		wpi.4
 _xen.4=		xen.4
 

Copied: stable/8/share/man/man4/viawd.4 (from r228431, head/share/man/man4/viawd.4)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/8/share/man/man4/viawd.4	Tue Jan 10 08:41:10 2012	(r229928, copy of r228431, head/share/man/man4/viawd.4)
@@ -0,0 +1,79 @@
+.\"-
+.\" Copyright (c) 2011 Fabien Thomas <fabient@FreeBSD.org>
+.\" All rights reserved.
+.\"
+.\" 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 AUTHOR 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 AUTHOR 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd December 7, 2011
+.Dt VIAWD 4
+.Os
+.Sh NAME
+.Nm viawd
+.Nd device driver for VIA south bridge watchdog timer
+.Sh SYNOPSIS
+To compile this driver into the kernel,
+place the following line in your
+kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device viawd"
+.Ed
+.Pp
+Alternatively, to load the driver as a
+module at boot time, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+viawd_load="YES"
+.Ed
+.Sh DESCRIPTION
+The
+.Nm
+driver provides
+.Xr watchdog 4
+support for the watchdog interrupt timer present on
+VIA south bridge chipset (VT8251, CX700, VX800, VX855, VX900).
+.Pp
+The VIA south bridge have a built-in watchdog timer,
+which can be enabled and disabled by user's program and set between
+1 to 1023 seconds.
+.Pp
+The
+.Nm
+driver when unloaded with running watchdog will reschedule the watchdog
+to 5 minutes.
+.Sh SEE ALSO
+.Xr watchdog 4 ,
+.Xr watchdog 8 ,
+.Xr watchdogd 8 ,
+.Xr watchdog 9
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Fx 10.0 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver and this manual page were written by
+.An Fabien Thomas Aq fabient@FreeBSD.org .

Modified: stable/8/sys/amd64/conf/NOTES
==============================================================================
--- stable/8/sys/amd64/conf/NOTES	Tue Jan 10 08:16:28 2012	(r229927)
+++ stable/8/sys/amd64/conf/NOTES	Tue Jan 10 08:41:10 2012	(r229928)
@@ -459,6 +459,7 @@ device		tpm
 #
 device		ichwd
 device		amdsbwd
+device		viawd
 
 #
 # Temperature sensors:

Modified: stable/8/sys/conf/files.amd64
==============================================================================
--- stable/8/sys/conf/files.amd64	Tue Jan 10 08:16:28 2012	(r229927)
+++ stable/8/sys/conf/files.amd64	Tue Jan 10 08:41:10 2012	(r229928)
@@ -231,6 +231,7 @@ dev/tpm/tpm.c			optional	tpm
 dev/tpm/tpm_acpi.c		optional	tpm acpi
 dev/tpm/tpm_isa.c		optional	tpm isa
 dev/uart/uart_cpu_amd64.c	optional	uart
+dev/viawd/viawd.c		optional	viawd
 dev/wpi/if_wpi.c		optional	wpi
 isa/syscons_isa.c		optional	sc
 isa/vga_isa.c			optional	vga

Modified: stable/8/sys/conf/files.i386
==============================================================================
--- stable/8/sys/conf/files.i386	Tue Jan 10 08:16:28 2012	(r229927)
+++ stable/8/sys/conf/files.i386	Tue Jan 10 08:41:10 2012	(r229928)
@@ -236,6 +236,7 @@ dev/tpm/tpm.c			optional tpm
 dev/tpm/tpm_acpi.c		optional tpm acpi
 dev/tpm/tpm_isa.c		optional tpm isa
 dev/uart/uart_cpu_i386.c	optional uart
+dev/viawd/viawd.c		optional viawd
 dev/acpica/acpi_if.m		standard
 dev/acpi_support/acpi_wmi_if.m	standard
 dev/wpi/if_wpi.c		optional wpi

Modified: stable/8/sys/dev/viawd/viawd.c
==============================================================================
--- head/sys/dev/viawd/viawd.c	Mon Dec 12 09:50:33 2011	(r228431)
+++ stable/8/sys/dev/viawd/viawd.c	Tue Jan 10 08:41:10 2012	(r229928)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2011 Fabien Thomas <fthomas@FreeBSD.org>
+ * Copyright (c) 2011 Fabien Thomas <fabient@FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,10 +42,9 @@ __FBSDID("$FreeBSD$");
 
 #include "viawd.h"
 
-#define viawd_read_wd_4(sc, off) \
-	bus_space_read_4((sc)->wd_bst, (sc)->wd_bsh, (off))
-#define viawd_write_wd_4(sc, off, val) \
-	bus_space_write_4((sc)->wd_bst, (sc)->wd_bsh, (off), (val))
+#define	viawd_read_4(sc, off)	bus_read_4((sc)->wd_res, (off))
+#define	viawd_write_4(sc, off, val)	\
+	bus_write_4((sc)->wd_res, (off), (val))
 
 static struct viawd_device viawd_devices[] = {
 	{ DEVICEID_VT8251, "VIA VT8251 watchdog timer" },
@@ -58,37 +57,17 @@ static struct viawd_device viawd_devices
 
 static devclass_t viawd_devclass;
 
-static device_t
-viawd_find(struct viawd_device **id_p)
-{
-	struct viawd_device *id;
-	device_t sb_dev = NULL;
-
-	/* Look for a supported VIA south bridge. */
-	for (id = viawd_devices; id->desc != NULL; ++id)
-		if ((sb_dev = pci_find_device(VENDORID_VIA, id->device)) != NULL)
-			break;
-
-	if (sb_dev == NULL)
-		return (NULL);
-
-	if (id_p != NULL)
-		*id_p = id;
-
-	return (sb_dev);
-}
-
 static void
 viawd_tmr_state(struct viawd_softc *sc, int enable)
 {
 	uint32_t reg;
 
-	reg = viawd_read_wd_4(sc, VIAWD_MEM_CTRL);
+	reg = viawd_read_4(sc, VIAWD_MEM_CTRL);
 	if (enable)
 		reg |= VIAWD_MEM_CTRL_TRIGGER | VIAWD_MEM_CTRL_ENABLE;
 	else
 		reg &= ~VIAWD_MEM_CTRL_ENABLE;
-	viawd_write_wd_4(sc, VIAWD_MEM_CTRL, reg);
+	viawd_write_4(sc, VIAWD_MEM_CTRL, reg);
 }
 
 static void
@@ -101,7 +80,7 @@ viawd_tmr_set(struct viawd_softc *sc, un
 	else if (timeout > VIAWD_MEM_COUNT_MAX)
 		timeout = VIAWD_MEM_COUNT_MAX;
 
-	viawd_write_wd_4(sc, VIAWD_MEM_COUNT, timeout);
+	viawd_write_4(sc, VIAWD_MEM_COUNT, timeout);
 	sc->timeout = timeout;
 }
 
@@ -127,35 +106,40 @@ viawd_event(void *arg, unsigned int cmd,
 		viawd_tmr_state(sc, 0);
 }
 
-static void
-viawd_identify(driver_t *driver, device_t parent)
+/* Look for a supported VIA south bridge. */
+static struct viawd_device *
+viawd_find(device_t dev)
 {
-	device_t dev;
-	device_t sb_dev;
-	struct viawd_device *id_p;
+	struct viawd_device *id;
 
-	sb_dev = viawd_find(&id_p);
-	if (sb_dev == NULL)
-		return;
+	if (pci_get_vendor(dev) != VENDORID_VIA)
+		return (NULL);
+	for (id = viawd_devices; id->desc != NULL; id++)
+		if (pci_get_device(dev) == id->device)
+			return (id);
+	return (NULL);
+}
 
-	/* Good, add child to bus. */
-	if ((dev = device_find_child(parent, driver->name, 0)) == NULL)
-		dev = BUS_ADD_CHILD(parent, 0, driver->name, 0);
+static void
+viawd_identify(driver_t *driver, device_t parent)
+{
 
-	if (dev == NULL)
+	if (viawd_find(parent) == NULL)
 		return;
 
-	device_set_desc_copy(dev, id_p->desc);
+	if (device_find_child(parent, driver->name, -1) == NULL)
+		BUS_ADD_CHILD(parent, 0, driver->name, 0);
 }
 
 static int
 viawd_probe(device_t dev)
 {
+	struct viawd_device *id;
 
-	/* Do not claim some ISA PnP device by accident. */
-	if (isa_get_logicalid(dev) != 0)
-		return (ENXIO);
-	return (0);
+	id = viawd_find(device_get_parent(dev));
+	KASSERT(id != NULL, ("parent should be a valid VIA SB"));
+	device_set_desc(dev, id->desc);
+	return (BUS_PROBE_GENERIC);
 }
 
 static int
@@ -163,13 +147,12 @@ viawd_attach(device_t dev)
 {
 	device_t sb_dev;
 	struct viawd_softc *sc;
-	struct viawd_device *id_p;
 	uint32_t pmbase, reg;
 
 	sc = device_get_softc(dev);
 	sc->dev = dev;
 
-	sb_dev = viawd_find(&id_p);
+	sb_dev = device_get_parent(dev);
 	if (sb_dev == NULL) {
 		device_printf(dev, "Can not find watchdog device.\n");
 		goto fail;
@@ -193,16 +176,14 @@ viawd_attach(device_t dev)
 		device_printf(dev, "Unable to map watchdog memory\n");
 		goto fail;
 	}
-	sc->wd_bst = rman_get_bustag(sc->wd_res);
-	sc->wd_bsh = rman_get_bushandle(sc->wd_res);
 
 	/* Check if watchdog fired last boot. */
-	reg = viawd_read_wd_4(sc, VIAWD_MEM_CTRL);
+	reg = viawd_read_4(sc, VIAWD_MEM_CTRL);
 	if (reg & VIAWD_MEM_CTRL_FIRED) {
 		device_printf(dev,
 		    "ERROR: watchdog rebooted the system\n");
 		/* Reset bit state. */
-		viawd_write_wd_4(sc, VIAWD_MEM_CTRL, reg);
+		viawd_write_4(sc, VIAWD_MEM_CTRL, reg);
 	}
 
 	/* Register the watchdog event handler. */
@@ -233,7 +214,7 @@ viawd_detach(device_t dev)
 	 * Do not stop the watchdog on shutdown if active but bump the
 	 * timer to avoid spurious reset.
 	 */
-	reg = viawd_read_wd_4(sc, VIAWD_MEM_CTRL);
+	reg = viawd_read_4(sc, VIAWD_MEM_CTRL);
 	if (reg & VIAWD_MEM_CTRL_ENABLE) {
 		viawd_tmr_set(sc, VIAWD_TIMEOUT_SHUTDOWN);
 		viawd_tmr_state(sc, 1);
@@ -264,23 +245,4 @@ static driver_t viawd_driver = {
 	sizeof(struct viawd_softc),
 };
 
-static int
-viawd_modevent(module_t mode, int type, void *data)
-{
-	int error = 0;
-
-	switch (type) {
-	case MOD_LOAD:
-		printf("viawd module loaded\n");
-		break;
-	case MOD_UNLOAD:
-		printf("viawd module unloaded\n");
-		break;
-	case MOD_SHUTDOWN:
-		printf("viawd module shutting down\n");
-		break;
-	}
-	return (error);
-}
-
-DRIVER_MODULE(viawd, isa, viawd_driver, viawd_devclass, viawd_modevent, NULL);
+DRIVER_MODULE(viawd, isab, viawd_driver, viawd_devclass, NULL, NULL);

Modified: stable/8/sys/dev/viawd/viawd.h
==============================================================================
--- head/sys/dev/viawd/viawd.h	Mon Dec 12 09:50:33 2011	(r228431)
+++ stable/8/sys/dev/viawd/viawd.h	Tue Jan 10 08:41:10 2012	(r229928)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2011 Fabien Thomas <fthomas@FreeBSD.org>
+ * Copyright (c) 2011 Fabien Thomas <fabient@FreeBSD.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -40,8 +40,6 @@ struct viawd_softc {
 
 	int			wd_rid;
 	struct resource		*wd_res;
-	bus_space_tag_t		wd_bst;
-	bus_space_handle_t	wd_bsh;
 
 	eventhandler_tag	ev_tag;
 	unsigned int		timeout;

Modified: stable/8/sys/i386/conf/NOTES
==============================================================================
--- stable/8/sys/i386/conf/NOTES	Tue Jan 10 08:16:28 2012	(r229927)
+++ stable/8/sys/i386/conf/NOTES	Tue Jan 10 08:41:10 2012	(r229928)
@@ -844,6 +844,7 @@ hint.pcf.0.irq="5"
 #
 device		ichwd
 device		amdsbwd
+device		viawd
 
 #
 # Temperature sensors:

Modified: stable/8/sys/modules/Makefile
==============================================================================
--- stable/8/sys/modules/Makefile	Tue Jan 10 08:16:28 2012	(r229927)
+++ stable/8/sys/modules/Makefile	Tue Jan 10 08:41:10 2012	(r229928)
@@ -306,6 +306,7 @@ SUBDIR=	${_3dfx} \
 	utopia \
 	${_vesa} \
 	vge \
+	${_viawd} \
 	vkbd \
 	${_vpo} \
 	vr \
@@ -503,6 +504,7 @@ _nve=		nve
 _nvram=		nvram
 _nxge=		nxge
 _tpm=		tpm
+_viawd=		viawd
 _wpi=		wpi
 _wpifw=		wpifw
 .if ${MK_CRYPT} != "no" || defined(ALL_MODULES)
@@ -602,6 +604,7 @@ _tmpfs=		tmpfs
 _tpm=		tpm
 _twa=		twa
 _vesa=		vesa
+_viawd=		viawd
 _x86bios=	x86bios
 _wi=		wi
 _wpi=		wpi



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201100841.q0A8fAH9098207>