xref: /openbmc/linux/Documentation/w1/slaves/w1_ds2438.rst (revision fd6ec5d79507f99639c94f107e8a98550c9e1cf6)
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
25e9bb6275SMauro Carvalho Chehabexcept "iad" 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
47*fd6ec5d7SLuiz Sampaio"page1"
48*fd6ec5d7SLuiz Sampaio-------
49*fd6ec5d7SLuiz SampaioThis file provides full 8 bytes of the chip Page 1 (01h).
50*fd6ec5d7SLuiz SampaioThis page contains the ICA, elapsed time meter and current offset data of the DS2438.
51*fd6ec5d7SLuiz SampaioInternally when this file is read, the additional CRC byte is also obtained
52*fd6ec5d7SLuiz Sampaiofrom the slave device. If it is correct, the 8 bytes page data are passed
53*fd6ec5d7SLuiz Sampaioto userspace, otherwise an I/O error is returned.
54*fd6ec5d7SLuiz Sampaio
55e9bb6275SMauro Carvalho Chehab"temperature"
56e9bb6275SMauro Carvalho Chehab-------------
57e9bb6275SMauro Carvalho ChehabOpening and reading this file initiates the CONVERT_T (temperature conversion)
58e9bb6275SMauro Carvalho Chehabcommand of the chip, afterwards the temperature is read from the device
59e9bb6275SMauro Carvalho Chehabregisters and provided as an ASCII decimal value.
60e9bb6275SMauro Carvalho Chehab
61e9bb6275SMauro Carvalho ChehabImportant: The returned value has to be divided by 256 to get a real
62e9bb6275SMauro Carvalho Chehabtemperature in degrees Celsius.
63e9bb6275SMauro Carvalho Chehab
64e9bb6275SMauro Carvalho Chehab"vad", "vdd"
65e9bb6275SMauro Carvalho Chehab------------
66e9bb6275SMauro Carvalho ChehabOpening and reading this file initiates the CONVERT_V (voltage conversion)
67e9bb6275SMauro Carvalho Chehabcommand of the chip.
68e9bb6275SMauro Carvalho Chehab
69e9bb6275SMauro Carvalho ChehabDepending on a sysfs filename a different input for the A/D will be selected:
70e9bb6275SMauro Carvalho Chehab
71e9bb6275SMauro Carvalho Chehabvad:
72e9bb6275SMauro Carvalho Chehab    general purpose A/D input (VAD)
73e9bb6275SMauro Carvalho Chehabvdd:
74e9bb6275SMauro Carvalho Chehab    battery input (VDD)
75e9bb6275SMauro Carvalho Chehab
76e9bb6275SMauro Carvalho ChehabAfter the voltage conversion the value is returned as decimal ASCII.
77e9bb6275SMauro Carvalho ChehabNote: To get a volts the value has to be divided by 100.
78