Add new driver for dbCool(tm) family of Thermal Monitor and Fan Controller.

Supported chips: ADM1027, ADM1030, ADT7463, ADT7466, ADT7467, ADT7468,
ADT7473, ADT7475, and ADT7476.  Notably missing is the ADT7490, and fan
controller support on the ADT7466 is still on the to-do list.

Tested by myself and njoly@
Reviewed by garbled@
Commit approved by christos@, bouyer@, cube@, and matt@
This commit is contained in:
pgoyette 2008-10-02 00:47:51 +00:00
parent 9766bcabdc
commit 0219f2ad21
6 changed files with 2530 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.475 2008/09/30 16:48:39 jmcneill Exp $
# $NetBSD: Makefile,v 1.476 2008/10/02 00:47:51 pgoyette Exp $
# @(#)Makefile 8.1 (Berkeley) 6/18/93
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 acpidalb.4 \
@ -110,7 +110,7 @@ MAN+= sc.4 si.4
MAN+= fwohci.4 fwip.4 sbp.4
# machine-independent I2C devices
MAN+= lmtemp.4 spdmem.4
MAN+= dbcool.4 lmtemp.4 sdtemp.4 spdmem.4
# machine-independent SPI devices
MAN += m25p.4 tm121temp.4
@ -146,6 +146,16 @@ MLINKS+=bktr.4 vbi.4
MLINKS+=cardbus.4 cardslot.4
MLINKS+=cardbus.4 cbb.4
MLINKS+=crypto.4 swcrypto.4
MLINKS+=dbcool.4 dbCool.4
MLINKS+=dbcool.4 adm1027.4
MLINKS+=dbcool.4 adm1030.4
MLINKS+=dbcool.4 adt7463.4
MLINKS+=dbcool.4 adt7466.4
MLINKS+=dbcool.4 adt7467.4
MLINKS+=dbcool.4 adt7468.4
MLINKS+=dbcool.4 adt7473.4
MLINKS+=dbcool.4 adt7475.4
MLINKS+=dbcool.4 adt7476.4
MLINKS+=fd.4 stderr.4 fd.4 stdin.4 fd.4 stdout.4
MLINKS+=fpa.4 fea.4 fpa.4 fta.4
MLINKS+=icp.4 icpsp.4

259
share/man/man4/dbcool.4 Normal file
View File

@ -0,0 +1,259 @@
.\" $NetBSD: dbcool.4,v 1.1 2008/10/02 00:47:51 pgoyette Exp $
.\"
.\" Copyright (c) 2008 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Paul Goyette.
.\"
.\" 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 September 28, 2008
.Dt dbCool 4
.Os
.Sh NAME
.Nm dbcool ,
.Nm adm1027 ,
.Nm adt7463 ,
.Nm adt7466 ,
.Nm adt7467 ,
.Nm adt7468 ,
.Nm adt7473 ,
.Nm adt7475 ,
.Nm adt7476
.Nd dbCool(tm) family of environmental monitors and fan controllers
.Sh SYNOPSIS
.Cd "dbcool* at ki2c?"
.Cd "dbcool* at iic? addr 0x2e"
.Sh DESCRIPTION
The
.Nm
driver provides support for the
.Tn Analog Devices
dbCool environmental monitor chips to be used with the
.Xr envsys 4
API.
.Pp
These chips support up to twelve sensors. Not all of the following sensors
are supported on all chips.
.Bl -column "Sensor" "Units" "Typical" -offset indent
.It Sy "Sensor" Ta Sy "Units" Ta Sy "Typical Use"
.It Li "l_temp" Ta "uK" Ta "local chip temperature"
.It Li "r1_temp" Ta "uK" Ta "CPU temperature"
.It Li "r2_temp" Ta "uK" Ta "GPU temperature"
.It Li "Vccp" Ta "uV DC" Ta "CPU Vcore"
.It Li "Vcc" Ta "uV DC" Ta "Chip's supply voltage"
.It Li "2.5V" Ta "uV DC" Ta "2.5V supply"
.It Li "5V" Ta "uV DC" Ta "5V supply"
.It Li "12V" Ta "uV DC" Ta "12V supply"
.It Li "AIN1" Ta "uV DC" Ta "Analog In (2.25V ref, ADT7466 only)"
.It Li "AIN2" Ta "uV DC" Ta "Analog In (2.25V ref, ADT7466 only)"
.It Li "fan1" Ta "RPM" Ta "Chassis Fan"
.It Li "fan2" Ta "RPM" Ta "Chassis Fan"
.It Li "fan3" Ta "RPM" Ta "Chassis Fan"
.It Li "fan4" Ta "RPM" Ta "Chassis Fan"
.El
.Pp
Except on the ADT7466, each temperature and voltage sensor has a
programmable high- and low-limit; fan sensors have only a low-limit. The
user can set the threshold values using
.Xr sysctl 8
.Bd -literal -offset indent
hw.dbcool0.l_temp.low_lim = 35 degrees C
hw.dbcool0.l_temp.hi_lim = 75 degrees C
hw.dbcool0.fan1.low_lim = 300 RPM
hw.dbcool0.Vcc.low_lim = 2250 milliVolts
hw.dbcool0.Vcc.hi_lim = 2750 milliVolts
.Ed
.Pp
Temperature sensors also have
.Em Tmin ,
.Em Thyst ,
and
.Em Ttherm
.Xr sysctl 8
variables; these values are used by the fan speed controllers.
.Pp
All
.Xr sysctl 8
variables associated with temperature sensors are in units of degC, since
this is the unit which is programmed into the device registers. Limit
values for voltage sensors are in millivolts. The low limit value for
fan sensors is measured in RPM; due to the manner in which fan speed is
measured, the lowest possible value for a fan limit is 83 RPM.
.Pp
All members of the dbCool family support Pulse-Width Modulated (PWM)
fan speed control based on temperature thresholds - the fan will spin up
when one or more thermal sensors exceeds its configured
.Em Tmin
value. The fan will go faster as the temperature rises, and will slow
down as the temperature falls. If the temperature exceeds the sensor's
.Em Ttherm
value, the THERM signal will be asserted, and if enabled the fan will
run at full speed. The fan will be turned
off when the sensor(s) that triggered it reports a temperature which is
at least
.Em Thyst
degrees below its
.Em Tmin
threshold.
.Pp
Each fan controller is programmable using the following
.Xr sysctl 8
variables.
.Bd -literal -offset indent
hw.dbcool0.fan_ctl_0.behavior
hw.dbcool0.fan_ctl_0.range
hw.dbcool0.fan_ctl_0.min_duty
hw.dbcool0.fan_ctl_0.max_duty
hw.dbcool0.fan_ctl_0.cur_duty
.Ed
(On the ADM1030, the
.Em range
variable is associated with each individual temperature sensor rather
than with the fan controller.)
.Pp
The
.Em behavior
variable controls the selection of temperature sensors associated with
the fan controller. When the associated temperature sensor reaches its
.Em Tmin
value, the fan controller starts the fan at its minimum duty cycle;
when the associated temperature sensor reaches its
.Em Ttherm
value and asserts the THERM signal (or if an external THERM signal is
asserted), the fan controller sets the fan speed to a 100% duty cycle.
Between these two settings, each temperature sensor is used to calculate
a duty cycle linearly based on the slope defined by the temperature sensor's
.Em range
variable. When the associated temperature falls at least
.Em Thyst
degress below its
.Em Tmin
value, the fan controller will turn off the fan. (On the ADM1030, the
value for
.Em Thyst
is fixed at 5 degrees C.)
.Pp
Valid values for the
.Em behavior
variable are:
.Bd -literal -offset indent
local (not available on ADM1030)
remote1
remote2 (not available on ADM1030)
local+remote2 (not available on ADM1030)
all-temps
full-speed (not available on ADM1030)
manual
disabled
.Ed
.Pp
When the
.Em behavior
variable is set to "manual", the
.Em cur-duty
variable becomes user-writeable and can be set to any value between 0 and
100 inclusive to control the fan's duty cycle manually. In all other
.Em behavior
modes, the
.Em cur-duty
variable is read-only and updates are ignored.
.Pp
The
.Em min-duty
and
.Em max-duty
variables define the range over which the fan controller will manage the
fan's duty cycle. On the ADM1030, these values are not separately
controllable. The
.Em max-duty
is fixed at 100%, and the
.Em cur-duty
variable is used to specify the minimum duty cycle when the fan
controller is running in automatic mode.
.Pp
Note that the duty-cycle value does not directly correspond to the fan's
speed. That is, a 33% duty cycle does not mean that the fan runs at 33%
of its maximum speed; in actuality, a 33% duty cycle drives the fan at
a speed close to 50% of its maximum. Fan speed correlates approximately
to the square root of the duty cycle.
.Sh EXAMPLES
The
.Xr envstat 8
utility can be used to determine the sensors supported:
.Bd -literal -offset indent
Current CritMax CritMin CritCap Unit
l_temp: 44.250 degC
r1_temp: 41.250 degC
r2_temp: N/A
Vccp: 0.002 V
Vcc: 3.351 V
fan1: N/A
fan2: N/A
fan3: N/A
fan4: N/A
.Ed
.Pp
Using this information, the following commands in /etc/envsys.conf will
set appropriate limits for CPU temperature and chip supply voltage, and
powerd will be notified if the limits are exceeded:
.Bd -literal -offset indent
dbcool0 {
sensor0 {
warning-max = 60C;
critical-max = 65C;
}
sensor4 {
critical-min = 3.1;
warning-min = 3.2;
critical-max = 3.5;
}
}
.Ed
.Pp
Alternatively, set the following commands in /etc/sysctl.conf to perform
limit checking in the hardware:
.Bd -literal -offset indent
hw.dbcool0.l_temp.hi_lim = 65
hw.dbcool0.Vcc.low_lim = 3200
hw.dbcool0.Vcc.hi_lim = 3500
.Ed
.Sh SEE ALSO
.Xr envsys 4 ,
.Xr envstat 8 ,
.Xr powerd 8 ,
.Xr sysctl 8
.Sh HISTORY
The
.Nm
device appeared in
.Nx 5.0 .
.Sh BUGS
Although the sensor limit registers can be programmed, there is currently
no use of the dbCool chips' ability to generate an SMBus interrupt when the
limits are exceeded. Limit checking is only performed when the sensor
values are polled and refreshed.
.Pp
The ADT7466 chip, although officially a member of the dbCool family, is
programmed quite differently. The fan controllers and sensor limits on
this chip are not currently implemented.

1711
sys/dev/i2c/dbcool.c Normal file

File diff suppressed because it is too large Load Diff

392
sys/dev/i2c/dbcool_reg.h Normal file
View File

@ -0,0 +1,392 @@
/* $NetBSD: dbcool_reg.h,v 1.1 2008/10/02 00:47:51 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Paul Goyette
*
* 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.
*/
/*
* a driver for the dbCool(tm) family of environmental controllers
*/
#ifndef DBCOOLREG_H
#define DBCOOLREG_H
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dbcool_reg.h,v 1.1 2008/10/02 00:47:51 pgoyette Exp $");
#define DBCOOL_ADDRMASK 0x7f
#define DBCOOL_ADDR 0x2e /* Some chips have multiple addrs */
/* The dBCool chip family register set */
/* Not all registers are available on all chips! */
#define DBCOOL_CONFIG5A_REG 0x04
#define DBCOOL_CONFIG6_REG 0x10
#define DBCOOL_CONFIG7_REG 0x11
#define DBCOOL_INTERNAL_TRIP 0x13
#define DBCOOL_EXTERNAL_TRIP 0x14
#define DBCOOL_TEST 0x15
#define DBCOOL_CHANNEL_MODE 0x16
#define DBCOOL_INT_TRIP_FIXED 0x17
#define DBCOOL_EXT_TRIP_FIXED 0x18
#define DBCOOL_ANALOG_OUT 0x19
#define DBCOOL_PECI1 0x1A
#define DBCOOL_PECI2 0x1B
#define DBCOOL_PECI3 0x1C
#define DBCOOL_IMON 0x1D
#define DBCOOL_VTT 0x1E
#define DBCOOL_EXTRES 0x1F
#define DBCOOL_OFFSET 0x1F
#define DBCOOL_25VIN 0x20
#define DBCOOL_CPU_VOLTAGE 0x21
#define DBCOOL_SUPPLY_VOLTAGE 0x22
#define DBCOOL_5VIN 0x23
#define DBCOOL_12VIN 0x24
#define DBCOOL_CPU_VOLTAGE2 0x25
#define DBCOOL_REMOTE1_TEMP 0x25
#define DBCOOL_LOCAL_TEMP 0x26
#define DBCOOL_REMOTE2_TEMP 0x27
#define DBCOOL_FAN1_TACH_LSB 0x28
#define DBCOOL_FAN1_TACH_MSB 0x29
#define DBCOOL_FAN2_TACH_LSB 0x2A
#define DBCOOL_FAN2_TACH_MSB 0x2B
#define DBCOOL_FAN3_TACH_LSB 0x2C
#define DBCOOL_FAN3_TACH_MSB 0x2D
#define DBCOOL_FAN4_TACH_LSB 0x2E
#define DBCOOL_FAN4_TACH_MSB 0x2F
#define DBCOOL_PWM1_CURDUTY 0x30
#define DBCOOL_DAC0_START 0x30
#define DBCOOL_PWM2_CURDUTY 0x31
#define DBCOOL_DAC1_START 0x31
#define DBCOOL_PWM3_CURDUTY 0x32
#define DBCOOL_DAC0_MIN 0x32
#define DBCOOL_PECI0 0x33
#define DBCOOL_DAC1_MIN 0x33
#define DBCOOL_PECI_LOWLIM 0x34
#define DBCOOL_DAC0_MAX 0x34
#define DBCOOL_PECI_HIGHLIM 0x35
#define DBCOOL_DAC1_MAX 0x35
#define DBCOOL_PECI_CFG1 0x36
#define DBCOOL_DYNTMIN_CNTRL1 0x36
#define DBCOOL_DYNTMIN_CNTRL2 0x37
#define DBCOOL_PWM1_MAXDUTY 0x38
#define DBCOOL_PWM2_MAXDUTY 0x39
#define DBCOOL_PWM3_MAXDUTY 0x3A
/*
* Note: ADT7490 reused the Device_ID register for PECI Tcontrol limit
*/
#define DBCOOL_DEVICEID_REG 0x3D
#define DBCOOL_PECI_TCRTL_LIM 0x3D
#define DBCOOL_COMPANYID_REG 0x3E
#define DBCOOL_REVISION_REG 0x3F
#define DBCOOL_CONFIG1_REG 0x40
#define DBCOOL_DAC0_OUT 0x40
#define DBCOOL_ISR1_REG 0x41
#define DBCOOL_DAC1_OUT 0x41
#define DBCOOL_ISR2_REG 0x42
#define DBCOOL_ISR3_REG 0x43
#define DBCOOL_VID_REG 0x43
#define DBCOOL_25VIN_LOWLIM 0x44
#define DBCOOL_25VIN_HIGHLIM 0x45
#define DBCOOL_VCCP_LOWLIM 0x46
#define DBCOOL_VCCP_HIGHLIM 0x47
#define DBCOOL_VIDB 0x47
#define DBCOOL_VCC_LOWLIM 0x48
#define DBCOOL_VCC_HIGHLIM 0x49
#define DBCOOL_VID4 0x49
#define DBCOOL_5VIN_LOWLIM 0x4A
#define DBCOOL_5VIN_HIGHLIM 0x4B
#define DBCOOL_12VIN_LOWLIM 0x4C
#define DBCOOL_12VIN_HIGHLIM 0x4D
#define DBCOOL_REMOTE1_LOWLIM 0x4E
#define DBCOOL_REMOTE1_HIGHLIM 0x4F
#define DBCOOL_LOCAL_LOWLIM 0x50
#define DBCOOL_LOCAL_HIGHLIM 0x51
#define DBCOOL_REMOTE2_LOWLIM 0x52
#define DBCOOL_REMOTE2_HIGHLIM 0x53
#define DBCOOL_TACH1_MIN_LSB 0x54
#define DBCOOL_TACH1_MIN_MSB 0x55
#define DBCOOL_TACH2_MIN_LSB 0x56
#define DBCOOL_TACH2_MIN_MSB 0x57
#define DBCOOL_TACH3_MIN_LSB 0x58
#define DBCOOL_TACH3_MIN_MSB 0x59
#define DBCOOL_TACH4_MIN_LSB 0x5A
#define DBCOOL_TACH4_MIN_MSB 0x5B
#define DBCOOL_PWM1_CTL 0x5C
#define DBCOOL_PWM2_CTL 0x5D
#define DBCOOL_PWM3_CTL 0x5E
#define DBCOOL_PWM1_TRANGE 0x5F
#define DBCOOL_PWM2_TRANGE 0x60
#define DBCOOL_PWM3_TRANGE 0x61
#define DBCOOL_ENH_ACOUST_1 0x62
#define DBCOOL_ENH_ACOUST_2 0x63
#define DBCOOL_PWM1_MINDUTY 0x64
#define DBCOOL_PWM2_MINDUTY 0x65
#define DBCOOL_PWM3_MINDUTY 0x66
#define DBCOOL_REMOTE1_TMIN 0x67
#define DBCOOL_LOCAL_TMIN 0x68
#define DBCOOL_REMOTE2_TMIN 0x69
#define DBCOOL_REMOTE1_TTHRESH 0x6A
#define DBCOOL_LOCAL_TTHRESH 0x6B
#define DBCOOL_REMOTE2_TTHRESH 0x6C
#define DBCOOL_R1_LCL_TMIN_HYST 0x6D
#define DBCOOL_R2_TMIN_HYST 0x6E
#define DBCOOL_XNOR_ENABLE 0x6F
#define DBCOOL_REMOTE1_TEMPOFF 0x70
#define DBCOOL_LOCAL_TEMPOFF 0x71
#define DBCOOL_REMOTE2_TEMPOFF 0x72
#define DBCOOL_CONFIG2_REG 0x73
#define DBCOOL_IMASK1_REG 0x74
#define DBCOOL_IMASK2_REG 0x75
#define DBCOOL_EXTRES1_REG 0x76
#define DBCOOL_EXTRES2_REG 0x77
#define DBCOOL_CONFIG3_REG 0x78
#define DBCOOL_THERM_TIMERSTATUS_REG 0x79
#define DBCOOL_THERM_TIMERLIMIT_REG 0x7A
#define DBCOOL_TACHPULSE_REG 0x7B
#define DBCOOL_CONFIG5_REG 0x7C
#define DBCOOL_CONFIG4_REG 0x7D
#define DBCOOL_TEST1_REG 0x7E
#define DBCOOL_TEST2_REG 0x7F
#define DBCOOL_GPIO_CONFIG 0x80
#define DBCOOL_ISR4_REG 0x81
#define DBCOOL_IMASK3_REG 0x82
#define DBCOOL_IMASK4_REG 0x83
#define DBCOOL_VTT_LOWLIM 0x84
#define DBCOOL_IMON_LOWLIM 0x85
#define DBCOOL_VTT_HIGHLIM 0x86
#define DBCOOL_IMON_HIGHLIM 0x87
#define DBCOOL_PECI_CFG2 0x88
#define DBCOOL_TEST3_REG 0x89
#define DBCOOL_PECI_OP_PT 0x8A
#define DBCOOL_REMOTE1_OP_PT 0x8B
#define DBCOOL_LOCAL_OP_PT 0x8C
#define DBCOOL_REMOTE2_OP_PT 0x8D
#define DBCOOL_DYNTMIN_CTL1 0x8E
#define DBCOOL_DYNTMIN_CTL2 0x8F
#define DBCOOL_DYNTMIN_CTL3 0x90
#define DBCOOL_PECI0_TEMPOFF 0x94
#define DBCOOL_PECI1_TEMPOFF 0x95
#define DBCOOL_PECI2_TEMPOFF 0x96
#define DBCOOL_PECI3_TEMPOFF 0x97
#define DBCOOL_NO_REG 0xff
/* Config register bit definitions */
#define DBCOOL_CFG1_START 0x01
#define DBCOOL_CFG1_LOCK 0x02
#define DBCOOL_CFG1_RDY 0x04
#define DBCOOL_CFG1_FSPD 0x08
#define DBCOOL_CFG1_VxI 0x10
#define DBCOOL_CFG1_RESET 0x10
#define DBCOOL_CFG1_FSPDIS 0x20
#define DBCOOL_CFG1_12VVID4_SEL 0x20
#define DBCOOL_CFG1_TODIS 0x40
#define DBCOOL_CFG1_Vcc 0x80
#define DBCOOL_CFG1_RESET_LATCH 0x80
#define DBCOOL_CFG2_AIN1 0x01
#define DBCOOL_CFG2_AIN2 0x02
#define DBCOOL_CFG2_AIN3 0x04
#define DBCOOL_CFG2_AIN4 0x08
#define DBCOOL_CFG2_AVG 0x10
#define DBCOOL_CFG2_ATTN 0x20
#define DBCOOL_CFG2_CONV 0x40
#define DBCOOL_CFG2_SHDN 0x80
#define DBCOOL_CFG3_ALERT 0x01
#define DBCOOL_CFG3_THERM 0x02
#define DBCOOL_CFG3_BOOST 0x04
#define DBCOOL_CFG3_FAST 0x08
#define DBCOOL_CFG3_DC1 0x10
#define DBCOOL_CFG3_DC2 0x20
#define DBCOOL_CFG3_DC3 0x40
#define DBCOOL_CFG3_DC4 0x80
#define DBCOOL_CFG4_PIN9FUNC 0x03
#define DBCOOL_CFG4_AINL 0x0C
#define DBCOOL_CFG4_BYPASS_ATTN 0x20
#define DBCOOL_CFG5_TWOSCOMP 0x01
#define DBCOOL_CFG5_FREQ 0x02
#define DBCOOL_CFG5_GPIOD 0x04
#define DBCOOL_CFG5_GPIOP 0x08
#define DBCOOL_CFG6_SLOW_REM1 0x01
#define DBCOOL_CFG6_SLOW_LOCAL 0x02
#define DBCOOL_CFG6_SLOW_REM2 0x04
#define DBCOOL_CFG6_THERM_MAN 0x08
#define DBCOOL_CFG6_VCCP_LOW 0x40
#define DBCOOL_CFG6_EXTRASLOW 0x80
#define DBCOOL_CFG7_DIS_THERM_HYST 0x10
/*
* The ADT7466 is an orphan stepchild in the dbCool family
*/
#define DBCOOL_ADT7466_CONFIG1 0x00
#define DBCOOL_ADT7466_CONFIG2 0x01
#define DBCOOL_ADT7466_CONFIG3 0x02
#define DBCOOL_ADT7466_CONFIG4 0x03
#define DBCOOL_ADT7466_CONFIG5 0x04
#define DBCOOL_ADT7466_AFC1 0x05
#define DBCOOL_ADT7466_AFC2 0x06
#define DBCOOL_ADT7466_REM_TEMP_LSB 0x08
#define DBCOOL_ADT7466_LCL_TEMP_LSB 0x09
#define DBCOOL_ADT7466_AIN1 0x0A
#define DBCOOL_ADT7466_AIN2 0x0B
#define DBCOOL_ADT7466_VCC 0x0C
#define DBCOOL_ADT7466_REM_TEMP_MSB 0x0D
#define DBCOOL_ADT7466_LCL_TEMP_MSB 0x0E
#define DBCOOL_ADT7466_PROCHOT 0x0F
#define DBCOOL_ADT7466_INTRPT1 0x10
#define DBCOOL_ADT7466_INTRPT2 0x11
#define DBCOOL_ADT7466_INTMSK1 0x12
#define DBCOOL_ADT7466_INTMSK2 0x13
#define DBCOOL_ADT7466_AIN1_LOLIM 0x14
#define DBCOOL_ADT7466_AIN1_HILIM 0x15
#define DBCOOL_ADT7466_AIN2_LOLIM 0x16
#define DBCOOL_ADT7466_AIN2_HILIM 0x17
#define DBCOOL_ADT7466_VCC_LOLIM 0x18
#define DBCOOL_ADT7466_VCC_HILIM 0x19
#define DBCOOL_ADT7466_REM_TEMP_LOLIM 0x1A
#define DBCOOL_ADT7466_REM_TEMP_HILIM 0x1B
#define DBCOOL_ADT7466_LCL_TEMP_LOLIM 0x1C
#define DBCOOL_ADT7466_LCL_TEMP_HILIM 0x1D
#define DBCOOL_ADT7466_PROCHOT_LIM 0x1E
#define DBCOOL_ADT7466_AIN1_THERM 0x1F
#define DBCOOL_ADT7466_AIN2_THREM 0x20
#define DBCOOL_ADT7466_REM_THERM 0x21
#define DBCOOL_ADT7466_LCL_THERM 0x22
#define DBCOOL_ADT7466_AIN1_OFFSET 0x24
#define DBCOOL_ADT7466_AIN2_OFFSET 0x25
#define DBCOOL_ADT7466_REM_OFFSET 0x26
#define DBCOOL_ADT7466_LCL_OFFSET 0x27
#define DBCOOL_ADT7466_AIN1_TMIN 0x28
#define DBCOOL_ADT7466_AIN2_TMIN 0x29
#define DBCOOL_ADT7466_REM_TMIN 0x2A
#define DBCOOL_ADT7466_LCL_TMIN 0x2B
#define DBCOOL_ADT7466_AIN_RANGES 0x2C
#define DBCOOL_ADT7466_LCL_REM_RANGES 0x2D
#define DBCOOL_ADT7466_AIN_HYSTS 0x2E
#define DBCOOL_ADT7466_LCL_REM_HYSTS 0x2F
#define DBCOOL_ADT7466_FANA_STARTV 0x30
#define DBCOOL_ADT7466_FANB_STARTV 0x31
#define DBCOOL_ADT7466_FANA_MINV 0x32
#define DBCOOL_ADT7466_FANB_MINV 0x33
#define DBCOOL_ADT7466_FANA_MAXRPM_MSB 0x34
#define DBCOOL_ADT7466_FANB_MAXRPM_MSB 0x35
#define DBCOOL_ADT7466_ENH_ACOUSTICS 0x36
#define DBCOOL_ADT7466_FAULT_INCR 0x37
#define DBCOOL_ADT7466_TIMEOUT 0x38
#define DBCOOL_ADT7466_PULSES 0x39
#define DBCOOL_ADT7466_DRIVE1 0x40
#define DBCOOL_ADT7466_DRIVE2 0x41
#define DBCOOL_ADT7466_XOR_TEST 0x42
#define DBCOOL_ADT7466_FANA_LSB 0x48
#define DBCOOL_ADT7466_FANA_MSB 0x49
#define DBCOOL_ADT7466_FANB_LSB 0x4A
#define DBCOOL_ADT7466_FANB_MSB 0x4B
#define DBCOOL_ADT7466_FANA_LOLIM_LSB 0x4C
#define DBCOOL_ADT7466_FANA_LOLIM_MSB 0x4D
#define DBCOOL_ADT7466_FANB_LOLIM_LSB 0x4E
#define DBCOOL_ADT7466_FANB_LOLIM_MSB 0x4F
#define DBCOOL_ADT7466_CFG1_Vcc 0x40
#define DBCOOL_ADT7466_CFG2_SHDN 0x40
/*
* Even though it's not really a member of the dbCool family, we also
* support the ADM1030 chip. It has a different register set.
*/
#define DBCOOL_ADM1030_CFG1 0x00
#define DBCOOL_ADM1030_CFG2 0x01
#define DBCOOL_ADM1030_STATUS1 0x02
#define DBCOOL_ADM1030_STATUS2 0x03
#define DBCOOL_ADM1030_TEMP_EXTRES 0x06
#define DBCOOL_ADM1030_TEST_REG 0x07
#define DBCOOL_ADM1030_FAN_TACH 0x08
#define DBCOOL_ADM1030_L_TEMP 0x0A
#define DBCOOL_ADM1030_R_TEMP 0x0B
#define DBCOOL_ADM1030_L_OFFSET 0x0D
#define DBCOOL_ADM1030_R_OFFSET 0x0E
#define DBCOOL_ADM1030_FAN_LO_LIM 0x10
#define DBCOOL_ADM1030_L_HI_LIM 0x14
#define DBCOOL_ADM1030_L_LO_LIM 0x15
#define DBCOOL_ADM1030_L_TTHRESH 0x16
#define DBCOOL_ADM1030_R_HI_LIM 0x18
#define DBCOOL_ADM1030_R_LO_LIM 0x19
#define DBCOOL_ADM1030_R_TTHRESH 0x1A
#define DBCOOL_ADM1030_FAN_CHAR 0x20
#define DBCOOL_ADM1030_FAN_SPEED_CFG 0x22
#define DBCOOL_ADM1030_FAN_FILTER 0x23
#define DBCOOL_ADM1030_L_TMIN 0x24
#define DBCOOL_ADM1030_R_TMIN 0x25
#define DBCOOL_ADM1030_DEVICEID DBCOOL_DEVICEID_REG
#define DBCOOL_ADM1030_COMPANYID DBCOOL_COMPANYID_REG
#define DBCOOL_ADM1030_REVISION DBCOOL_REVISION_REG
/*
* Macros to locate limit registers for the various sensor types
*/
#define DBCOOL_VOLT_LOLIM(reg) ((reg - DBCOOL_25VIN) * 2 + DBCOOL_25VIN_LOWLIM)
#define DBCOOL_VOLT_HILIM(reg) (DBCOOL_VOLT_LOLIM(reg) + 1)
#define DBCOOL_TEMP_LOLIM(reg) \
((reg - DBCOOL_LOCAL_TEMP) * 2 + DBCOOL_LOCAL_LOWLIM)
#define DBCOOL_TEMP_HILIM(reg) (DBCOOL_TEMP_LOLIM(reg) + 1)
#define DBCOOL_TACH_LOLIM(reg) \
(reg - DBCOOL_FAN1_TACH_LSB + DBCOOL_TACH1_MIN_LSB)
#define ADM1030_TEMP_HILIM(reg) \
((reg - DBCOOL_ADM1030_L_TEMP) * 3 + DBCOOL_ADM1030_L_HI_LIM)
#define ADM1030_TEMP_LOLIM(reg) \
((reg - DBCOOL_ADM1030_L_TEMP) * 3 + DBCOOL_ADM1030_L_LO_LIM)
#define ADT7466_LIM_OFFSET(reg) \
((reg - DBCOOL_AIN1) * 2 + DBCOOL_AIN1_LOWLIM)
#define ADT7466_FAN_LIM_OFFSET(reg) \
(reg - DBCOOL_FANA_LSB + DBCOOL_FANA_LOWLIM_LSB)
/* Company and Device ID values */
#define DBCOOL_COMPANYID 0x41
#define ADM1027_DEVICEID 0x27
#define ADM1030_DEVICEID 0x30
#define ADT7463_DEVICEID 0x27
#define ADT7466_DEVICEID 0x66
#define ADT7467_DEVICEID 0x67
#define ADT7468_DEVICEID 0x68
#define ADT7473_DEVICEID 0x73
#define ADT7475_DEVICEID 0x75
#define ADT7476_DEVICEID 0x76
#define ADM1027_REV_ID 0x60
#define ADT7463_REV_ID1 0x62
#define ADT7463_REV_ID2 0x6A
#define ADT7467_REV_ID1 0x71
#define ADT7467_REV_ID2 0x72
#define ADT7473_REV_ID 0x68
#define ADT7473_1_REV_ID 0x69
#endif /* def DBCOOLREG_H */

149
sys/dev/i2c/dbcool_var.h Normal file
View File

@ -0,0 +1,149 @@
/* $NetBSD: dbcool_var.h,v 1.1 2008/10/02 00:47:51 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Paul Goyette
*
* 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.
*/
/*
* A driver for dbCool(tm) family of environmental controllers
*/
#ifndef DBCOOLVAR_H
#define DBCOOLVAR_H
#define DBCOOL_DEBUG
/*
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dbcool_var.h,v 1.1 2008/10/02 00:47:51 pgoyette Exp $");
#include <dev/i2c/i2cvar.h>
#include <dev/sysmon/sysmonvar.h>
#include "sysmon_envsys.h"
#include <dev/i2c/dbcool_reg.h>
enum dbc_pwm_params {
DBC_PWM_BEHAVIOR = 0,
DBC_PWM_RANGE,
DBC_PWM_MIN_DUTY,
DBC_PWM_MAX_DUTY,
DBC_PWM_CUR_DUTY,
DBC_PWM_LAST_PARAM
};
enum dbc_sensor_type {
DBC_CTL = 0,
DBC_TEMP,
DBC_VOLT,
DBC_FAN,
DBC_EOF
};
#define DBCFLAG_TEMPOFFSET 0x0001
#define DBCFLAG_HAS_MAXDUTY 0x0002
#define DBCFLAG_HAS_SHDN 0x0004
#define DBCFLAG_MULTI_VCC 0x0008
#define DBCFLAG_4BIT_VER 0x0010
#define DBCFLAG_HAS_VID 0x0020
#define DBCFLAG_HAS_VID_SEL 0x0040
#define DBCFLAG_ADM1027 0x1000
#define DBCFLAG_ADM1030 0x2000
#define DBCFLAG_ADT7466 0x4000
/* Maximum sensors for any dbCool device */
#define DBCOOL_MAXSENSORS 15
struct reg_list {
uint8_t val_reg;
uint8_t hi_lim_reg;
uint8_t lo_lim_reg;
};
struct dbcool_sensor {
enum dbc_sensor_type type;
struct reg_list reg;
int name_index;
int sysctl_index;
};
/*
* The members of dbcool_power_control need to stay in the same order
* as the enum dbc_pwm_params above
*/
struct dbcool_power_control {
uint8_t behavior;
uint8_t range;
uint8_t min;
uint8_t max;
uint8_t cur;
const char *desc;
};
struct chip_id;
struct dbcool_softc {
struct device *parent;
i2c_tag_t sc_tag;
i2c_addr_t sc_addr;
struct chip_id *sc_chip;
struct sysmon_envsys *sc_sme;
envsys_data_t sc_sensor[DBCOOL_MAXSENSORS];
int sc_sysctl_num[DBCOOL_MAXSENSORS];
struct reg_list *sc_regs[DBCOOL_MAXSENSORS];
uint8_t sc_suspend;
uint8_t sc_temp_offset;
#ifdef DBCOOL_DEBUG
uint8_t sc_user_reg;
#endif
};
struct chip_id {
uint8_t company;
uint8_t device;
uint8_t rev;
struct dbcool_sensor *table;
struct dbcool_power_control *power;
int flags;
int rpm_dividend;
const char *name;
};
/*
* Expose some routines for the macppc's ki2c match/attach routines
*/
uint8_t dbcool_readreg(struct dbcool_softc *, uint8_t);
void dbcool_writereg(struct dbcool_softc *, uint8_t, uint8_t);
void dbcool_setup(device_t);
int dbcool_chip_ident(struct dbcool_softc *);
bool dbcool_pmf_suspend(device_t PMF_FN_PROTO);
bool dbcool_pmf_resume(device_t PMF_FN_PROTO);
#endif /* def DBCOOLVAR_H */

View File

@ -1,4 +1,4 @@
# $NetBSD: files.i2c,v 1.18 2008/09/11 20:48:50 pgoyette Exp $
# $NetBSD: files.i2c,v 1.19 2008/10/02 00:47:51 pgoyette Exp $
defflag opt_i2cbus.h I2C_SCAN
define i2cbus { }
@ -71,6 +71,12 @@ device adt7467c: sysmon_envsys
attach adt7467c at iic
file dev/i2c/adt7467.c adt7467c
# Analog Devices dBCool family of thermal monitors / fan controllers
define dbcool {}
device dbcool: sysmon_envsys
attach dbcool at iic
file dev/i2c/dbcool.c dbcool
# Analog Devices ADM 1030 thermal monitor / fan controller
define adm1030c {}
device adm1030c: sysmon_envsys