Michael Hennerich | 14f88f1 | 2011-03-09 16:01:45 +0100 | [diff] [blame] | 1 | /* |
| 2 | * AD5624R SPI DAC driver |
| 3 | * |
| 4 | * Copyright 2010-2011 Analog Devices Inc. |
| 5 | * |
| 6 | * Licensed under the GPL-2. |
| 7 | */ |
Barry Song | 6790e29 | 2010-10-27 21:44:07 -0400 | [diff] [blame] | 8 | #ifndef SPI_AD5624R_H_ |
| 9 | #define SPI_AD5624R_H_ |
| 10 | |
Michael Hennerich | 14f88f1 | 2011-03-09 16:01:45 +0100 | [diff] [blame] | 11 | #define AD5624R_DAC_CHANNELS 4 |
Barry Song | 6790e29 | 2010-10-27 21:44:07 -0400 | [diff] [blame] | 12 | |
Michael Hennerich | 14f88f1 | 2011-03-09 16:01:45 +0100 | [diff] [blame] | 13 | #define AD5624R_ADDR_DAC0 0x0 |
| 14 | #define AD5624R_ADDR_DAC1 0x1 |
| 15 | #define AD5624R_ADDR_DAC2 0x2 |
| 16 | #define AD5624R_ADDR_DAC3 0x3 |
| 17 | #define AD5624R_ADDR_ALL_DAC 0x7 |
Barry Song | 6790e29 | 2010-10-27 21:44:07 -0400 | [diff] [blame] | 18 | |
Michael Hennerich | 14f88f1 | 2011-03-09 16:01:45 +0100 | [diff] [blame] | 19 | #define AD5624R_CMD_WRITE_INPUT_N 0x0 |
| 20 | #define AD5624R_CMD_UPDATE_DAC_N 0x1 |
| 21 | #define AD5624R_CMD_WRITE_INPUT_N_UPDATE_ALL 0x2 |
| 22 | #define AD5624R_CMD_WRITE_INPUT_N_UPDATE_N 0x3 |
| 23 | #define AD5624R_CMD_POWERDOWN_DAC 0x4 |
| 24 | #define AD5624R_CMD_RESET 0x5 |
| 25 | #define AD5624R_CMD_LDAC_SETUP 0x6 |
| 26 | #define AD5624R_CMD_INTERNAL_REFER_SETUP 0x7 |
Barry Song | 6790e29 | 2010-10-27 21:44:07 -0400 | [diff] [blame] | 27 | |
Michael Hennerich | 14f88f1 | 2011-03-09 16:01:45 +0100 | [diff] [blame] | 28 | #define AD5624R_LDAC_PWRDN_NONE 0x0 |
| 29 | #define AD5624R_LDAC_PWRDN_1K 0x1 |
| 30 | #define AD5624R_LDAC_PWRDN_100K 0x2 |
| 31 | #define AD5624R_LDAC_PWRDN_3STATE 0x3 |
| 32 | |
| 33 | /** |
| 34 | * struct ad5624r_chip_info - chip specific information |
Lars-Peter Clausen | 275de9f | 2011-11-15 16:31:24 +0100 | [diff] [blame] | 35 | * @channels: channel spec for the DAC |
Michael Hennerich | 14f88f1 | 2011-03-09 16:01:45 +0100 | [diff] [blame] | 36 | * @int_vref_mv: AD5620/40/60: the internal reference voltage |
| 37 | */ |
| 38 | |
| 39 | struct ad5624r_chip_info { |
Lars-Peter Clausen | 275de9f | 2011-11-15 16:31:24 +0100 | [diff] [blame] | 40 | const struct iio_chan_spec *channels; |
Michael Hennerich | 14f88f1 | 2011-03-09 16:01:45 +0100 | [diff] [blame] | 41 | u16 int_vref_mv; |
| 42 | }; |
| 43 | |
| 44 | /** |
| 45 | * struct ad5446_state - driver instance specific data |
| 46 | * @indio_dev: the industrial I/O device |
| 47 | * @us: spi_device |
| 48 | * @chip_info: chip model specific constants, available modes etc |
| 49 | * @reg: supply regulator |
| 50 | * @vref_mv: actual reference voltage used |
| 51 | * @pwr_down_mask power down mask |
| 52 | * @pwr_down_mode current power down mode |
| 53 | */ |
| 54 | |
| 55 | struct ad5624r_state { |
Michael Hennerich | 14f88f1 | 2011-03-09 16:01:45 +0100 | [diff] [blame] | 56 | struct spi_device *us; |
| 57 | const struct ad5624r_chip_info *chip_info; |
| 58 | struct regulator *reg; |
| 59 | unsigned short vref_mv; |
| 60 | unsigned pwr_down_mask; |
| 61 | unsigned pwr_down_mode; |
| 62 | }; |
| 63 | |
| 64 | /** |
| 65 | * ad5624r_supported_device_ids: |
| 66 | * The AD5624/44/64 parts are available in different |
| 67 | * fixed internal reference voltage options. |
| 68 | */ |
| 69 | |
| 70 | enum ad5624r_supported_device_ids { |
| 71 | ID_AD5624R3, |
| 72 | ID_AD5644R3, |
| 73 | ID_AD5664R3, |
| 74 | ID_AD5624R5, |
| 75 | ID_AD5644R5, |
| 76 | ID_AD5664R5, |
| 77 | }; |
| 78 | |
| 79 | #endif /* SPI_AD5624R_H_ */ |