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