Module Name:    src
Committed By:   cnst
Date:           Sun Feb 21 05:16:29 UTC 2010

Modified Files:
        src/distrib/sets/lists/man: mi
        src/share/man/man4: Makefile isa.4 lm.4
        src/sys/arch/amd64/conf: GENERIC XEN3_DOM0
        src/sys/arch/i386/conf: ALL GENERIC XEN3_DOM0
        src/sys/dev/isa: files.isa lm_isa.c
Added Files:
        src/share/man/man4: wbsio.4
        src/sys/dev/isa: wbsio.c

Log Message:
New wbsio(4) driver for Winbond Super I/O attachment of lm(4) on any port.

    http://mail-index.netbsd.org/tech-kern/2010/02/17/msg007338.html

Reviewed by <pgoyette>, <tech-kern>.


To generate a diff of this commit:
cvs rdiff -u -r1.1192 -r1.1193 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.504 -r1.505 src/share/man/man4/Makefile
cvs rdiff -u -r1.40 -r1.41 src/share/man/man4/isa.4
cvs rdiff -u -r1.31 -r1.32 src/share/man/man4/lm.4
cvs rdiff -u -r0 -r1.1 src/share/man/man4/wbsio.4
cvs rdiff -u -r1.266 -r1.267 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/amd64/conf/XEN3_DOM0
cvs rdiff -u -r1.238 -r1.239 src/sys/arch/i386/conf/ALL
cvs rdiff -u -r1.968 -r1.969 src/sys/arch/i386/conf/GENERIC
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/i386/conf/XEN3_DOM0
cvs rdiff -u -r1.158 -r1.159 src/sys/dev/isa/files.isa
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/isa/lm_isa.c
cvs rdiff -u -r0 -r1.1 src/sys/dev/isa/wbsio.c

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.1192 src/distrib/sets/lists/man/mi:1.1193
--- src/distrib/sets/lists/man/mi:1.1192	Sun Feb 21 03:18:46 2010
+++ src/distrib/sets/lists/man/mi	Sun Feb 21 05:16:29 2010
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1192 2010/02/21 03:18:46 darran Exp $
+# $NetBSD: mi,v 1.1193 2010/02/21 05:16:29 cnst Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -1684,6 +1684,7 @@
 ./usr/share/man/cat4/vr.0			man-sys-catman		.cat
 ./usr/share/man/cat4/wapbl.0			man-sys-catman		.cat
 ./usr/share/man/cat4/wb.0			man-sys-catman		.cat
+./usr/share/man/cat4/wbsio.0			man-sys-catman		.cat
 ./usr/share/man/cat4/wd.0			man-sys-catman		.cat
 ./usr/share/man/cat4/wdc.0			man-sys-catman		.cat
 ./usr/share/man/cat4/wds.0			man-sys-catman		.cat
@@ -4248,6 +4249,7 @@
 ./usr/share/man/html4/vr.html			man-sys-htmlman		html
 ./usr/share/man/html4/wapbl.html		man-sys-htmlman		html
 ./usr/share/man/html4/wb.html			man-sys-htmlman		html
+./usr/share/man/html4/wbsio.html		man-sys-htmlman		html
 ./usr/share/man/html4/wd.html			man-sys-htmlman		html
 ./usr/share/man/html4/wdc.html			man-sys-htmlman		html
 ./usr/share/man/html4/wds.html			man-sys-htmlman		html
@@ -6750,6 +6752,7 @@
 ./usr/share/man/man4/vr.4			man-sys-man		.man
 ./usr/share/man/man4/wapbl.4			man-sys-man		.man
 ./usr/share/man/man4/wb.4			man-sys-man		.man
+./usr/share/man/man4/wbsio.4			man-sys-man		.man
 ./usr/share/man/man4/wd.4			man-sys-man		.man
 ./usr/share/man/man4/wdc.4			man-sys-man		.man
 ./usr/share/man/man4/wds.4			man-sys-man		.man

Index: src/share/man/man4/Makefile
diff -u src/share/man/man4/Makefile:1.504 src/share/man/man4/Makefile:1.505
--- src/share/man/man4/Makefile:1.504	Tue Feb  9 03:19:50 2010
+++ src/share/man/man4/Makefile	Sun Feb 21 05:16:29 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.504 2010/02/09 03:19:50 cnst Exp $
+#	$NetBSD: Makefile,v 1.505 2010/02/21 05:16:29 cnst Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/18/93
 
 MAN=	aac.4 ac97.4 acardide.4 aceride.4 acphy.4 acpidalb.4 \
@@ -59,8 +59,8 @@
 	ubsec.4 udp.4 uep.4 ug.4 uha.4 uk.4 ukphy.4 unix.4 userconf.4 \
 	veriexec.4 vga.4 vge.4 viaide.4 video.4 vlan.4 vmmon.4 vmnet.4 \
 	vnd.4 vr.4 \
-	wapbl.4 wb.4 wd.4 wdc.4 wi.4 wm.4 wpi.4 wscons.4 wsdisplay.4 wsfont.4 \
-	wskbd.4 wsmouse.4 wsmux.4 \
+	wapbl.4 wb.4 wbsio.4 wd.4 wdc.4 wi.4 wm.4 wpi.4 \
+	wscons.4 wsdisplay.4 wsfont.4 wskbd.4 wsmouse.4 wsmux.4 \
 	xbox.4 xge.4 \
 	yds.4 ym.4 \
 	zero.4 zstty.4 zyd.4

Index: src/share/man/man4/isa.4
diff -u src/share/man/man4/isa.4:1.40 src/share/man/man4/isa.4:1.41
--- src/share/man/man4/isa.4:1.40	Sat Dec 23 06:58:20 2006
+++ src/share/man/man4/isa.4	Sun Feb 21 05:16:29 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: isa.4,v 1.40 2006/12/23 06:58:20 wiz Exp $
+.\"	$NetBSD: isa.4,v 1.41 2010/02/21 05:16:29 cnst Exp $
 .\"
 .\" Copyright (c) 1997 Jason R. Thorpe.  All rights reserved.
 .\" Copyright (c) 1997 Jonathan Stone
@@ -276,6 +276,8 @@
 controllers.
 .It vga
 VGA graphics boards.
+.It wbsio
+Winbond LPC Super I/O.
 .El
 .Pp
 Note that some
@@ -370,6 +372,7 @@
 .Xr tr 4 ,
 .Xr uha 4 ,
 .Xr vga 4 ,
+.Xr wbsio 4 ,
 .Xr wd 4 ,
 .Xr wdc 4 ,
 .Xr wds 4 ,

Index: src/share/man/man4/lm.4
diff -u src/share/man/man4/lm.4:1.31 src/share/man/man4/lm.4:1.32
--- src/share/man/man4/lm.4:1.31	Fri Feb 12 10:54:53 2010
+++ src/share/man/man4/lm.4	Sun Feb 21 05:16:29 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: lm.4,v 1.31 2010/02/12 10:54:53 njoly Exp $
+.\"	$NetBSD: lm.4,v 1.32 2010/02/21 05:16:29 cnst Exp $
 .\"
 .\" Copyright (c) 2000 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd February 8, 2010
+.Dd February 16, 2010
 .Dt LM 4
 .Os
 .Sh NAME
@@ -40,6 +40,7 @@
 .Cd "lm3 at isa? port 0xa00 flags 0x00"
 .Cd "lm0 at pnpbios0 index ? flags 0x00"
 .Cd "lm0 at iic? addr 0x2e flags 0x00"
+.Cd "lm* at wbsio?"
 .Sh DESCRIPTION
 The
 .Nm
@@ -116,6 +117,7 @@
 .El
 .Sh SEE ALSO
 .Xr envsys 4 ,
+.Xr wbsio 4 ,
 .Xr envstat 8
 .Sh HISTORY
 The

Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.266 src/sys/arch/amd64/conf/GENERIC:1.267
--- src/sys/arch/amd64/conf/GENERIC:1.266	Tue Feb  9 03:19:50 2010
+++ src/sys/arch/amd64/conf/GENERIC	Sun Feb 21 05:16:29 2010
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.266 2010/02/09 03:19:50 cnst Exp $
+# $NetBSD: GENERIC,v 1.267 2010/02/21 05:16:29 cnst Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.266 $"
+#ident 		"GENERIC-$Revision: 1.267 $"
 
 maxusers	64		# estimated number of users
 
@@ -422,9 +422,14 @@
 
 amdtemp* at pci? dev ? function ?	# AMD CPU Temperature sensors
 
+# Winbond LPC Super I/O
+#wbsio*	at isa? port 0x2e
+#wbsio*	at isa? port 0x4e
+
 # LM7[89] and compatible hardware monitors
 # Use flags to select temp sensor type (see lm(4) man page for details)
 #lm0	at isa?	port 0x290 flags 0x0	# other common ports: 0x280, 0x310
+#lm*	at wbsio?
 
 # SMSC LPC47B397 hardware monitor functions
 #smsc0   at isa? port 0x02e

Index: src/sys/arch/amd64/conf/XEN3_DOM0
diff -u src/sys/arch/amd64/conf/XEN3_DOM0:1.49 src/sys/arch/amd64/conf/XEN3_DOM0:1.50
--- src/sys/arch/amd64/conf/XEN3_DOM0:1.49	Tue Feb  9 03:19:50 2010
+++ src/sys/arch/amd64/conf/XEN3_DOM0	Sun Feb 21 05:16:29 2010
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.49 2010/02/09 03:19:50 cnst Exp $
+# $NetBSD: XEN3_DOM0,v 1.50 2010/02/21 05:16:29 cnst Exp $
 
 include 	"arch/amd64/conf/std.xen"
 
@@ -298,8 +298,13 @@
 #dbcool* at iic? addr 0x2D		# Tyan S2881
 #dbcool* at iic? addr 0x2E		# Tyan S2882-D
 
+# Winbond LPC Super I/O
+#wbsio*	at isa? port 0x2e
+#wbsio*	at isa? port 0x4e
+
 # LM7[89] and compatible hardware monitors
 #lm0	at isa?	port 0x290		# other common: 0x280, 0x310, 0xc00
+#lm*	at wbsio?
 
 # VIA VT82C686A/VT8231 Hardware Monitor and Power Management TImer
 #viaenv*	at pci? dev ? function ?

Index: src/sys/arch/i386/conf/ALL
diff -u src/sys/arch/i386/conf/ALL:1.238 src/sys/arch/i386/conf/ALL:1.239
--- src/sys/arch/i386/conf/ALL:1.238	Fri Feb 12 15:51:16 2010
+++ src/sys/arch/i386/conf/ALL	Sun Feb 21 05:16:29 2010
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.238 2010/02/12 15:51:16 hubertf Exp $
+# $NetBSD: ALL,v 1.239 2010/02/21 05:16:29 cnst Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"ALL-$Revision: 1.238 $"
+#ident 		"ALL-$Revision: 1.239 $"
 
 maxusers	64		# estimated number of users
 
@@ -698,8 +698,13 @@
 # iTE IT87xxF Super I/O with watchdog and sensors support
 itesio0 	at isa? port 0x2e
 
+# Winbond LPC Super I/O
+wbsio*	at isa? port 0x2e
+wbsio*	at isa? port 0x4e
+
 # LM7[89] and compatible hardware monitors
 lm0	at isa?	port 0x290 flags 0x0	# other common: 0x280, 0x310
+lm*	at wbsio?
 
 # SMSC LPC47B397 hardware monitor functions
 smsc0	at isa? port 0x02e

Index: src/sys/arch/i386/conf/GENERIC
diff -u src/sys/arch/i386/conf/GENERIC:1.968 src/sys/arch/i386/conf/GENERIC:1.969
--- src/sys/arch/i386/conf/GENERIC:1.968	Fri Feb 12 15:51:16 2010
+++ src/sys/arch/i386/conf/GENERIC	Sun Feb 21 05:16:29 2010
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.968 2010/02/12 15:51:16 hubertf Exp $
+# $NetBSD: GENERIC,v 1.969 2010/02/21 05:16:29 cnst Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.968 $"
+#ident 		"GENERIC-$Revision: 1.969 $"
 
 maxusers	64		# estimated number of users
 
@@ -652,9 +652,14 @@
 # iTE IT87xxF Super I/O with watchdog and sensors support
 #itesio0 	at isa? port 0x2e
 
+# Winbond LPC Super I/O
+#wbsio*	at isa? port 0x2e
+#wbsio*	at isa? port 0x4e
+
 # LM7[89] and compatible hardware monitors
 # Use flags to select temp sensor type (see lm(4) man page for details)
 #lm0	at isa?	port 0x290 flags 0x0	# other common: 0x280, 0x310
+#lm*	at wbsio?
 
 # SMSC LPC47B397 hardware monitor functions
 #smsc0	at isa? port 0x02e

Index: src/sys/arch/i386/conf/XEN3_DOM0
diff -u src/sys/arch/i386/conf/XEN3_DOM0:1.28 src/sys/arch/i386/conf/XEN3_DOM0:1.29
--- src/sys/arch/i386/conf/XEN3_DOM0:1.28	Mon Feb  8 21:45:32 2010
+++ src/sys/arch/i386/conf/XEN3_DOM0	Sun Feb 21 05:16:29 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: XEN3_DOM0,v 1.28 2010/02/08 21:45:32 pgoyette Exp $
+#	$NetBSD: XEN3_DOM0,v 1.29 2010/02/21 05:16:29 cnst Exp $
 #
 #	XEN3_0: Xen 3.0 domain0 kernel
 
@@ -281,9 +281,14 @@
 #dbcool* at iic? addr 0x2D		# Tyan S2881
 #dbcool* at iic? addr 0x2E		# Tyan S2882-D
 
+# Winbond LPC Super I/O
+#wbsio*	at isa? port 0x2e
+#wbsio*	at isa? port 0x4e
+
 # LM7[89] and compatible hardware monitors
 # Use flags to select temp sensor type (see lm(4) man page for details)
 #lm0	at isa?	port 0x290 flags 0x0	# other common: 0x280, 0x310, 0xc00
+#lm*	at wbsio?
 
 # VIA VT82C686A/VT8231 Hardware Monitor and Power Management TImer
 #viaenv* 	at pci? dev ? function ?

Index: src/sys/dev/isa/files.isa
diff -u src/sys/dev/isa/files.isa:1.158 src/sys/dev/isa/files.isa:1.159
--- src/sys/dev/isa/files.isa:1.158	Tue Jan 19 12:41:41 2010
+++ src/sys/dev/isa/files.isa	Sun Feb 21 05:16:29 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: files.isa,v 1.158 2010/01/19 12:41:41 pooka Exp $
+#	$NetBSD: files.isa,v 1.159 2010/02/21 05:16:29 cnst Exp $
 #
 # Config file and device description for machine-independent ISA code.
 # Included by ports that need it.  Requires that the SCSI files be
@@ -451,9 +451,15 @@
 attach	smsc at isa with smsc
 file	dev/isa/smsc.c			smsc			needs-flag
 
+# Winbond LPC Super I/O
+device	wbsio {}
+attach	wbsio at isa
+file	dev/isa/wbsio.c			wbsio
+
 # LM78 temp/fanspeed monitor
 attach	lm at isa with lm_isa
-file	dev/isa/lm_isa.c		lm_isa
+attach	lm at wbsio with lm_wbsio
+file	dev/isa/lm_isa.c		lm_isa | lm_wbsio
 
 # iTE Super I/O with hardware monitor
 device	itesio: sysmon_envsys, sysmon_wdog
@@ -521,4 +527,3 @@
 # ISA PnP devices often use `device' declarations listed in this file.
 #
 include	"dev/isapnp/files.isapnp"
-

Index: src/sys/dev/isa/lm_isa.c
diff -u src/sys/dev/isa/lm_isa.c:1.22 src/sys/dev/isa/lm_isa.c:1.23
--- src/sys/dev/isa/lm_isa.c:1.22	Sun Oct 12 23:07:32 2008
+++ src/sys/dev/isa/lm_isa.c	Sun Feb 21 05:16:29 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: lm_isa.c,v 1.22 2008/10/12 23:07:32 pgoyette Exp $ */
+/*	$NetBSD: lm_isa.c,v 1.23 2010/02/21 05:16:29 cnst Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lm_isa.c,v 1.22 2008/10/12 23:07:32 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lm_isa.c,v 1.23 2010/02/21 05:16:29 cnst Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,6 +63,9 @@
 CFATTACH_DECL_NEW(lm_isa, sizeof(struct lm_isa_softc),
     lm_isa_match, lm_isa_attach, lm_isa_detach, NULL);
 
+CFATTACH_DECL_NEW(lm_wbsio, sizeof(struct lm_isa_softc),
+    lm_isa_match, lm_isa_attach, lm_isa_detach, NULL);
+
 int
 lm_isa_match(device_t parent, cfdata_t match, void *aux)
 {

Added files:

Index: src/share/man/man4/wbsio.4
diff -u /dev/null src/share/man/man4/wbsio.4:1.1
--- /dev/null	Sun Feb 21 05:16:30 2010
+++ src/share/man/man4/wbsio.4	Sun Feb 21 05:16:29 2010
@@ -0,0 +1,58 @@
+.\"	$NetBSD: wbsio.4,v 1.1 2010/02/21 05:16:29 cnst Exp $
+.\"	$OpenBSD: wbsio.4,v 1.2 2008/02/17 16:48:47 jmc Exp $
+.\"
+.\" Copyright (c) 2008 Mark Kettenis <kette...@openbsd.org>
+.\"
+.\" 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 February 16, 2010
+.Dt WBSIO 4
+.Os
+.Sh NAME
+.Nm wbsio
+.Nd Winbond LPC Super I/O
+.Sh SYNOPSIS
+.Cd "wbsio* at isa? port 0x2e"
+.Cd "wbsio* at isa? port 0x4e"
+.Cd "lm* at wbsio?"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for the Winbond LPC Super I/O ICs.
+Only the hardware monitoring function is currently supported.
+.Pp
+Support for the hardware monitor function is provided through the
+.Xr lm 4
+driver.
+.Sh SEE ALSO
+.Xr intro 4 ,
+.Xr isa 4 ,
+.Xr lm 4
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Ox 4.3 .
+.Nx
+support was added in
+.Nx 6.0 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver was written by
+.An Mark Kettenis Aq kette...@openbsd.org .
+It was adapted to
+.Nx
+by
+.An Constantine A. Murenin Aq c...@netbsd.org .

Index: src/sys/dev/isa/wbsio.c
diff -u /dev/null src/sys/dev/isa/wbsio.c:1.1
--- /dev/null	Sun Feb 21 05:16:30 2010
+++ src/sys/dev/isa/wbsio.c	Sun Feb 21 05:16:29 2010
@@ -0,0 +1,236 @@
+/*	$NetBSD: wbsio.c,v 1.1 2010/02/21 05:16:29 cnst Exp $	*/
+/*	$OpenBSD: wbsio.c,v 1.5 2009/03/29 21:53:52 sthen Exp $	*/
+/*
+ * Copyright (c) 2008 Mark Kettenis <kette...@openbsd.org>
+ *
+ * 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.
+ */
+
+/*
+ * Winbond LPC Super I/O driver.
+ */
+
+#include <sys/param.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+
+#include <machine/bus.h>
+
+#include <dev/isa/isareg.h>
+#include <dev/isa/isavar.h>
+
+/* ISA bus registers */
+#define WBSIO_INDEX		0x00	/* Configuration Index Register */
+#define WBSIO_DATA		0x01	/* Configuration Data Register */
+
+#define WBSIO_IOSIZE		0x02	/* ISA I/O space size */
+
+#define WBSIO_CONF_EN_MAGIC	0x87	/* enable configuration mode */
+#define WBSIO_CONF_DS_MAGIC	0xaa	/* disable configuration mode */
+
+/* Configuration Space Registers */
+#define WBSIO_LDN		0x07	/* Logical Device Number */
+#define WBSIO_ID		0x20	/* Device ID */
+#define WBSIO_REV		0x21	/* Device Revision */
+
+#define WBSIO_ID_W83627HF	0x52
+#define WBSIO_ID_W83627THF	0x82
+#define WBSIO_ID_W83627EHF	0x88
+#define WBSIO_ID_W83627DHG	0xa0
+#define WBSIO_ID_W83627SF	0x59
+#define WBSIO_ID_W83637HF	0x70
+#define WBSIO_ID_W83697HF	0x60
+
+/* Logical Device Number (LDN) Assignments */
+#define WBSIO_LDN_HM		0x0b
+
+/* Hardware Monitor Control Registers (LDN B) */
+#define WBSIO_HM_ADDR_MSB	0x60	/* Address [15:8] */
+#define WBSIO_HM_ADDR_LSB	0x61	/* Address [7:0] */
+
+struct wbsio_softc {
+	struct device		sc_dev;
+
+	bus_space_tag_t		sc_iot;
+	bus_space_handle_t	sc_ioh;
+};
+
+int	wbsio_probe(device_t, cfdata_t, void *);
+void	wbsio_attach(device_t, device_t, void *);
+int	wbsio_print(void *, const char *);
+
+CFATTACH_DECL_NEW(wbsio, sizeof(struct wbsio_softc),
+    wbsio_probe, wbsio_attach, NULL, NULL);
+
+static __inline void
+wbsio_conf_enable(bus_space_tag_t iot, bus_space_handle_t ioh)
+{
+	bus_space_write_1(iot, ioh, WBSIO_INDEX, WBSIO_CONF_EN_MAGIC);
+	bus_space_write_1(iot, ioh, WBSIO_INDEX, WBSIO_CONF_EN_MAGIC);
+}
+
+static __inline void
+wbsio_conf_disable(bus_space_tag_t iot, bus_space_handle_t ioh)
+{
+	bus_space_write_1(iot, ioh, WBSIO_INDEX, WBSIO_CONF_DS_MAGIC);
+}
+
+static __inline u_int8_t
+wbsio_conf_read(bus_space_tag_t iot, bus_space_handle_t ioh, u_int8_t index)
+{
+	bus_space_write_1(iot, ioh, WBSIO_INDEX, index);
+	return (bus_space_read_1(iot, ioh, WBSIO_DATA));
+}
+
+static __inline void
+wbsio_conf_write(bus_space_tag_t iot, bus_space_handle_t ioh, u_int8_t index,
+    u_int8_t data)
+{
+	bus_space_write_1(iot, ioh, WBSIO_INDEX, index);
+	bus_space_write_1(iot, ioh, WBSIO_DATA, data);
+}
+
+int
+wbsio_probe(device_t parent, cfdata_t match, void *aux)
+{
+	struct isa_attach_args *ia = aux;
+	bus_space_tag_t iot;
+	bus_space_handle_t ioh;
+	u_int8_t reg;
+
+	/* Must supply an address */
+	if (ia->ia_nio < 1)
+		return 0;
+
+	if (ISA_DIRECT_CONFIG(ia))
+		return 0;
+
+	if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT)
+		return 0;
+
+	/* Match by device ID */
+	iot = ia->ia_iot;
+	if (bus_space_map(iot, ia->ia_io[0].ir_addr, WBSIO_IOSIZE, 0, &ioh))
+		return 0;
+	wbsio_conf_enable(iot, ioh);
+	reg = wbsio_conf_read(iot, ioh, WBSIO_ID);
+	aprint_debug("wbsio_probe: id 0x%02x\n", reg);
+	wbsio_conf_disable(iot, ioh);
+	bus_space_unmap(iot, ioh, WBSIO_IOSIZE);
+	switch (reg) {
+	case WBSIO_ID_W83627HF:
+	case WBSIO_ID_W83627THF:
+	case WBSIO_ID_W83627EHF:
+	case WBSIO_ID_W83627DHG:
+	case WBSIO_ID_W83637HF:
+	case WBSIO_ID_W83697HF:
+		ia->ia_nio = 1;
+		ia->ia_io[0].ir_size = WBSIO_IOSIZE;
+		ia->ia_niomem = 0;
+		ia->ia_nirq = 0;
+		ia->ia_ndrq = 0;
+		return 1;
+	}
+
+	return 0;
+}
+
+void
+wbsio_attach(device_t parent, device_t self, void *aux)
+{
+	struct wbsio_softc *sc = (void *)self;
+	struct isa_attach_args *ia = aux;
+	struct isa_attach_args nia;
+	const char *desc = NULL;
+	u_int8_t reg, reg0, reg1;
+	u_int16_t iobase;
+
+	/* Map ISA I/O space */
+	sc->sc_iot = ia->ia_iot;
+	if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr,
+	    WBSIO_IOSIZE, 0, &sc->sc_ioh)) {
+		aprint_error(": can't map i/o space\n");
+		return;
+	}
+
+	/* Enter configuration mode */
+	wbsio_conf_enable(sc->sc_iot, sc->sc_ioh);
+
+	/* Read device ID */
+	reg = wbsio_conf_read(sc->sc_iot, sc->sc_ioh, WBSIO_ID);
+	switch (reg) {
+	case WBSIO_ID_W83627HF:
+		desc = "W83627HF";
+		break;
+	case WBSIO_ID_W83627THF:
+		desc = "W83627THF";
+		break;
+	case WBSIO_ID_W83627EHF:
+		desc = "W83627EHF";
+		break;
+	case WBSIO_ID_W83627DHG:
+		desc = "W83627DHG";
+		break;
+	case WBSIO_ID_W83637HF:
+		desc = "W83637HF";
+		break;
+	case WBSIO_ID_W83697HF:
+		desc = "W83697HF";
+		break;
+	}
+
+	/* Read device revision */
+	reg = wbsio_conf_read(sc->sc_iot, sc->sc_ioh, WBSIO_REV);
+
+	aprint_naive("\n");
+	aprint_normal(": Winbond LPC Super I/O %s rev 0x%02x\n", desc, reg);
+
+	/* Select HM logical device */
+	wbsio_conf_write(sc->sc_iot, sc->sc_ioh, WBSIO_LDN, WBSIO_LDN_HM);
+
+	/*
+	 * The address should be 8-byte aligned, but it seems some
+	 * BIOSes ignore this.  They get away with it, because
+	 * Apparently the hardware simply ignores the lower three
+	 * bits.  We do the same here.
+	 */
+	reg0 = wbsio_conf_read(sc->sc_iot, sc->sc_ioh, WBSIO_HM_ADDR_LSB);
+	reg1 = wbsio_conf_read(sc->sc_iot, sc->sc_ioh, WBSIO_HM_ADDR_MSB);
+	iobase = (reg1 << 8) | (reg0 & ~0x7);
+
+	/* Escape from configuration mode */
+	wbsio_conf_disable(sc->sc_iot, sc->sc_ioh);
+
+	if (iobase == 0)
+		return;
+
+	nia = *ia;
+	nia.ia_io[0].ir_addr = iobase;
+	config_found(self, &nia, wbsio_print);
+}
+
+int
+wbsio_print(void *aux, const char *pnp)
+{
+	struct isa_attach_args *ia = aux;
+
+	if (pnp)
+		aprint_normal("%s", pnp);
+	if (ia->ia_io[0].ir_size)
+		aprint_normal(" port 0x%x", ia->ia_io[0].ir_addr);
+	if (ia->ia_io[0].ir_size > 1)
+		aprint_normal("-0x%x", ia->ia_io[0].ir_addr +
+		    ia->ia_io[0].ir_size - 1);
+	return (UNCONF);
+}

Reply via email to