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 | eef1deb | 2012-12-06 14:51:27 -0800 | [diff] [blame] | 100 | #ifdef __KERNEL__ |
Siddartha Mohanadoss | 53c16f9 | 2011-10-17 15:57:15 -0700 | [diff] [blame] | 101 | struct 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 Mohanadoss | 79f975f | 2012-07-11 10:13:30 -0700 | [diff] [blame] | 111 | #endif |
Siddartha Mohanadoss | eb90c92 | 2012-03-27 22:58:06 -0700 | [diff] [blame] | 112 | |
| 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 Mohanadoss | efddea4 | 2012-09-04 08:23:43 -0700 | [diff] [blame] | 123 | |
| 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 Mohanadoss | 53c16f9 | 2011-10-17 15:57:15 -0700 | [diff] [blame] | 160 | #endif /* __EPM_ADC_H */ |