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