blob: 14cb14887fa4d8d368a302b33e8373775c3f9e55 [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;
42 uint32_t reading_value;
43};
44
45struct epm_psoc_get_buffered_data {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080046 uint8_t cmd;
47 uint8_t dev_num;
48 uint8_t status_mask;
49 uint8_t chan_idx;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070050 uint32_t chan_mask;
51 uint32_t timestamp_start;
52 uint32_t timestamp_end;
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080053 uint8_t buff_data[48];
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070054};
55
56struct epm_psoc_system_time_stamp {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080057 uint8_t cmd;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070058 uint32_t timestamp;
59};
60
61struct epm_psoc_set_channel {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080062 uint8_t cmd;
63 uint8_t dev_num;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070064 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 Mohanadosseef1deb2012-12-06 14:51:27 -080074 uint8_t cmd;
75 uint8_t status;
Siddartha Mohanadoss6e77b772012-09-19 21:58:13 -070076 uint32_t timestamp_start;
77 uint32_t channel_mask;
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080078 uint8_t avg_data[54];
Siddartha Mohanadoss6e77b772012-09-19 21:58:13 -070079 struct result_buffer data[54];
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070080};
81
82struct epm_psoc_set_channel_switch {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080083 uint8_t cmd;
84 uint8_t dev;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070085 uint32_t delay;
86};
87
88struct epm_psoc_set_vadc {
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080089 uint8_t cmd;
90 uint8_t vadc_dev;
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070091 uint32_t vadc_voltage;
92};
93
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -070094struct epm_chan_properties {
Siddartha Mohanadossefddea42012-09-04 08:23:43 -070095 uint32_t resistorvalue;
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -070096 uint32_t gain;
97};
98
Siddartha Mohanadosseef1deb2012-12-06 14:51:27 -080099#ifdef __KERNEL__
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -0700100struct 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 */