blob: f94eb9417f3a581fa5931635ebc61aeb5debb6bb [file] [log] [blame]
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -07001#ifndef __EPM_ADC_H
2#define __EPM_ADC_H
3
4#include <linux/i2c.h>
5
6struct epm_chan_request {
7 /* EPM ADC device index. 0 - ADC1, 1 - ADC2 */
8 uint32_t device_idx;
9 /* Channel number within the EPM ADC device */
10 uint32_t channel_idx;
11 /* The data meaningful for each individual channel whether it is
12 * voltage, current etc. */
13 int32_t physical;
14};
15
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070016struct epm_psoc_init_resp {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080017 uint8_t cmd;
18 uint8_t version;
19 uint8_t compatible_ver;
20 uint8_t firm_ver[3];
21 uint8_t num_dev;
22 uint8_t num_channel;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070023};
24
25struct epm_psoc_channel_configure {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080026 uint8_t cmd;
27 uint8_t device_num;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070028 uint32_t channel_num;
29};
30
31struct epm_psoc_set_avg {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080032 uint8_t cmd;
33 uint8_t avg_period;
34 uint8_t return_code;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070035};
36
37struct epm_psoc_get_data {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080038 uint8_t cmd;
39 uint8_t dev_num;
40 uint8_t chan_num;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070041 uint32_t timestamp_resp_value;
Siddartha Mohanadoss899173a2013-01-29 19:18:50 -080042 int16_t reading_raw;
43 int32_t reading_value;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070044};
45
46struct epm_psoc_get_buffered_data {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080047 uint8_t cmd;
48 uint8_t dev_num;
49 uint8_t status_mask;
50 uint8_t chan_idx;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070051 uint32_t chan_mask;
52 uint32_t timestamp_start;
53 uint32_t timestamp_end;
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080054 uint8_t buff_data[48];
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070055};
56
57struct epm_psoc_system_time_stamp {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080058 uint8_t cmd;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070059 uint32_t timestamp;
60};
61
62struct epm_psoc_set_channel {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080063 uint8_t cmd;
64 uint8_t dev_num;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070065 uint32_t channel_mask;
66};
67
Siddartha Mohanadoss6e77b772012-09-19 21:58:13 -070068struct result_buffer {
69 uint32_t channel;
70 uint32_t avg_buffer_sample;
71 uint32_t result;
72};
73
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070074struct epm_psoc_get_avg_buffered_switch_data {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080075 uint8_t cmd;
76 uint8_t status;
Siddartha Mohanadoss6e77b772012-09-19 21:58:13 -070077 uint32_t timestamp_start;
78 uint32_t channel_mask;
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080079 uint8_t avg_data[54];
Siddartha Mohanadoss6e77b772012-09-19 21:58:13 -070080 struct result_buffer data[54];
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070081};
82
83struct epm_psoc_set_channel_switch {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080084 uint8_t cmd;
85 uint8_t dev;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070086 uint32_t delay;
87};
88
89struct epm_psoc_set_vadc {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080090 uint8_t cmd;
91 uint8_t vadc_dev;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070092 uint32_t vadc_voltage;
93};
94
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -070095struct epm_chan_properties {
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070096 uint32_t resistorvalue;
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -070097 uint32_t gain;
98};
99
Siddartha Mohanadoss3efc4d82013-06-11 15:34:52 -0700100struct epm_marker_level {
101 uint8_t level;
102};
103
Siddartha Mohanadoss97242fe2013-06-11 16:05:16 -0700104struct epm_gpio_buffer_request {
105 uint8_t cmd;
106 uint8_t bitmask_monitor_pin;
107 uint8_t status;
108};
109
110struct epm_get_gpio_buffer_resp {
111 uint8_t cmd;
112 uint8_t status;
113 uint8_t bitmask_monitor_pin;
114 uint32_t timestamp;
115};
116
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -0800117#ifdef __KERNEL__
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -0700118struct epm_adc_platform_data {
119 struct epm_chan_properties *channel;
120 uint32_t num_channels;
121 uint32_t num_adc;
122 uint32_t chan_per_adc;
123 uint32_t chan_per_mux;
124 struct i2c_board_info epm_i2c_board_info;
125 uint32_t bus_id;
126 uint32_t gpio_expander_base_addr;
127};
Siddartha Mohanadoss79f975f2012-07-11 10:13:30 -0700128#endif
Siddartha Mohanadosseb90c922012-03-27 22:58:06 -0700129
130#define EPM_ADC_IOCTL_CODE 0x91
131
132#define EPM_ADC_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 1, \
133 struct epm_chan_request)
134
135#define EPM_ADC_INIT _IOR(EPM_ADC_IOCTL_CODE, 2, \
136 uint32_t)
137
138#define EPM_ADC_DEINIT _IOR(EPM_ADC_IOCTL_CODE, 3, \
139 uint32_t)
Siddartha Mohanadossefddea42012-09-04 08:23:43 -0700140
Siddartha Mohanadoss97242fe2013-06-11 16:05:16 -0700141#define EPM_MARKER1_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 90, \
Siddartha Mohanadoss3efc4d82013-06-11 15:34:52 -0700142 uint32_t)
143
Siddartha Mohanadoss97242fe2013-06-11 16:05:16 -0700144#define EPM_MARKER1_RELEASE _IOWR(EPM_ADC_IOCTL_CODE, 91, \
Siddartha Mohanadoss3efc4d82013-06-11 15:34:52 -0700145 uint32_t)
146
Siddartha Mohanadoss97242fe2013-06-11 16:05:16 -0700147#define EPM_MARKER2_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 95, \
Siddartha Mohanadoss3efc4d82013-06-11 15:34:52 -0700148 uint32_t)
149
Siddartha Mohanadoss97242fe2013-06-11 16:05:16 -0700150#define EPM_MARKER2_RELEASE _IOWR(EPM_ADC_IOCTL_CODE, 92, \
Siddartha Mohanadoss3efc4d82013-06-11 15:34:52 -0700151 uint32_t)
152
Siddartha Mohanadoss97242fe2013-06-11 16:05:16 -0700153#define EPM_PSOC_ADC_INIT _IOWR(EPM_ADC_IOCTL_CODE, 4, \
Siddartha Mohanadossefddea42012-09-04 08:23:43 -0700154 struct epm_psoc_init_resp)
155
156#define EPM_PSOC_ADC_CHANNEL_ENABLE _IOWR(EPM_ADC_IOCTL_CODE, 5, \
157 struct epm_psoc_channel_configure)
158
159#define EPM_PSOC_ADC_CHANNEL_DISABLE _IOWR(EPM_ADC_IOCTL_CODE, 6, \
160 struct epm_psoc_channel_configure)
161
162#define EPM_PSOC_ADC_SET_AVERAGING _IOWR(EPM_ADC_IOCTL_CODE, 7, \
163 struct epm_psoc_set_avg)
164
165#define EPM_PSOC_ADC_GET_LAST_MEASUREMENT _IOWR(EPM_ADC_IOCTL_CODE, 8, \
166 struct epm_psoc_get_data)
167
168#define EPM_PSOC_ADC_GET_BUFFERED_DATA _IOWR(EPM_ADC_IOCTL_CODE, 9, \
169 struct epm_psoc_get_buffered_data)
170
171#define EPM_PSOC_ADC_GET_SYSTEM_TIMESTAMP _IOWR(EPM_ADC_IOCTL_CODE, 10, \
172 struct epm_psoc_system_time_stamp)
173
174#define EPM_PSOC_ADC_SET_SYSTEM_TIMESTAMP _IOWR(EPM_ADC_IOCTL_CODE, 11, \
175 struct epm_psoc_system_time_stamp)
176
177#define EPM_PSOC_ADC_GET_AVERAGE_DATA _IOWR(EPM_ADC_IOCTL_CODE, 12, \
178 struct epm_psoc_get_avg_buffered_switch_data)
179
180#define EPM_PSOC_SET_CHANNEL_SWITCH _IOWR(EPM_ADC_IOCTL_CODE, 13, \
181 struct epm_psoc_set_channel_switch)
182
183#define EPM_PSOC_CLEAR_BUFFER _IOWR(EPM_ADC_IOCTL_CODE, 14, \
184 uint32_t)
185
186#define EPM_PSOC_ADC_SET_VADC_REFERENCE _IOWR(EPM_ADC_IOCTL_CODE, 15, \
187 struct epm_psoc_set_vadc)
188
Siddartha Mohanadoss97242fe2013-06-11 16:05:16 -0700189#define EPM_PSOC_ADC_DEINIT _IOWR(EPM_ADC_IOCTL_CODE, 16, \
190 uint32_t)
191
192#define EPM_PSOC_GPIO_BUFFER_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 17, \
Siddartha Mohanadoss46aff912013-07-10 18:53:48 -0700193 struct epm_gpio_buffer_request)
Siddartha Mohanadoss97242fe2013-06-11 16:05:16 -0700194
195#define EPM_PSOC_GET_GPIO_BUFFER_DATA _IOWR(EPM_ADC_IOCTL_CODE, 18, \
Siddartha Mohanadoss46aff912013-07-10 18:53:48 -0700196 struct epm_get_gpio_buffer_resp)
197
198#define EPM_PSOC_PAUSE_CONVERSION_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 19, \
Siddartha Mohanadoss97242fe2013-06-11 16:05:16 -0700199 uint32_t)
200
Siddartha Mohanadoss46aff912013-07-10 18:53:48 -0700201#define EPM_PSOC_UNPAUSE_CONVERSION_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 20, \
202 uint32_t)
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -0700203#endif /* __EPM_ADC_H */