1Kernel driver w83781d
2=====================
3
4Supported chips:
5  * Winbond W83781D
6    Prefix: 'w83781d'
7    Addresses scanned: I2C 0x28 - 0x2f, ISA 0x290 (8 I/O ports)
8    Datasheet: http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/w83781d.pdf
9  * Winbond W83782D
10    Prefix: 'w83782d'
11    Addresses scanned: I2C 0x28 - 0x2f, ISA 0x290 (8 I/O ports)
12    Datasheet: http://www.winbond.com
13  * Winbond W83783S
14    Prefix: 'w83783s'
15    Addresses scanned: I2C 0x2d
16    Datasheet: http://www.winbond-usa.com/products/winbond_products/pdfs/PCIC/w83783s.pdf
17  * Asus AS99127F
18    Prefix: 'as99127f'
19    Addresses scanned: I2C 0x28 - 0x2f
20    Datasheet: Unavailable from Asus
21
22Authors:
23        Frodo Looijaard <frodol@dds.nl>,
24        Philip Edelbrock <phil@netroedge.com>,
25        Mark Studebaker <mdsxyz123@yahoo.com>
26
27Module parameters
28-----------------
29
30* init int
31  (default 1)
32  Use 'init=0' to bypass initializing the chip.
33  Try this if your computer crashes when you load the module.
34
35* reset int
36  (default 0)
37  The driver used to reset the chip on load, but does no more. Use
38  'reset=1' to restore the old behavior. Report if you need to do this.
39
40force_subclients=bus,caddr,saddr,saddr
41  This is used to force the i2c addresses for subclients of
42  a certain chip. Typical usage is `force_subclients=0,0x2d,0x4a,0x4b'
43  to force the subclients of chip 0x2d on bus 0 to i2c addresses
44  0x4a and 0x4b. This parameter is useful for certain Tyan boards.
45
46Description
47-----------
48
49This driver implements support for the Winbond W83781D, W83782D, W83783S
50chips, and the Asus AS99127F chips. We will refer to them collectively as
51W8378* chips.
52
53There is quite some difference between these chips, but they are similar
54enough that it was sensible to put them together in one driver.
55The Asus chips are similar to an I2C-only W83782D.
56
57Chip        #vin    #fanin  #pwm    #temp   wchipid vendid  i2c     ISA
58as99127f    7       3       0       3       0x31    0x12c3  yes     no
59as99127f rev.2 (type_name = as99127f)       0x31    0x5ca3  yes     no
60w83781d     7       3       0       3       0x10-1  0x5ca3  yes     yes
61w83782d     9       3       2-4     3       0x30    0x5ca3  yes     yes
62w83783s     5-6     3       2       1-2     0x40    0x5ca3  yes     no
63
64Detection of these chips can sometimes be foiled because they can be in
65an internal state that allows no clean access. If you know the address
66of the chip, use a 'force' parameter; this will put them into a more
67well-behaved state first.
68
69The W8378* implements temperature sensors (three on the W83781D and W83782D,
70two on the W83783S), three fan rotation speed sensors, voltage sensors
71(seven on the W83781D, nine on the W83782D and six on the W83783S), VID
72lines, alarms with beep warnings, and some miscellaneous stuff.
73
74Temperatures are measured in degrees Celsius. There is always one main
75temperature sensor, and one (W83783S) or two (W83781D and W83782D) other
76sensors. An alarm is triggered for the main sensor once when the
77Overtemperature Shutdown limit is crossed; it is triggered again as soon as
78it drops below the Hysteresis value. A more useful behavior
79can be found by setting the Hysteresis value to +127 degrees Celsius; in
80this case, alarms are issued during all the time when the actual temperature
81is above the Overtemperature Shutdown value. The driver sets the
82hysteresis value for temp1 to 127 at initialization.
83
84For the other temperature sensor(s), an alarm is triggered when the
85temperature gets higher then the Overtemperature Shutdown value; it stays
86on until the temperature falls below the Hysteresis value. But on the
87W83781D, there is only one alarm that functions for both other sensors!
88Temperatures are guaranteed within a range of -55 to +125 degrees. The
89main temperature sensors has a resolution of 1 degree; the other sensor(s)
90of 0.5 degree.
91
92Fan rotation speeds are reported in RPM (rotations per minute). An alarm is
93triggered if the rotation speed has dropped below a programmable limit. Fan
94readings can be divided by a programmable divider (1, 2, 4 or 8 for the
95W83781D; 1, 2, 4, 8, 16, 32, 64 or 128 for the others) to give
96the readings more range or accuracy. Not all RPM values can accurately
97be represented, so some rounding is done. With a divider of 2, the lowest
98representable value is around 2600 RPM.
99
100Voltage sensors (also known as IN sensors) report their values in volts.
101An alarm is triggered if the voltage has crossed a programmable minimum
102or maximum limit. Note that minimum in this case always means 'closest to
103zero'; this is important for negative voltage measurements. All voltage
104inputs can measure voltages between 0 and 4.08 volts, with a resolution
105of 0.016 volt.
106
107The VID lines encode the core voltage value: the voltage level your processor
108should work with. This is hardcoded by the mainboard and/or processor itself.
109It is a value in volts. When it is unconnected, you will often find the
110value 3.50 V here.
111
112The W83782D and W83783S temperature conversion machine understands about
113several kinds of temperature probes. You can program the so-called
114beta value in the sensor files. '1' is the PII/Celeron diode, '2' is the
115TN3904 transistor, and 3435 the default thermistor value. Other values
116are (not yet) supported.
117
118In addition to the alarms described above, there is a CHAS alarm on the
119chips which triggers if your computer case is open.
120
121When an alarm goes off, you can be warned by a beeping signal through
122your computer speaker. It is possible to enable all beeping globally,
123or only the beeping for some alarms.
124
125Individual alarm and beep bits:
126
1270x000001: in0
1280x000002: in1
1290x000004: in2
1300x000008: in3
1310x000010: temp1
1320x000020: temp2 (+temp3 on W83781D)
1330x000040: fan1
1340x000080: fan2
1350x000100: in4
1360x000200: in5
1370x000400: in6
1380x000800: fan3
1390x001000: chassis
1400x002000: temp3 (W83782D only)
1410x010000: in7 (W83782D only)
1420x020000: in8 (W83782D only)
143
144If an alarm triggers, it will remain triggered until the hardware register
145is read at least once. This means that the cause for the alarm may
146already have disappeared! Note that in the current implementation, all
147hardware registers are read whenever any data is read (unless it is less
148than 1.5 seconds since the last update). This means that you can easily
149miss once-only alarms.
150
151The chips only update values each 1.5 seconds; reading them more often
152will do no harm, but will return 'old' values.
153
154AS99127F PROBLEMS
155-----------------
156The as99127f support was developed without the benefit of a datasheet.
157In most cases it is treated as a w83781d (although revision 2 of the
158AS99127F looks more like a w83782d).
159This support will be BETA until a datasheet is released.
160One user has reported problems with fans stopping
161occasionally.
162
163Note that the individual beep bits are inverted from the other chips.
164The driver now takes care of this so that user-space applications
165don't have to know about it.
166
167Known problems:
168	- Problems with diode/thermistor settings (supported?)
169	- One user reports fans stopping under high server load.
170	- Revision 2 seems to have 2 PWM registers but we don't know
171	  how to handle them. More details below.
172
173These will not be fixed unless we get a datasheet.
174If you have problems, please lobby Asus to release a datasheet.
175Unfortunately several others have without success.
176Please do not send mail to us asking for better as99127f support.
177We have done the best we can without a datasheet.
178Please do not send mail to the author or the sensors group asking for
179a datasheet or ideas on how to convince Asus. We can't help.
180
181
182NOTES:
183-----
184  783s has no in1 so that in[2-6] are compatible with the 781d/782d.
185
186  783s pin is programmable for -5V or temp1; defaults to -5V,
187       no control in driver so temp1 doesn't work.
188
189  782d and 783s datasheets differ on which is pwm1 and which is pwm2.
190       We chose to follow 782d.
191
192  782d and 783s pin is programmable for fan3 input or pwm2 output;
193       defaults to fan3 input.
194       If pwm2 is enabled (with echo 255 1 > pwm2), then
195       fan3 will report 0.
196
197  782d has pwm1-2 for ISA, pwm1-4 for i2c. (pwm3-4 share pins with
198       the ISA pins)
199
200Data sheet updates:
201------------------
202	- PWM clock registers:
203
204		000: master /  512
205		001: master / 1024
206		010: master / 2048
207		011: master / 4096
208		100: master / 8192
209
210
211Answers from Winbond tech support
212---------------------------------
213>
214> 1) In the W83781D data sheet section 7.2 last paragraph, it talks about
215>    reprogramming the R-T table if the Beta of the thermistor is not
216>    3435K. The R-T table is described briefly in section 8.20.
217>    What formulas do I use to program a new R-T table for a given Beta?
218>
219	We are sorry that the calculation for R-T table value is
220confidential. If you have another Beta value of thermistor, we can help
221to calculate the R-T table for you. But you should give us real R-T
222Table which can be gotten by thermistor vendor. Therefore we will calculate
223them and obtain 32-byte data, and you can fill the 32-byte data to the
224register in Bank0.CR51 of W83781D.
225
226
227> 2) In the W83782D data sheet, it mentions that pins 38, 39, and 40 are
228>    programmable to be either thermistor or Pentium II diode inputs.
229>    How do I program them for diode inputs? I can't find any register
230>    to program these to be diode inputs.
231 --> You may program Bank0 CR[5Dh] and CR[59h] registers.
232
233 	CR[5Dh]    		bit 1(VTIN1)    bit 2(VTIN2)   bit 3(VTIN3)
234
235      	thermistor                0		 0		0
236 	diode 		          1		 1		1
237
238
239(error) CR[59h] 		bit 4(VTIN1)	bit 2(VTIN2)   bit 3(VTIN3)
240(right) CR[59h] 		bit 4(VTIN1)	bit 5(VTIN2)   bit 6(VTIN3)
241
242 	PII thermal diode         1		 1		1
243 	2N3904	diode	          0		 0		0
244
245
246Asus Clones
247-----------
248
249We have no datasheets for the Asus clones (AS99127F and ASB100 Bach).
250Here are some very useful information that were given to us by Alex Van
251Kaam about how to detect these chips, and how to read their values. He
252also gives advice for another Asus chipset, the Mozart-2 (which we
253don't support yet). Thanks Alex!
254I reworded some parts and added personal comments.
255
256# Detection:
257
258AS99127F rev.1, AS99127F rev.2 and ASB100:
259- I2C address range: 0x29 - 0x2F
260- If register 0x58 holds 0x31 then we have an Asus (either ASB100 or
261  AS99127F)
262- Which one depends on register 0x4F (manufacturer ID):
263  0x06 or 0x94: ASB100
264  0x12 or 0xC3: AS99127F rev.1
265  0x5C or 0xA3: AS99127F rev.2
266  Note that 0x5CA3 is Winbond's ID (WEC), which let us think Asus get their
267  AS99127F rev.2 direct from Winbond. The other codes mean ATT and DVC,
268  respectively. ATT could stand for Asustek something (although it would be
269  very badly chosen IMHO), I don't know what DVC could stand for. Maybe
270  these codes simply aren't meant to be decoded that way.
271
272Mozart-2:
273- I2C address: 0x77
274- If register 0x58 holds 0x56 or 0x10 then we have a Mozart-2
275- Of the Mozart there are 3 types:
276  0x58=0x56, 0x4E=0x94, 0x4F=0x36: Asus ASM58 Mozart-2
277  0x58=0x56, 0x4E=0x94, 0x4F=0x06: Asus AS2K129R Mozart-2
278  0x58=0x10, 0x4E=0x5C, 0x4F=0xA3: Asus ??? Mozart-2
279  You can handle all 3 the exact same way :)
280
281# Temperature sensors:
282
283ASB100:
284- sensor 1: register 0x27
285- sensor 2 & 3 are the 2 LM75's on the SMBus
286- sensor 4: register 0x17
287Remark: I noticed that on Intel boards sensor 2 is used for the CPU
288  and 4 is ignored/stuck, on AMD boards sensor 4 is the CPU and sensor 2 is
289  either ignored or a socket temperature.
290
291AS99127F (rev.1 and 2 alike):
292- sensor 1: register 0x27
293- sensor 2 & 3 are the 2 LM75's on the SMBus
294Remark: Register 0x5b is suspected to be temperature type selector. Bit 1
295  would control temp1, bit 3 temp2 and bit 5 temp3.
296
297Mozart-2:
298- sensor 1: register 0x27
299- sensor 2: register 0x13
300
301# Fan sensors:
302
303ASB100, AS99127F (rev.1 and 2 alike):
304- 3 fans, identical to the W83781D
305
306Mozart-2:
307- 2 fans only, 1350000/RPM/div
308- fan 1: register 0x28,  divisor on register 0xA1 (bits 4-5)
309- fan 2: register 0x29,  divisor on register 0xA1 (bits 6-7)
310
311# Voltages:
312
313This is where there is a difference between AS99127F rev.1 and 2.
314Remark: The difference is similar to the difference between
315  W83781D and W83782D.
316
317ASB100:
318in0=r(0x20)*0.016
319in1=r(0x21)*0.016
320in2=r(0x22)*0.016
321in3=r(0x23)*0.016*1.68
322in4=r(0x24)*0.016*3.8
323in5=r(0x25)*(-0.016)*3.97
324in6=r(0x26)*(-0.016)*1.666
325
326AS99127F rev.1:
327in0=r(0x20)*0.016
328in1=r(0x21)*0.016
329in2=r(0x22)*0.016
330in3=r(0x23)*0.016*1.68
331in4=r(0x24)*0.016*3.8
332in5=r(0x25)*(-0.016)*3.97
333in6=r(0x26)*(-0.016)*1.503
334
335AS99127F rev.2:
336in0=r(0x20)*0.016
337in1=r(0x21)*0.016
338in2=r(0x22)*0.016
339in3=r(0x23)*0.016*1.68
340in4=r(0x24)*0.016*3.8
341in5=(r(0x25)*0.016-3.6)*5.14+3.6
342in6=(r(0x26)*0.016-3.6)*3.14+3.6
343
344Mozart-2:
345in0=r(0x20)*0.016
346in1=255
347in2=r(0x22)*0.016
348in3=r(0x23)*0.016*1.68
349in4=r(0x24)*0.016*4
350in5=255
351in6=255
352
353
354# PWM
355
356* Additional info about PWM on the AS99127F (may apply to other Asus
357chips as well) by Jean Delvare as of 2004-04-09:
358
359AS99127F revision 2 seems to have two PWM registers at 0x59 and 0x5A,
360and a temperature sensor type selector at 0x5B (which basically means
361that they swapped registers 0x59 and 0x5B when you compare with Winbond
362chips).
363Revision 1 of the chip also has the temperature sensor type selector at
3640x5B, but PWM registers have no effect.
365
366We don't know exactly how the temperature sensor type selection works.
367Looks like bits 1-0 are for temp1, bits 3-2 for temp2 and bits 5-4 for
368temp3, although it is possible that only the most significant bit matters
369each time. So far, values other than 0 always broke the readings.
370
371PWM registers seem to be split in two parts: bit 7 is a mode selector,
372while the other bits seem to define a value or threshold.
373
374When bit 7 is clear, bits 6-0 seem to hold a threshold value. If the value
375is below a given limit, the fan runs at low speed. If the value is above
376the limit, the fan runs at full speed. We have no clue as to what the limit
377represents. Note that there seem to be some inertia in this mode, speed
378changes may need some time to trigger. Also, an hysteresis mechanism is
379suspected since walking through all the values increasingly and then
380decreasingly led to slightly different limits.
381
382When bit 7 is set, bits 3-0 seem to hold a threshold value, while bits 6-4
383would not be significant. If the value is below a given limit, the fan runs
384at full speed, while if it is above the limit it runs at low speed (so this
385is the contrary of the other mode, in a way). Here again, we don't know
386what the limit is supposed to represent.
387
388One remarkable thing is that the fans would only have two or three
389different speeds (transitional states left apart), not a whole range as
390you usually get with PWM.
391
392As a conclusion, you can write 0x00 or 0x8F to the PWM registers to make
393fans run at low speed, and 0x7F or 0x80 to make them run at full speed.
394
395Please contact us if you can figure out how it is supposed to work. As
396long as we don't know more, the w83781d driver doesn't handle PWM on
397AS99127F chips at all.
398
399* Additional info about PWM on the AS99127F rev.1 by Hector Martin:
400
401I've been fiddling around with the (in)famous 0x59 register and
402found out the following values do work as a form of coarse pwm:
403
4040x80 - seems to turn fans off after some time(1-2 minutes)... might be
405some form of auto-fan-control based on temp? hmm (Qfan? this mobo is an
406old ASUS, it isn't marketed as Qfan. Maybe some beta pre-attempt at Qfan
407that was dropped at the BIOS)
4080x81 - off
4090x82 - slightly "on-ner" than off, but my fans do not get to move. I can
410hear the high-pitched PWM sound that motors give off at too-low-pwm.
4110x83 - now they do move. Estimate about 70% speed or so.
4120x84-0x8f - full on
413
414Changing the high nibble doesn't seem to do much except the high bit
415(0x80) must be set for PWM to work, else the current pwm doesn't seem to
416change.
417
418My mobo is an ASUS A7V266-E. This behavior is similar to what I got
419with speedfan under Windows, where 0-15% would be off, 15-2x% (can't
420remember the exact value) would be 70% and higher would be full on.
421
422* Additional info about PWM on the AS99127F rev.1 from lm-sensors
423  ticket #2350:
424
425I conducted some experiment on Asus P3B-F motherboard with AS99127F
426(Ver. 1).
427
428I confirm that 0x59 register control the CPU_Fan Header on this
429motherboard, and 0x5a register control PWR_Fan.
430
431In order to reduce the dependency of specific fan, the measurement is
432conducted with a digital scope without fan connected. I found out that
433P3B-F actually output variable DC voltage on fan header center pin,
434looks like PWM is filtered on this motherboard.
435
436Here are some of measurements:
437
4380x80     20 mV
4390x81     20 mV
4400x82    232 mV
4410x83   1.2  V
4420x84   2.31 V
4430x85   3.44 V
4440x86   4.62 V
4450x87   5.81 V
4460x88   7.01 V
4479x89   8.22 V
4480x8a   9.42 V
4490x8b  10.6  V
4500x8c  11.9  V
4510x8d  12.4  V
4520x8e  12.4  V
4530x8f  12.4  V
454