Commit | Line | Data |
---|---|---|
b9618c0c MH |
1 | /* |
2 | * AD7606 ADC driver | |
3 | * | |
4 | * Copyright 2011 Analog Devices Inc. | |
5 | * | |
6 | * Licensed under the GPL-2. | |
7 | */ | |
8 | ||
9 | #ifndef IIO_ADC_AD7606_H_ | |
10 | #define IIO_ADC_AD7606_H_ | |
11 | ||
12 | /* | |
13 | * TODO: struct ad7606_platform_data needs to go into include/linux/iio | |
14 | */ | |
15 | ||
16 | /** | |
e3c5be2b | 17 | * struct ad7606_platform_data - platform/board specific information |
b9618c0c MH |
18 | * @default_os: default oversampling value {0, 2, 4, 8, 16, 32, 64} |
19 | * @default_range: default range +/-{5000, 10000} mVolt | |
20 | * @gpio_convst: number of gpio connected to the CONVST pin | |
21 | * @gpio_reset: gpio connected to the RESET pin, if not used set to -1 | |
22 | * @gpio_range: gpio connected to the RANGE pin, if not used set to -1 | |
23 | * @gpio_os0: gpio connected to the OS0 pin, if not used set to -1 | |
24 | * @gpio_os1: gpio connected to the OS1 pin, if not used set to -1 | |
25 | * @gpio_os2: gpio connected to the OS2 pin, if not used set to -1 | |
26 | * @gpio_frstdata: gpio connected to the FRSTDAT pin, if not used set to -1 | |
27 | * @gpio_stby: gpio connected to the STBY pin, if not used set to -1 | |
28 | */ | |
29 | ||
30 | struct ad7606_platform_data { | |
51fadb98 AS |
31 | unsigned int default_os; |
32 | unsigned int default_range; | |
33 | unsigned int gpio_convst; | |
34 | unsigned int gpio_reset; | |
35 | unsigned int gpio_range; | |
36 | unsigned int gpio_os0; | |
37 | unsigned int gpio_os1; | |
38 | unsigned int gpio_os2; | |
39 | unsigned int gpio_frstdata; | |
40 | unsigned int gpio_stby; | |
b9618c0c MH |
41 | }; |
42 | ||
43 | /** | |
e3c5be2b | 44 | * struct ad7606_chip_info - chip specific information |
3f79410c | 45 | * @name: identification string for chip |
1caf7cb4 MH |
46 | * @channels: channel specification |
47 | * @num_channels: number of channels | |
b9618c0c MH |
48 | */ |
49 | ||
50 | struct ad7606_chip_info { | |
13cfac20 | 51 | const char *name; |
f4e4b955 | 52 | const struct iio_chan_spec *channels; |
51fadb98 | 53 | unsigned int num_channels; |
b9618c0c MH |
54 | }; |
55 | ||
56 | /** | |
57 | * struct ad7606_state - driver instance specific data | |
58 | */ | |
59 | ||
60 | struct ad7606_state { | |
b9618c0c MH |
61 | struct device *dev; |
62 | const struct ad7606_chip_info *chip_info; | |
63 | struct ad7606_platform_data *pdata; | |
64 | struct regulator *reg; | |
65 | struct work_struct poll_work; | |
66 | wait_queue_head_t wq_data_avail; | |
b9618c0c | 67 | const struct ad7606_bus_ops *bops; |
51fadb98 AS |
68 | unsigned int range; |
69 | unsigned int oversampling; | |
b9618c0c | 70 | bool done; |
b9618c0c MH |
71 | void __iomem *base_address; |
72 | ||
73 | /* | |
74 | * DMA (thus cache coherency maintenance) requires the | |
75 | * transfer buffers to live in their own cache lines. | |
76 | */ | |
77 | ||
78 | unsigned short data[8] ____cacheline_aligned; | |
79 | }; | |
80 | ||
81 | struct ad7606_bus_ops { | |
82 | /* more methods added in future? */ | |
83 | int (*read_block)(struct device *, int, void *); | |
84 | }; | |
85 | ||
e61181d0 | 86 | struct iio_dev *ad7606_probe(struct device *dev, int irq, |
51fadb98 | 87 | void __iomem *base_address, unsigned int id, |
b9618c0c | 88 | const struct ad7606_bus_ops *bops); |
8cbb36a0 | 89 | int ad7606_remove(struct iio_dev *indio_dev, int irq); |
b9618c0c MH |
90 | int ad7606_reset(struct ad7606_state *st); |
91 | ||
92 | enum ad7606_supported_device_ids { | |
93 | ID_AD7606_8, | |
94 | ID_AD7606_6, | |
95 | ID_AD7606_4 | |
96 | }; | |
97 | ||
b9618c0c MH |
98 | int ad7606_register_ring_funcs_and_init(struct iio_dev *indio_dev); |
99 | void ad7606_ring_cleanup(struct iio_dev *indio_dev); | |
2c3a5236 LPC |
100 | |
101 | #ifdef CONFIG_PM_SLEEP | |
102 | extern const struct dev_pm_ops ad7606_pm_ops; | |
103 | #define AD7606_PM_OPS (&ad7606_pm_ops) | |
104 | #else | |
105 | #define AD7606_PM_OPS NULL | |
106 | #endif | |
107 | ||
b9618c0c | 108 | #endif /* IIO_ADC_AD7606_H_ */ |