blob: b7b7d9016d75542144e89caeecd94536c217ece4 [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 {
17 u8 cmd;
18 u8 version;
19 u8 compatible_ver;
20 u8 firm_ver[3];
21 u8 num_dev;
22 u8 num_channel;
23};
24
25struct epm_psoc_channel_configure {
26 u8 cmd;
27 u8 device_num;
28 uint32_t channel_num;
29};
30
31struct epm_psoc_set_avg {
32 u8 cmd;
33 u8 avg_period;
34 u8 return_code;
35};
36
37struct epm_psoc_get_data {
38 u8 cmd;
39 u8 dev_num;
40 u8 chan_num;
41 uint32_t timestamp_resp_value;
42 uint32_t reading_value;
43};
44
45struct epm_psoc_get_buffered_data {
46 u8 cmd;
47 u8 dev_num;
48 u8 status_mask;
49 u8 chan_idx;
50 uint32_t chan_mask;
51 uint32_t timestamp_start;
52 uint32_t timestamp_end;
53 u8 buff_data[48];
54};
55
56struct epm_psoc_system_time_stamp {
57 u8 cmd;
58 uint32_t timestamp;
59};
60
61struct epm_psoc_set_channel {
62 u8 cmd;
63 u8 dev_num;
64 uint32_t channel_mask;
65};
66
Siddartha Mohanadoss6e77b772012-09-19 21:58:13 -070067struct result_buffer {
68 uint32_t channel;
69 uint32_t avg_buffer_sample;
70 uint32_t result;
71};
72
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070073struct epm_psoc_get_avg_buffered_switch_data {
Siddartha Mohanadoss6e77b772012-09-19 21:58:13 -070074 u8 cmd;
75 u8 status;
76 uint32_t timestamp_start;
77 uint32_t channel_mask;
78 u8 avg_data[54];
79 struct result_buffer data[54];
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070080};
81
82struct epm_psoc_set_channel_switch {
83 u8 cmd;
84 u8 dev;
85 uint32_t delay;
86};
87
88struct epm_psoc_set_vadc {
89 u8 cmd;
90 u8 vadc_dev;
91 uint32_t vadc_voltage;
92};
93
Siddartha Mohanadoss79f975f2012-07-11 10:13:30 -070094#ifdef __KERNEL__
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
100struct epm_adc_platform_data {
101 struct epm_chan_properties *channel;
102 uint32_t num_channels;
103 uint32_t num_adc;
104 uint32_t chan_per_adc;
105 uint32_t chan_per_mux;
106 struct i2c_board_info epm_i2c_board_info;
107 uint32_t bus_id;
108 uint32_t gpio_expander_base_addr;
109};
Siddartha Mohanadoss79f975f2012-07-11 10:13:30 -0700110#endif
Siddartha Mohanadosseb90c922012-03-27 22:58:06 -0700111
112#define EPM_ADC_IOCTL_CODE 0x91
113
114#define EPM_ADC_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 1, \
115 struct epm_chan_request)
116
117#define EPM_ADC_INIT _IOR(EPM_ADC_IOCTL_CODE, 2, \
118 uint32_t)
119
120#define EPM_ADC_DEINIT _IOR(EPM_ADC_IOCTL_CODE, 3, \
121 uint32_t)
Siddartha Mohanadossefddea42012-09-04 08:23:43 -0700122
123#define EPM_PSOC_ADC_INIT _IOR(EPM_ADC_IOCTL_CODE, 4, \
124 struct epm_psoc_init_resp)
125
126#define EPM_PSOC_ADC_CHANNEL_ENABLE _IOWR(EPM_ADC_IOCTL_CODE, 5, \
127 struct epm_psoc_channel_configure)
128
129#define EPM_PSOC_ADC_CHANNEL_DISABLE _IOWR(EPM_ADC_IOCTL_CODE, 6, \
130 struct epm_psoc_channel_configure)
131
132#define EPM_PSOC_ADC_SET_AVERAGING _IOWR(EPM_ADC_IOCTL_CODE, 7, \
133 struct epm_psoc_set_avg)
134
135#define EPM_PSOC_ADC_GET_LAST_MEASUREMENT _IOWR(EPM_ADC_IOCTL_CODE, 8, \
136 struct epm_psoc_get_data)
137
138#define EPM_PSOC_ADC_GET_BUFFERED_DATA _IOWR(EPM_ADC_IOCTL_CODE, 9, \
139 struct epm_psoc_get_buffered_data)
140
141#define EPM_PSOC_ADC_GET_SYSTEM_TIMESTAMP _IOWR(EPM_ADC_IOCTL_CODE, 10, \
142 struct epm_psoc_system_time_stamp)
143
144#define EPM_PSOC_ADC_SET_SYSTEM_TIMESTAMP _IOWR(EPM_ADC_IOCTL_CODE, 11, \
145 struct epm_psoc_system_time_stamp)
146
147#define EPM_PSOC_ADC_GET_AVERAGE_DATA _IOWR(EPM_ADC_IOCTL_CODE, 12, \
148 struct epm_psoc_get_avg_buffered_switch_data)
149
150#define EPM_PSOC_SET_CHANNEL_SWITCH _IOWR(EPM_ADC_IOCTL_CODE, 13, \
151 struct epm_psoc_set_channel_switch)
152
153#define EPM_PSOC_CLEAR_BUFFER _IOWR(EPM_ADC_IOCTL_CODE, 14, \
154 uint32_t)
155
156#define EPM_PSOC_ADC_SET_VADC_REFERENCE _IOWR(EPM_ADC_IOCTL_CODE, 15, \
157 struct epm_psoc_set_vadc)
158
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -0700159#endif /* __EPM_ADC_H */