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