xref: /OK3568_Linux_fs/kernel/Documentation/w1/slaves/w1_ds2438.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunKernel driver w1_ds2438
2*4882a593Smuzhiyun=======================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunSupported chips:
5*4882a593Smuzhiyun
6*4882a593Smuzhiyun  * Maxim DS2438 Smart Battery Monitor
7*4882a593Smuzhiyun
8*4882a593Smuzhiyunsupported family codes:
9*4882a593Smuzhiyun        ================        ====
10*4882a593Smuzhiyun        W1_FAMILY_DS2438        0x26
11*4882a593Smuzhiyun        ================        ====
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunAuthor: Mariusz Bialonczyk <manio@skyboo.net>
14*4882a593Smuzhiyun
15*4882a593SmuzhiyunDescription
16*4882a593Smuzhiyun-----------
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunThe DS2438 chip provides several functions that are desirable to carry in
19*4882a593Smuzhiyuna battery pack. It also has a 40 bytes of nonvolatile EEPROM.
20*4882a593SmuzhiyunBecause the ability of temperature, current and voltage measurement, the chip
21*4882a593Smuzhiyunis also often used in weather stations and applications such as: rain gauge,
22*4882a593Smuzhiyunwind speed/direction measuring, humidity sensing, etc.
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunCurrent support is provided through the following sysfs files (all files
25*4882a593Smuzhiyunexcept "iad" are readonly):
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun"iad"
28*4882a593Smuzhiyun-----
29*4882a593SmuzhiyunThis file controls the 'Current A/D Control Bit' (IAD) in the
30*4882a593SmuzhiyunStatus/Configuration Register.
31*4882a593SmuzhiyunWriting a zero value will clear the IAD bit and disables the current
32*4882a593Smuzhiyunmeasurements.
33*4882a593SmuzhiyunWriting value "1" is setting the IAD bit (enables the measurements).
34*4882a593SmuzhiyunThe IAD bit is enabled by default in the DS2438.
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunWhen writing to sysfs file bits 2-7 are ignored, so it's safe to write ASCII.
37*4882a593SmuzhiyunAn I/O error is returned when there is a problem setting the new value.
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun"page0"
40*4882a593Smuzhiyun-------
41*4882a593SmuzhiyunThis file provides full 8 bytes of the chip Page 0 (00h).
42*4882a593SmuzhiyunThis page contains the most frequently accessed information of the DS2438.
43*4882a593SmuzhiyunInternally when this file is read, the additional CRC byte is also obtained
44*4882a593Smuzhiyunfrom the slave device. If it is correct, the 8 bytes page data are passed
45*4882a593Smuzhiyunto userspace, otherwise an I/O error is returned.
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun"temperature"
48*4882a593Smuzhiyun-------------
49*4882a593SmuzhiyunOpening and reading this file initiates the CONVERT_T (temperature conversion)
50*4882a593Smuzhiyuncommand of the chip, afterwards the temperature is read from the device
51*4882a593Smuzhiyunregisters and provided as an ASCII decimal value.
52*4882a593Smuzhiyun
53*4882a593SmuzhiyunImportant: The returned value has to be divided by 256 to get a real
54*4882a593Smuzhiyuntemperature in degrees Celsius.
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun"vad", "vdd"
57*4882a593Smuzhiyun------------
58*4882a593SmuzhiyunOpening and reading this file initiates the CONVERT_V (voltage conversion)
59*4882a593Smuzhiyuncommand of the chip.
60*4882a593Smuzhiyun
61*4882a593SmuzhiyunDepending on a sysfs filename a different input for the A/D will be selected:
62*4882a593Smuzhiyun
63*4882a593Smuzhiyunvad:
64*4882a593Smuzhiyun    general purpose A/D input (VAD)
65*4882a593Smuzhiyunvdd:
66*4882a593Smuzhiyun    battery input (VDD)
67*4882a593Smuzhiyun
68*4882a593SmuzhiyunAfter the voltage conversion the value is returned as decimal ASCII.
69*4882a593SmuzhiyunNote: To get a volts the value has to be divided by 100.
70