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