staging:iio: ring core cleanups + check if read_last available in lis3l02dq
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / staging / iio / dac / ad5791.h
blobf09ad9a430c38ca38de1b306a0627a7e4c7e396a
1 /*
2 * AD5791 SPI DAC driver
4 * Copyright 2011 Analog Devices Inc.
6 * Licensed under the GPL-2.
7 */
9 #ifndef SPI_AD5791_H_
10 #define SPI_AD5791_H_
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)
20 /* Registers */
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
56 /**
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 {
64 u16 vref_pos_mv;
65 u16 vref_neg_mv;
66 bool use_rbuf_gain2;
69 /**
70 * struct ad5791_chip_info - chip specific information
71 * @bits: accuracy of the DAC in bits
72 * @left_shift: number of bits the datum must be shifted
73 * @get_lin_comp: function pointer to the device specific function
76 struct ad5791_chip_info {
77 u8 bits;
78 u8 left_shift;
79 int (*get_lin_comp) (unsigned int span);
82 /**
83 * struct ad5791_state - driver instance specific data
84 * @indio_dev: the industrial I/O device
85 * @us: spi_device
86 * @reg_vdd: positive supply regulator
87 * @reg_vss: negative supply regulator
88 * @chip_info: chip model specific constants
89 * @vref_mv: actual reference voltage used
90 * @pwr_down_mode current power down mode
93 struct ad5791_state {
94 struct iio_dev *indio_dev;
95 struct spi_device *spi;
96 struct regulator *reg_vdd;
97 struct regulator *reg_vss;
98 const struct ad5791_chip_info *chip_info;
99 unsigned short vref_mv;
100 unsigned ctrl;
101 unsigned pwr_down_mode;
102 bool pwr_down;
106 * ad5791_supported_device_ids:
109 enum ad5791_supported_device_ids {
110 ID_AD5760,
111 ID_AD5780,
112 ID_AD5781,
113 ID_AD5791,
116 #endif /* SPI_AD5791_H_ */