blob: 076302b060ecb0b4fab8fc22d3b680270a4f4071 [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 Mohanadossb0b8a6e2012-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
67struct epm_psoc_get_avg_buffered_switch_data {
68 u8 cmd;
69 u8 status;
70 uint32_t timestamp_start;
71 uint32_t channel_mask;
72 u8 avg_data[54];
73};
74
75struct epm_psoc_set_channel_switch {
76 u8 cmd;
77 u8 dev;
78 uint32_t delay;
79};
80
81struct epm_psoc_set_vadc {
82 u8 cmd;
83 u8 vadc_dev;
84 uint32_t vadc_voltage;
85};
86
Siddartha Mohanadoss79f975f2012-07-11 10:13:30 -070087#ifdef __KERNEL__
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -070088struct epm_chan_properties {
Siddartha Mohanadossb0b8a6e2012-09-04 08:23:43 -070089 uint32_t resistorvalue;
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -070090 uint32_t gain;
91};
92
93struct epm_adc_platform_data {
94 struct epm_chan_properties *channel;
95 uint32_t num_channels;
96 uint32_t num_adc;
97 uint32_t chan_per_adc;
98 uint32_t chan_per_mux;
99 struct i2c_board_info epm_i2c_board_info;
100 uint32_t bus_id;
101 uint32_t gpio_expander_base_addr;
102};
Siddartha Mohanadoss79f975f2012-07-11 10:13:30 -0700103#endif
Siddartha Mohanadosseb90c922012-03-27 22:58:06 -0700104
105#define EPM_ADC_IOCTL_CODE 0x91
106
107#define EPM_ADC_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 1, \
108 struct epm_chan_request)
109
110#define EPM_ADC_INIT _IOR(EPM_ADC_IOCTL_CODE, 2, \
111 uint32_t)
112
113#define EPM_ADC_DEINIT _IOR(EPM_ADC_IOCTL_CODE, 3, \
114 uint32_t)
Siddartha Mohanadossb0b8a6e2012-09-04 08:23:43 -0700115
116#define EPM_PSOC_ADC_INIT _IOR(EPM_ADC_IOCTL_CODE, 4, \
117 struct epm_psoc_init_resp)
118
119#define EPM_PSOC_ADC_CHANNEL_ENABLE _IOWR(EPM_ADC_IOCTL_CODE, 5, \
120 struct epm_psoc_channel_configure)
121
122#define EPM_PSOC_ADC_CHANNEL_DISABLE _IOWR(EPM_ADC_IOCTL_CODE, 6, \
123 struct epm_psoc_channel_configure)
124
125#define EPM_PSOC_ADC_SET_AVERAGING _IOWR(EPM_ADC_IOCTL_CODE, 7, \
126 struct epm_psoc_set_avg)
127
128#define EPM_PSOC_ADC_GET_LAST_MEASUREMENT _IOWR(EPM_ADC_IOCTL_CODE, 8, \
129 struct epm_psoc_get_data)
130
131#define EPM_PSOC_ADC_GET_BUFFERED_DATA _IOWR(EPM_ADC_IOCTL_CODE, 9, \
132 struct epm_psoc_get_buffered_data)
133
134#define EPM_PSOC_ADC_GET_SYSTEM_TIMESTAMP _IOWR(EPM_ADC_IOCTL_CODE, 10, \
135 struct epm_psoc_system_time_stamp)
136
137#define EPM_PSOC_ADC_SET_SYSTEM_TIMESTAMP _IOWR(EPM_ADC_IOCTL_CODE, 11, \
138 struct epm_psoc_system_time_stamp)
139
140#define EPM_PSOC_ADC_GET_AVERAGE_DATA _IOWR(EPM_ADC_IOCTL_CODE, 12, \
141 struct epm_psoc_get_avg_buffered_switch_data)
142
143#define EPM_PSOC_SET_CHANNEL_SWITCH _IOWR(EPM_ADC_IOCTL_CODE, 13, \
144 struct epm_psoc_set_channel_switch)
145
146#define EPM_PSOC_CLEAR_BUFFER _IOWR(EPM_ADC_IOCTL_CODE, 14, \
147 uint32_t)
148
149#define EPM_PSOC_ADC_SET_VADC_REFERENCE _IOWR(EPM_ADC_IOCTL_CODE, 15, \
150 struct epm_psoc_set_vadc)
151
Siddartha Mohanadoss53c16f92011-10-17 15:57:15 -0700152#endif /* __EPM_ADC_H */