Siddartha Mohanadoss | 53c16f9 | 2011-10-17 15:57:15 -0700 | [diff] [blame] | 1 | #ifndef __EPM_ADC_H |
| 2 | #define __EPM_ADC_H |
| 3 | |
| 4 | #include <linux/i2c.h> |
| 5 | |
| 6 | struct 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 Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 16 | struct epm_psoc_init_resp { |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 17 | 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 Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | struct epm_psoc_channel_configure { |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 26 | uint8_t cmd; |
| 27 | uint8_t device_num; |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 28 | uint32_t channel_num; |
| 29 | }; |
| 30 | |
| 31 | struct epm_psoc_set_avg { |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 32 | uint8_t cmd; |
| 33 | uint8_t avg_period; |
| 34 | uint8_t return_code; |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 35 | }; |
| 36 | |
| 37 | struct epm_psoc_get_data { |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 38 | uint8_t cmd; |
| 39 | uint8_t dev_num; |
| 40 | uint8_t chan_num; |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 41 | uint32_t timestamp_resp_value; |
Siddartha Mohanadoss | 899173a | 2013-01-29 19:18:50 -0800 | [diff] [blame] | 42 | int16_t reading_raw; |
| 43 | int32_t reading_value; |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | struct epm_psoc_get_buffered_data { |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 47 | uint8_t cmd; |
| 48 | uint8_t dev_num; |
| 49 | uint8_t status_mask; |
| 50 | uint8_t chan_idx; |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 51 | uint32_t chan_mask; |
| 52 | uint32_t timestamp_start; |
| 53 | uint32_t timestamp_end; |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 54 | uint8_t buff_data[48]; |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | struct epm_psoc_system_time_stamp { |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 58 | uint8_t cmd; |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 59 | uint32_t timestamp; |
| 60 | }; |
| 61 | |
| 62 | struct epm_psoc_set_channel { |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 63 | uint8_t cmd; |
| 64 | uint8_t dev_num; |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 65 | uint32_t channel_mask; |
| 66 | }; |
| 67 | |
Siddartha Mohanadoss | 6e77b77 | 2012-09-19 21:58:13 -0700 | [diff] [blame] | 68 | struct result_buffer { |
| 69 | uint32_t channel; |
| 70 | uint32_t avg_buffer_sample; |
| 71 | uint32_t result; |
| 72 | }; |
| 73 | |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 74 | struct epm_psoc_get_avg_buffered_switch_data { |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 75 | uint8_t cmd; |
| 76 | uint8_t status; |
Siddartha Mohanadoss | 6e77b77 | 2012-09-19 21:58:13 -0700 | [diff] [blame] | 77 | uint32_t timestamp_start; |
| 78 | uint32_t channel_mask; |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 79 | uint8_t avg_data[54]; |
Siddartha Mohanadoss | 6e77b77 | 2012-09-19 21:58:13 -0700 | [diff] [blame] | 80 | struct result_buffer data[54]; |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | struct epm_psoc_set_channel_switch { |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 84 | uint8_t cmd; |
| 85 | uint8_t dev; |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 86 | uint32_t delay; |
| 87 | }; |
| 88 | |
| 89 | struct epm_psoc_set_vadc { |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 90 | uint8_t cmd; |
| 91 | uint8_t vadc_dev; |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 92 | uint32_t vadc_voltage; |
| 93 | }; |
| 94 | |
Siddartha Mohanadoss | 53c16f9 | 2011-10-17 15:57:15 -0700 | [diff] [blame] | 95 | struct epm_chan_properties { |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 96 | uint32_t resistorvalue; |
Siddartha Mohanadoss | 53c16f9 | 2011-10-17 15:57:15 -0700 | [diff] [blame] | 97 | uint32_t gain; |
| 98 | }; |
| 99 | |
Siddartha Mohanadoss | 3efc4d8 | 2013-06-11 15:34:52 -0700 | [diff] [blame] | 100 | struct epm_marker_level { |
| 101 | uint8_t level; |
| 102 | }; |
| 103 | |
Siddartha Mohanadoss | 97242fe | 2013-06-11 16:05:16 -0700 | [diff] [blame] | 104 | struct epm_gpio_buffer_request { |
| 105 | uint8_t cmd; |
| 106 | uint8_t bitmask_monitor_pin; |
| 107 | uint8_t status; |
| 108 | }; |
| 109 | |
| 110 | struct epm_get_gpio_buffer_resp { |
| 111 | uint8_t cmd; |
| 112 | uint8_t status; |
| 113 | uint8_t bitmask_monitor_pin; |
| 114 | uint32_t timestamp; |
| 115 | }; |
| 116 | |
Siddartha Mohanadoss | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 117 | #ifdef __KERNEL__ |
Siddartha Mohanadoss | 53c16f9 | 2011-10-17 15:57:15 -0700 | [diff] [blame] | 118 | struct epm_adc_platform_data { |
| 119 | struct epm_chan_properties *channel; |
| 120 | uint32_t num_channels; |
| 121 | uint32_t num_adc; |
| 122 | uint32_t chan_per_adc; |
| 123 | uint32_t chan_per_mux; |
| 124 | struct i2c_board_info epm_i2c_board_info; |
| 125 | uint32_t bus_id; |
| 126 | uint32_t gpio_expander_base_addr; |
| 127 | }; |
Siddartha Mohanadoss | 79f975f | 2012-07-11 10:13:30 -0700 | [diff] [blame] | 128 | #endif |
Siddartha Mohanadoss | eb90c92 | 2012-03-27 22:58:06 -0700 | [diff] [blame] | 129 | |
| 130 | #define EPM_ADC_IOCTL_CODE 0x91 |
| 131 | |
| 132 | #define EPM_ADC_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 1, \ |
| 133 | struct epm_chan_request) |
| 134 | |
| 135 | #define EPM_ADC_INIT _IOR(EPM_ADC_IOCTL_CODE, 2, \ |
| 136 | uint32_t) |
| 137 | |
| 138 | #define EPM_ADC_DEINIT _IOR(EPM_ADC_IOCTL_CODE, 3, \ |
| 139 | uint32_t) |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 140 | |
Siddartha Mohanadoss | 97242fe | 2013-06-11 16:05:16 -0700 | [diff] [blame] | 141 | #define EPM_MARKER1_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 90, \ |
Siddartha Mohanadoss | 3efc4d8 | 2013-06-11 15:34:52 -0700 | [diff] [blame] | 142 | uint32_t) |
| 143 | |
Siddartha Mohanadoss | 97242fe | 2013-06-11 16:05:16 -0700 | [diff] [blame] | 144 | #define EPM_MARKER1_RELEASE _IOWR(EPM_ADC_IOCTL_CODE, 91, \ |
Siddartha Mohanadoss | 3efc4d8 | 2013-06-11 15:34:52 -0700 | [diff] [blame] | 145 | uint32_t) |
| 146 | |
Siddartha Mohanadoss | 97242fe | 2013-06-11 16:05:16 -0700 | [diff] [blame] | 147 | #define EPM_MARKER2_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 95, \ |
Siddartha Mohanadoss | 3efc4d8 | 2013-06-11 15:34:52 -0700 | [diff] [blame] | 148 | uint32_t) |
| 149 | |
Siddartha Mohanadoss | 97242fe | 2013-06-11 16:05:16 -0700 | [diff] [blame] | 150 | #define EPM_MARKER2_RELEASE _IOWR(EPM_ADC_IOCTL_CODE, 92, \ |
Siddartha Mohanadoss | 3efc4d8 | 2013-06-11 15:34:52 -0700 | [diff] [blame] | 151 | uint32_t) |
| 152 | |
Siddartha Mohanadoss | 97242fe | 2013-06-11 16:05:16 -0700 | [diff] [blame] | 153 | #define EPM_PSOC_ADC_INIT _IOWR(EPM_ADC_IOCTL_CODE, 4, \ |
Siddartha Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 154 | struct epm_psoc_init_resp) |
| 155 | |
| 156 | #define EPM_PSOC_ADC_CHANNEL_ENABLE _IOWR(EPM_ADC_IOCTL_CODE, 5, \ |
| 157 | struct epm_psoc_channel_configure) |
| 158 | |
| 159 | #define EPM_PSOC_ADC_CHANNEL_DISABLE _IOWR(EPM_ADC_IOCTL_CODE, 6, \ |
| 160 | struct epm_psoc_channel_configure) |
| 161 | |
| 162 | #define EPM_PSOC_ADC_SET_AVERAGING _IOWR(EPM_ADC_IOCTL_CODE, 7, \ |
| 163 | struct epm_psoc_set_avg) |
| 164 | |
| 165 | #define EPM_PSOC_ADC_GET_LAST_MEASUREMENT _IOWR(EPM_ADC_IOCTL_CODE, 8, \ |
| 166 | struct epm_psoc_get_data) |
| 167 | |
| 168 | #define EPM_PSOC_ADC_GET_BUFFERED_DATA _IOWR(EPM_ADC_IOCTL_CODE, 9, \ |
| 169 | struct epm_psoc_get_buffered_data) |
| 170 | |
| 171 | #define EPM_PSOC_ADC_GET_SYSTEM_TIMESTAMP _IOWR(EPM_ADC_IOCTL_CODE, 10, \ |
| 172 | struct epm_psoc_system_time_stamp) |
| 173 | |
| 174 | #define EPM_PSOC_ADC_SET_SYSTEM_TIMESTAMP _IOWR(EPM_ADC_IOCTL_CODE, 11, \ |
| 175 | struct epm_psoc_system_time_stamp) |
| 176 | |
| 177 | #define EPM_PSOC_ADC_GET_AVERAGE_DATA _IOWR(EPM_ADC_IOCTL_CODE, 12, \ |
| 178 | struct epm_psoc_get_avg_buffered_switch_data) |
| 179 | |
| 180 | #define EPM_PSOC_SET_CHANNEL_SWITCH _IOWR(EPM_ADC_IOCTL_CODE, 13, \ |
| 181 | struct epm_psoc_set_channel_switch) |
| 182 | |
| 183 | #define EPM_PSOC_CLEAR_BUFFER _IOWR(EPM_ADC_IOCTL_CODE, 14, \ |
| 184 | uint32_t) |
| 185 | |
| 186 | #define EPM_PSOC_ADC_SET_VADC_REFERENCE _IOWR(EPM_ADC_IOCTL_CODE, 15, \ |
| 187 | struct epm_psoc_set_vadc) |
| 188 | |
Siddartha Mohanadoss | 97242fe | 2013-06-11 16:05:16 -0700 | [diff] [blame] | 189 | #define EPM_PSOC_ADC_DEINIT _IOWR(EPM_ADC_IOCTL_CODE, 16, \ |
| 190 | uint32_t) |
| 191 | |
| 192 | #define EPM_PSOC_GPIO_BUFFER_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 17, \ |
Siddartha Mohanadoss | 46aff91 | 2013-07-10 18:53:48 -0700 | [diff] [blame] | 193 | struct epm_gpio_buffer_request) |
Siddartha Mohanadoss | 97242fe | 2013-06-11 16:05:16 -0700 | [diff] [blame] | 194 | |
| 195 | #define EPM_PSOC_GET_GPIO_BUFFER_DATA _IOWR(EPM_ADC_IOCTL_CODE, 18, \ |
Siddartha Mohanadoss | 46aff91 | 2013-07-10 18:53:48 -0700 | [diff] [blame] | 196 | struct epm_get_gpio_buffer_resp) |
| 197 | |
| 198 | #define EPM_PSOC_PAUSE_CONVERSION_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 19, \ |
Siddartha Mohanadoss | 97242fe | 2013-06-11 16:05:16 -0700 | [diff] [blame] | 199 | uint32_t) |
| 200 | |
Siddartha Mohanadoss | 46aff91 | 2013-07-10 18:53:48 -0700 | [diff] [blame] | 201 | #define EPM_PSOC_UNPAUSE_CONVERSION_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 20, \ |
| 202 | uint32_t) |
Siddartha Mohanadoss | 53c16f9 | 2011-10-17 15:57:15 -0700 | [diff] [blame] | 203 | #endif /* __EPM_ADC_H */ |