epm_adc.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. #ifndef __EPM_ADC_H
  2. #define __EPM_ADC_H
  3. #include <linux/i2c.h>
  4. struct epm_chan_request {
  5. /* EPM ADC device index. 0 - ADC1, 1 - ADC2 */
  6. uint32_t device_idx;
  7. /* Channel number within the EPM ADC device */
  8. uint32_t channel_idx;
  9. /* The data meaningful for each individual channel whether it is
  10. * voltage, current etc. */
  11. int32_t physical;
  12. };
  13. struct epm_psoc_init_resp {
  14. uint8_t cmd;
  15. uint8_t version;
  16. uint8_t compatible_ver;
  17. uint8_t firm_ver[3];
  18. uint8_t num_dev;
  19. uint8_t num_channel;
  20. };
  21. struct epm_psoc_channel_configure {
  22. uint8_t cmd;
  23. uint8_t device_num;
  24. uint32_t channel_num;
  25. };
  26. struct epm_psoc_set_avg {
  27. uint8_t cmd;
  28. uint8_t avg_period;
  29. uint8_t return_code;
  30. };
  31. struct epm_psoc_get_data {
  32. uint8_t cmd;
  33. uint8_t dev_num;
  34. uint8_t chan_num;
  35. uint32_t timestamp_resp_value;
  36. int16_t reading_raw;
  37. int32_t reading_value;
  38. };
  39. struct epm_psoc_get_buffered_data {
  40. uint8_t cmd;
  41. uint8_t dev_num;
  42. uint8_t status_mask;
  43. uint8_t chan_idx;
  44. uint32_t chan_mask;
  45. uint32_t timestamp_start;
  46. uint32_t timestamp_end;
  47. uint8_t buff_data[48];
  48. };
  49. struct epm_psoc_system_time_stamp {
  50. uint8_t cmd;
  51. uint32_t timestamp;
  52. };
  53. struct epm_psoc_set_channel {
  54. uint8_t cmd;
  55. uint8_t dev_num;
  56. uint32_t channel_mask;
  57. };
  58. struct result_buffer {
  59. uint32_t channel;
  60. uint32_t avg_buffer_sample;
  61. uint32_t result;
  62. };
  63. struct epm_psoc_get_avg_buffered_switch_data {
  64. uint8_t cmd;
  65. uint8_t status;
  66. uint32_t timestamp_start;
  67. uint32_t channel_mask;
  68. uint8_t avg_data[54];
  69. struct result_buffer data[54];
  70. };
  71. struct epm_psoc_set_channel_switch {
  72. uint8_t cmd;
  73. uint8_t dev;
  74. uint32_t delay;
  75. };
  76. struct epm_psoc_set_vadc {
  77. uint8_t cmd;
  78. uint8_t vadc_dev;
  79. uint32_t vadc_voltage;
  80. };
  81. struct epm_chan_properties {
  82. uint32_t resistorvalue;
  83. uint32_t gain;
  84. };
  85. struct epm_marker_level {
  86. uint8_t level;
  87. };
  88. struct epm_gpio_buffer_request {
  89. uint8_t cmd;
  90. uint8_t bitmask_monitor_pin;
  91. uint8_t status;
  92. };
  93. struct epm_get_gpio_buffer_resp {
  94. uint8_t cmd;
  95. uint8_t status;
  96. uint8_t bitmask_monitor_pin;
  97. uint32_t timestamp;
  98. };
  99. #ifdef __KERNEL__
  100. struct 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. };
  110. #endif
  111. #define EPM_ADC_IOCTL_CODE 0x91
  112. #define EPM_ADC_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 1, \
  113. struct epm_chan_request)
  114. #define EPM_ADC_INIT _IOR(EPM_ADC_IOCTL_CODE, 2, \
  115. uint32_t)
  116. #define EPM_ADC_DEINIT _IOR(EPM_ADC_IOCTL_CODE, 3, \
  117. uint32_t)
  118. #define EPM_MARKER1_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 90, \
  119. uint32_t)
  120. #define EPM_MARKER1_RELEASE _IOWR(EPM_ADC_IOCTL_CODE, 91, \
  121. uint32_t)
  122. #define EPM_MARKER2_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 95, \
  123. uint32_t)
  124. #define EPM_MARKER2_RELEASE _IOWR(EPM_ADC_IOCTL_CODE, 92, \
  125. uint32_t)
  126. #define EPM_PSOC_ADC_INIT _IOWR(EPM_ADC_IOCTL_CODE, 4, \
  127. struct epm_psoc_init_resp)
  128. #define EPM_PSOC_ADC_CHANNEL_ENABLE _IOWR(EPM_ADC_IOCTL_CODE, 5, \
  129. struct epm_psoc_channel_configure)
  130. #define EPM_PSOC_ADC_CHANNEL_DISABLE _IOWR(EPM_ADC_IOCTL_CODE, 6, \
  131. struct epm_psoc_channel_configure)
  132. #define EPM_PSOC_ADC_SET_AVERAGING _IOWR(EPM_ADC_IOCTL_CODE, 7, \
  133. struct epm_psoc_set_avg)
  134. #define EPM_PSOC_ADC_GET_LAST_MEASUREMENT _IOWR(EPM_ADC_IOCTL_CODE, 8, \
  135. struct epm_psoc_get_data)
  136. #define EPM_PSOC_ADC_GET_BUFFERED_DATA _IOWR(EPM_ADC_IOCTL_CODE, 9, \
  137. struct epm_psoc_get_buffered_data)
  138. #define EPM_PSOC_ADC_GET_SYSTEM_TIMESTAMP _IOWR(EPM_ADC_IOCTL_CODE, 10, \
  139. struct epm_psoc_system_time_stamp)
  140. #define EPM_PSOC_ADC_SET_SYSTEM_TIMESTAMP _IOWR(EPM_ADC_IOCTL_CODE, 11, \
  141. struct epm_psoc_system_time_stamp)
  142. #define EPM_PSOC_ADC_GET_AVERAGE_DATA _IOWR(EPM_ADC_IOCTL_CODE, 12, \
  143. struct epm_psoc_get_avg_buffered_switch_data)
  144. #define EPM_PSOC_SET_CHANNEL_SWITCH _IOWR(EPM_ADC_IOCTL_CODE, 13, \
  145. struct epm_psoc_set_channel_switch)
  146. #define EPM_PSOC_CLEAR_BUFFER _IOWR(EPM_ADC_IOCTL_CODE, 14, \
  147. uint32_t)
  148. #define EPM_PSOC_ADC_SET_VADC_REFERENCE _IOWR(EPM_ADC_IOCTL_CODE, 15, \
  149. struct epm_psoc_set_vadc)
  150. #define EPM_PSOC_ADC_DEINIT _IOWR(EPM_ADC_IOCTL_CODE, 16, \
  151. uint32_t)
  152. #define EPM_PSOC_GPIO_BUFFER_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 17, \
  153. struct epm_gpio_buffer_request)
  154. #define EPM_PSOC_GET_GPIO_BUFFER_DATA _IOWR(EPM_ADC_IOCTL_CODE, 18, \
  155. struct epm_get_gpio_buffer_resp)
  156. #define EPM_PSOC_PAUSE_CONVERSION_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 19, \
  157. uint32_t)
  158. #define EPM_PSOC_UNPAUSE_CONVERSION_REQUEST _IOWR(EPM_ADC_IOCTL_CODE, 20, \
  159. uint32_t)
  160. #endif /* __EPM_ADC_H */