^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) =============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) AD525x Digital Potentiometers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) =============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) The ad525x_dpot driver exports a simple sysfs interface. This allows you to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) work with the immediate resistance settings as well as update the saved startup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) settings. Access to the factory programmed tolerance is also provided, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) interpretation of this settings is required by the end application according to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) the specific part in use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) Files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) =====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) Each dpot device will have a set of eeprom, rdac, and tolerance files. How
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) many depends on the actual part you have, as will the range of allowed values.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) The eeprom files are used to program the startup value of the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) The rdac files are used to program the immediate value of the device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) The tolerance files are the read-only factory programmed tolerance settings
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) and may vary greatly on a part-by-part basis. For exact interpretation of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) this field, please consult the datasheet for your part. This is presented
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) as a hex file for easier parsing.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) Example
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) =======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) Locate the device in your sysfs tree. This is probably easiest by going into
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) the common i2c directory and locating the device by the i2c slave address::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) # ls /sys/bus/i2c/devices/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 0-0022 0-0027 0-002f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) So assuming the device in question is on the first i2c bus and has the slave
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) address of 0x2f, we descend (unrelated sysfs entries have been trimmed)::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) # ls /sys/bus/i2c/devices/0-002f/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) eeprom0 rdac0 tolerance0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) You can use simple reads/writes to access these files::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) # cd /sys/bus/i2c/devices/0-002f/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) # cat eeprom0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) # echo 10 > eeprom0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) # cat eeprom0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) # cat rdac0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) # echo 3 > rdac0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) # cat rdac0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 3