cm36652.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * This software is licensed under the terms of the GNU General Public
  3. * License version 2, as published by the Free Software Foundation, and
  4. * may be copied, distributed, and modified under those terms.
  5. *
  6. * This program is distributed in the hope that it will be useful,
  7. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. * GNU General Public License for more details.
  10. *
  11. */
  12. /*
  13. * Definitions for CM36652 als/ps sensor chip.
  14. */
  15. #ifndef __CM36652_H__
  16. #define __CM36652_H__
  17. #include <linux/ioctl.h>
  18. /*cm36652 als/ps sensor register related macro*/
  19. #define CM36652_REG_CS_CONF 0X00
  20. #define CM36652_REG_ALS_THDH 0X01
  21. #define CM36652_REG_ALS_THDL 0X02
  22. #define CM36652_REG_PS_CONF1_2 0X03
  23. #define CM36652_REG_PS_THD 0X05
  24. #define CM36652_REG_PS_CANC 0X06
  25. #define CM36652_REG_PS_DATA 0X07
  26. #define CM36652_REG_ALS_DATA 0X09
  27. #define CM36652_REG_INT_FLAG 0X0C
  28. #define CM36652_REG_ID_MODE 0X0D
  29. /*CM36652 related driver tag macro*/
  30. #define CM36652_SUCCESS 0
  31. #define CM36652_ERR_I2C -1
  32. #define CM36652_ERR_STATUS -3
  33. #define CM36652_ERR_SETUP_FAILURE -4
  34. #define CM36652_ERR_GETGSENSORDATA -5
  35. #define CM36652_ERR_IDENTIFICATION -6
  36. /*----------------------------------------------------------------------------*/
  37. enum CM36652_NOTIFY_TYPE {
  38. CM36652_NOTIFY_PROXIMITY_CHANGE = 1,
  39. };
  40. /*----------------------------------------------------------------------------*/
  41. enum CM36652_CUST_ACTION {
  42. CM36652_CUST_ACTION_SET_CUST = 1,
  43. CM36652_CUST_ACTION_CLR_CALI,
  44. CM36652_CUST_ACTION_SET_CALI,
  45. CM36652_CUST_ACTION_SET_PS_THRESHODL,
  46. CM36652_CUST_ACTION_SET_EINT_INFO,
  47. CM36652_CUST_ACTION_GET_ALS_RAW_DATA,
  48. CM36652_CUST_ACTION_GET_PS_RAW_DATA,
  49. };
  50. /*----------------------------------------------------------------------------*/
  51. struct CM36652_CUST {
  52. uint16_t action;
  53. };
  54. /*----------------------------------------------------------------------------*/
  55. struct CM36652_SET_CUST {
  56. uint16_t action;
  57. uint16_t part;
  58. int32_t data[0];
  59. };
  60. /*----------------------------------------------------------------------------*/
  61. struct CM36652_SET_CALI {
  62. uint16_t action;
  63. int32_t cali;
  64. };
  65. /*----------------------------------------------------------------------------*/
  66. struct CM36652_SET_PS_THRESHOLD {
  67. uint16_t action;
  68. int32_t threshold[2];
  69. };
  70. /*----------------------------------------------------------------------------*/
  71. struct CM36652_SET_EINT_INFO {
  72. uint16_t action;
  73. uint32_t gpio_pin;
  74. uint32_t gpio_mode;
  75. uint32_t eint_num;
  76. uint32_t eint_is_deb_en;
  77. uint32_t eint_type;
  78. };
  79. /*----------------------------------------------------------------------------*/
  80. struct CM36652_GET_ALS_RAW_DATA {
  81. uint16_t action;
  82. uint16_t als;
  83. };
  84. /*----------------------------------------------------------------------------*/
  85. struct CM36652_GET_PS_RAW_DATA {
  86. uint16_t action;
  87. uint16_t ps;
  88. };
  89. /*----------------------------------------------------------------------------*/
  90. union CM36652_CUST_DATA {
  91. uint32_t data[10];
  92. struct CM36652_CUST cust;
  93. struct CM36652_SET_CUST setCust;
  94. struct CM36652_CUST clearCali;
  95. struct CM36652_SET_CALI setCali;
  96. struct CM36652_SET_PS_THRESHOLD setPSThreshold;
  97. struct CM36652_SET_EINT_INFO setEintInfo;
  98. struct CM36652_GET_ALS_RAW_DATA getALSRawData;
  99. struct CM36652_GET_PS_RAW_DATA getPSRawData;
  100. };
  101. /*----------------------------------------------------------------------------*/
  102. extern struct platform_device *get_alsps_platformdev(void);
  103. #endif