162306a36Sopenharmony_ciKernel driver w1_ds2438 262306a36Sopenharmony_ci======================= 362306a36Sopenharmony_ci 462306a36Sopenharmony_ciSupported chips: 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci * Maxim DS2438 Smart Battery Monitor 762306a36Sopenharmony_ci 862306a36Sopenharmony_cisupported family codes: 962306a36Sopenharmony_ci ================ ==== 1062306a36Sopenharmony_ci W1_FAMILY_DS2438 0x26 1162306a36Sopenharmony_ci ================ ==== 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ciAuthor: Mariusz Bialonczyk <manio@skyboo.net> 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ciDescription 1662306a36Sopenharmony_ci----------- 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ciThe DS2438 chip provides several functions that are desirable to carry in 1962306a36Sopenharmony_cia battery pack. It also has a 40 bytes of nonvolatile EEPROM. 2062306a36Sopenharmony_ciBecause the ability of temperature, current and voltage measurement, the chip 2162306a36Sopenharmony_ciis also often used in weather stations and applications such as: rain gauge, 2262306a36Sopenharmony_ciwind speed/direction measuring, humidity sensing, etc. 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ciCurrent support is provided through the following sysfs files (all files 2562306a36Sopenharmony_ciexcept "iad" and "offset" are readonly): 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci"iad" 2862306a36Sopenharmony_ci----- 2962306a36Sopenharmony_ciThis file controls the 'Current A/D Control Bit' (IAD) in the 3062306a36Sopenharmony_ciStatus/Configuration Register. 3162306a36Sopenharmony_ciWriting a zero value will clear the IAD bit and disables the current 3262306a36Sopenharmony_cimeasurements. 3362306a36Sopenharmony_ciWriting value "1" is setting the IAD bit (enables the measurements). 3462306a36Sopenharmony_ciThe IAD bit is enabled by default in the DS2438. 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ciWhen writing to sysfs file bits 2-7 are ignored, so it's safe to write ASCII. 3762306a36Sopenharmony_ciAn I/O error is returned when there is a problem setting the new value. 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci"page0" 4062306a36Sopenharmony_ci------- 4162306a36Sopenharmony_ciThis file provides full 8 bytes of the chip Page 0 (00h). 4262306a36Sopenharmony_ciThis page contains the most frequently accessed information of the DS2438. 4362306a36Sopenharmony_ciInternally when this file is read, the additional CRC byte is also obtained 4462306a36Sopenharmony_cifrom the slave device. If it is correct, the 8 bytes page data are passed 4562306a36Sopenharmony_cito userspace, otherwise an I/O error is returned. 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci"page1" 4862306a36Sopenharmony_ci------- 4962306a36Sopenharmony_ciThis file provides full 8 bytes of the chip Page 1 (01h). 5062306a36Sopenharmony_ciThis page contains the ICA, elapsed time meter and current offset data of the DS2438. 5162306a36Sopenharmony_ciInternally when this file is read, the additional CRC byte is also obtained 5262306a36Sopenharmony_cifrom the slave device. If it is correct, the 8 bytes page data are passed 5362306a36Sopenharmony_cito userspace, otherwise an I/O error is returned. 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci"offset" 5662306a36Sopenharmony_ci-------- 5762306a36Sopenharmony_ciThis file controls the 2-byte Offset Register of the chip. 5862306a36Sopenharmony_ciWriting a 2-byte value will change the Offset Register, which changes the 5962306a36Sopenharmony_cicurrent measurement done by the chip. Changing this register to the two's complement 6062306a36Sopenharmony_ciof the current register while forcing zero current through the load will calibrate 6162306a36Sopenharmony_cithe chip, canceling offset errors in the current ADC. 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci"temperature" 6562306a36Sopenharmony_ci------------- 6662306a36Sopenharmony_ciOpening and reading this file initiates the CONVERT_T (temperature conversion) 6762306a36Sopenharmony_cicommand of the chip, afterwards the temperature is read from the device 6862306a36Sopenharmony_ciregisters and provided as an ASCII decimal value. 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ciImportant: The returned value has to be divided by 256 to get a real 7162306a36Sopenharmony_citemperature in degrees Celsius. 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci"vad", "vdd" 7462306a36Sopenharmony_ci------------ 7562306a36Sopenharmony_ciOpening and reading this file initiates the CONVERT_V (voltage conversion) 7662306a36Sopenharmony_cicommand of the chip. 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ciDepending on a sysfs filename a different input for the A/D will be selected: 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_civad: 8162306a36Sopenharmony_ci general purpose A/D input (VAD) 8262306a36Sopenharmony_civdd: 8362306a36Sopenharmony_ci battery input (VDD) 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_ciAfter the voltage conversion the value is returned as decimal ASCII. 8662306a36Sopenharmony_ciNote: To get a volts the value has to be divided by 100. 87