blob: 4fa41b590376d8e2eba74aac1cf69ef775e26430 [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 Mohanadosseef1deb2012-12-06 14:51:27 -0800100#ifdef __KERNEL__
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -0700101struct epm_adc_platform_data {
102 struct epm_chan_properties *channel;
103 uint32_t num_channels;
104 uint32_t num_adc;
105 uint32_t chan_per_adc;
106 uint32_t chan_per_mux;
107 struct i2c_board_info epm_i2c_board_info;
108 uint32_t bus_id;
109 uint32_t gpio_expander_base_addr;
110};
Siddartha Mohanadoss79f975f2012-07-11 10:13:30 -0700111#endif
Siddartha Mohanadosseb90c922012-03-27 22:58:06 -0700112
113#define EPM_ADC_IOCTL_CODE 0x91
114
115#define EPM_ADC_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 1, \
116 struct epm_chan_request)
117
118#define EPM_ADC_INIT _IOR(EPM_ADC_IOCTL_CODE, 2, \
119 uint32_t)
120
121#define EPM_ADC_DEINIT _IOR(EPM_ADC_IOCTL_CODE, 3, \
122 uint32_t)
Siddartha Mohanadossefddea42012-09-04 08:23:43 -0700123
124#define EPM_PSOC_ADC_INIT _IOR(EPM_ADC_IOCTL_CODE, 4, \
125 struct epm_psoc_init_resp)
126
127#define EPM_PSOC_ADC_CHANNEL_ENABLE _IOWR(EPM_ADC_IOCTL_CODE, 5, \
128 struct epm_psoc_channel_configure)
129
130#define EPM_PSOC_ADC_CHANNEL_DISABLE _IOWR(EPM_ADC_IOCTL_CODE, 6, \
131 struct epm_psoc_channel_configure)
132
133#define EPM_PSOC_ADC_SET_AVERAGING _IOWR(EPM_ADC_IOCTL_CODE, 7, \
134 struct epm_psoc_set_avg)
135
136#define EPM_PSOC_ADC_GET_LAST_MEASUREMENT _IOWR(EPM_ADC_IOCTL_CODE, 8, \
137 struct epm_psoc_get_data)
138
139#define EPM_PSOC_ADC_GET_BUFFERED_DATA _IOWR(EPM_ADC_IOCTL_CODE, 9, \
140 struct epm_psoc_get_buffered_data)
141
142#define EPM_PSOC_ADC_GET_SYSTEM_TIMESTAMP _IOWR(EPM_ADC_IOCTL_CODE, 10, \
143 struct epm_psoc_system_time_stamp)
144
145#define EPM_PSOC_ADC_SET_SYSTEM_TIMESTAMP _IOWR(EPM_ADC_IOCTL_CODE, 11, \
146 struct epm_psoc_system_time_stamp)
147
148#define EPM_PSOC_ADC_GET_AVERAGE_DATA _IOWR(EPM_ADC_IOCTL_CODE, 12, \
149 struct epm_psoc_get_avg_buffered_switch_data)
150
151#define EPM_PSOC_SET_CHANNEL_SWITCH _IOWR(EPM_ADC_IOCTL_CODE, 13, \
152 struct epm_psoc_set_channel_switch)
153
154#define EPM_PSOC_CLEAR_BUFFER _IOWR(EPM_ADC_IOCTL_CODE, 14, \
155 uint32_t)
156
157#define EPM_PSOC_ADC_SET_VADC_REFERENCE _IOWR(EPM_ADC_IOCTL_CODE, 15, \
158 struct epm_psoc_set_vadc)
159
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -0700160#endif /* __EPM_ADC_H */