xref: /OK3568_Linux_fs/kernel/Documentation/hwmon/vt1211.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunKernel driver vt1211
2*4882a593Smuzhiyun====================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunSupported chips:
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun  * VIA VT1211
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun    Prefix: 'vt1211'
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun    Addresses scanned: none, address read from Super-I/O config space
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun    Datasheet: Provided by VIA upon request and under NDA
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunAuthors: Juerg Haefliger <juergh@gmail.com>
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunThis driver is based on the driver for kernel 2.4 by Mark D. Studebaker and
17*4882a593Smuzhiyunits port to kernel 2.6 by Lars Ekman.
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunThanks to Joseph Chan and Fiona Gatt from VIA for providing documentation and
20*4882a593Smuzhiyuntechnical support.
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunModule Parameters
24*4882a593Smuzhiyun-----------------
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun* uch_config: int
28*4882a593Smuzhiyun			Override the BIOS default universal channel (UCH)
29*4882a593Smuzhiyun			configuration for channels 1-5.
30*4882a593Smuzhiyun			Legal values are in the range of 0-31. Bit 0 maps to
31*4882a593Smuzhiyun			UCH1, bit 1 maps to UCH2 and so on. Setting a bit to 1
32*4882a593Smuzhiyun			enables the thermal input of that particular UCH and
33*4882a593Smuzhiyun			setting a bit to 0 enables the voltage input.
34*4882a593Smuzhiyun
35*4882a593Smuzhiyun* int_mode: int
36*4882a593Smuzhiyun			Override the BIOS default temperature interrupt mode.
37*4882a593Smuzhiyun			The only possible value is 0 which forces interrupt
38*4882a593Smuzhiyun			mode 0. In this mode, any pending interrupt is cleared
39*4882a593Smuzhiyun			when the status register is read but is regenerated as
40*4882a593Smuzhiyun			long as the temperature stays above the hysteresis
41*4882a593Smuzhiyun			limit.
42*4882a593Smuzhiyun
43*4882a593SmuzhiyunBe aware that overriding BIOS defaults might cause some unwanted side effects!
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun
46*4882a593SmuzhiyunDescription
47*4882a593Smuzhiyun-----------
48*4882a593Smuzhiyun
49*4882a593SmuzhiyunThe VIA VT1211 Super-I/O chip includes complete hardware monitoring
50*4882a593Smuzhiyuncapabilities. It monitors 2 dedicated temperature sensor inputs (temp1 and
51*4882a593Smuzhiyuntemp2), 1 dedicated voltage (in5) and 2 fans. Additionally, the chip
52*4882a593Smuzhiyunimplements 5 universal input channels (UCH1-5) that can be individually
53*4882a593Smuzhiyunprogrammed to either monitor a voltage or a temperature.
54*4882a593Smuzhiyun
55*4882a593SmuzhiyunThis chip also provides manual and automatic control of fan speeds (according
56*4882a593Smuzhiyunto the datasheet). The driver only supports automatic control since the manual
57*4882a593Smuzhiyunmode doesn't seem to work as advertised in the datasheet. In fact I couldn't
58*4882a593Smuzhiyunget manual mode to work at all! Be aware that automatic mode hasn't been
59*4882a593Smuzhiyuntested very well (due to the fact that my EPIA M10000 doesn't have the fans
60*4882a593Smuzhiyunconnected to the PWM outputs of the VT1211 :-().
61*4882a593Smuzhiyun
62*4882a593SmuzhiyunThe following table shows the relationship between the vt1211 inputs and the
63*4882a593Smuzhiyunsysfs nodes.
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun=============== ============== =========== ================================
66*4882a593SmuzhiyunSensor          Voltage Mode   Temp Mode   Default Use (from the datasheet)
67*4882a593Smuzhiyun=============== ============== =========== ================================
68*4882a593SmuzhiyunReading 1                      temp1       Intel thermal diode
69*4882a593SmuzhiyunReading 3                      temp2       Internal thermal diode
70*4882a593SmuzhiyunUCH1/Reading2   in0            temp3       NTC type thermistor
71*4882a593SmuzhiyunUCH2            in1            temp4       +2.5V
72*4882a593SmuzhiyunUCH3            in2            temp5       VccP (processor core)
73*4882a593SmuzhiyunUCH4            in3            temp6       +5V
74*4882a593SmuzhiyunUCH5            in4            temp7       +12V
75*4882a593Smuzhiyun+3.3V           in5                        Internal VCC (+3.3V)
76*4882a593Smuzhiyun=============== ============== =========== ================================
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunVoltage Monitoring
80*4882a593Smuzhiyun------------------
81*4882a593Smuzhiyun
82*4882a593SmuzhiyunVoltages are sampled by an 8-bit ADC with a LSB of ~10mV. The supported input
83*4882a593Smuzhiyunrange is thus from 0 to 2.60V. Voltage values outside of this range need
84*4882a593Smuzhiyunexternal scaling resistors. This external scaling needs to be compensated for
85*4882a593Smuzhiyunvia compute lines in sensors.conf, like:
86*4882a593Smuzhiyun
87*4882a593Smuzhiyuncompute inx @*(1+R1/R2), @/(1+R1/R2)
88*4882a593Smuzhiyun
89*4882a593SmuzhiyunThe board level scaling resistors according to VIA's recommendation are as
90*4882a593Smuzhiyunfollows. And this is of course totally dependent on the actual board
91*4882a593Smuzhiyunimplementation :-) You will have to find documentation for your own
92*4882a593Smuzhiyunmotherboard and edit sensors.conf accordingly.
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun============= ====== ====== ========= ============
95*4882a593Smuzhiyun				      Expected
96*4882a593SmuzhiyunVoltage       R1     R2     Divider   Raw Value
97*4882a593Smuzhiyun============= ====== ====== ========= ============
98*4882a593Smuzhiyun+2.5V         2K     10K    1.2       2083 mV
99*4882a593SmuzhiyunVccP          ---    ---    1.0       1400 mV [1]_
100*4882a593Smuzhiyun+5V           14K    10K    2.4       2083 mV
101*4882a593Smuzhiyun+12V          47K    10K    5.7       2105 mV
102*4882a593Smuzhiyun+3.3V (int)   2K     3.4K   1.588     3300 mV [2]_
103*4882a593Smuzhiyun+3.3V (ext)   6.8K   10K    1.68      1964 mV
104*4882a593Smuzhiyun============= ====== ====== ========= ============
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun.. [1] Depending on the CPU (1.4V is for a VIA C3 Nehemiah).
107*4882a593Smuzhiyun
108*4882a593Smuzhiyun.. [2] R1 and R2 for 3.3V (int) are internal to the VT1211 chip and the driver
109*4882a593Smuzhiyun       performs the scaling and returns the properly scaled voltage value.
110*4882a593Smuzhiyun
111*4882a593SmuzhiyunEach measured voltage has an associated low and high limit which triggers an
112*4882a593Smuzhiyunalarm when crossed.
113*4882a593Smuzhiyun
114*4882a593Smuzhiyun
115*4882a593SmuzhiyunTemperature Monitoring
116*4882a593Smuzhiyun----------------------
117*4882a593Smuzhiyun
118*4882a593SmuzhiyunTemperatures are reported in millidegree Celsius. Each measured temperature
119*4882a593Smuzhiyunhas a high limit which triggers an alarm if crossed. There is an associated
120*4882a593Smuzhiyunhysteresis value with each temperature below which the temperature has to drop
121*4882a593Smuzhiyunbefore the alarm is cleared (this is only true for interrupt mode 0). The
122*4882a593Smuzhiyuninterrupt mode can be forced to 0 in case the BIOS doesn't do it
123*4882a593Smuzhiyunautomatically. See the 'Module Parameters' section for details.
124*4882a593Smuzhiyun
125*4882a593SmuzhiyunAll temperature channels except temp2 are external. Temp2 is the VT1211
126*4882a593Smuzhiyuninternal thermal diode and the driver does all the scaling for temp2 and
127*4882a593Smuzhiyunreturns the temperature in millidegree Celsius. For the external channels
128*4882a593Smuzhiyuntemp1 and temp3-temp7, scaling depends on the board implementation and needs
129*4882a593Smuzhiyunto be performed in userspace via sensors.conf.
130*4882a593Smuzhiyun
131*4882a593SmuzhiyunTemp1 is an Intel-type thermal diode which requires the following formula to
132*4882a593Smuzhiyunconvert between sysfs readings and real temperatures:
133*4882a593Smuzhiyun
134*4882a593Smuzhiyuncompute temp1 (@-Offset)/Gain, (@*Gain)+Offset
135*4882a593Smuzhiyun
136*4882a593SmuzhiyunAccording to the VIA VT1211 BIOS porting guide, the following gain and offset
137*4882a593Smuzhiyunvalues should be used:
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun=============== ======== ===========
140*4882a593SmuzhiyunDiode Type      Offset   Gain
141*4882a593Smuzhiyun=============== ======== ===========
142*4882a593SmuzhiyunIntel CPU       88.638   0.9528
143*4882a593Smuzhiyun		65.000   0.9686 [3]_
144*4882a593SmuzhiyunVIA C3 Ezra     83.869   0.9528
145*4882a593SmuzhiyunVIA C3 Ezra-T   73.869   0.9528
146*4882a593Smuzhiyun=============== ======== ===========
147*4882a593Smuzhiyun
148*4882a593Smuzhiyun.. [3] This is the formula from the lm_sensors 2.10.0 sensors.conf file. I don't
149*4882a593Smuzhiyun       know where it comes from or how it was derived, it's just listed here for
150*4882a593Smuzhiyun       completeness.
151*4882a593Smuzhiyun
152*4882a593SmuzhiyunTemp3-temp7 support NTC thermistors. For these channels, the driver returns
153*4882a593Smuzhiyunthe voltages as seen at the individual pins of UCH1-UCH5. The voltage at the
154*4882a593Smuzhiyunpin (Vpin) is formed by a voltage divider made of the thermistor (Rth) and a
155*4882a593Smuzhiyunscaling resistor (Rs)::
156*4882a593Smuzhiyun
157*4882a593Smuzhiyun  Vpin = 2200 * Rth / (Rs + Rth)   (2200 is the ADC max limit of 2200 mV)
158*4882a593Smuzhiyun
159*4882a593SmuzhiyunThe equation for the thermistor is as follows (google it if you want to know
160*4882a593Smuzhiyunmore about it)::
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun  Rth = Ro * exp(B * (1 / T - 1 / To))   (To is 298.15K (25C) and Ro is the
163*4882a593Smuzhiyun					  nominal resistance at 25C)
164*4882a593Smuzhiyun
165*4882a593SmuzhiyunMingling the above two equations and assuming Rs = Ro and B = 3435 yields the
166*4882a593Smuzhiyunfollowing formula for sensors.conf::
167*4882a593Smuzhiyun
168*4882a593Smuzhiyun  compute tempx 1 / (1 / 298.15 - (` (2200 / @ - 1)) / 3435) - 273.15,
169*4882a593Smuzhiyun		2200 / (1 + (^ (3435 / 298.15 - 3435 / (273.15 + @))))
170*4882a593Smuzhiyun
171*4882a593Smuzhiyun
172*4882a593SmuzhiyunFan Speed Control
173*4882a593Smuzhiyun-----------------
174*4882a593Smuzhiyun
175*4882a593SmuzhiyunThe VT1211 provides 2 programmable PWM outputs to control the speeds of 2
176*4882a593Smuzhiyunfans. Writing a 2 to any of the two pwm[1-2]_enable sysfs nodes will put the
177*4882a593SmuzhiyunPWM controller in automatic mode. There is only a single controller that
178*4882a593Smuzhiyuncontrols both PWM outputs but each PWM output can be individually enabled and
179*4882a593Smuzhiyundisabled.
180*4882a593Smuzhiyun
181*4882a593SmuzhiyunEach PWM has 4 associated distinct output duty-cycles: full, high, low and
182*4882a593Smuzhiyunoff. Full and off are internally hard-wired to 255 (100%) and 0 (0%),
183*4882a593Smuzhiyunrespectively. High and low can be programmed via
184*4882a593Smuzhiyunpwm[1-2]_auto_point[2-3]_pwm. Each PWM output can be associated with a
185*4882a593Smuzhiyundifferent thermal input but - and here's the weird part - only one set of
186*4882a593Smuzhiyunthermal thresholds exist that controls both PWMs output duty-cycles. The
187*4882a593Smuzhiyunthermal thresholds are accessible via pwm[1-2]_auto_point[1-4]_temp. Note
188*4882a593Smuzhiyunthat even though there are 2 sets of 4 auto points each, they map to the same
189*4882a593Smuzhiyunregisters in the VT1211 and programming one set is sufficient (actually only
190*4882a593Smuzhiyunthe first set pwm1_auto_point[1-4]_temp is writable, the second set is
191*4882a593Smuzhiyunread-only).
192*4882a593Smuzhiyun
193*4882a593Smuzhiyun========================== =========================================
194*4882a593SmuzhiyunPWM Auto Point             PWM Output Duty-Cycle
195*4882a593Smuzhiyun========================== =========================================
196*4882a593Smuzhiyunpwm[1-2]_auto_point4_pwm   full speed duty-cycle (hard-wired to 255)
197*4882a593Smuzhiyunpwm[1-2]_auto_point3_pwm   high speed duty-cycle
198*4882a593Smuzhiyunpwm[1-2]_auto_point2_pwm   low speed duty-cycle
199*4882a593Smuzhiyunpwm[1-2]_auto_point1_pwm   off duty-cycle (hard-wired to 0)
200*4882a593Smuzhiyun========================== =========================================
201*4882a593Smuzhiyun
202*4882a593Smuzhiyun==========================  =================
203*4882a593SmuzhiyunTemp Auto Point             Thermal Threshold
204*4882a593Smuzhiyun==========================  =================
205*4882a593Smuzhiyunpwm[1-2]_auto_point4_temp   full speed temp
206*4882a593Smuzhiyunpwm[1-2]_auto_point3_temp   high speed temp
207*4882a593Smuzhiyunpwm[1-2]_auto_point2_temp   low speed temp
208*4882a593Smuzhiyunpwm[1-2]_auto_point1_temp   off temp
209*4882a593Smuzhiyun==========================  =================
210*4882a593Smuzhiyun
211*4882a593SmuzhiyunLong story short, the controller implements the following algorithm to set the
212*4882a593SmuzhiyunPWM output duty-cycle based on the input temperature:
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun=================== ======================= ========================
215*4882a593SmuzhiyunThermal Threshold   Output Duty-Cycle       Output Duty-Cycle
216*4882a593Smuzhiyun		    (Rising Temp)           (Falling Temp)
217*4882a593Smuzhiyun=================== ======================= ========================
218*4882a593Smuzhiyun-                   full speed duty-cycle   full speed duty-cycle
219*4882a593Smuzhiyunfull speed temp
220*4882a593Smuzhiyun-		    high speed duty-cycle   full speed duty-cycle
221*4882a593Smuzhiyunhigh speed temp
222*4882a593Smuzhiyun-		    low speed duty-cycle    high speed duty-cycle
223*4882a593Smuzhiyunlow speed temp
224*4882a593Smuzhiyun-		    off duty-cycle          low speed duty-cycle
225*4882a593Smuzhiyunoff temp
226*4882a593Smuzhiyun=================== ======================= ========================
227