1/*
2 * AD7476/5/7/8 (A) SPI ADC driver
3 *
4 * Copyright 2010 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8#ifndef IIO_ADC_AD7476_H_
9#define IIO_ADC_AD7476_H_
10
11#define RES_MASK(bits)	((1 << (bits)) - 1)
12
13/*
14 * TODO: struct ad7476_platform_data needs to go into include/linux/iio
15 */
16
17struct ad7476_platform_data {
18	u16				vref_mv;
19};
20
21struct ad7476_chip_info {
22	u16				int_vref_mv;
23	struct iio_chan_spec		channel[2];
24};
25
26struct ad7476_state {
27	struct spi_device		*spi;
28	const struct ad7476_chip_info	*chip_info;
29	struct regulator		*reg;
30	size_t				d_size;
31	u16				int_vref_mv;
32	struct spi_transfer		xfer;
33	struct spi_message		msg;
34	/*
35	 * DMA (thus cache coherency maintenance) requires the
36	 * transfer buffers to live in their own cache lines.
37	 */
38	unsigned char			data[2] ____cacheline_aligned;
39};
40
41enum ad7476_supported_device_ids {
42	ID_AD7466,
43	ID_AD7467,
44	ID_AD7468,
45	ID_AD7475,
46	ID_AD7476,
47	ID_AD7477,
48	ID_AD7478,
49	ID_AD7495
50};
51
52#ifdef CONFIG_IIO_BUFFER
53int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev);
54void ad7476_ring_cleanup(struct iio_dev *indio_dev);
55#else /* CONFIG_IIO_BUFFER */
56
57static inline int
58ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
59{
60	return 0;
61}
62
63static inline void ad7476_ring_cleanup(struct iio_dev *indio_dev)
64{
65}
66#endif /* CONFIG_IIO_BUFFER */
67#endif /* IIO_ADC_AD7476_H_ */
68