Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ad7298.h
Go to the documentation of this file.
1 /*
2  * AD7298 SPI ADC driver
3  *
4  * Copyright 2011 Analog Devices Inc.
5  *
6  * Licensed under the GPL-2.
7  */
8 
9 #ifndef IIO_ADC_AD7298_H_
10 #define IIO_ADC_AD7298_H_
11 
12 #define AD7298_WRITE (1 << 15) /* write to the control register */
13 #define AD7298_REPEAT (1 << 14) /* repeated conversion enable */
14 #define AD7298_CH(x) (1 << (13 - (x))) /* channel select */
15 #define AD7298_TSENSE (1 << 5) /* temperature conversion enable */
16 #define AD7298_EXTREF (1 << 2) /* external reference enable */
17 #define AD7298_TAVG (1 << 1) /* temperature sensor averaging enable */
18 #define AD7298_PDD (1 << 0) /* partial power down enable */
19 
20 #define AD7298_MAX_CHAN 8
21 #define AD7298_BITS 12
22 #define AD7298_STORAGE_BITS 16
23 #define AD7298_INTREF_mV 2500
24 
25 #define AD7298_CH_TEMP 9
26 
27 #define RES_MASK(bits) ((1 << (bits)) - 1)
28 
29 /*
30  * TODO: struct ad7298_platform_data needs to go into include/linux/iio
31  */
32 
34  /* External Vref voltage applied */
36 };
37 
38 struct ad7298_state {
39  struct spi_device *spi;
40  struct regulator *reg;
42  unsigned ext_ref;
43  struct spi_transfer ring_xfer[10];
47  /*
48  * DMA (thus cache coherency maintenance) requires the
49  * transfer buffers to live in their own cache lines.
50  */
51  unsigned short rx_buf[8] ____cacheline_aligned;
52  unsigned short tx_buf[2];
53 };
54 
55 #ifdef CONFIG_IIO_BUFFER
56 int ad7298_register_ring_funcs_and_init(struct iio_dev *indio_dev);
57 void ad7298_ring_cleanup(struct iio_dev *indio_dev);
58 int ad7298_update_scan_mode(struct iio_dev *indio_dev,
59  const unsigned long *active_scan_mask);
60 #else /* CONFIG_IIO_BUFFER */
61 
62 static inline int
64 {
65  return 0;
66 }
67 
68 static inline void ad7298_ring_cleanup(struct iio_dev *indio_dev)
69 {
70 }
71 
72 #define ad7298_update_scan_mode NULL
73 
74 #endif /* CONFIG_IIO_BUFFER */
75 #endif /* IIO_ADC_AD7298_H_ */