1. 19 May, 2020 24 commits
  2. 17 May, 2020 9 commits
  3. 15 May, 2020 7 commits
    • Akira Shimahara's avatar
      w1_therm: adding bulk read support to trigger multiple conversion on bus · 57c76221
      Akira Shimahara authored
      Adding bulk read support:
      Sending a 'trigger' command in the dedicated sysfs entry of bus master
      device send a conversion command for all the slaves on the bus. The sysfs
      entry is added as soon as at least one device supporting this feature
      is detected on the bus.
      
      The behavior of the sysfs reading temperature on the device is as follow:
       * If no bulk read pending, trigger a conversion on the device, wait for
       the conversion to be done, read the temperature in device RAM
       * If a bulk read has been trigger, access directly the device RAM
      This behavior is the same on the 2 sysfs entries ('temperature' and
      'w1_slave').
      
      Reading the therm_bulk_read sysfs give the status of bulk operations:
       * '-1': conversion in progress on at least 1 sensor
       * '1': conversion complete but at least one sensor has not been read yet
       * '0': no bulk operation. Reading temperature on ecah device will trigger
      a conversion
      
      As not all devices support bulk read feature, it has been added in device
      family structure.
      
      The attribute is set at master level as soon as a supporting device is
      discover. It is removed when the last supported device leave the bus.
      The count of supported device is kept with the static counter
      bulk_read_device_counter.
      
      A strong pull up is apply on the line if at least one device required it.
      The duration of the pull up is the max time required by a device on the
      line, which depends on the resolution settings of each device. The strong
      pull up could be adjust with the a module parameter.
      
      Updating documentation in Documentation/ABI/testing/sysfs-driver-w1_therm
      and Documentation/w1/slaves/w1_therm.rst accordingly.
      Signed-off-by: default avatarAkira Shimahara <akira215corp@gmail.com>
      Link: https://lore.kernel.org/r/20200511203820.411483-1-akira215corp@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57c76221
    • Akira Shimahara's avatar
      w1_therm: adding alarm sysfs entry · e2c94d6f
      Akira Shimahara authored
      Adding device alarms settings by a dedicated sysfs entry alarms (RW):
      read or write TH and TL in the device RAM. Checking devices in alarm
      state could be performed using the master search command.
      
      As alarms temperature level are store in a 8 bit register on the device
      and are signed values, a safe cast shall be performed using the min and
      max temperature that device are able to measure. This is done by
      int_to_short inline function.
      
      A 'write_data' field is added in the device structure, to bind the
      correct writing function, as some devices may have 2 or 3 bytes RAM.
      
      Updating Documentation/ABI/testing/sysfs-driver-w1_therm accordingly.
      Signed-off-by: default avatarAkira Shimahara <akira215corp@gmail.com>
      Link: https://lore.kernel.org/r/20200511203801.411253-1-akira215corp@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e2c94d6f
    • Akira Shimahara's avatar
      w1_therm: optimizing temperature read timings · 67b392f7
      Akira Shimahara authored
      Optimizing temperature reading by reducing waiting conversion time
      according to device resolution settings, as per device specification.
      This is device dependent as not all the devices supports resolution
      setting, so it has been added in device family structures.
      
      The process to read the temperature on the device has been adapted in a
      new function 'convert_t()', which replace the former 'read_therm()', is
      introduce to deal with this timing. Strong pull up is also applied during
      the required time, according to device power status needs and
      'strong_pullup' module parameter.
      
      'temperature_from_RAM()' function is introduced to get the correct
      temperature computation (device dependent) from device RAM data.
      
      An new sysfs entry has been added to ouptut only temperature. The old
      entry w1_slave has been kept for compatibility, without changing its
      output format.
      
      Updating Documentation/ABI/testing/sysfs-driver-w1_therm accordingly.
      Signed-off-by: default avatarAkira Shimahara <akira215corp@gmail.com>
      Link: https://lore.kernel.org/r/20200511203742.411039-1-akira215corp@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      67b392f7
    • Akira Shimahara's avatar
      w1_therm: adding eeprom sysfs entry · 45d457a4
      Akira Shimahara authored
      The driver implement 2 hardware functions to access device RAM:
       * copy_scratchpad
       * recall_scratchpad
      They act according to device specifications.
      
      As EEPROM operations are not device dependent (all w1_therm can perform
      EEPROM read/write operation following the same protocol), it is removed
      from device families structures.
      
      Updating Documentation/ABI/testing/sysfs-driver-w1_therm accordingly.
      Signed-off-by: default avatarAkira Shimahara <akira215corp@gmail.com>
      Link: https://lore.kernel.org/r/20200511203725.410844-1-akira215corp@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45d457a4
    • Akira Shimahara's avatar
      w1_therm: adding resolution sysfs entry · 308bdb94
      Akira Shimahara authored
      Adding resolution sysfs entry (RW) to get or set the device resolution
      Write values are managed as follow:
      	* '9..12': resolution to set in bit
      	* Anything else: do nothing
      Read values are :
      	* '9..12': device resolution in bit
      	* '-xx': xx is kernel error when reading the resolution
      
      Only supported devices will show the sysfs entry. A new family has been
      created for DS18S20 devices as they do not implement resolution feature.
      
      The resolution of each device is check when the device is
      discover by the bus master, in 'w1_therm_add_slave(struct w1_slave *)'.
      The status is stored in the device structure w1_therm_family_data so
      that the driver always knows the resolution of each device, which could
      be used later to determine the required conversion duration (resolution
      dependent).
      
      The resolution is re evaluate each time a user read or write the sysfs
      entry.
      
      To avoid looping through the w1_therm_families at run time, the pointer
      'specific_functions' is set up to the correct 'w1_therm_family_converter'
      when the slave is added (which mean when it is discovered by the master).
      This initialization is done by a helper function
      'device_family(struct w1_slave *sl)', and a dedicated macro
      'SLAVE_SPECIFIC_FUNC(sl)' allow the access to the specific function of the
      slave device.
      
      'read_scratchpad' and 'write_scratchpad' are the hardware functions to
      access the device RAM, as per protocol specification.
      
      It cancel the former 'precision' functions, which was only set and never
      read (so not stored in the device struct).
      
      Updating Documentation/ABI/testing/sysfs-driver-w1_therm accordingly.
      Signed-off-by: default avatarAkira Shimahara <akira215corp@gmail.com>
      Link: https://lore.kernel.org/r/20200511203708.410649-1-akira215corp@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      308bdb94
    • Akira Shimahara's avatar
      w1_therm: adding ext_power sysfs entry · b7bb6ca1
      Akira Shimahara authored
      Adding ext_power sysfs entry (RO). Return the power status of the device:
       - 0: device parasite powered
       - 1: device externally powered
       - xx: xx is kernel error
      
      The power status of each device is check when the device is
      discover by the bus master, in 'w1_therm_add_slave(struct w1_slave *)'.
      The status is stored in the device structure w1_therm_family_data so
      that the driver always knows the power state of each device, which could
      be used later to determine the required strong pull up to apply on the
      line.
      
      The power status is re evaluate each time the sysfs ext_power read by
      a user.
      
      The hardware function 'read_powermode(struct w1_slave *sl)' act just as
      per device specifications, sending W1_READ_PSUPPLY command on the bus,
      and issue a read time slot, reading only one bit.
      
      A helper function 'bool bus_mutex_lock(struct mutex *lock)' is introduced.
      It try to aquire the bus mutex several times (W1_THERM_MAX_TRY), waiting
      W1_THERM_RETRY_DELAY between two attempt.
      
      Updating Documentation/ABI/testing/sysfs-driver-w1_therm accordingly.
      Signed-off-by: default avatarAkira Shimahara <akira215corp@gmail.com>
      Link: https://lore.kernel.org/r/20200511203650.410439-1-akira215corp@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b7bb6ca1
    • Akira Shimahara's avatar
      w1_therm: adding sysfs-driver-w1_therm doc · daa3cfeb
      Akira Shimahara authored
      Adding a sysfs-driver-w1_therm documentation file in
      Documentation/ABI/testing. It describe the onlys sysfs entry of w1_therm
      module, based on Documentation/w1/slaves/w1_therm.rst
      Signed-off-by: default avatarAkira Shimahara <akira215corp@gmail.com>
      Link: https://lore.kernel.org/r/20200511203631.410227-1-akira215corp@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      daa3cfeb