• Ivan Zaentsev's avatar
    w1: w1_therm: Add sysfs entries to control conversion time and driver features · 021da53e
    Ivan Zaentsev authored
    The conversion time of common DS18B20 clones deviates from
    datasheet specs. Allow adjustment and automatic measure of the
    conversion time.
    
    Add 'conv_time' sysfs attribute:
      *read*: Current conversion time in milliseconds.
      *write*:
         '0': Set default conversion time.
         '1': Measure and set the conversion time. Make a
              single temperature conversion, poll and measure
              an actual value. Measured value is increased
              by 20% for temperature drift. A new conversion
              time is returned by reading the same attribute.
         other positive value:
            Set the conversion time in milliseconds.
    
    The setting is active until a resolution change. Then it is reset to
    default conversion time for a new resolution.
    
    Add 'features' sysfs attribute to control optional driver settings
    per device. Bit masks to read/write (logical OR):
      1: Enable check for conversion success. If byte 6 of
         scratchpad memory is 0xC after conversion, and
         temperature reads 85.00 (powerup value) or 127.94
         (insufficient power) - return a conversion error.
    
      2: Enable poll for conversion completion. Generate read cycles
         after the conversion start and wait for 1's. In parasite
         power mode this feature is not available.
    
    There are some clones of DS18B20 with fixed 12 bit resolution. Make the
    driver verify the resolution by reading back the device after resolution
    change.
    Signed-off-by: default avatarIvan Zaentsev <ivan.zaentsev@wirenboard.ru>
    Acked-by: default avatarEvgeniy Polyakov <zbr@ioremap.net>
    Link: https://lore.kernel.org/r/20200904160004.87710-1-ivan.zaentsev@wirenboard.ruSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    021da53e
sysfs-driver-w1_therm 6.14 KB