2 * AD5791 SPI DAC driver
4 * Copyright 2011 Analog Devices Inc.
6 * Licensed under the GPL-2.
12 #define AD5791_RES_MASK(x) ((1 << (x)) - 1)
13 #define AD5791_DAC_MASK AD5791_RES_MASK(20)
14 #define AD5791_DAC_MSB (1 << 19)
16 #define AD5791_CMD_READ (1 << 23)
17 #define AD5791_CMD_WRITE (0 << 23)
18 #define AD5791_ADDR(addr) ((addr) << 20)
21 #define AD5791_ADDR_NOOP 0
22 #define AD5791_ADDR_DAC0 1
23 #define AD5791_ADDR_CTRL 2
24 #define AD5791_ADDR_CLRCODE 3
25 #define AD5791_ADDR_SW_CTRL 4
27 /* Control Register */
28 #define AD5791_CTRL_RBUF (1 << 1)
29 #define AD5791_CTRL_OPGND (1 << 2)
30 #define AD5791_CTRL_DACTRI (1 << 3)
31 #define AD5791_CTRL_BIN2SC (1 << 4)
32 #define AD5791_CTRL_SDODIS (1 << 5)
33 #define AD5761_CTRL_LINCOMP(x) ((x) << 6)
35 #define AD5791_LINCOMP_0_10 0
36 #define AD5791_LINCOMP_10_12 1
37 #define AD5791_LINCOMP_12_16 2
38 #define AD5791_LINCOMP_16_19 3
39 #define AD5791_LINCOMP_19_20 12
41 #define AD5780_LINCOMP_0_10 0
42 #define AD5780_LINCOMP_10_20 12
44 /* Software Control Register */
45 #define AD5791_SWCTRL_LDAC (1 << 0)
46 #define AD5791_SWCTRL_CLR (1 << 1)
47 #define AD5791_SWCTRL_RESET (1 << 2)
49 #define AD5791_DAC_PWRDN_6K 0
50 #define AD5791_DAC_PWRDN_3STATE 1
53 * TODO: struct ad5791_platform_data needs to go into include/linux/iio
57 * struct ad5791_platform_data - platform specific information
58 * @vref_pos_mv: Vdd Positive Analog Supply Volatge (mV)
59 * @vref_neg_mv: Vdd Negative Analog Supply Volatge (mV)
60 * @use_rbuf_gain2: ext. amplifier connected in gain of two configuration
63 struct ad5791_platform_data
{
70 * struct ad5791_chip_info - chip specific information
71 * @get_lin_comp: function pointer to the device specific function
74 struct ad5791_chip_info
{
75 int (*get_lin_comp
) (unsigned int span
);
79 * struct ad5791_state - driver instance specific data
81 * @reg_vdd: positive supply regulator
82 * @reg_vss: negative supply regulator
83 * @chip_info: chip model specific constants
84 * @vref_mv: actual reference voltage used
85 * @vref_neg_mv: voltage of the negative supply
86 * @pwr_down_mode current power down mode
90 struct spi_device
*spi
;
91 struct regulator
*reg_vdd
;
92 struct regulator
*reg_vss
;
93 const struct ad5791_chip_info
*chip_info
;
94 unsigned short vref_mv
;
95 unsigned int vref_neg_mv
;
97 unsigned pwr_down_mode
;
102 * ad5791_supported_device_ids:
105 enum ad5791_supported_device_ids
{
112 #endif /* SPI_AD5791_H_ */