Re: [RFC] winbond watchdog driver for FreeBSD/i386 and FreeBSD/amd64

2011-12-13 Thread Bjoern A. Zeeb
On 13. Dec 2011, at 00:01 , Keith Simonsen wrote:

 On 12/12/2011 12:25, Mike Tancsa wrote:
 On 12/12/2011 2:49 PM, Keith Simonsen wrote:
 
 I've  been using 20110718-02-wbwd.diff for a few months now on a project
 with PC Engines Alix 1.d boards (http://pcengines.ch/alix1d.htm). They
 have a  Winbond W83627HG chip. I don't see any probing/attach messages
 on boot but the driver seems to be properly configuring the chip - if I
 kill watchdogd with -9 the board reboots with watchdog timeout.
 
 Are you sure thats the watchdog thats doing the 'killing' so to speak ?
 If you have
 option  CPU_GEODE
 in your kernel config, you will get the watchdog code there no ?
 ( /usr/src/sys/i386/i386/geode.c)
 
 Yes I do have CPU_GEODE in my kernel and I see the geode MFGPT probed in the 
 verbose dmesg output. I'm not sure how I can tell what piece of hardware 
 /dev/fido is linked to but I think you're correct and I'm using the geode 
 watchdog and not the winbond chip. Maybe this has something do with me not 
 having 'device eisa' in my kernel config!
 
 I'm going to start compiling a new nanobsd image right now with eisa and the 
 newer wbwd.c driver and see how it goes Thanks

You probably don't need eisa but if using my variant make sure you have the
hint enabled or the hints file installed/updated to include it.
You should see the debug sysctls for the watchdog or it did not attach and
is not used.

-- 
Bjoern A. Zeeb You have to have visions!
 Stop bit received. Insert coin for new address family.

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] winbond watchdog driver for FreeBSD/i386 and FreeBSD/amd64

2011-12-12 Thread Keith Simonsen



On 12/7/2011 02:17, Bjoern A. Zeeb wrote:

On 7. Dec 2011, at 09:29 , Pawel Jakub Dawidek wrote:


On Tue, Jun 28, 2011 at 03:32:41PM -0700, Xin LI wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Hi,

I'd like to request for comments on the attached driver, which supports
watchdogs on several Winbond super I/O chip models and have been tested
on a few of recent Supermicro motherboards.


Is there any reason this is not yet committed? Please commit, pretty
please.


Yes we have 2+ of them and are trying to merge.  The other one sits here
and allows you even longer timeouts as well as time setting the timeout
independent of watchdogd in case you have two watchdogs and want to do tricks
like NMI/reset with the other one... but is lacking the man page yet.
I have added another one or two IC revisions I think that I had found
and tested privately.

http://people.freebsd.org/~bz/patch-20110710-03-wbwd.diff



I've  been using 20110718-02-wbwd.diff for a few months now on a project 
with PC Engines Alix 1.d boards (http://pcengines.ch/alix1d.htm). They 
have a  Winbond W83627HG chip. I don't see any probing/attach messages 
on boot but the driver seems to be properly configuring the chip - if I 
kill watchdogd with -9 the board reboots with watchdog timeout.


I'm also trying to use the above winbond chip for GPIO (userland bit 
banging at this point).



/bz



-Keith
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] winbond watchdog driver for FreeBSD/i386 and FreeBSD/amd64

2011-12-12 Thread Mike Tancsa
On 12/12/2011 2:49 PM, Keith Simonsen wrote:
 
 I've  been using 20110718-02-wbwd.diff for a few months now on a project
 with PC Engines Alix 1.d boards (http://pcengines.ch/alix1d.htm). They
 have a  Winbond W83627HG chip. I don't see any probing/attach messages
 on boot but the driver seems to be properly configuring the chip - if I
 kill watchdogd with -9 the board reboots with watchdog timeout.

Are you sure thats the watchdog thats doing the 'killing' so to speak ?
If you have
option  CPU_GEODE
in your kernel config, you will get the watchdog code there no ?
( /usr/src/sys/i386/i386/geode.c)


---Mike


-- 
---
Mike Tancsa, tel +1 519 651 3400
Sentex Communications, m...@sentex.net
Providing Internet services since 1994 www.sentex.net
Cambridge, Ontario Canada   http://www.tancsa.com/
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] winbond watchdog driver for FreeBSD/i386 and FreeBSD/amd64

2011-12-12 Thread Keith Simonsen



On 12/12/2011 12:25, Mike Tancsa wrote:

On 12/12/2011 2:49 PM, Keith Simonsen wrote:


I've  been using 20110718-02-wbwd.diff for a few months now on a project
with PC Engines Alix 1.d boards (http://pcengines.ch/alix1d.htm). They
have a  Winbond W83627HG chip. I don't see any probing/attach messages
on boot but the driver seems to be properly configuring the chip - if I
kill watchdogd with -9 the board reboots with watchdog timeout.


Are you sure thats the watchdog thats doing the 'killing' so to speak ?
If you have
option  CPU_GEODE
in your kernel config, you will get the watchdog code there no ?
( /usr/src/sys/i386/i386/geode.c)


Yes I do have CPU_GEODE in my kernel and I see the geode MFGPT probed in 
the verbose dmesg output. I'm not sure how I can tell what piece of 
hardware /dev/fido is linked to but I think you're correct and I'm using 
the geode watchdog and not the winbond chip. Maybe this has something do 
with me not having 'device eisa' in my kernel config!


I'm going to start compiling a new nanobsd image right now with eisa and 
the newer wbwd.c driver and see how it goes Thanks





---Mike



-Keith

___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] winbond watchdog driver for FreeBSD/i386 and FreeBSD/amd64

2011-12-07 Thread Pawel Jakub Dawidek
On Tue, Jun 28, 2011 at 03:32:41PM -0700, Xin LI wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA256
 
 Hi,
 
 I'd like to request for comments on the attached driver, which supports
 watchdogs on several Winbond super I/O chip models and have been tested
 on a few of recent Supermicro motherboards.

Is there any reason this is not yet committed? Please commit, pretty
please.

One minor problem I found is described below. Other than that it works
for me, thanks!

[...]
 +static void
 +winbondwd_event(void *arg, unsigned int cmd, int *error)
 +{
 + struct winbondwd_softc *sc = arg;
 + unsigned char rtimeout;
 + uint64_t timeout;
 +
 + if (cmd == 0)
 + winbondwd_set_timeout(sc, 0);
 + else {
 + timeout = (uint64_t)1  (cmd  WD_INTERVAL);
 + if (timeout  (uint64_t)0xff * 1000 * 1000 * 1000) {
 + rtimeout = timeout / (1000 * 1000 * 1000);
 + if (rtimeout == 0)
 + rtimeout = 0xff;
 + winbondwd_set_timeout(sc, rtimeout);
 + } else {
 + device_printf(sc-device,
 + Value %u too big, disabling\n, cmd  WD_INTERVAL);
 + /* Proposed timeout can not be satisified */
 + winbondwd_set_timeout(sc, 0);
 + }

You should add '*error = 0;' right here. Without it we return some
random error, in my case watchdgod is able to arm the watchdog but exits
when trying to pat it, as it gets an error, which leads to a reset short
aferwards.

 + }
 +}

-- 
Pawel Jakub Dawidek   http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://yomoli.com


pgpOBGKr7YKAI.pgp
Description: PGP signature


Re: [RFC] winbond watchdog driver for FreeBSD/i386 and FreeBSD/amd64

2011-12-07 Thread Bjoern A. Zeeb
On 7. Dec 2011, at 09:29 , Pawel Jakub Dawidek wrote:

 On Tue, Jun 28, 2011 at 03:32:41PM -0700, Xin LI wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA256
 
 Hi,
 
 I'd like to request for comments on the attached driver, which supports
 watchdogs on several Winbond super I/O chip models and have been tested
 on a few of recent Supermicro motherboards.
 
 Is there any reason this is not yet committed? Please commit, pretty
 please.

Yes we have 2+ of them and are trying to merge.  The other one sits here
and allows you even longer timeouts as well as time setting the timeout
independent of watchdogd in case you have two watchdogs and want to do tricks
like NMI/reset with the other one... but is lacking the man page yet.
I have added another one or two IC revisions I think that I had found
and tested privately.

http://people.freebsd.org/~bz/patch-20110710-03-wbwd.diff

/bz

-- 
Bjoern A. Zeeb You have to have visions!
 Stop bit received. Insert coin for new address family.
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] winbond watchdog driver for FreeBSD/i386 and FreeBSD/amd64

2011-06-29 Thread Andriy Gapon
on 29/06/2011 01:32 Xin LI said the following:
 Hi,
 
 I'd like to request for comments on the attached driver, which supports
 watchdogs on several Winbond super I/O chip models and have been tested
 on a few of recent Supermicro motherboards.

Some comments.

 From 343b2e7b6ed19e4b6ca2bf76c0ca6b8544dd4320 Mon Sep 17 00:00:00 2001
 From: Xin LI d...@delphij.net
 Date: Mon, 27 Jun 2011 21:54:13 -0700
 Subject: [PATCH] Driver for Winbond watchdog.
 
 ---
  share/man/man4/Makefile|3 +
  share/man/man4/winbondwd.4 |   88 ++
  sys/amd64/conf/NOTES   |2 +
  sys/conf/files.amd64   |1 +
  sys/conf/files.i386|1 +
  sys/dev/winbondwd/winbondwd.c  |  368 
 
  sys/dev/winbondwd/winbondwd.h  |   47 +
  sys/i386/conf/NOTES|2 +
  sys/modules/Makefile   |3 +
  sys/modules/winbondwd/Makefile |8 +
  10 files changed, 523 insertions(+), 0 deletions(-)
  create mode 100644 share/man/man4/winbondwd.4
  create mode 100644 sys/dev/winbondwd/winbondwd.c
  create mode 100644 sys/dev/winbondwd/winbondwd.h
  create mode 100644 sys/modules/winbondwd/Makefile
 
 diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
 index 7fb..777e2fd 100644
 --- a/share/man/man4/Makefile
 +++ b/share/man/man4/Makefile
 @@ -447,6 +447,7 @@ MAN=  aac.4 \
   tun.4 \
   twa.4 \
   twe.4 \
 + tws.4 \

Looks like this has sneaked in accidentally.

   tx.4 \
   txp.4 \
   u3g.4 \
 @@ -503,6 +504,7 @@ MAN=  aac.4 \
   watchdog.4 \
   wb.4 \
   wi.4 \
 + ${_winbondwd.4} \
   witness.4 \
   wlan.4 \
   wlan_acl.4 \
 @@ -706,6 +708,7 @@ _speaker.4=   speaker.4
  _spkr.4= spkr.4
  _tpm.4=  tpm.4
  _urtw.4= urtw.4
 +_winbondwd.4=winbondwd.4
  _wpi.4=  wpi.4
  _xen.4=  xen.4
  
 diff --git a/share/man/man4/winbondwd.4 b/share/man/man4/winbondwd.4
 new file mode 100644
 index 000..6fd2719
 --- /dev/null
 +++ b/share/man/man4/winbondwd.4
 @@ -0,0 +1,88 @@
 +.\-
 +.\ Copyright (c) 2011 Xin LI delp...@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 July 1, 2011
 +.Dt WINBONDWD 4
 +.Os
 +.Sh NAME
 +.Nm winbondwd
 +.Nd device driver for the Winbond Super I/O 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 winbondwd
 +.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
 +winbondwd_load=YES
 +.Ed
 +.Sh DESCRIPTION
 +The
 +.Nm
 +driver provides
 +.Xr watchdog 4
 +support for the watchdog interrupt timer present on
 +all Winbond super I/O controllers.
 +.Pp
 +The Winbond super I/O controller have a built-in watchdog timer,
 +which can be enabled and disabled by user's program and set between
 +1 to 255 seconds or 1 to 255 minutes.
 +Supported watchdog intervals range from 1 to 255 seconds.
 +.Pp
 +On some systems the watchdog timer is enabled and set to 5 minutes
 +by BIOS on boot.
 +The
 +.Nm
 +driver will detect and print out the existing setting, however, 
 +it will not make any changes unless told by the userland through
 +the
 +.Xr watchdog 4
 +interface,
 +for instance by using the
 +.Xr watchdogd 8
 +daemon.
 +.Sh SEE ALSO
 +.Xr watchdog 4 ,
 +.Xr watchdog 8 ,
 +.Xr watchdogd 8 ,
 +.Xr watchdog 9
 +.Sh HISTORY
 +The
 +.Nm
 +driver first appeared in
 +.Fx 9.0 .
 +.Sh AUTHORS
 +.An -nosplit
 +The
 +.Nm
 +driver and this manual page were 

Re: [RFC] winbond watchdog driver for FreeBSD/i386 and FreeBSD/amd64

2011-06-29 Thread John Baldwin
On Wednesday, June 29, 2011 5:22:26 am Andriy Gapon wrote:
 on 29/06/2011 01:32 Xin LI said the following:
  +/*
  + * Look for Winbond device.
  + */
  +static void
  +winbondwd_identify(driver_t *driver, device_t parent)
  +{
  +   unsigned int baseport;
  +   device_t dev;
  +
  +if ((dev = device_find_child(parent, driver-name, 0)) == NULL) {
  +   if (resource_int_value(winbondwd, 0, baseport, baseport) 
  != 0) {
  +   baseport = winbondwd_baseport_probe();
  +   if (baseport == (unsigned int)(-1)) {
  +   printf(winbondwd0: Compatible Winbond Super 
  I/O not found.\n);
  +   return;
  +   }
  +   }
  +
  +   dev = BUS_ADD_CHILD(parent, 0, driver-name, 0);
  +
  +   bus_set_resource(dev, SYS_RES_IOPORT, 0, baseport, 2);
  +   }
  +
  +   if (dev == NULL)
  +   return;
 
 These last two lines are redundant?
 
 Also, maybe I am confused, but I think that in ISA identify method you don't
 actually need to parse any hints/tunables.  That is, you can use standard 
 hints
 approach like e.g.:
 hint.winbondwd.0.at=isa
 hint.winbondwd.0.port=0x3F0
 and ISA will automatically add a winbondwd child with an I/O port resource at
 0x3F0.  The identify method should only add a child for a 
 no-hints/auto-probing
 case.
 E.g. see boiler-plate code for the ISA case in
 share/examples/drivers/make_device_driver.sh, especially the comments.
 
 I am not saying that your approach won't work (apparently it does) or that it 
 is
 inherently bad.  It just seems to be different from how other ISA drivers do
 their identify+probe dance.

I agree, it should probably look something like this:

{
if (device_find_child(parent, driver-name, 0) != NULL)
return;

if (resource_int_value(driver-name, 0, port, baseport) == 0)
return;

baseport = winbondwd_baseport_probe();
if (baseport == -1)
/* No reason to warn on every boot here. */
return;

dev = BUS_ADD_CHILD(parent, 0, driver-name, 0);
if (dev != NULL)
bus_set_resource(dev, SYS_RES_IOPORT, 0, baseport, 2);
}

  +   sc-wb_bst = rman_get_bustag(sc-wb_res);
  +   sc-wb_bsh = rman_get_bushandle(sc-wb_res);

Please don't use these.  bus_read_X(sc-wb_wres) is easier on the eyes.

One other comment, several places in the code are using various magic
numbers for register offsets, bit field values, etc.  For example:

+   winbondwd_write_reg(sc, /* LDN bit 7:1 */ 0x7, /* GPIO Port 2 */ 0x8);
+   winbondwd_write_reg(sc, /* CR30 */ 0x30, /* Activate */ 0x1);

Could you add a winbondwdreg.h header and define constants for the registers
and their bitfields instead?

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org