Module Name: src
Committed By: jruoho
Date: Sun Jan 9 15:12:35 UTC 2011
Modified Files:
src/distrib/sets/lists/man: mi
src/distrib/sets/lists/modules: md.amd64 md.i386
src/share/man/man4: Makefile acpi.4 acpitz.4
src/sys/arch/amd64/conf: GENERIC
src/sys/arch/i386/conf: ALL GENERIC
src/sys/dev/acpi: files.acpi
src/sys/modules: Makefile
Added Files:
src/share/man/man4: acpifan.4
src/sys/dev/acpi: acpi_fan.c
src/sys/modules/acpifan: ACPIFAN.ioconf Makefile
Log Message:
Add a dummy-driver for ACPI fans.
To generate a diff of this commit:
cvs rdiff -u -r1.1272 -r1.1273 src/distrib/sets/lists/man/mi
cvs rdiff -u -r1.10 -r1.11 src/distrib/sets/lists/modules/md.amd64
cvs rdiff -u -r1.11 -r1.12 src/distrib/sets/lists/modules/md.i386
cvs rdiff -u -r1.541 -r1.542 src/share/man/man4/Makefile
cvs rdiff -u -r1.65 -r1.66 src/share/man/man4/acpi.4
cvs rdiff -u -r0 -r1.1 src/share/man/man4/acpifan.4
cvs rdiff -u -r1.11 -r1.12 src/share/man/man4/acpitz.4
cvs rdiff -u -r1.297 -r1.298 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.283 -r1.284 src/sys/arch/i386/conf/ALL
cvs rdiff -u -r1.1005 -r1.1006 src/sys/arch/i386/conf/GENERIC
cvs rdiff -u -r0 -r1.1 src/sys/dev/acpi/acpi_fan.c
cvs rdiff -u -r1.83 -r1.84 src/sys/dev/acpi/files.acpi
cvs rdiff -u -r1.57 -r1.58 src/sys/modules/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/modules/acpifan/ACPIFAN.ioconf \
src/sys/modules/acpifan/Makefile
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.1272 src/distrib/sets/lists/man/mi:1.1273
--- src/distrib/sets/lists/man/mi:1.1272 Wed Jan 5 20:08:12 2011
+++ src/distrib/sets/lists/man/mi Sun Jan 9 15:12:33 2011
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1272 2011/01/05 20:08:12 jruoho Exp $
+# $NetBSD: mi,v 1.1273 2011/01/09 15:12:33 jruoho Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -635,6 +635,7 @@
./usr/share/man/cat4/acpidalb.0 man-sys-catman .cat
./usr/share/man/cat4/acpiec.0 man-sys-catman .cat
./usr/share/man/cat4/acpiecdt.0 man-sys-catman .cat
+./usr/share/man/cat4/acpifan.0 man-sys-catman .cat
./usr/share/man/cat4/acpilid.0 man-sys-catman .cat
./usr/share/man/cat4/acpiout.0 man-sys-catman .cat
./usr/share/man/cat4/acpipmtr.0 man-sys-catman .cat
@@ -3400,6 +3401,7 @@
./usr/share/man/html4/acpidalb.html man-sys-htmlman html
./usr/share/man/html4/acpiec.html man-sys-htmlman html
./usr/share/man/html4/acpiecdt.html man-sys-htmlman html
+./usr/share/man/html4/acpifan.html man-sys-htmlman html
./usr/share/man/html4/acpilid.html man-sys-htmlman html
./usr/share/man/html4/acpiout.html man-sys-htmlman html
./usr/share/man/html4/acpipmtr.html man-sys-htmlman html
@@ -5865,6 +5867,7 @@
./usr/share/man/man4/acpidalb.4 man-sys-man .man
./usr/share/man/man4/acpiec.4 man-sys-man .man
./usr/share/man/man4/acpiecdt.4 man-sys-man .man
+./usr/share/man/man4/acpifan.4 man-sys-man .man
./usr/share/man/man4/acpilid.4 man-sys-man .man
./usr/share/man/man4/acpiout.4 man-sys-man .man
./usr/share/man/man4/acpipmtr.4 man-sys-man .man
Index: src/distrib/sets/lists/modules/md.amd64
diff -u src/distrib/sets/lists/modules/md.amd64:1.10 src/distrib/sets/lists/modules/md.amd64:1.11
--- src/distrib/sets/lists/modules/md.amd64:1.10 Wed Jan 5 20:15:52 2011
+++ src/distrib/sets/lists/modules/md.amd64 Sun Jan 9 15:12:33 2011
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.10 2011/01/05 20:15:52 jruoho Exp $
+# $NetBSD: md.amd64,v 1.11 2011/01/09 15:12:33 jruoho Exp $
./@MODULEDIR@/acpiacad base-kernel-modules kmod
./@MODULEDIR@/acpiacad/acpiacad.kmod base-kernel-modules kmod
./@MODULEDIR@/acpibat base-kernel-modules kmod
@@ -9,6 +9,8 @@
./@MODULEDIR@/acpicpu/acpicpu.kmod base-kernel-modules kmod
./@MODULEDIR@/acpidalb base-kernel-modules kmod
./@MODULEDIR@/acpidalb/acpidalb.kmod base-kernel-modules kmod
+./@MODULEDIR@/acpifan base-kernel-modules kmod
+./@MODULEDIR@/acpifan/acpifan.kmod base-kernel-modules kmod
./@MODULEDIR@/acpilid base-kernel-modules kmod
./@MODULEDIR@/acpilid/acpilid.kmod base-kernel-modules kmod
./@MODULEDIR@/acpipmtr base-kernel-modules kmod
Index: src/distrib/sets/lists/modules/md.i386
diff -u src/distrib/sets/lists/modules/md.i386:1.11 src/distrib/sets/lists/modules/md.i386:1.12
--- src/distrib/sets/lists/modules/md.i386:1.11 Wed Jan 5 20:15:52 2011
+++ src/distrib/sets/lists/modules/md.i386 Sun Jan 9 15:12:33 2011
@@ -1,4 +1,4 @@
-# $NetBSD: md.i386,v 1.11 2011/01/05 20:15:52 jruoho Exp $
+# $NetBSD: md.i386,v 1.12 2011/01/09 15:12:33 jruoho Exp $
./@MODULEDIR@/acpiacad base-kernel-modules kmod
./@MODULEDIR@/acpiacad/acpiacad.kmod base-kernel-modules kmod
./@MODULEDIR@/acpibat base-kernel-modules kmod
@@ -9,6 +9,8 @@
./@MODULEDIR@/acpicpu/acpicpu.kmod base-kernel-modules kmod
./@MODULEDIR@/acpidalb base-kernel-modules kmod
./@MODULEDIR@/acpidalb/acpidalb.kmod base-kernel-modules kmod
+./@MODULEDIR@/acpifan base-kernel-modules kmod
+./@MODULEDIR@/acpifan/acpifan.kmod base-kernel-modules kmod
./@MODULEDIR@/acpilid base-kernel-modules kmod
./@MODULEDIR@/acpilid/acpilid.kmod base-kernel-modules kmod
./@MODULEDIR@/acpipmtr base-kernel-modules kmod
Index: src/share/man/man4/Makefile
diff -u src/share/man/man4/Makefile:1.541 src/share/man/man4/Makefile:1.542
--- src/share/man/man4/Makefile:1.541 Wed Jan 5 20:08:13 2011
+++ src/share/man/man4/Makefile Sun Jan 9 15:12:34 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.541 2011/01/05 20:08:13 jruoho Exp $
+# $NetBSD: Makefile,v 1.542 2011/01/09 15:12:34 jruoho Exp $
# @(#)Makefile 8.1 (Berkeley) 6/18/93
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -82,7 +82,7 @@
# ACPI devices
MAN+= acpi.4 acpiacad.4 acpibat.4 acpibut.4 acpicpu.4 \
- acpidalb.4 acpiec.4 acpilid.4 \
+ acpidalb.4 acpiec.4 acpifan.4 acpilid.4 \
acpipmtr.4 acpismbus.4 acpitz.4 acpivga.4 acpiwmi.4
# Radio devices
Index: src/share/man/man4/acpi.4
diff -u src/share/man/man4/acpi.4:1.65 src/share/man/man4/acpi.4:1.66
--- src/share/man/man4/acpi.4:1.65 Wed Jan 5 21:09:16 2011
+++ src/share/man/man4/acpi.4 Sun Jan 9 15:12:34 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: acpi.4,v 1.65 2011/01/05 21:09:16 jruoho Exp $
+.\" $NetBSD: acpi.4,v 1.66 2011/01/09 15:12:34 jruoho Exp $
.\"
.\" Copyright (c) 2002, 2004, 2010 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -24,7 +24,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd January 5, 2011
+.Dd January 9, 2011
.Dt ACPI 4
.Os
.Sh NAME
@@ -238,6 +238,9 @@
.Tn ACPI
Embedded Controller Boot Resource Table
.Pq Tn ECDT .
+.It Xr acpifan 4
+.Tn ACPI
+fans.
.It Xr acpilid 4
.Tn ACPI
lid switches.
Index: src/share/man/man4/acpitz.4
diff -u src/share/man/man4/acpitz.4:1.11 src/share/man/man4/acpitz.4:1.12
--- src/share/man/man4/acpitz.4:1.11 Sun Apr 25 06:54:40 2010
+++ src/share/man/man4/acpitz.4 Sun Jan 9 15:12:34 2011
@@ -1,6 +1,6 @@
-.\" $NetBSD: acpitz.4,v 1.11 2010/04/25 06:54:40 jruoho Exp $
+.\" $NetBSD: acpitz.4,v 1.12 2011/01/09 15:12:34 jruoho Exp $
.\"
-.\" Copyright (c) 2003, 2004 The NetBSD Foundation, Inc.
+.\" Copyright (c) 2003, 2004, 2011 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 25, 2010
+.Dd January 9, 2011
.Dt ACPITZ 4
.Os
.Sh NAME
@@ -94,6 +94,7 @@
instantly and no event will have a chance to be sent.
.Sh SEE ALSO
.Xr acpi 4 ,
+.Xr acpifan 4 ,
.Xr envsys 4 ,
.Xr envstat 8 ,
.Xr powerd 8
@@ -103,6 +104,8 @@
driver
appeared in
.Nx 2.0 .
+.Sh AUTHORS
+.An Jared D. McNeill Aq [email protected]
.Sh CAVEATS
While no pronounced bugs are known to exist,
several caveats can be mentioned:
Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.297 src/sys/arch/amd64/conf/GENERIC:1.298
--- src/sys/arch/amd64/conf/GENERIC:1.297 Sun Jan 9 08:05:47 2011
+++ src/sys/arch/amd64/conf/GENERIC Sun Jan 9 15:12:33 2011
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.297 2011/01/09 08:05:47 jruoho Exp $
+# $NetBSD: GENERIC,v 1.298 2011/01/09 15:12:33 jruoho Exp $
#
# GENERIC machine description file
#
@@ -22,7 +22,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.297 $"
+#ident "GENERIC-$Revision: 1.298 $"
maxusers 64 # estimated number of users
@@ -278,6 +278,7 @@
acpidalb* at acpi? # Direct Application Launch Button
acpiec* at acpi? # ACPI Embedded Controller (late)
acpiecdt* at acpi? # ACPI Embedded Controller (early)
+acpifan* at acpi? # ACPI Fan
acpilid* at acpi? # ACPI Lid Switch
#acpipmtr* at acpi? # ACPI Power Meter (experimental)
#acpismbus* at acpi? # ACPI SMBus CMI (experimental)
Index: src/sys/arch/i386/conf/ALL
diff -u src/sys/arch/i386/conf/ALL:1.283 src/sys/arch/i386/conf/ALL:1.284
--- src/sys/arch/i386/conf/ALL:1.283 Mon Jan 3 06:07:43 2011
+++ src/sys/arch/i386/conf/ALL Sun Jan 9 15:12:33 2011
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.283 2011/01/03 06:07:43 tsutsui Exp $
+# $NetBSD: ALL,v 1.284 2011/01/09 15:12:33 jruoho 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.283 $"
+#ident "ALL-$Revision: 1.284 $"
maxusers 64 # estimated number of users
@@ -364,12 +364,11 @@
acpibut* at acpi? # ACPI Button
acpicpu* at acpi? # ACPI CPU
acpidalb* at acpi? # ACPI Direct Application Launch Button
-# The ACPI Embedded Controller is generally configured via the special ECDT.
-# This is required as parts of the DSDT can reference the EC before the normal
-# attach phase.
-acpiec* at acpi? # ACPI Embedded Controller (late binding)
-acpiecdt* at acpi? # ACPI Embedded Controller (early binding)
+acpiec* at acpi? # ACPI Embedded Controller (late)
+acpiecdt* at acpi? # ACPI Embedded Controller (early)
+acpifan* at acpi? # ACPI Fan
acpilid* at acpi? # ACPI Lid Switch
+acpipmtr* at acpi? # ACPI Power Meter (experimental)
# XXX Do not enable this in a real kernel unless you also disable any
# XXX "native" i2c controller. Otherwise you'll have two accessors to
# XXX the same bus, and bad things (tm) will happen!
Index: src/sys/arch/i386/conf/GENERIC
diff -u src/sys/arch/i386/conf/GENERIC:1.1005 src/sys/arch/i386/conf/GENERIC:1.1006
--- src/sys/arch/i386/conf/GENERIC:1.1005 Wed Jan 5 20:08:12 2011
+++ src/sys/arch/i386/conf/GENERIC Sun Jan 9 15:12:33 2011
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1005 2011/01/05 20:08:12 jruoho Exp $
+# $NetBSD: GENERIC,v 1.1006 2011/01/09 15:12:33 jruoho Exp $
#
# GENERIC machine description file
#
@@ -22,7 +22,7 @@
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.1005 $"
+#ident "GENERIC-$Revision: 1.1006 $"
maxusers 64 # estimated number of users
@@ -358,6 +358,7 @@
acpidalb* at acpi? # ACPI Direct Application Launch Button
acpiec* at acpi? # ACPI Embedded Controller (late)
acpiecdt* at acpi? # ACPI Embedded Controller (early)
+acpifan* at acpi? # ACPI Fan
acpilid* at acpi? # ACPI Lid Switch
#acpipmtr* at acpi? # ACPI Power Meter (experimental)
#acpismbus* at acpi? # ACPI SMBus CMI (experimental)
Index: src/sys/dev/acpi/files.acpi
diff -u src/sys/dev/acpi/files.acpi:1.83 src/sys/dev/acpi/files.acpi:1.84
--- src/sys/dev/acpi/files.acpi:1.83 Wed Jan 5 20:08:12 2011
+++ src/sys/dev/acpi/files.acpi Sun Jan 9 15:12:34 2011
@@ -1,4 +1,4 @@
-# $NetBSD: files.acpi,v 1.83 2011/01/05 20:08:12 jruoho Exp $
+# $NetBSD: files.acpi,v 1.84 2011/01/09 15:12:34 jruoho Exp $
include "dev/acpi/acpica/files.acpica"
@@ -73,6 +73,11 @@
attach acpiout at acpivga
file dev/acpi/acpi_display.c acpivga|acpiout
+# ACPI Fan
+device acpifan: sysmon_envsys
+attach acpifan at acpinodebus
+file dev/acpi/acpi_fan.c acpifan
+
# ACPI Power Meter
device acpipmtr: sysmon_envsys
attach acpipmtr at acpinodebus
Index: src/sys/modules/Makefile
diff -u src/sys/modules/Makefile:1.57 src/sys/modules/Makefile:1.58
--- src/sys/modules/Makefile:1.57 Wed Jan 5 20:15:52 2011
+++ src/sys/modules/Makefile Sun Jan 9 15:12:34 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.57 2011/01/05 20:15:52 jruoho Exp $
+# $NetBSD: Makefile,v 1.58 2011/01/09 15:12:34 jruoho Exp $
.include <bsd.own.mk>
@@ -102,6 +102,7 @@
SUBDIR+= acpibut
SUBDIR+= acpicpu
SUBDIR+= acpidalb
+SUBDIR+= acpifan
SUBDIR+= acpilid
SUBDIR+= acpipmtr
SUBDIR+= acpitz
Added files:
Index: src/share/man/man4/acpifan.4
diff -u /dev/null src/share/man/man4/acpifan.4:1.1
--- /dev/null Sun Jan 9 15:12:35 2011
+++ src/share/man/man4/acpifan.4 Sun Jan 9 15:12:34 2011
@@ -0,0 +1,75 @@
+.\" $NetBSD
+.\"
+.\" Copyright (c) 2010 Jukka Ruohonen <[email protected]>
+.\" 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. Neither the name of the author nor the names of any
+.\" contributors may be used to endorse or promote products derived
+.\" from this software without specific prior written permission.
+.\"
+.\" 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 FOUNDATION 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.
+.\"
+.Dd January 9, 2011
+.Dt ACPIFAN 4
+.Os
+.Sh NAME
+.Nm acpifan
+.Nd ACPI Fan
+.Sh SYNOPSIS
+.Cd "acpifan* at acpi?"
+.Sh DESCRIPTION
+The
+.Nm
+device driver supports fans possibly exposed by the
+.Tn BIOS .
+Even though a system may have only one physical fan, multiple
+.Nm
+instances may be present.
+In such cases each
+.Nm
+typically represents an
+.Xr acpitz 4
+thermal zone, and the combined state of all
+instances reveals the speed of the fan.
+.Pp
+The
+.Nm
+driver does not support controlling the fan.
+The current state (on or off) is made available through the
+.Xr envsys 4
+.Tn API
+and the
+.Xr envstat 8
+command.
+.Sh SEE ALSO
+.Xr acpi 4 ,
+.Xr acpitz 4
+.Sh HISTORY
+The
+.Nm
+device driver appeared in
+.Nx 6.0 .
+.Sh AUTHORS
+.An Jukka Ruohonen
+.Aq [email protected]
+.Sh BUGS
+The
+.Nm
+driver does not yet support additional functionality introduced in the
+.Tn ACPI
+4.0 specification.
Index: src/sys/dev/acpi/acpi_fan.c
diff -u /dev/null src/sys/dev/acpi/acpi_fan.c:1.1
--- /dev/null Sun Jan 9 15:12:35 2011
+++ src/sys/dev/acpi/acpi_fan.c Sun Jan 9 15:12:34 2011
@@ -0,0 +1,256 @@
+/* $NetBSD: acpi_fan.c,v 1.1 2011/01/09 15:12:34 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 Jukka Ruohonen <[email protected]>
+ * 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.
+ */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: acpi_fan.c,v 1.1 2011/01/09 15:12:34 jruoho Exp $");
+
+#include <sys/param.h>
+#include <sys/module.h>
+
+#include <dev/acpi/acpireg.h>
+#include <dev/acpi/acpivar.h>
+#include <dev/acpi/acpi_power.h>
+
+#include <dev/sysmon/sysmonvar.h>
+
+#define _COMPONENT ACPI_RESOURCE_COMPONENT
+ACPI_MODULE_NAME ("acpi_fan")
+
+struct acpifan_softc {
+ device_t sc_dev;
+ struct acpi_devnode *sc_node;
+ struct sysmon_envsys *sc_sme;
+ envsys_data_t sc_sensor;
+ int sc_state;
+};
+
+const char * const acpi_fan_ids[] = {
+ "PNP0C0B",
+ NULL
+};
+
+static int acpifan_match(device_t, cfdata_t, void *);
+static void acpifan_attach(device_t, device_t, void *);
+static int acpifan_detach(device_t, int);
+static bool acpifan_suspend(device_t, const pmf_qual_t *);
+static bool acpifan_resume(device_t, const pmf_qual_t *);
+static bool acpifan_shutdown(device_t, int);
+static bool acpifan_sensor_init(device_t);
+static void acpifan_sensor_state(device_t);
+static void acpifan_sensor_refresh(struct sysmon_envsys *,envsys_data_t *);
+
+CFATTACH_DECL_NEW(acpifan, sizeof(struct acpifan_softc),
+ acpifan_match, acpifan_attach, acpifan_detach, NULL);
+
+static int
+acpifan_match(device_t parent, cfdata_t match, void *aux)
+{
+ struct acpi_attach_args *aa = aux;
+
+ if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE)
+ return 0;
+
+ return acpi_match_hid(aa->aa_node->ad_devinfo, acpi_fan_ids);
+}
+
+static void
+acpifan_attach(device_t parent, device_t self, void *aux)
+{
+ struct acpifan_softc *sc = device_private(self);
+ struct acpi_attach_args *aa = aux;
+ ACPI_HANDLE tmp;
+ ACPI_STATUS rv;
+
+ sc->sc_sme = NULL;
+ sc->sc_dev = self;
+ sc->sc_node = aa->aa_node;
+ sc->sc_state = ACPI_STATE_ERROR;
+
+ aprint_naive("\n");
+ aprint_normal(": ACPI Fan\n");
+
+ if (acpifan_sensor_init(self) != true)
+ aprint_error_dev(self, "failed to initialize\n");
+
+ (void)acpi_power_register(sc->sc_node->ad_handle);
+ (void)pmf_device_register1(self, acpifan_suspend,
+ acpifan_resume, acpifan_shutdown);
+
+ rv = AcpiGetHandle(sc->sc_node->ad_handle, "_FIF", &tmp);
+
+ if (ACPI_SUCCESS(rv))
+ aprint_verbose_dev(self, "ACPI 4.0 functionality present\n");
+}
+
+static int
+acpifan_detach(device_t self, int flags)
+{
+ struct acpifan_softc *sc = device_private(self);
+
+ pmf_device_deregister(self);
+ acpi_power_deregister(sc->sc_node->ad_handle);
+
+ if (sc->sc_sme != NULL)
+ sysmon_envsys_unregister(sc->sc_sme);
+
+ return 0;
+}
+
+static bool
+acpifan_suspend(device_t self, const pmf_qual_t *qual)
+{
+ struct acpifan_softc *sc = device_private(self);
+
+ if (sc->sc_state == ACPI_STATE_ERROR)
+ return true;
+
+ (void)acpi_power_get(sc->sc_node->ad_handle, &sc->sc_state);
+ (void)acpi_power_set(sc->sc_node->ad_handle, ACPI_STATE_D0);
+
+ return true;
+}
+
+static bool
+acpifan_resume(device_t self, const pmf_qual_t *qual)
+{
+ struct acpifan_softc *sc = device_private(self);
+
+ if (sc->sc_state != ACPI_STATE_ERROR)
+ (void)acpi_power_set(sc->sc_node->ad_handle, sc->sc_state);
+
+ return true;
+}
+
+static bool
+acpifan_shutdown(device_t self, int how)
+{
+ struct acpifan_softc *sc = device_private(self);
+
+ if (sc->sc_state != ACPI_STATE_ERROR)
+ (void)acpi_power_set(sc->sc_node->ad_handle, ACPI_STATE_D3);
+
+ return true;
+}
+
+static bool
+acpifan_sensor_init(device_t self)
+{
+ struct acpifan_softc *sc = device_private(self);
+
+ if (acpi_power_get(sc->sc_node->ad_handle, &sc->sc_state) != true)
+ return false;
+
+ sc->sc_sme = sysmon_envsys_create();
+
+ acpifan_sensor_state(self);
+ sc->sc_sensor.units = ENVSYS_INDICATOR;
+
+ (void)strlcpy(sc->sc_sensor.desc, "state", sizeof(sc->sc_sensor.desc));
+
+ sc->sc_sme->sme_cookie = self;
+ sc->sc_sme->sme_flags = SME_POLL_ONLY;
+ sc->sc_sme->sme_name = device_xname(self);
+ sc->sc_sme->sme_refresh = acpifan_sensor_refresh;
+
+ if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor) != 0)
+ goto fail;
+
+ if (sysmon_envsys_register(sc->sc_sme) != 0)
+ goto fail;
+
+ return true;
+
+fail:
+ sysmon_envsys_destroy(sc->sc_sme);
+ sc->sc_sme = NULL;
+
+ return false;
+}
+
+static void
+acpifan_sensor_state(device_t self)
+{
+ struct acpifan_softc *sc = device_private(self);
+ int state = ACPI_STATE_ERROR;
+
+ (void)acpi_power_get(sc->sc_node->ad_handle, &state);
+
+ switch (state) {
+
+ case ACPI_STATE_D0:
+ case ACPI_STATE_D1:
+ case ACPI_STATE_D2:
+ sc->sc_sensor.value_cur = 1;
+ sc->sc_sensor.state = ENVSYS_SVALID;
+ break;
+
+ case ACPI_STATE_D3:
+ sc->sc_sensor.value_cur = 0;
+ sc->sc_sensor.state = ENVSYS_SVALID;
+ break;
+
+ default:
+ sc->sc_sensor.state = ENVSYS_SINVALID;
+ break;
+ }
+}
+
+static void
+acpifan_sensor_refresh(struct sysmon_envsys *sme, envsys_data_t *edata)
+{
+ device_t self = sme->sme_cookie;
+
+ acpifan_sensor_state(self);
+}
+
+#ifdef _MODULE
+
+MODULE(MODULE_CLASS_DRIVER, acpifan, NULL);
+
+#include "ioconf.c"
+
+static int
+acpifan_modcmd(modcmd_t cmd, void *context)
+{
+
+ switch (cmd) {
+
+ case MODULE_CMD_INIT:
+ return config_init_component(cfdriver_ioconf_acpifan,
+ cfattach_ioconf_acpifan, cfdata_ioconf_acpifan);
+
+ case MODULE_CMD_FINI:
+ return config_fini_component(cfdriver_ioconf_acpifan,
+ cfattach_ioconf_acpifan, cfdata_ioconf_acpifan);
+
+ default:
+ return ENOTTY;
+ }
+}
+
+#endif /* _MODULE */
Index: src/sys/modules/acpifan/ACPIFAN.ioconf
diff -u /dev/null src/sys/modules/acpifan/ACPIFAN.ioconf:1.1
--- /dev/null Sun Jan 9 15:12:35 2011
+++ src/sys/modules/acpifan/ACPIFAN.ioconf Sun Jan 9 15:12:34 2011
@@ -0,0 +1,10 @@
+# $NetBSD: ACPIFAN.ioconf,v 1.1 2011/01/09 15:12:34 jruoho Exp $
+
+ioconf acpifan
+
+include "conf/files"
+include "dev/acpi/files.acpi"
+
+pseudo-root acpi*
+
+acpifan* at acpi?
Index: src/sys/modules/acpifan/Makefile
diff -u /dev/null src/sys/modules/acpifan/Makefile:1.1
--- /dev/null Sun Jan 9 15:12:35 2011
+++ src/sys/modules/acpifan/Makefile Sun Jan 9 15:12:34 2011
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1 2011/01/09 15:12:34 jruoho Exp $
+
+.include "../Makefile.inc"
+
+.PATH: ${S}/dev/acpi
+
+KMOD= acpifan
+IOCONF= ACPIFAN.ioconf
+SRCS= acpi_fan.c
+
+WARNS= 4
+
+.include <bsd.kmodule.mk>