Pull up following revision(s) (requested by jdp in ticket #893): sys/arch/sparc64/dev/tda.c 1.7-1.8 share/man/man4/man4.sparc64/tda.4 1.1-1.3 share/man/man4/man4.sparc64/Makefile 1.7 distrib/sets/lists/man/mi 1.1419 Add sysmon support to display the CPU and Sytem fan speeds for the tda driver. Add a manual page for tda(4). Fix a bug which caused the system fan to always run at full speed.diff -r1.1379.2.9 -r1.1379.2.10 src/distrib/sets/lists/man/mi
(msaitoh)
--- src/distrib/sets/lists/man/mi 2012/12/15 05:40:18 1.1379.2.9
+++ src/distrib/sets/lists/man/mi 2013/06/13 07:30:45 1.1379.2.10
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | # $NetBSD: mi,v 1.1379.2.9 2012/12/15 05:40:18 riz Exp $ | 1 | # $NetBSD: mi,v 1.1379.2.10 2013/06/13 07:30:45 msaitoh Exp $ | |
2 | # | 2 | # | |
3 | # Note: don't delete entries from here - mark them as "obsolete" instead. | 3 | # Note: don't delete entries from here - mark them as "obsolete" instead. | |
4 | # | 4 | # | |
5 | ./etc/mtree/set.man man-sys-root | 5 | ./etc/mtree/set.man man-sys-root | |
6 | ./usr/share/info/am-utils.info man-amd-info info | 6 | ./usr/share/info/am-utils.info man-amd-info info | |
7 | ./usr/share/info/as.info man-computil-info binutils,info | 7 | ./usr/share/info/as.info man-computil-info binutils,info | |
8 | ./usr/share/info/awk.info man-util-info info | 8 | ./usr/share/info/awk.info man-util-info info | |
9 | ./usr/share/info/bfd.info man-computil-info binutils,info | 9 | ./usr/share/info/bfd.info man-computil-info binutils,info | |
10 | ./usr/share/info/binutils.info man-computil-info binutils,info | 10 | ./usr/share/info/binutils.info man-computil-info binutils,info | |
11 | ./usr/share/info/bzip2.info man-obsolete obsolete | 11 | ./usr/share/info/bzip2.info man-obsolete obsolete | |
12 | ./usr/share/info/cpp.info man-util-info gcccmds,info | 12 | ./usr/share/info/cpp.info man-util-info gcccmds,info | |
13 | ./usr/share/info/cvs.info man-cvs-info cvs,info | 13 | ./usr/share/info/cvs.info man-cvs-info cvs,info | |
14 | ./usr/share/info/cvsclient.info man-cvs-info cvs,info | 14 | ./usr/share/info/cvsclient.info man-cvs-info cvs,info | |
@@ -1577,26 +1577,27 @@ | @@ -1577,26 +1577,27 @@ | |||
1577 | ./usr/share/man/cat4/sparc/tcx.0 man-sys-catman .cat | 1577 | ./usr/share/man/cat4/sparc/tcx.0 man-sys-catman .cat | |
1578 | ./usr/share/man/cat4/sparc/timer.0 man-sys-catman .cat | 1578 | ./usr/share/man/cat4/sparc/timer.0 man-sys-catman .cat | |
1579 | ./usr/share/man/cat4/sparc/tslot.0 man-sys-catman .cat | 1579 | ./usr/share/man/cat4/sparc/tslot.0 man-sys-catman .cat | |
1580 | ./usr/share/man/cat4/sparc/xd.0 man-sys-catman .cat | 1580 | ./usr/share/man/cat4/sparc/xd.0 man-sys-catman .cat | |
1581 | ./usr/share/man/cat4/sparc/xy.0 man-sys-catman .cat | 1581 | ./usr/share/man/cat4/sparc/xy.0 man-sys-catman .cat | |
1582 | ./usr/share/man/cat4/sparc/zx.0 man-sys-catman .cat | 1582 | ./usr/share/man/cat4/sparc/zx.0 man-sys-catman .cat | |
1583 | ./usr/share/man/cat4/sparc64/envctrl.0 man-sys-catman .cat | 1583 | ./usr/share/man/cat4/sparc64/envctrl.0 man-sys-catman .cat | |
1584 | ./usr/share/man/cat4/sparc64/fdc.0 man-sys-catman .cat | 1584 | ./usr/share/man/cat4/sparc64/fdc.0 man-sys-catman .cat | |
1585 | ./usr/share/man/cat4/sparc64/ffb.0 man-sys-catman .cat | 1585 | ./usr/share/man/cat4/sparc64/ffb.0 man-sys-catman .cat | |
1586 | ./usr/share/man/cat4/sparc64/intro.0 man-sys-catman .cat | 1586 | ./usr/share/man/cat4/sparc64/intro.0 man-sys-catman .cat | |
1587 | ./usr/share/man/cat4/sparc64/lom.0 man-sys-catman .cat | 1587 | ./usr/share/man/cat4/sparc64/lom.0 man-sys-catman .cat | |
1588 | ./usr/share/man/cat4/sparc64/sab.0 man-sys-catman .cat | 1588 | ./usr/share/man/cat4/sparc64/sab.0 man-sys-catman .cat | |
1589 | ./usr/share/man/cat4/sparc64/sabtty.0 man-sys-catman .cat | 1589 | ./usr/share/man/cat4/sparc64/sabtty.0 man-sys-catman .cat | |
1590 | ./usr/share/man/cat4/sparc64/tda.0 man-sys-catman .cat | |||
1590 | ./usr/share/man/cat4/spc.0 man-sys-catman .cat | 1591 | ./usr/share/man/cat4/spc.0 man-sys-catman .cat | |
1591 | ./usr/share/man/cat4/spdmem.0 man-sys-catman .cat | 1592 | ./usr/share/man/cat4/spdmem.0 man-sys-catman .cat | |
1592 | ./usr/share/man/cat4/speaker.0 man-sys-catman .cat | 1593 | ./usr/share/man/cat4/speaker.0 man-sys-catman .cat | |
1593 | ./usr/share/man/cat4/spi.0 man-sys-catman .cat | 1594 | ./usr/share/man/cat4/spi.0 man-sys-catman .cat | |
1594 | ./usr/share/man/cat4/spic.0 man-obsolete obsolete | 1595 | ./usr/share/man/cat4/spic.0 man-obsolete obsolete | |
1595 | ./usr/share/man/cat4/spif.0 man-sys-catman .cat | 1596 | ./usr/share/man/cat4/spif.0 man-sys-catman .cat | |
1596 | ./usr/share/man/cat4/spkr.0 man-sys-catman .cat | 1597 | ./usr/share/man/cat4/spkr.0 man-sys-catman .cat | |
1597 | ./usr/share/man/cat4/spp.0 man-obsolete obsolete | 1598 | ./usr/share/man/cat4/spp.0 man-obsolete obsolete | |
1598 | ./usr/share/man/cat4/sqphy.0 man-sys-catman .cat | 1599 | ./usr/share/man/cat4/sqphy.0 man-sys-catman .cat | |
1599 | ./usr/share/man/cat4/ss.0 man-sys-catman .cat | 1600 | ./usr/share/man/cat4/ss.0 man-sys-catman .cat | |
1600 | ./usr/share/man/cat4/st.0 man-sys-catman .cat | 1601 | ./usr/share/man/cat4/st.0 man-sys-catman .cat | |
1601 | ./usr/share/man/cat4/stderr.0 man-sys-catman .cat | 1602 | ./usr/share/man/cat4/stderr.0 man-sys-catman .cat | |
1602 | ./usr/share/man/cat4/stdin.0 man-sys-catman .cat | 1603 | ./usr/share/man/cat4/stdin.0 man-sys-catman .cat | |
@@ -4383,26 +4384,27 @@ | @@ -4383,26 +4384,27 @@ | |||
4383 | ./usr/share/man/html4/sparc/tcx.html man-sys-htmlman html | 4384 | ./usr/share/man/html4/sparc/tcx.html man-sys-htmlman html | |
4384 | ./usr/share/man/html4/sparc/timer.html man-sys-htmlman html | 4385 | ./usr/share/man/html4/sparc/timer.html man-sys-htmlman html | |
4385 | ./usr/share/man/html4/sparc/tslot.html man-sys-htmlman html | 4386 | ./usr/share/man/html4/sparc/tslot.html man-sys-htmlman html | |
4386 | ./usr/share/man/html4/sparc/xd.html man-sys-htmlman html | 4387 | ./usr/share/man/html4/sparc/xd.html man-sys-htmlman html | |
4387 | ./usr/share/man/html4/sparc/xy.html man-sys-htmlman html | 4388 | ./usr/share/man/html4/sparc/xy.html man-sys-htmlman html | |
4388 | ./usr/share/man/html4/sparc/zx.html man-sys-htmlman html | 4389 | ./usr/share/man/html4/sparc/zx.html man-sys-htmlman html | |
4389 | ./usr/share/man/html4/sparc64/envctrl.html man-sys-htmlman html | 4390 | ./usr/share/man/html4/sparc64/envctrl.html man-sys-htmlman html | |
4390 | ./usr/share/man/html4/sparc64/fdc.html man-sys-htmlman html | 4391 | ./usr/share/man/html4/sparc64/fdc.html man-sys-htmlman html | |
4391 | ./usr/share/man/html4/sparc64/ffb.html man-sys-htmlman html | 4392 | ./usr/share/man/html4/sparc64/ffb.html man-sys-htmlman html | |
4392 | ./usr/share/man/html4/sparc64/intro.html man-sys-htmlman html | 4393 | ./usr/share/man/html4/sparc64/intro.html man-sys-htmlman html | |
4393 | ./usr/share/man/html4/sparc64/lom.html man-sys-htmlman html | 4394 | ./usr/share/man/html4/sparc64/lom.html man-sys-htmlman html | |
4394 | ./usr/share/man/html4/sparc64/sab.html man-sys-htmlman html | 4395 | ./usr/share/man/html4/sparc64/sab.html man-sys-htmlman html | |
4395 | ./usr/share/man/html4/sparc64/sabtty.html man-sys-htmlman html | 4396 | ./usr/share/man/html4/sparc64/sabtty.html man-sys-htmlman html | |
4397 | ./usr/share/man/html4/sparc64/tda.html man-sys-htmlman html | |||
4396 | ./usr/share/man/html4/spc.html man-sys-htmlman html | 4398 | ./usr/share/man/html4/spc.html man-sys-htmlman html | |
4397 | ./usr/share/man/html4/spdmem.html man-sys-htmlman html | 4399 | ./usr/share/man/html4/spdmem.html man-sys-htmlman html | |
4398 | ./usr/share/man/html4/speaker.html man-sys-htmlman html | 4400 | ./usr/share/man/html4/speaker.html man-sys-htmlman html | |
4399 | ./usr/share/man/html4/spi.html man-sys-htmlman html | 4401 | ./usr/share/man/html4/spi.html man-sys-htmlman html | |
4400 | ./usr/share/man/html4/spif.html man-sys-htmlman html | 4402 | ./usr/share/man/html4/spif.html man-sys-htmlman html | |
4401 | ./usr/share/man/html4/spkr.html man-sys-htmlman html | 4403 | ./usr/share/man/html4/spkr.html man-sys-htmlman html | |
4402 | ./usr/share/man/html4/sqphy.html man-sys-htmlman html | 4404 | ./usr/share/man/html4/sqphy.html man-sys-htmlman html | |
4403 | ./usr/share/man/html4/ss.html man-sys-htmlman html | 4405 | ./usr/share/man/html4/ss.html man-sys-htmlman html | |
4404 | ./usr/share/man/html4/st.html man-sys-htmlman html | 4406 | ./usr/share/man/html4/st.html man-sys-htmlman html | |
4405 | ./usr/share/man/html4/stderr.html man-sys-htmlman html | 4407 | ./usr/share/man/html4/stderr.html man-sys-htmlman html | |
4406 | ./usr/share/man/html4/stdin.html man-sys-htmlman html | 4408 | ./usr/share/man/html4/stdin.html man-sys-htmlman html | |
4407 | ./usr/share/man/html4/stdout.html man-sys-htmlman html | 4409 | ./usr/share/man/html4/stdout.html man-sys-htmlman html | |
4408 | ./usr/share/man/html4/ste.html man-sys-htmlman html | 4410 | ./usr/share/man/html4/ste.html man-sys-htmlman html | |
@@ -7102,26 +7104,27 @@ | @@ -7102,26 +7104,27 @@ | |||
7102 | ./usr/share/man/man4/sparc/tcx.4 man-sys-man .man | 7104 | ./usr/share/man/man4/sparc/tcx.4 man-sys-man .man | |
7103 | ./usr/share/man/man4/sparc/timer.4 man-sys-man .man | 7105 | ./usr/share/man/man4/sparc/timer.4 man-sys-man .man | |
7104 | ./usr/share/man/man4/sparc/tslot.4 man-sys-man .man | 7106 | ./usr/share/man/man4/sparc/tslot.4 man-sys-man .man | |
7105 | ./usr/share/man/man4/sparc/xd.4 man-sys-man .man | 7107 | ./usr/share/man/man4/sparc/xd.4 man-sys-man .man | |
7106 | ./usr/share/man/man4/sparc/xy.4 man-sys-man .man | 7108 | ./usr/share/man/man4/sparc/xy.4 man-sys-man .man | |
7107 | ./usr/share/man/man4/sparc/zx.4 man-sys-man .man | 7109 | ./usr/share/man/man4/sparc/zx.4 man-sys-man .man | |
7108 | ./usr/share/man/man4/sparc64/envctrl.4 man-sys-man .man | 7110 | ./usr/share/man/man4/sparc64/envctrl.4 man-sys-man .man | |
7109 | ./usr/share/man/man4/sparc64/fdc.4 man-sys-man .man | 7111 | ./usr/share/man/man4/sparc64/fdc.4 man-sys-man .man | |
7110 | ./usr/share/man/man4/sparc64/ffb.4 man-sys-man .man | 7112 | ./usr/share/man/man4/sparc64/ffb.4 man-sys-man .man | |
7111 | ./usr/share/man/man4/sparc64/intro.4 man-sys-man .man | 7113 | ./usr/share/man/man4/sparc64/intro.4 man-sys-man .man | |
7112 | ./usr/share/man/man4/sparc64/lom.4 man-sys-man .man | 7114 | ./usr/share/man/man4/sparc64/lom.4 man-sys-man .man | |
7113 | ./usr/share/man/man4/sparc64/sab.4 man-sys-man .man | 7115 | ./usr/share/man/man4/sparc64/sab.4 man-sys-man .man | |
7114 | ./usr/share/man/man4/sparc64/sabtty.4 man-sys-man .man | 7116 | ./usr/share/man/man4/sparc64/sabtty.4 man-sys-man .man | |
7117 | ./usr/share/man/man4/sparc64/tda.4 man-sys-man .man | |||
7115 | ./usr/share/man/man4/spc.4 man-sys-man .man | 7118 | ./usr/share/man/man4/spc.4 man-sys-man .man | |
7116 | ./usr/share/man/man4/spdmem.4 man-sys-man .man | 7119 | ./usr/share/man/man4/spdmem.4 man-sys-man .man | |
7117 | ./usr/share/man/man4/speaker.4 man-sys-man .man | 7120 | ./usr/share/man/man4/speaker.4 man-sys-man .man | |
7118 | ./usr/share/man/man4/spi.4 man-sys-man .man | 7121 | ./usr/share/man/man4/spi.4 man-sys-man .man | |
7119 | ./usr/share/man/man4/spic.4 man-obsolete obsolete | 7122 | ./usr/share/man/man4/spic.4 man-obsolete obsolete | |
7120 | ./usr/share/man/man4/spif.4 man-sys-man .man | 7123 | ./usr/share/man/man4/spif.4 man-sys-man .man | |
7121 | ./usr/share/man/man4/spkr.4 man-sys-man .man | 7124 | ./usr/share/man/man4/spkr.4 man-sys-man .man | |
7122 | ./usr/share/man/man4/spp.4 man-obsolete obsolete | 7125 | ./usr/share/man/man4/spp.4 man-obsolete obsolete | |
7123 | ./usr/share/man/man4/sqphy.4 man-sys-man .man | 7126 | ./usr/share/man/man4/sqphy.4 man-sys-man .man | |
7124 | ./usr/share/man/man4/ss.4 man-sys-man .man | 7127 | ./usr/share/man/man4/ss.4 man-sys-man .man | |
7125 | ./usr/share/man/man4/st.4 man-sys-man .man | 7128 | ./usr/share/man/man4/st.4 man-sys-man .man | |
7126 | ./usr/share/man/man4/stderr.4 man-sys-man .man | 7129 | ./usr/share/man/man4/stderr.4 man-sys-man .man | |
7127 | ./usr/share/man/man4/stdin.4 man-sys-man .man | 7130 | ./usr/share/man/man4/stdin.4 man-sys-man .man |
--- src/share/man/man4/man4.sparc64/Makefile 2011/04/09 19:37:13 1.6
+++ src/share/man/man4/man4.sparc64/Makefile 2013/06/13 07:30:45 1.6.6.1
.\" $NetBSD: tda.4,v 1.3.4.2 2013/06/13 07:30:45 msaitoh Exp $
.\"
.\" Copyright (c) 2013 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Julian Coleman
.\"
.\" 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 NETBSD FOUNDATION, INC. 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 February 2, 2013
.Dt TDA 4 sparc64
.Os
.Sh NAME
.Nm tda
.Nd TDA8444 fan speed controller
.Sh SYNOPSIS
.Cd "tda0 at iic1 addr 0x24: fan-control"
.Sh DESCRIPTION
The
.Nm
driver provides support for the TDA8444 DAC used to control the fan speeds
in Sun Blade 1000 and Blade 2000 systems.
The speed of the CPU fan and of the system fan are automatically adjusted
every 60 seconds, based on the currently reported CPU and system
temperatures, respectively.
.Pp
The speed-related values are made available through the
.Xr envstat 8
interface.
The range of the values are:
.Bl -column -offset indent ".Sy System temperature" ".Sy Minimum" ".Sy Maximum"
.It Sy Ta Sy Minimum Ta Sy Maximum
.It Li CPU temperature Ta <=57 Ta >=67
.It Li System temperature Ta <=20 Ta >=30
.It Li Speed value Ta 12 Ta 63
.El
.Sh SEE ALSO
.Xr admtemp 4 ,
.Xr envstat 8
.Sh BUGS
The temperatures are reported as
.Sq internal
and
.Sq external
instead of
.Sq system
and
.Sq CPU ,
respectively.
--- src/sys/arch/sparc64/dev/tda.c 2011/04/03 06:25:11 1.4
+++ src/sys/arch/sparc64/dev/tda.c 2013/06/13 07:30:45 1.4.10.1
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tda.c,v 1.4 2011/04/03 06:25:11 jdc Exp $ */ | 1 | /* $NetBSD: tda.c,v 1.4.10.1 2013/06/13 07:30:45 msaitoh Exp $ */ | |
2 | /* $OpenBSD: tda.c,v 1.4 2008/02/27 17:25:00 robert Exp $ */ | 2 | /* $OpenBSD: tda.c,v 1.4 2008/02/27 17:25:00 robert Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> | 5 | * Copyright (c) 2008 Robert Nagy <robert@openbsd.org> | |
6 | * Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org> | 6 | * Copyright (c) 2008 Mark Kettenis <kettenis@openbsd.org> | |
7 | * | 7 | * | |
8 | * Permission to use, copy, modify, and distribute this software for any | 8 | * Permission to use, copy, modify, and distribute this software for any | |
9 | * purpose with or without fee is hereby granted, provided that the above | 9 | * purpose with or without fee is hereby granted, provided that the above | |
10 | * copyright notice and this permission notice appear in all copies. | 10 | * copyright notice and this permission notice appear in all copies. | |
11 | * | 11 | * | |
12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
@@ -31,56 +31,66 @@ | @@ -31,56 +31,66 @@ | |||
31 | #include <dev/i2c/i2cvar.h> | 31 | #include <dev/i2c/i2cvar.h> | |
32 | 32 | |||
33 | /* fan control registers */ | 33 | /* fan control registers */ | |
34 | #define TDA_SYSFAN_REG 0xf0 | 34 | #define TDA_SYSFAN_REG 0xf0 | |
35 | #define TDA_CPUFAN_REG 0xf2 | 35 | #define TDA_CPUFAN_REG 0xf2 | |
36 | #define TDA_PSFAN_REG 0xf4 | 36 | #define TDA_PSFAN_REG 0xf4 | |
37 | 37 | |||
38 | #define TDA_FANSPEED_MIN 0x0c | 38 | #define TDA_FANSPEED_MIN 0x0c | |
39 | #define TDA_FANSPEED_MAX 0x3f | 39 | #define TDA_FANSPEED_MAX 0x3f | |
40 | 40 | |||
41 | #define TDA_PSFAN_ON 0x1f | 41 | #define TDA_PSFAN_ON 0x1f | |
42 | #define TDA_PSFAN_OFF 0x00 | 42 | #define TDA_PSFAN_OFF 0x00 | |
43 | 43 | |||
44 | /* Internal and External temperature senor numbers */ | 44 | /* Internal and External temperature sensor numbers */ | |
45 | #define SENSOR_TEMP_EXT 0 | 45 | #define SENSOR_TEMP_EXT 0 | |
46 | #define SENSOR_TEMP_INT 1 | 46 | #define SENSOR_TEMP_INT 1 | |
47 | 47 | |||
48 | /* Fan sensor numbers */ | |||
49 | #define SENSOR_FAN_CPU 0 | |||
50 | #define SENSOR_FAN_SYS 1 | |||
51 | ||||
48 | #define CPU_TEMP_MAX (67 * 1000000 + 273150000) | 52 | #define CPU_TEMP_MAX (67 * 1000000 + 273150000) | |
49 | #define CPU_TEMP_MIN (57 * 1000000 + 273150000) | 53 | #define CPU_TEMP_MIN (57 * 1000000 + 273150000) | |
50 | #define SYS_TEMP_MAX (30 * 1000000 + 273150000) | 54 | #define SYS_TEMP_MAX (30 * 1000000 + 273150000) | |
51 | #define SYS_TEMP_MIN (20 * 1000000 + 273150000) | 55 | #define SYS_TEMP_MIN (20 * 1000000 + 273150000) | |
52 | 56 | |||
53 | struct tda_softc { | 57 | struct tda_softc { | |
54 | device_t sc_dev; | 58 | device_t sc_dev; | |
55 | i2c_tag_t sc_tag; | 59 | i2c_tag_t sc_tag; | |
56 | i2c_addr_t sc_addr; | 60 | i2c_addr_t sc_addr; | |
57 | 61 | |||
58 | u_int16_t sc_cfan_speed; /* current CPU fan speed */ | 62 | u_int16_t sc_cfan_speed; /* current CPU fan speed */ | |
59 | u_int16_t sc_sfan_speed; /* current SYS fan speed */ | 63 | u_int16_t sc_sfan_speed; /* current SYS fan speed */ | |
60 | 64 | |||
65 | struct sysmon_envsys *sc_sme; | |||
66 | envsys_data_t sc_sensor[2]; | |||
67 | ||||
61 | callout_t sc_timer; | 68 | callout_t sc_timer; | |
62 | }; | 69 | }; | |
63 | 70 | |||
64 | int tda_match(struct device *, struct cfdata *, void *); | 71 | int tda_match(struct device *, struct cfdata *, void *); | |
65 | void tda_attach(struct device *, struct device *, void *); | 72 | void tda_attach(struct device *, struct device *, void *); | |
73 | static int tda_detach(struct device *, int); | |||
74 | void tda_refresh(struct sysmon_envsys *, envsys_data_t *); | |||
66 | 75 | |||
67 | void tda_setspeed(struct tda_softc *); | 76 | void tda_setspeed(struct tda_softc *); | |
68 | static void tda_adjust(void *); | 77 | static void tda_adjust(void *); | |
69 | static void tda_timeout(void *); | 78 | static void tda_timeout(void *); | |
70 | 79 | |||
71 | 80 | |||
72 | CFATTACH_DECL_NEW(tda, sizeof(struct tda_softc), | 81 | CFATTACH_DECL3_NEW(tda, sizeof(struct tda_softc), | |
73 | tda_match, tda_attach, NULL, NULL); | 82 | tda_match, tda_attach, tda_detach, NULL, NULL, NULL, | |
83 | DVF_DETACH_SHUTDOWN); | |||
74 | 84 | |||
75 | int | 85 | int | |
76 | tda_match(struct device *parent, struct cfdata *match, void *aux) | 86 | tda_match(struct device *parent, struct cfdata *match, void *aux) | |
77 | { | 87 | { | |
78 | struct i2c_attach_args *ia = aux; | 88 | struct i2c_attach_args *ia = aux; | |
79 | char name[32]; | 89 | char name[32]; | |
80 | 90 | |||
81 | /* Only attach on the Sun Blade 1000/2000. */ | 91 | /* Only attach on the Sun Blade 1000/2000. */ | |
82 | if (OF_getprop(findroot(), "name", name, sizeof(name)) <= 0) | 92 | if (OF_getprop(findroot(), "name", name, sizeof(name)) <= 0) | |
83 | return (0); | 93 | return (0); | |
84 | if (strcmp(name, "SUNW,Sun-Blade-1000") != 0) | 94 | if (strcmp(name, "SUNW,Sun-Blade-1000") != 0) | |
85 | return (0); | 95 | return (0); | |
86 | 96 | |||
@@ -102,29 +112,81 @@ tda_attach(struct device *parent, struct | @@ -102,29 +112,81 @@ tda_attach(struct device *parent, struct | |||
102 | sc->sc_dev = self; | 112 | sc->sc_dev = self; | |
103 | sc->sc_tag = ia->ia_tag; | 113 | sc->sc_tag = ia->ia_tag; | |
104 | sc->sc_addr = ia->ia_addr; | 114 | sc->sc_addr = ia->ia_addr; | |
105 | 115 | |||
106 | aprint_normal(": %s\n", ia->ia_name); | 116 | aprint_normal(": %s\n", ia->ia_name); | |
107 | aprint_naive(": Environment sensor\n"); | 117 | aprint_naive(": Environment sensor\n"); | |
108 | 118 | |||
109 | /* | 119 | /* | |
110 | * Set the fans to maximum speed and save the power levels; | 120 | * Set the fans to maximum speed and save the power levels; | |
111 | * the controller is write-only. | 121 | * the controller is write-only. | |
112 | */ | 122 | */ | |
113 | sc->sc_cfan_speed = sc->sc_sfan_speed = (TDA_FANSPEED_MAX+TDA_FANSPEED_MIN)/2; | 123 | sc->sc_cfan_speed = sc->sc_sfan_speed = (TDA_FANSPEED_MAX+TDA_FANSPEED_MIN)/2; | |
114 | tda_setspeed(sc); | 124 | tda_setspeed(sc); | |
115 | 125 | |||
116 | callout_init(&sc->sc_timer, CALLOUT_MPSAFE); | 126 | callout_init(&sc->sc_timer, CALLOUT_MPSAFE); | |
117 | callout_reset(&sc->sc_timer, hz*20, tda_timeout, sc); | 127 | callout_reset(&sc->sc_timer, hz*20, tda_timeout, sc); | |
128 | ||||
129 | /* Initialise sensor data */ | |||
130 | sc->sc_sensor[SENSOR_FAN_CPU].state = ENVSYS_SINVALID; | |||
131 | sc->sc_sensor[SENSOR_FAN_CPU].units = ENVSYS_INTEGER; | |||
132 | sc->sc_sensor[SENSOR_FAN_CPU].flags = ENVSYS_FMONNOTSUPP; | |||
133 | strlcpy(sc->sc_sensor[SENSOR_FAN_CPU].desc, | |||
134 | "fan.cpu",sizeof("fan.cpu")); | |||
135 | sc->sc_sensor[SENSOR_FAN_SYS].state = ENVSYS_SINVALID; | |||
136 | sc->sc_sensor[SENSOR_FAN_SYS].units = ENVSYS_INTEGER; | |||
137 | sc->sc_sensor[SENSOR_FAN_SYS].flags = ENVSYS_FMONNOTSUPP; | |||
138 | strlcpy(sc->sc_sensor[SENSOR_FAN_SYS].desc, | |||
139 | "fan.sys",sizeof("fan.sys")); | |||
140 | sc->sc_sme = sysmon_envsys_create(); | |||
141 | if (sysmon_envsys_sensor_attach( | |||
142 | sc->sc_sme, &sc->sc_sensor[SENSOR_FAN_CPU])) { | |||
143 | sysmon_envsys_destroy(sc->sc_sme); | |||
144 | aprint_error_dev(self, | |||
145 | "unable to attach cpu fan at sysmon\n"); | |||
146 | return; | |||
147 | } | |||
148 | if (sysmon_envsys_sensor_attach( | |||
149 | sc->sc_sme, &sc->sc_sensor[SENSOR_FAN_SYS])) { | |||
150 | sysmon_envsys_destroy(sc->sc_sme); | |||
151 | aprint_error_dev(self, | |||
152 | "unable to attach sys fan at sysmon\n"); | |||
153 | return; | |||
154 | } | |||
155 | sc->sc_sme->sme_name = device_xname(self); | |||
156 | sc->sc_sme->sme_cookie = sc; | |||
157 | sc->sc_sme->sme_refresh = tda_refresh; | |||
158 | if (sysmon_envsys_register(sc->sc_sme)) { | |||
159 | aprint_error_dev(self, | |||
160 | "unable to register with sysmon\n"); | |||
161 | sysmon_envsys_destroy(sc->sc_sme); | |||
162 | return; | |||
163 | } | |||
164 | } | |||
165 | ||||
166 | int | |||
167 | tda_detach(struct device *self, int flags) | |||
168 | { | |||
169 | struct tda_softc *sc = device_private(self); | |||
170 | ||||
171 | if (sc->sc_sme != NULL) | |||
172 | sysmon_envsys_destroy(sc->sc_sme); | |||
173 | ||||
174 | callout_halt(&sc->sc_timer, NULL); | |||
175 | callout_destroy(&sc->sc_timer); | |||
176 | ||||
177 | sc->sc_cfan_speed = sc->sc_sfan_speed = TDA_FANSPEED_MAX; | |||
178 | tda_setspeed(sc); | |||
179 | return 0; | |||
118 | } | 180 | } | |
119 | 181 | |||
120 | static void | 182 | static void | |
121 | tda_timeout(void *v) | 183 | tda_timeout(void *v) | |
122 | { | 184 | { | |
123 | struct tda_softc *sc = v; | 185 | struct tda_softc *sc = v; | |
124 | 186 | |||
125 | sysmon_task_queue_sched(0, tda_adjust, sc); | 187 | sysmon_task_queue_sched(0, tda_adjust, sc); | |
126 | callout_reset(&sc->sc_timer, hz*60, tda_timeout, sc); | 188 | callout_reset(&sc->sc_timer, hz*60, tda_timeout, sc); | |
127 | } | 189 | } | |
128 | 190 | |||
129 | void | 191 | void | |
130 | tda_setspeed(struct tda_softc *sc) | 192 | tda_setspeed(struct tda_softc *sc) | |
@@ -208,25 +270,44 @@ tda_adjust(void *v) | @@ -208,25 +270,44 @@ tda_adjust(void *v) | |||
208 | ctemp, stemp); | 270 | ctemp, stemp); | |
209 | 271 | |||
210 | if (ctemp < CPU_TEMP_MIN) | 272 | if (ctemp < CPU_TEMP_MIN) | |
211 | cspeed = TDA_FANSPEED_MIN; | 273 | cspeed = TDA_FANSPEED_MIN; | |
212 | else if (ctemp < CPU_TEMP_MAX) | 274 | else if (ctemp < CPU_TEMP_MAX) | |
213 | cspeed = TDA_FANSPEED_MIN + | 275 | cspeed = TDA_FANSPEED_MIN + | |
214 | (ctemp - CPU_TEMP_MIN) * | 276 | (ctemp - CPU_TEMP_MIN) * | |
215 | (TDA_FANSPEED_MAX - TDA_FANSPEED_MIN) / | 277 | (TDA_FANSPEED_MAX - TDA_FANSPEED_MIN) / | |
216 | (CPU_TEMP_MAX - CPU_TEMP_MIN); | 278 | (CPU_TEMP_MAX - CPU_TEMP_MIN); | |
217 | 279 | |||
218 | if (stemp < SYS_TEMP_MIN) | 280 | if (stemp < SYS_TEMP_MIN) | |
219 | sspeed = TDA_FANSPEED_MIN; | 281 | sspeed = TDA_FANSPEED_MIN; | |
220 | else if (stemp < SYS_TEMP_MAX) | 282 | else if (stemp < SYS_TEMP_MAX) | |
221 | sc->sc_sfan_speed = TDA_FANSPEED_MIN + | 283 | sspeed = TDA_FANSPEED_MIN + | |
222 | (stemp - SYS_TEMP_MIN) * | 284 | (stemp - SYS_TEMP_MIN) * | |
223 | (TDA_FANSPEED_MAX - TDA_FANSPEED_MIN) / | 285 | (TDA_FANSPEED_MAX - TDA_FANSPEED_MIN) / | |
224 | (SYS_TEMP_MAX - SYS_TEMP_MIN); | 286 | (SYS_TEMP_MAX - SYS_TEMP_MIN); | |
225 | 287 | |||
226 | if (sspeed == sc->sc_sfan_speed && cspeed == sc->sc_cfan_speed) | 288 | if (sspeed == sc->sc_sfan_speed && cspeed == sc->sc_cfan_speed) | |
227 | return; | 289 | return; | |
228 | 290 | |||
229 | sc->sc_sfan_speed = sspeed; | 291 | sc->sc_sfan_speed = sspeed; | |
230 | sc->sc_cfan_speed = cspeed; | 292 | sc->sc_cfan_speed = cspeed; | |
231 | tda_setspeed(sc); | 293 | tda_setspeed(sc); | |
232 | } | 294 | } | |
295 | ||||
296 | void | |||
297 | tda_refresh(struct sysmon_envsys *sme, envsys_data_t *edata) | |||
298 | { | |||
299 | struct tda_softc *sc = sme->sme_cookie; | |||
300 | u_int16_t speed; | |||
301 | ||||
302 | if (edata->sensor == SENSOR_FAN_CPU) | |||
303 | speed = sc->sc_cfan_speed; | |||
304 | else | |||
305 | speed = sc->sc_sfan_speed; | |||
306 | if (!speed) | |||
307 | edata->state = ENVSYS_SINVALID; | |||
308 | else { | |||
309 | edata->value_cur = speed; | |||
310 | edata->state = ENVSYS_SVALID; | |||
311 | } | |||
312 | } | |||
313 |