1
2
3
4
5
6
7
8 #ifndef IIO_ADC_AD7606_H_
9 #define IIO_ADC_AD7606_H_
10
11 #define AD760X_CHANNEL(num, mask_sep, mask_type, mask_all) { \
12 .type = IIO_VOLTAGE, \
13 .indexed = 1, \
14 .channel = num, \
15 .address = num, \
16 .info_mask_separate = mask_sep, \
17 .info_mask_shared_by_type = mask_type, \
18 .info_mask_shared_by_all = mask_all, \
19 .scan_index = num, \
20 .scan_type = { \
21 .sign = 's', \
22 .realbits = 16, \
23 .storagebits = 16, \
24 .endianness = IIO_CPU, \
25 }, \
26 }
27
28 #define AD7605_CHANNEL(num) \
29 AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW), \
30 BIT(IIO_CHAN_INFO_SCALE), 0)
31
32 #define AD7606_CHANNEL(num) \
33 AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW), \
34 BIT(IIO_CHAN_INFO_SCALE), \
35 BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO))
36
37 #define AD7616_CHANNEL(num) \
38 AD760X_CHANNEL(num, BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),\
39 0, BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO))
40
41
42
43
44
45
46
47
48
49
50
51
52 struct ad7606_chip_info {
53 const struct iio_chan_spec *channels;
54 unsigned int num_channels;
55 const unsigned int *oversampling_avail;
56 unsigned int oversampling_num;
57 bool os_req_reset;
58 unsigned long init_delay_ms;
59 };
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 struct ad7606_state {
93 struct device *dev;
94 const struct ad7606_chip_info *chip_info;
95 struct regulator *reg;
96 const struct ad7606_bus_ops *bops;
97 unsigned int range[16];
98 unsigned int oversampling;
99 void __iomem *base_address;
100 bool sw_mode_en;
101 const unsigned int *scale_avail;
102 unsigned int num_scales;
103 const unsigned int *oversampling_avail;
104 unsigned int num_os_ratios;
105 int (*write_scale)(struct iio_dev *indio_dev, int ch, int val);
106 int (*write_os)(struct iio_dev *indio_dev, int val);
107
108 struct mutex lock;
109 struct gpio_desc *gpio_convst;
110 struct gpio_desc *gpio_reset;
111 struct gpio_desc *gpio_range;
112 struct gpio_desc *gpio_standby;
113 struct gpio_desc *gpio_frstdata;
114 struct gpio_descs *gpio_os;
115 struct iio_trigger *trig;
116 struct completion completion;
117
118
119
120
121
122
123 unsigned short data[20] ____cacheline_aligned;
124 __be16 d16[2];
125 };
126
127
128
129
130
131
132
133
134
135
136
137 struct ad7606_bus_ops {
138
139 int (*read_block)(struct device *dev, int num, void *data);
140 int (*sw_mode_config)(struct iio_dev *indio_dev);
141 int (*reg_read)(struct ad7606_state *st, unsigned int addr);
142 int (*reg_write)(struct ad7606_state *st,
143 unsigned int addr,
144 unsigned int val);
145 int (*write_mask)(struct ad7606_state *st,
146 unsigned int addr,
147 unsigned long mask,
148 unsigned int val);
149 u16 (*rd_wr_cmd)(int addr, char isWriteOp);
150 };
151
152 int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
153 const char *name, unsigned int id,
154 const struct ad7606_bus_ops *bops);
155
156 enum ad7606_supported_device_ids {
157 ID_AD7605_4,
158 ID_AD7606_8,
159 ID_AD7606_6,
160 ID_AD7606_4,
161 ID_AD7606B,
162 ID_AD7616,
163 };
164
165 #ifdef CONFIG_PM_SLEEP
166 extern const struct dev_pm_ops ad7606_pm_ops;
167 #define AD7606_PM_OPS (&ad7606_pm_ops)
168 #else
169 #define AD7606_PM_OPS NULL
170 #endif
171
172 #endif