Module Name: src Committed By: msaitoh Date: Thu Jun 13 07:30:45 UTC 2013
Modified Files: src/distrib/sets/lists/man [netbsd-6]: mi src/share/man/man4/man4.sparc64 [netbsd-6]: Makefile src/sys/arch/sparc64/dev [netbsd-6]: tda.c Added Files: src/share/man/man4/man4.sparc64 [netbsd-6]: tda.4 Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.1379.2.9 -r1.1379.2.10 src/distrib/sets/lists/man/mi cvs rdiff -u -r1.6 -r1.6.6.1 src/share/man/man4/man4.sparc64/Makefile cvs rdiff -u -r0 -r1.3.4.2 src/share/man/man4/man4.sparc64/tda.4 cvs rdiff -u -r1.4 -r1.4.10.1 src/sys/arch/sparc64/dev/tda.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.1379.2.9 src/distrib/sets/lists/man/mi:1.1379.2.10 --- src/distrib/sets/lists/man/mi:1.1379.2.9 Sat Dec 15 05:40:18 2012 +++ src/distrib/sets/lists/man/mi Thu Jun 13 07:30:45 2013 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1379.2.9 2012/12/15 05:40:18 riz Exp $ +# $NetBSD: mi,v 1.1379.2.10 2013/06/13 07:30:45 msaitoh Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -1587,6 +1587,7 @@ ./usr/share/man/cat4/sparc64/lom.0 man-sys-catman .cat ./usr/share/man/cat4/sparc64/sab.0 man-sys-catman .cat ./usr/share/man/cat4/sparc64/sabtty.0 man-sys-catman .cat +./usr/share/man/cat4/sparc64/tda.0 man-sys-catman .cat ./usr/share/man/cat4/spc.0 man-sys-catman .cat ./usr/share/man/cat4/spdmem.0 man-sys-catman .cat ./usr/share/man/cat4/speaker.0 man-sys-catman .cat @@ -4393,6 +4394,7 @@ ./usr/share/man/html4/sparc64/lom.html man-sys-htmlman html ./usr/share/man/html4/sparc64/sab.html man-sys-htmlman html ./usr/share/man/html4/sparc64/sabtty.html man-sys-htmlman html +./usr/share/man/html4/sparc64/tda.html man-sys-htmlman html ./usr/share/man/html4/spc.html man-sys-htmlman html ./usr/share/man/html4/spdmem.html man-sys-htmlman html ./usr/share/man/html4/speaker.html man-sys-htmlman html @@ -7112,6 +7114,7 @@ ./usr/share/man/man4/sparc64/lom.4 man-sys-man .man ./usr/share/man/man4/sparc64/sab.4 man-sys-man .man ./usr/share/man/man4/sparc64/sabtty.4 man-sys-man .man +./usr/share/man/man4/sparc64/tda.4 man-sys-man .man ./usr/share/man/man4/spc.4 man-sys-man .man ./usr/share/man/man4/spdmem.4 man-sys-man .man ./usr/share/man/man4/speaker.4 man-sys-man .man Index: src/share/man/man4/man4.sparc64/Makefile diff -u src/share/man/man4/man4.sparc64/Makefile:1.6 src/share/man/man4/man4.sparc64/Makefile:1.6.6.1 --- src/share/man/man4/man4.sparc64/Makefile:1.6 Sat Apr 9 19:37:13 2011 +++ src/share/man/man4/man4.sparc64/Makefile Thu Jun 13 07:30:45 2013 @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.6 2011/04/09 19:37:13 jdc Exp $ +# $NetBSD: Makefile,v 1.6.6.1 2013/06/13 07:30:45 msaitoh Exp $ MANSUBDIR=/sparc64 -MAN= envctrl.4 ffb.4 fdc.4 intro.4 lom.4 sab.4 +MAN= envctrl.4 ffb.4 fdc.4 intro.4 lom.4 sab.4 tda.4 MLINKS+= sab.4 sabtty.4 Index: src/sys/arch/sparc64/dev/tda.c diff -u src/sys/arch/sparc64/dev/tda.c:1.4 src/sys/arch/sparc64/dev/tda.c:1.4.10.1 --- src/sys/arch/sparc64/dev/tda.c:1.4 Sun Apr 3 06:25:11 2011 +++ src/sys/arch/sparc64/dev/tda.c Thu Jun 13 07:30:45 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: tda.c,v 1.4 2011/04/03 06:25:11 jdc Exp $ */ +/* $NetBSD: tda.c,v 1.4.10.1 2013/06/13 07:30:45 msaitoh Exp $ */ /* $OpenBSD: tda.c,v 1.4 2008/02/27 17:25:00 robert Exp $ */ /* @@ -41,10 +41,14 @@ #define TDA_PSFAN_ON 0x1f #define TDA_PSFAN_OFF 0x00 -/* Internal and External temperature senor numbers */ +/* Internal and External temperature sensor numbers */ #define SENSOR_TEMP_EXT 0 #define SENSOR_TEMP_INT 1 +/* Fan sensor numbers */ +#define SENSOR_FAN_CPU 0 +#define SENSOR_FAN_SYS 1 + #define CPU_TEMP_MAX (67 * 1000000 + 273150000) #define CPU_TEMP_MIN (57 * 1000000 + 273150000) #define SYS_TEMP_MAX (30 * 1000000 + 273150000) @@ -58,19 +62,25 @@ struct tda_softc { u_int16_t sc_cfan_speed; /* current CPU fan speed */ u_int16_t sc_sfan_speed; /* current SYS fan speed */ + struct sysmon_envsys *sc_sme; + envsys_data_t sc_sensor[2]; + callout_t sc_timer; }; int tda_match(struct device *, struct cfdata *, void *); void tda_attach(struct device *, struct device *, void *); +static int tda_detach(struct device *, int); +void tda_refresh(struct sysmon_envsys *, envsys_data_t *); void tda_setspeed(struct tda_softc *); static void tda_adjust(void *); static void tda_timeout(void *); -CFATTACH_DECL_NEW(tda, sizeof(struct tda_softc), - tda_match, tda_attach, NULL, NULL); +CFATTACH_DECL3_NEW(tda, sizeof(struct tda_softc), + tda_match, tda_attach, tda_detach, NULL, NULL, NULL, + DVF_DETACH_SHUTDOWN); int tda_match(struct device *parent, struct cfdata *match, void *aux) @@ -112,9 +122,61 @@ tda_attach(struct device *parent, struct */ sc->sc_cfan_speed = sc->sc_sfan_speed = (TDA_FANSPEED_MAX+TDA_FANSPEED_MIN)/2; tda_setspeed(sc); - + callout_init(&sc->sc_timer, CALLOUT_MPSAFE); callout_reset(&sc->sc_timer, hz*20, tda_timeout, sc); + + /* Initialise sensor data */ + sc->sc_sensor[SENSOR_FAN_CPU].state = ENVSYS_SINVALID; + sc->sc_sensor[SENSOR_FAN_CPU].units = ENVSYS_INTEGER; + sc->sc_sensor[SENSOR_FAN_CPU].flags = ENVSYS_FMONNOTSUPP; + strlcpy(sc->sc_sensor[SENSOR_FAN_CPU].desc, + "fan.cpu",sizeof("fan.cpu")); + sc->sc_sensor[SENSOR_FAN_SYS].state = ENVSYS_SINVALID; + sc->sc_sensor[SENSOR_FAN_SYS].units = ENVSYS_INTEGER; + sc->sc_sensor[SENSOR_FAN_SYS].flags = ENVSYS_FMONNOTSUPP; + strlcpy(sc->sc_sensor[SENSOR_FAN_SYS].desc, + "fan.sys",sizeof("fan.sys")); + sc->sc_sme = sysmon_envsys_create(); + if (sysmon_envsys_sensor_attach( + sc->sc_sme, &sc->sc_sensor[SENSOR_FAN_CPU])) { + sysmon_envsys_destroy(sc->sc_sme); + aprint_error_dev(self, + "unable to attach cpu fan at sysmon\n"); + return; + } + if (sysmon_envsys_sensor_attach( + sc->sc_sme, &sc->sc_sensor[SENSOR_FAN_SYS])) { + sysmon_envsys_destroy(sc->sc_sme); + aprint_error_dev(self, + "unable to attach sys fan at sysmon\n"); + return; + } + sc->sc_sme->sme_name = device_xname(self); + sc->sc_sme->sme_cookie = sc; + sc->sc_sme->sme_refresh = tda_refresh; + if (sysmon_envsys_register(sc->sc_sme)) { + aprint_error_dev(self, + "unable to register with sysmon\n"); + sysmon_envsys_destroy(sc->sc_sme); + return; + } +} + +int +tda_detach(struct device *self, int flags) +{ + struct tda_softc *sc = device_private(self); + + if (sc->sc_sme != NULL) + sysmon_envsys_destroy(sc->sc_sme); + + callout_halt(&sc->sc_timer, NULL); + callout_destroy(&sc->sc_timer); + + sc->sc_cfan_speed = sc->sc_sfan_speed = TDA_FANSPEED_MAX; + tda_setspeed(sc); + return 0; } static void @@ -218,7 +280,7 @@ tda_adjust(void *v) if (stemp < SYS_TEMP_MIN) sspeed = TDA_FANSPEED_MIN; else if (stemp < SYS_TEMP_MAX) - sc->sc_sfan_speed = TDA_FANSPEED_MIN + + sspeed = TDA_FANSPEED_MIN + (stemp - SYS_TEMP_MIN) * (TDA_FANSPEED_MAX - TDA_FANSPEED_MIN) / (SYS_TEMP_MAX - SYS_TEMP_MIN); @@ -230,3 +292,22 @@ tda_adjust(void *v) sc->sc_cfan_speed = cspeed; tda_setspeed(sc); } + +void +tda_refresh(struct sysmon_envsys *sme, envsys_data_t *edata) +{ + struct tda_softc *sc = sme->sme_cookie; + u_int16_t speed; + + if (edata->sensor == SENSOR_FAN_CPU) + speed = sc->sc_cfan_speed; + else + speed = sc->sc_sfan_speed; + if (!speed) + edata->state = ENVSYS_SINVALID; + else { + edata->value_cur = speed; + edata->state = ENVSYS_SVALID; + } +} + Added files: Index: src/share/man/man4/man4.sparc64/tda.4 diff -u /dev/null src/share/man/man4/man4.sparc64/tda.4:1.3.4.2 --- /dev/null Thu Jun 13 07:30:45 2013 +++ src/share/man/man4/man4.sparc64/tda.4 Thu Jun 13 07:30:45 2013 @@ -0,0 +1,69 @@ +.\" $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.