staging: iio: dac: Enable driver support for AD5444 and AD5446 DA converters
[firefly-linux-kernel-4.4.55.git] / drivers / staging / iio / dac / ad5446.h
1 /*
2  * AD5446 SPI DAC driver
3  *
4  * Copyright 2010 Analog Devices Inc.
5  *
6  * Licensed under the GPL-2 or later.
7  */
8 #ifndef IIO_ADC_AD5446_H_
9 #define IIO_ADC_AD5446_H_
10
11 /* DAC Control Bits */
12
13 #define AD5446_LOAD             (0x0 << 14) /* Load and update */
14 #define AD5446_SDO_DIS          (0x1 << 14) /* Disable SDO */
15 #define AD5446_NOP              (0x2 << 14) /* No operation */
16 #define AD5446_CLK_RISING       (0x3 << 14) /* Clock data on rising edge */
17
18 #define RES_MASK(bits)  ((1 << (bits)) - 1)
19
20 struct ad5446_chip_info {
21         u8                              bits;           /* number of DAC bits */
22         u8                              storagebits;    /* number of bits written to the DAC */
23         u8                              left_shift;     /* number of bits the datum must be shifted */
24         char                            sign;           /* [s]igned or [u]nsigned */
25 };
26
27 struct ad5446_state {
28         struct iio_dev                  *indio_dev;
29         struct spi_device               *spi;
30         const struct ad5446_chip_info   *chip_info;
31         struct regulator                *reg;
32         struct work_struct              poll_work;
33         unsigned short                  vref_mv;
34         struct spi_transfer             xfer;
35         struct spi_message              msg;
36         unsigned short                  data;
37 };
38
39 enum ad5446_supported_device_ids {
40         ID_AD5444,
41         ID_AD5446,
42         ID_AD5542A,
43         ID_AD5512A,
44 };
45
46 #endif /* IIO_ADC_AD5446_H_ */