summaryrefslogtreecommitdiff
path: root/include/uapi/linux/epm_adc.h
blob: 9a2f613950dedbe5af8c81bc83d4d2bf314136f2 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#ifndef _UAPI_EPM_ADC_H
#define _UAPI_EPM_ADC_H

struct epm_chan_request {
	/* EPM ADC device index. 0 - ADC1, 1 - ADC2 */
	uint32_t device_idx;
	/* Channel number within the EPM ADC device  */
	uint32_t channel_idx;
	/* The data meaningful for each individual channel whether it is
	 * voltage, current etc. */
	int32_t physical;
};

struct epm_psoc_init_resp {
	uint8_t	cmd;
	uint8_t	version;
	uint8_t	compatible_ver;
	uint8_t	firm_ver[3];
	uint8_t	num_dev;
	uint8_t	num_channel;
};

struct epm_psoc_channel_configure {
	uint8_t		cmd;
	uint8_t		device_num;
	uint32_t	channel_num;
};

struct epm_psoc_set_avg {
	uint8_t	cmd;
	uint8_t	avg_period;
	uint8_t	return_code;
};

struct epm_psoc_get_data {
	uint8_t		cmd;
	uint8_t		dev_num;
	uint8_t		chan_num;
	uint32_t	timestamp_resp_value;
	int16_t		reading_raw;
	int32_t		reading_value;
};

struct epm_psoc_get_buffered_data {
	uint8_t		cmd;
	uint8_t		dev_num;
	uint8_t		status_mask;
	uint8_t		chan_idx;
	uint32_t	chan_mask;
	uint32_t	timestamp_start;
	uint32_t	timestamp_end;
	uint8_t		buff_data[48];
};

struct epm_psoc_system_time_stamp {
	uint8_t		cmd;
	uint32_t	timestamp;
};

struct epm_psoc_set_channel {
	uint8_t		cmd;
	uint8_t		dev_num;
	uint32_t	channel_mask;
};

struct result_buffer {
	uint32_t	channel;
	uint32_t	avg_buffer_sample;
	uint32_t	result;
};

struct epm_psoc_get_avg_buffered_switch_data {
	uint8_t			cmd;
	uint8_t			status;
	uint32_t		timestamp_start;
	uint32_t		channel_mask;
	uint8_t			avg_data[54];
	struct result_buffer	data[54];
};

struct epm_psoc_set_channel_switch {
	uint8_t		cmd;
	uint8_t		dev;
	uint32_t	delay;
};

struct epm_psoc_set_vadc {
	uint8_t		cmd;
	uint8_t		vadc_dev;
	uint32_t	vadc_voltage;
};

struct epm_chan_properties {
	uint32_t resistorvalue;
	uint32_t gain;
};

struct epm_marker_level {
	uint8_t		level;
};

struct epm_gpio_buffer_request {
	uint8_t		cmd;
	uint8_t		bitmask_monitor_pin;
	uint8_t		status;
};

struct epm_get_gpio_buffer_resp {
	uint8_t		cmd;
	uint8_t		status;
	uint8_t		bitmask_monitor_pin;
	uint32_t	timestamp;
};

struct epm_get_high_res_avg_data {
	uint8_t		cmd;
	uint8_t		status;
	uint32_t	channel_mask;
	uint32_t	timestamp;
	uint8_t		buf_data[54];
};

struct epm_generic_request {
	uint8_t		buf[64];
};


#define EPM_ADC_IOCTL_CODE		0x91

#define EPM_ADC_REQUEST		_IOWR(EPM_ADC_IOCTL_CODE, 1,	\
					struct epm_chan_request)

#define EPM_ADC_INIT		_IOR(EPM_ADC_IOCTL_CODE, 2,	\
					     uint32_t)

#define EPM_ADC_DEINIT		_IOR(EPM_ADC_IOCTL_CODE, 3,	\
					     uint32_t)

#define EPM_MARKER1_REQUEST	_IOR(EPM_ADC_IOCTL_CODE, 90,	\
						uint32_t)


#define EPM_MARKER1_RELEASE	_IOR(EPM_ADC_IOCTL_CODE, 91,	\
						uint32_t)

#define EPM_MARKER1_SET_LEVEL	_IOWR(EPM_ADC_IOCTL_CODE, 92,	\
						uint32_t)

#define EPM_MARKER2_REQUEST	_IOR(EPM_ADC_IOCTL_CODE, 93,	\
						uint32_t)

#define EPM_MARKER2_SET_LEVEL	_IOWR(EPM_ADC_IOCTL_CODE, 94,	\
						uint32_t)

#define EPM_MARKER2_RELEASE	_IOR(EPM_ADC_IOCTL_CODE, 95,	\
						uint32_t)

#define EPM_PSOC_ADC_INIT		_IOWR(EPM_ADC_IOCTL_CODE, 4, \
					struct epm_psoc_init_resp)

#define EPM_PSOC_ADC_CHANNEL_ENABLE	_IOWR(EPM_ADC_IOCTL_CODE, 5, \
					struct epm_psoc_channel_configure)

#define EPM_PSOC_ADC_CHANNEL_DISABLE	_IOWR(EPM_ADC_IOCTL_CODE, 6, \
					struct epm_psoc_channel_configure)

#define EPM_PSOC_ADC_SET_AVERAGING	_IOWR(EPM_ADC_IOCTL_CODE, 7, \
					struct epm_psoc_set_avg)

#define EPM_PSOC_ADC_GET_LAST_MEASUREMENT	_IOWR(EPM_ADC_IOCTL_CODE, 8, \
						struct epm_psoc_get_data)

#define EPM_PSOC_ADC_GET_BUFFERED_DATA		_IOWR(EPM_ADC_IOCTL_CODE, 9, \
					struct epm_psoc_get_buffered_data)

#define EPM_PSOC_ADC_GET_SYSTEM_TIMESTAMP	_IOWR(EPM_ADC_IOCTL_CODE, 10, \
					struct epm_psoc_system_time_stamp)

#define EPM_PSOC_ADC_SET_SYSTEM_TIMESTAMP	_IOWR(EPM_ADC_IOCTL_CODE, 11, \
					struct epm_psoc_system_time_stamp)

#define EPM_PSOC_ADC_GET_AVERAGE_DATA		_IOWR(EPM_ADC_IOCTL_CODE, 12, \
				struct epm_psoc_get_avg_buffered_switch_data)

#define EPM_PSOC_SET_CHANNEL_SWITCH		_IOWR(EPM_ADC_IOCTL_CODE, 13, \
					struct epm_psoc_set_channel_switch)

#define EPM_PSOC_CLEAR_BUFFER			_IOWR(EPM_ADC_IOCTL_CODE, 14, \
						uint32_t)

#define EPM_PSOC_ADC_SET_VADC_REFERENCE		_IOWR(EPM_ADC_IOCTL_CODE, 15, \
						struct epm_psoc_set_vadc)

#define EPM_PSOC_ADC_DEINIT		_IOWR(EPM_ADC_IOCTL_CODE, 16,	\
							     uint32_t)

#define EPM_PSOC_GPIO_BUFFER_REQUEST	_IOWR(EPM_ADC_IOCTL_CODE, 17,	\
					struct epm_gpio_buffer_request)

#define EPM_PSOC_GET_GPIO_BUFFER_DATA	_IOWR(EPM_ADC_IOCTL_CODE, 18,	\
					struct epm_get_gpio_buffer_resp)

#define EPM_PSOC_PAUSE_CONVERSION_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 19,	\
								uint32_t)

#define EPM_PSOC_UNPAUSE_CONVERSION_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 20, \
								uint32_t)

#define EPM_PSOC_16_BIT_AVERAGED_REQUEST	_IOWR(EPM_ADC_IOCTL_CODE, 21, \
					struct epm_get_high_res_avg_data)

#define EPM_PSOC_GENERIC_REQUEST		_IOWR(EPM_ADC_IOCTL_CODE, 22, \
					struct epm_generic_request)

#endif /* _UAPI_EPM_ADC_H */