162306a36Sopenharmony_ci====================== 262306a36Sopenharmony_ciKernel driver w1_therm 362306a36Sopenharmony_ci====================== 462306a36Sopenharmony_ci 562306a36Sopenharmony_ciSupported chips: 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci * Maxim ds18*20 based temperature sensors. 862306a36Sopenharmony_ci * Maxim ds1825 based temperature sensors. 962306a36Sopenharmony_ci * GXCAS GX20MH01 temperature sensor. 1062306a36Sopenharmony_ci * Maxim MAX31850 thermoelement interface. 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ciAuthor: Evgeniy Polyakov <johnpol@2ka.mipt.ru> 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ciDescription 1662306a36Sopenharmony_ci----------- 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ciw1_therm provides basic temperature conversion for ds18*20, ds28ea00, GX20MH01 1962306a36Sopenharmony_ciand MAX31850 devices. 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ciSupported family codes: 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci==================== ==== 2462306a36Sopenharmony_ciW1_THERM_DS18S20 0x10 2562306a36Sopenharmony_ciW1_THERM_DS1822 0x22 2662306a36Sopenharmony_ciW1_THERM_DS18B20 0x28 2762306a36Sopenharmony_ciW1_THERM_DS1825 0x3B 2862306a36Sopenharmony_ciW1_THERM_DS28EA00 0x42 2962306a36Sopenharmony_ci==================== ==== 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ciSupport is provided through the sysfs entry ``w1_slave``. Each open and 3262306a36Sopenharmony_ciread sequence will initiate a temperature conversion, then provide two 3362306a36Sopenharmony_cilines of ASCII output. The first line contains the nine hex bytes 3462306a36Sopenharmony_ciread along with a calculated crc value and YES or NO if it matched. 3562306a36Sopenharmony_ciIf the crc matched the returned values are retained. The second line 3662306a36Sopenharmony_cidisplays the retained values along with a temperature in millidegrees 3762306a36Sopenharmony_ciCentigrade after t=. 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ciAlternatively, temperature can be read using ``temperature`` sysfs, it 4062306a36Sopenharmony_cireturns only the temperature in millidegrees Centigrade. 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ciA bulk read of all devices on the bus could be done writing ``trigger`` 4362306a36Sopenharmony_cito ``therm_bulk_read`` entry at w1_bus_master level. This will 4462306a36Sopenharmony_cisend the convert command to all devices on the bus, and if parasite 4562306a36Sopenharmony_cipowered devices are detected on the bus (and strong pullup is enabled 4662306a36Sopenharmony_ciin the module), it will drive the line high during the longer conversion 4762306a36Sopenharmony_citime required by parasited powered device on the line. Reading 4862306a36Sopenharmony_ci``therm_bulk_read`` will return 0 if no bulk conversion pending, 4962306a36Sopenharmony_ci-1 if at least one sensor still in conversion, 1 if conversion is complete 5062306a36Sopenharmony_cibut at least one sensor value has not been read yet. Result temperature is 5162306a36Sopenharmony_cithen accessed by reading the ``temperature`` entry of each device, which 5262306a36Sopenharmony_cimay return empty if conversion is still in progress. Note that if a bulk 5362306a36Sopenharmony_ciread is sent but one sensor is not read immediately, the next access to 5462306a36Sopenharmony_ci``temperature`` on this device will return the temperature measured at the 5562306a36Sopenharmony_citime of issue of the bulk read command (not the current temperature). 5662306a36Sopenharmony_ci 5762306a36Sopenharmony_ciA strong pullup will be applied during the conversion if required. 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci``conv_time`` is used to get current conversion time (read), and 6062306a36Sopenharmony_ciadjust it (write). A temperature conversion time depends on the device type and 6162306a36Sopenharmony_ciits current resolution. Default conversion time is set by the driver according 6262306a36Sopenharmony_cito the device datasheet. A conversion time for many original device clones 6362306a36Sopenharmony_cideviate from datasheet specs. There are three options: 1) manually set the 6462306a36Sopenharmony_cicorrect conversion time by writing a value in milliseconds to ``conv_time``; 2) 6562306a36Sopenharmony_ciauto measure and set a conversion time by writing ``1`` to 6662306a36Sopenharmony_ci``conv_time``; 3) use ``features`` to enable poll for conversion 6762306a36Sopenharmony_cicompletion. Options 2, 3 can't be used in parasite power mode. To get back to 6862306a36Sopenharmony_cithe default conversion time write ``0`` to ``conv_time``. 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ciWriting a resolution value (in bits) to ``w1_slave`` will change the 7162306a36Sopenharmony_ciprecision of the sensor for the next readings. Allowed resolutions are defined by 7262306a36Sopenharmony_cithe sensor. Resolution is reset when the sensor gets power-cycled. 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ciTo store the current resolution in EEPROM, write ``0`` to ``w1_slave``. 7562306a36Sopenharmony_ciSince the EEPROM has a limited amount of writes (>50k), this command should be 7662306a36Sopenharmony_ciused wisely. 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ciAlternatively, resolution can be read or written using the dedicated 7962306a36Sopenharmony_ci``resolution`` entry on each device, if supported by the sensor. 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ciSome non-genuine DS18B20 chips are fixed in 12-bit mode only, so the actual 8262306a36Sopenharmony_ciresolution is read back from the chip and verified. 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ciNote: Changing the resolution reverts the conversion time to default. 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ciThe write-only sysfs entry ``eeprom_cmd`` is an alternative for EEPROM operations. 8762306a36Sopenharmony_ciWrite ``save`` to save device RAM to EEPROM. Write ``restore`` to restore EEPROM 8862306a36Sopenharmony_cidata in device RAM. 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ci``ext_power`` entry allows checking the power state of each device. Reads 9162306a36Sopenharmony_ci``0`` if the device is parasite powered, ``1`` if the device is externally powered. 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_ciSysfs ``alarms`` allow read or write TH and TL (Temperature High an Low) alarms. 9462306a36Sopenharmony_ciValues shall be space separated and in the device range (typical -55 degC 9562306a36Sopenharmony_cito 125 degC). Values are integer as they are store in a 8bit register in 9662306a36Sopenharmony_cithe device. Lowest value is automatically put to TL. Once set, alarms could 9762306a36Sopenharmony_cibe search at master level. 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ciThe module parameter strong_pullup can be set to 0 to disable the 10062306a36Sopenharmony_cistrong pullup, 1 to enable autodetection or 2 to force strong pullup. 10162306a36Sopenharmony_ciIn case of autodetection, the driver will use the "READ POWER SUPPLY" 10262306a36Sopenharmony_cicommand to check if there are pariste powered devices on the bus. 10362306a36Sopenharmony_ciIf so, it will activate the master's strong pullup. 10462306a36Sopenharmony_ciIn case the detection of parasite devices using this command fails 10562306a36Sopenharmony_ci(seems to be the case with some DS18S20) the strong pullup can 10662306a36Sopenharmony_cibe force-enabled. 10762306a36Sopenharmony_ci 10862306a36Sopenharmony_ciIf the strong pullup is enabled, the master's strong pullup will be 10962306a36Sopenharmony_cidriven when the conversion is taking place, provided the master driver 11062306a36Sopenharmony_cidoes support the strong pullup (or it falls back to a pullup 11162306a36Sopenharmony_ciresistor). The DS18b20 temperature sensor specification lists a 11262306a36Sopenharmony_cimaximum current draw of 1.5mA and that a 5k pullup resistor is not 11362306a36Sopenharmony_cisufficient. The strong pullup is designed to provide the additional 11462306a36Sopenharmony_cicurrent required. 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ciThe DS28EA00 provides an additional two pins for implementing a sequence 11762306a36Sopenharmony_cidetection algorithm. This feature allows you to determine the physical 11862306a36Sopenharmony_cilocation of the chip in the 1-wire bus without needing pre-existing 11962306a36Sopenharmony_ciknowledge of the bus ordering. Support is provided through the sysfs 12062306a36Sopenharmony_ci``w1_seq``. The file will contain a single line with an integer value 12162306a36Sopenharmony_cirepresenting the device index in the bus starting at 0. 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci``features`` sysfs entry controls optional driver settings per device. 12462306a36Sopenharmony_ciInsufficient power in parasite mode, line noise and insufficient conversion 12562306a36Sopenharmony_citime may lead to conversion failure. Original DS18B20 and some clones allow for 12662306a36Sopenharmony_cidetection of invalid conversion. Write bit mask ``1`` to ``features`` to enable 12762306a36Sopenharmony_cichecking the conversion success. If byte 6 of scratchpad memory is 0xC after 12862306a36Sopenharmony_ciconversion and temperature reads 85.00 (powerup value) or 127.94 (insufficient 12962306a36Sopenharmony_cipower), the driver returns a conversion error. Bit mask ``2`` enables poll for 13062306a36Sopenharmony_ciconversion completion (normal power only) by generating read cycles on the bus 13162306a36Sopenharmony_ciafter conversion starts. In parasite power mode this feature is not available. 13262306a36Sopenharmony_ciFeature bit masks may be combined (OR). More details in 13362306a36Sopenharmony_ciDocumentation/ABI/testing/sysfs-driver-w1_therm 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ciGX20MH01 device shares family number 0x28 with DS18*20. The device is generally 13662306a36Sopenharmony_cicompatible with DS18B20. Added are lowest 2\ :sup:`-5`, 2\ :sup:`-6` temperature 13762306a36Sopenharmony_cibits in Config register; R2 bit in Config register enabling 13 and 14 bit 13862306a36Sopenharmony_ciresolutions. The device is powered up in 14-bit resolution mode. The conversion 13962306a36Sopenharmony_citimes specified in the datasheet are too low and have to be increased. The 14062306a36Sopenharmony_cidevice supports driver features ``1`` and ``2``. 14162306a36Sopenharmony_ci 14262306a36Sopenharmony_ciMAX31850 device shares family number 0x3B with DS1825. The device is generally 14362306a36Sopenharmony_cicompatible with DS1825. The higher 4 bits of Config register read all 1, 14462306a36Sopenharmony_ciindicating 15, but the device is always operating in 14-bit resolution mode. 145