This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | resources:tools-software:linux-drivers:misc:dpot [11 Mar 2015 11:04] – [Status] fix alignment Lars-Peter Clausen | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Digital Potentiometer Linux Driver ====== | ||
+ | |||
+ | ===== Supported Devices ===== | ||
+ | |||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | |||
+ | ===== Reference Circuits ===== | ||
+ | |||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | |||
+ | ===== Evaluation Boards ===== | ||
+ | |||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * [[adi> | ||
+ | * PMOD-DPOT | ||
+ | |||
+ | <source trunk/ | ||
+ | ===== Description ===== | ||
+ | |||
+ | The ad525x_dpot driver exports a simple sysfs interface. | ||
+ | work with the immediate resistance settings as well as update the saved startup | ||
+ | settings. | ||
+ | interpretation of this settings is required by the end application according to | ||
+ | the specific part in use. | ||
+ | |||
+ | ==== Files ==== | ||
+ | |||
+ | Each dpot device will have a set of **eeprom**, **rdac**, and **tolerance** files. | ||
+ | many depends on the actual part you have, as will the range of allowed values. | ||
+ | |||
+ | The **eeprom** files are used to program the startup value of the device. | ||
+ | |||
+ | The **rdac** files are used to program the immediate value of the device. | ||
+ | |||
+ | The **tolerance** files are the read-only factory programmed tolerance settings | ||
+ | and may vary greatly on a part-by-part basis. | ||
+ | this field, please consult the datasheet for your part. This is presented | ||
+ | as a hex file for easier parsing. | ||
+ | |||
+ | |||
+ | ====== Source Code ====== | ||
+ | |||
+ | ===== Status ===== | ||
+ | |||
+ | ^ Source ^ Mainlined? ^ | ||
+ | | [[git.linux.org> | ||
+ | |||
+ | ===== Files ===== | ||
+ | |||
+ | ^ Function ^ File ^ | ||
+ | | driver | ||
+ | | i2c bus support | ||
+ | | spi bus support | ||
+ | | include | [[git.linux.org> | ||
+ | |||
+ | |||
+ | ====== Example platform device initialization ====== | ||
+ | |||
+ | {{page> | ||
+ | |||
+ | ===== Example Platform / Board file (I2C Interface) ===== | ||
+ | |||
+ | {{page> | ||
+ | |||
+ | <code C> | ||
+ | static struct i2c_board_info __initdata bfin_i2c_board_info[] = { | ||
+ | #if defined(CONFIG_AD525X_DPOT) || defined(CONFIG_AD525X_DPOT_MODULE) | ||
+ | { | ||
+ | I2C_BOARD_INFO(" | ||
+ | }, | ||
+ | { | ||
+ | I2C_BOARD_INFO(" | ||
+ | }, | ||
+ | #endif | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Example Platform / Board file (SPI Interface) ===== | ||
+ | |||
+ | {{page> | ||
+ | |||
+ | <code C> | ||
+ | static struct spi_board_info bfin_spi_board_info[] __initdata = { | ||
+ | #if defined(CONFIG_AD525X_DPOT) || defined(CONFIG_AD525X_DPOT_MODULE) | ||
+ | { | ||
+ | .modalias = " | ||
+ | .max_speed_hz = 5000000, | ||
+ | .bus_num = 0, | ||
+ | .chip_select = 1, | ||
+ | }, | ||
+ | #endif | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | <WRAP tip> | ||
+ | |||
+ | __**Old Method**__ | ||
+ | |||
+ | <code C> | ||
+ | static struct spi_board_info bfin_spi_board_info[] __initdata = { | ||
+ | #if defined(CONFIG_AD525X_DPOT) || defined(CONFIG_AD525X_DPOT_MODULE) | ||
+ | { | ||
+ | .modalias = " | ||
+ | .platform_data = " | ||
+ | .max_speed_hz = 5000000, | ||
+ | .bus_num = 0, | ||
+ | .chip_select = 1, | ||
+ | }, | ||
+ | #endif | ||
+ | }; | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ====== Adding Linux driver support ====== | ||
+ | |||
+ | Configure kernel with "make menuconfig" | ||
+ | "make qconfig" | ||
+ | |||
+ | <WRAP round help> | ||
+ | The ad525x_dpot driver depends on **CONFIG_SPI** or **CONFIG_I2C** | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Device Drivers | ||
+ | [*] Misc devices | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | ====== Hardware configuration ====== | ||
+ | |||
+ | {{: | ||
+ | ====== Driver testing ====== | ||
+ | |||
+ | Locate the device in your sysfs tree. This is probably easiest by going into | ||
+ | the common i2c directory and locating the device by the i2c slave address. | ||
+ | |||
+ | < | ||
+ | # ls / | ||
+ | 0-0022 | ||
+ | </ | ||
+ | So assuming the device in question is on the first i2c bus and has the slave | ||
+ | address of 0x2f, we descend (unrelated sysfs entries have been trimmed). | ||
+ | |||
+ | < | ||
+ | # ls / | ||
+ | eeprom0 rdac0 tolerance0 | ||
+ | </ | ||
+ | You can use simple reads/ | ||
+ | |||
+ | < | ||
+ | # cd / | ||
+ | |||
+ | # cat eeprom0 | ||
+ | 0 | ||
+ | # echo 10 > eeprom0 | ||
+ | # cat eeprom0 | ||
+ | 10 | ||
+ | |||
+ | # cat rdac0 | ||
+ | 5 | ||
+ | # echo 3 > rdac0 | ||
+ | # cat rdac0 | ||
+ | 3 | ||
+ | </ | ||
+ | ====== More Information ====== | ||
+ | |||