summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/adc/ad7476.h
blob: 0d44976e846f4e79d85ef08c1ec67fbbc96432f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 * AD7476/5/7/8 (A) SPI ADC driver
 *
 * Copyright 2010 Analog Devices Inc.
 *
 * Licensed under the GPL-2 or later.
 */
#ifndef IIO_ADC_AD7476_H_
#define IIO_ADC_AD7476_H_

#define RES_MASK(bits)	((1 << (bits)) - 1)

/*
 * TODO: struct ad7476_platform_data needs to go into include/linux/iio
 */

struct ad7476_platform_data {
	u16				vref_mv;
};

struct ad7476_chip_info {
	u16				int_vref_mv;
	struct iio_chan_spec		channel[2];
};

struct ad7476_state {
	struct spi_device		*spi;
	const struct ad7476_chip_info	*chip_info;
	struct regulator		*reg;
	size_t				d_size;
	u16				int_vref_mv;
	struct spi_transfer		xfer;
	struct spi_message		msg;
	/*
	 * DMA (thus cache coherency maintenance) requires the
	 * transfer buffers to live in their own cache lines.
	 */
	unsigned char			data[2] ____cacheline_aligned;
};

enum ad7476_supported_device_ids {
	ID_AD7466,
	ID_AD7467,
	ID_AD7468,
	ID_AD7475,
	ID_AD7476,
	ID_AD7477,
	ID_AD7478,
	ID_AD7495
};

#ifdef CONFIG_IIO_RING_BUFFER
int ad7476_scan_from_ring(struct iio_dev *indio_dev);
int ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev);
void ad7476_ring_cleanup(struct iio_dev *indio_dev);
#else /* CONFIG_IIO_RING_BUFFER */
static inline int ad7476_scan_from_ring(struct iio_dev *indio_dev)
{
	return 0;
}

static inline int
ad7476_register_ring_funcs_and_init(struct iio_dev *indio_dev)
{
	return 0;
}

static inline void ad7476_ring_cleanup(struct iio_dev *indio_dev)
{
}
#endif /* CONFIG_IIO_RING_BUFFER */
#endif /* IIO_ADC_AD7476_H_ */