xref: /openbmc/linux/Documentation/w1/slaves/w1_ds2438.rst (revision 762f99f4f3cb41a775b5157dd761217beba65873)
1e9bb6275SMauro Carvalho ChehabKernel driver w1_ds2438
2e9bb6275SMauro Carvalho Chehab=======================
3e9bb6275SMauro Carvalho Chehab
4e9bb6275SMauro Carvalho ChehabSupported chips:
5e9bb6275SMauro Carvalho Chehab
6e9bb6275SMauro Carvalho Chehab  * Maxim DS2438 Smart Battery Monitor
7e9bb6275SMauro Carvalho Chehab
8e9bb6275SMauro Carvalho Chehabsupported family codes:
9e9bb6275SMauro Carvalho Chehab        ================        ====
10e9bb6275SMauro Carvalho Chehab        W1_FAMILY_DS2438        0x26
11e9bb6275SMauro Carvalho Chehab        ================        ====
12e9bb6275SMauro Carvalho Chehab
13e9bb6275SMauro Carvalho ChehabAuthor: Mariusz Bialonczyk <manio@skyboo.net>
14e9bb6275SMauro Carvalho Chehab
15e9bb6275SMauro Carvalho ChehabDescription
16e9bb6275SMauro Carvalho Chehab-----------
17e9bb6275SMauro Carvalho Chehab
18e9bb6275SMauro Carvalho ChehabThe DS2438 chip provides several functions that are desirable to carry in
19e9bb6275SMauro Carvalho Chehaba battery pack. It also has a 40 bytes of nonvolatile EEPROM.
20e9bb6275SMauro Carvalho ChehabBecause the ability of temperature, current and voltage measurement, the chip
21e9bb6275SMauro Carvalho Chehabis also often used in weather stations and applications such as: rain gauge,
22e9bb6275SMauro Carvalho Chehabwind speed/direction measuring, humidity sensing, etc.
23e9bb6275SMauro Carvalho Chehab
24e9bb6275SMauro Carvalho ChehabCurrent support is provided through the following sysfs files (all files
25c999fbbdSLuiz Sampaioexcept "iad" and "offset" are readonly):
26e9bb6275SMauro Carvalho Chehab
27e9bb6275SMauro Carvalho Chehab"iad"
28e9bb6275SMauro Carvalho Chehab-----
29e9bb6275SMauro Carvalho ChehabThis file controls the 'Current A/D Control Bit' (IAD) in the
30e9bb6275SMauro Carvalho ChehabStatus/Configuration Register.
31e9bb6275SMauro Carvalho ChehabWriting a zero value will clear the IAD bit and disables the current
32e9bb6275SMauro Carvalho Chehabmeasurements.
33e9bb6275SMauro Carvalho ChehabWriting value "1" is setting the IAD bit (enables the measurements).
34e9bb6275SMauro Carvalho ChehabThe IAD bit is enabled by default in the DS2438.
35e9bb6275SMauro Carvalho Chehab
36e9bb6275SMauro Carvalho ChehabWhen writing to sysfs file bits 2-7 are ignored, so it's safe to write ASCII.
37e9bb6275SMauro Carvalho ChehabAn I/O error is returned when there is a problem setting the new value.
38e9bb6275SMauro Carvalho Chehab
39e9bb6275SMauro Carvalho Chehab"page0"
40e9bb6275SMauro Carvalho Chehab-------
41e9bb6275SMauro Carvalho ChehabThis file provides full 8 bytes of the chip Page 0 (00h).
42e9bb6275SMauro Carvalho ChehabThis page contains the most frequently accessed information of the DS2438.
43e9bb6275SMauro Carvalho ChehabInternally when this file is read, the additional CRC byte is also obtained
44e9bb6275SMauro Carvalho Chehabfrom the slave device. If it is correct, the 8 bytes page data are passed
45e9bb6275SMauro Carvalho Chehabto userspace, otherwise an I/O error is returned.
46e9bb6275SMauro Carvalho Chehab
47fd6ec5d7SLuiz Sampaio"page1"
48fd6ec5d7SLuiz Sampaio-------
49fd6ec5d7SLuiz SampaioThis file provides full 8 bytes of the chip Page 1 (01h).
50fd6ec5d7SLuiz SampaioThis page contains the ICA, elapsed time meter and current offset data of the DS2438.
51fd6ec5d7SLuiz SampaioInternally when this file is read, the additional CRC byte is also obtained
52fd6ec5d7SLuiz Sampaiofrom the slave device. If it is correct, the 8 bytes page data are passed
53fd6ec5d7SLuiz Sampaioto userspace, otherwise an I/O error is returned.
54fd6ec5d7SLuiz Sampaio
55c999fbbdSLuiz Sampaio"offset"
56*83aacfbcSGreg Kroah-Hartman--------
57c999fbbdSLuiz SampaioThis file controls the 2-byte Offset Register of the chip.
58c999fbbdSLuiz SampaioWriting a 2-byte value will change the Offset Register, which changes the
59c999fbbdSLuiz Sampaiocurrent measurement done by the chip. Changing this register to the two's complement
60c999fbbdSLuiz Sampaioof the current register while forcing zero current through the load will calibrate
61c999fbbdSLuiz Sampaiothe chip, canceling offset errors in the current ADC.
62c999fbbdSLuiz Sampaio
63c999fbbdSLuiz Sampaio
64e9bb6275SMauro Carvalho Chehab"temperature"
65e9bb6275SMauro Carvalho Chehab-------------
66e9bb6275SMauro Carvalho ChehabOpening and reading this file initiates the CONVERT_T (temperature conversion)
67e9bb6275SMauro Carvalho Chehabcommand of the chip, afterwards the temperature is read from the device
68e9bb6275SMauro Carvalho Chehabregisters and provided as an ASCII decimal value.
69e9bb6275SMauro Carvalho Chehab
70e9bb6275SMauro Carvalho ChehabImportant: The returned value has to be divided by 256 to get a real
71e9bb6275SMauro Carvalho Chehabtemperature in degrees Celsius.
72e9bb6275SMauro Carvalho Chehab
73e9bb6275SMauro Carvalho Chehab"vad", "vdd"
74e9bb6275SMauro Carvalho Chehab------------
75e9bb6275SMauro Carvalho ChehabOpening and reading this file initiates the CONVERT_V (voltage conversion)
76e9bb6275SMauro Carvalho Chehabcommand of the chip.
77e9bb6275SMauro Carvalho Chehab
78e9bb6275SMauro Carvalho ChehabDepending on a sysfs filename a different input for the A/D will be selected:
79e9bb6275SMauro Carvalho Chehab
80e9bb6275SMauro Carvalho Chehabvad:
81e9bb6275SMauro Carvalho Chehab    general purpose A/D input (VAD)
82e9bb6275SMauro Carvalho Chehabvdd:
83e9bb6275SMauro Carvalho Chehab    battery input (VDD)
84e9bb6275SMauro Carvalho Chehab
85e9bb6275SMauro Carvalho ChehabAfter the voltage conversion the value is returned as decimal ASCII.
86e9bb6275SMauro Carvalho ChehabNote: To get a volts the value has to be divided by 100.
87