From owner-svn-src-all@freebsd.org Sun Nov 29 08:59:57 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 426CA47B07D; Sun, 29 Nov 2020 08:59:57 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CkMkh5yyHz3ssP; Sun, 29 Nov 2020 08:59:56 +0000 (UTC) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: from gndrsh.dnsmgr.net (localhost [127.0.0.1]) by gndrsh.dnsmgr.net (8.13.3/8.13.3) with ESMTP id 0AT8xsBi040040; Sun, 29 Nov 2020 00:59:54 -0800 (PST) (envelope-from freebsd@gndrsh.dnsmgr.net) Received: (from freebsd@localhost) by gndrsh.dnsmgr.net (8.13.3/8.13.3/Submit) id 0AT8xsHM040039; Sun, 29 Nov 2020 00:59:54 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <202011290859.0AT8xsHM040039@gndrsh.dnsmgr.net> Subject: Re: svn commit: r368130 - in head: share/man/man4 sys/dev/ftwd sys/modules sys/modules/ftwd In-Reply-To: <202011282234.0ASMYYo8094034@repo.freebsd.org> To: Poul-Henning Kamp Date: Sun, 29 Nov 2020 00:59:54 -0800 (PST) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Rspamd-Queue-Id: 4CkMkh5yyHz3ssP X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Nov 2020 08:59:57 -0000 > Author: phk > Date: Sat Nov 28 22:34:33 2020 > New Revision: 368130 > URL: https://svnweb.freebsd.org/changeset/base/368130 > > Log: > Add watchdog(9) driver for the Fintek F81803 SuperIO chip > > Added: > head/share/man/man4/ftwd.4 (contents, props changed) > head/sys/dev/ftwd/ > head/sys/dev/ftwd/ftwd.c (contents, props changed) > head/sys/modules/ftwd/ > head/sys/modules/ftwd/Makefile (contents, props changed) > Modified: > head/share/man/man4/Makefile > head/sys/modules/Makefile > > Modified: head/share/man/man4/Makefile > ============================================================================== > --- head/share/man/man4/Makefile Sat Nov 28 18:09:16 2020 (r368129) > +++ head/share/man/man4/Makefile Sat Nov 28 22:34:33 2020 (r368130) > @@ -158,6 +158,7 @@ MAN= aac.4 \ > ffclock.4 \ > filemon.4 \ > firewire.4 \ > + ${_ftwd.4} \ > full.4 \ > fwe.4 \ > fwip.4 \ > @@ -785,6 +786,7 @@ _chvgpio.4= chvgpio.4 > _coretemp.4= coretemp.4 > _cpuctl.4= cpuctl.4 > _dpms.4= dpms.4 > +_ftwd.4= ftwd.4 > _hpt27xx.4= hpt27xx.4 > _hptiop.4= hptiop.4 > _hptmv.4= hptmv.4 > > Added: head/share/man/man4/ftwd.4 > ============================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/share/man/man4/ftwd.4 Sat Nov 28 22:34:33 2020 (r368130) > @@ -0,0 +1,66 @@ > +.\" > +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD > +.\" > +.\" Copyright (c) 2012 Bjoern A. Zeeb > +.\" Copyright (c) 2019 Andriy Gapon This appears to be a new file, perhaps cloned from some place else? And later you assert that you wrote this manual page, so shouldn't you also be the copyright holder? > +.\" > +.\" 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 November 26, 2020 > +.Dt FTWD 4 > +.Os > +.Sh NAME > +.Nm ftwd > +.Nd Fintek F81803 watchdog timer > +.Sh SYNOPSIS > +To compile this driver into the kernel, place the following lines in your > +kernel configuration file: > +.Bd -ragged -offset indent > +.Cd "device superio" > +.Cd "device ftwd" > +.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 > +ftwd_load="YES" > +.Ed > +.Sh DESCRIPTION > +The > +.Nm > +driver provides > +.Xr watchdog 4 > +support for the watchdog timer in the Fintek F81803 chip. > +.Sh SEE ALSO > +.Xr superio 4 , > +.Xr watchdog 4 , > +.Xr device.hints 5 , > +.Xr watchdog 8 , > +.Xr watchdogd 8 , > +.Xr watchdog 9 > +.Sh AUTHORS > +.An -nosplit > +This manual page was written by > +.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org . Here you claim you wrote it... > > Added: head/sys/dev/ftwd/ftwd.c > ============================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/sys/dev/ftwd/ftwd.c Sat Nov 28 22:34:33 2020 (r368130) > @@ -0,0 +1,157 @@ > +/*- > + * SPDX-License-Identifier: BSD-2-Clause > + * > + * Copyright (c) 2020 Poul-Henning Kamp > + * > + * 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. > + */ > + > +#include > +__FBSDID("$FreeBSD$"); > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > + > +#include > +#include > + > +struct ftwd_softc { > + eventhandler_tag wd_ev; > +}; > + > +static void > +ftwd_func(void *priv, u_int cmd, int *error) > +{ > + device_t dev = priv; > + uint64_t timeout; > + uint8_t val = 0; > + uint8_t minutes = 0; > + > + if (cmd != 0) { > + cmd &= WD_INTERVAL; > + > + /* Convert the requested timeout to seconds. */ > + if (cmd >= WD_TO_1SEC) > + timeout = (uint64_t)1 << (cmd - WD_TO_1SEC); > + else > + timeout = 1; > + > + if (timeout <= UINT8_MAX) { > + val = timeout; > + *error = 0; > + } else if ((timeout / 60) <= UINT8_MAX) { > + val = timeout / 60; > + minutes = 1; > + *error = 0; > + } > + } > + if (bootverbose) { > + if (val == 0) { > + device_printf(dev, "disabling watchdog\n"); > + } else { > + device_printf(dev, > + "arm watchdog to %d %s%s (Was: 0x%02x)\n", > + val, minutes ? "minute" : "second", > + val == 1 ? "" : "s", > + superio_read(dev, 0xf6) > + ); > + } > + } > + superio_write(dev, 0xf0, 0x00); // Disable WDTRST# > + superio_write(dev, 0xf6, val); // Set Counter > + > + if (minutes) > + superio_write(dev, 0xf5, 0x7d); // minutes, act high, 125ms > + else > + superio_write(dev, 0xf5, 0x75); // seconds, act high, 125ms > + > + if (val) > + superio_write(dev, 0xf7, 0x01); // Disable PME > + if (val) > + superio_write(dev, 0xf0, 0x81); // Enable WDTRST# > + else > + superio_write(dev, 0xf0, 0x00); // Disable WDTRST > +} > + > +static int > +ftwd_probe(device_t dev) > +{ > + > + if (superio_vendor(dev) != SUPERIO_VENDOR_FINTEK || > + superio_get_type(dev) != SUPERIO_DEV_WDT) > + return (ENXIO); > + device_set_desc(dev, "Watchdog Timer on Fintek SuperIO"); > + return (BUS_PROBE_DEFAULT); > +} > + > +static int > +ftwd_attach(device_t dev) > +{ > + struct ftwd_softc *sc = device_get_softc(dev); > + > + /* > + * We do not touch the watchdog at this time, it might be armed > + * by firmware to protect the full boot sequence. > + */ > + > + sc->wd_ev = EVENTHANDLER_REGISTER(watchdog_list, ftwd_func, dev, 0); > + return (0); > +} > + > +static int > +ftwd_detach(device_t dev) > +{ > + struct ftwd_softc *sc = device_get_softc(dev); > + int dummy; > + > + if (sc->wd_ev != NULL) > + EVENTHANDLER_DEREGISTER(watchdog_list, sc->wd_ev); > + ftwd_func(dev, 0, &dummy); > + return (0); > +} > + > +static device_method_t ftwd_methods[] = { > + DEVMETHOD(device_probe, ftwd_probe), > + DEVMETHOD(device_attach, ftwd_attach), > + DEVMETHOD(device_detach, ftwd_detach), > + { 0, 0 } > +}; > + > +static driver_t ftwd_driver = { > + "ftwd", > + ftwd_methods, > + sizeof (struct ftwd_softc) > +}; > + > +static devclass_t ftwd_devclass; > + > +DRIVER_MODULE(ftwd, superio, ftwd_driver, ftwd_devclass, NULL, NULL); > +MODULE_DEPEND(ftwd, superio, 1, 1, 1); > +MODULE_VERSION(ftwd, 1); > > Modified: head/sys/modules/Makefile > ============================================================================== > --- head/sys/modules/Makefile Sat Nov 28 18:09:16 2020 (r368129) > +++ head/sys/modules/Makefile Sat Nov 28 22:34:33 2020 (r368130) > @@ -121,6 +121,7 @@ SUBDIR= \ > filemon \ > firewire \ > firmware \ > + ${_ftwd} \ > fusefs \ > ${_fxp} \ > gem \ > @@ -618,6 +619,7 @@ _cpufreq= cpufreq > _dpms= dpms > _em= em > _et= et > +_ftwd= ftwd > _exca= exca > _if_ndis= if_ndis > _io= io > > Added: head/sys/modules/ftwd/Makefile > ============================================================================== > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/sys/modules/ftwd/Makefile Sat Nov 28 22:34:33 2020 (r368130) > @@ -0,0 +1,9 @@ > +# $FreeBSD$ > + > +.PATH: ${SRCTOP}/sys/dev/ftwd > + > +KMOD= ftwd > +SRCS= ftwd.c > +SRCS+= device_if.h bus_if.h isa_if.h > + > +.include > -- Rod Grimes rgrimes@freebsd.org