cypress_touchkey.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. #ifndef _CYPRESS_TOUCHKEY_H
  2. #define _CYPRESS_TOUCHKEY_H
  3. #include <linux/module.h>
  4. #include <linux/init.h>
  5. #include <linux/kernel.h>
  6. #include <linux/input.h>
  7. #include <linux/i2c.h>
  8. #include <linux/interrupt.h>
  9. #include <linux/slab.h>
  10. #include <linux/hrtimer.h>
  11. #include <linux/gpio.h>
  12. #include <linux/irq.h>
  13. #include <linux/delay.h>
  14. #include <linux/wakelock.h>
  15. #ifdef CONFIG_HAS_EARLYSUSPEND
  16. #include <linux/earlysuspend.h>
  17. #endif
  18. #include <linux/i2c/touchkey_hl.h>
  19. /* Touchkey Register */
  20. #define CYPRESS_REG_STATUS 0x00
  21. #define CYPRESS_REG_FW_VER 0X01
  22. #define CYPRESS_REG_MD_VER 0X02
  23. #define CYPRESS_REG_COMMAND 0X03
  24. #define CYPRESS_REG_THRESHOLD 0X04
  25. #define CYPRESS_REG_AUTOCAL 0X05
  26. #define CYPRESS_REG_IDAC 0X06
  27. #define CYPRESS_REG_DIFF 0X0A
  28. #define CYPRESS_REG_RAW 0X0E
  29. #define CYPRESS_REG_BASE 0X12
  30. #define CYPRESS_REG_CRC 0X16
  31. #define CYPRESS_REG_DETECTION 0x18
  32. #define CYPRESS_REG_DETECTION_FLAG 0x1B
  33. #define KEYCODE_REG 0x00
  34. #define TK_BIT_PRESS_EV 0x08
  35. #define TK_BIT_KEYCODE 0x07
  36. #define TK_BIT_AUTOCAL 0x80
  37. #define TK_BIT_GLOVE 0x40
  38. #define TK_BIT_TA_ON 0x10
  39. #define TK_BIT_FW_ID_55 0x20
  40. #define TK_BIT_FW_ID_65 0x04
  41. #define TK_BIT_DETECTION_CONFIRM 0xEE
  42. #define TK_CMD_LED_ON 0x10
  43. #define TK_CMD_LED_OFF 0x20
  44. #define TK_CMD_DUAL_DETECTION 0x01
  45. #define I2C_M_WR 0 /* for i2c */
  46. #define TK_UPDATE_DOWN 1
  47. #define TK_UPDATE_FAIL -1
  48. #define TK_UPDATE_PASS 0
  49. /* Flip cover*/
  50. #define TKEY_FLIP_MODE
  51. #ifdef TKEY_FLIP_MODE
  52. #define TK_BIT_FLIP 0x08
  53. #endif
  54. #ifdef TK_USE_LDO_CONTROL
  55. /* LDO Regulator */
  56. #define TKEY_I2C_REGULATOR "8941_lvs3"
  57. /* LDO Regulator */
  58. #define TKEY_LED_REGULATOR "8941_l13"
  59. /* LED LDO Type*/
  60. #define LED_LDO_WITH_REGULATOR
  61. #endif
  62. /* Autocalibration */
  63. #define TK_HAS_AUTOCAL
  64. /* Generalized SMBus access */
  65. #define TK_USE_GENERAL_SMBUS
  66. /* Boot-up Firmware Update */
  67. #define TK_HAS_FIRMWARE_UPDATE
  68. #define TK_UPDATABLE_BD_ID 0
  69. #if defined(CONFIG_SEC_S_PROJECT)
  70. #define CYPRESS_CRC_CHECK
  71. #define TK_USE_RECENT
  72. #define FW_PATH "tkey/s_cypress_tkey.fw"
  73. #define TOUCHKEY_BOOSTER
  74. #else
  75. #define FW_PATH "tkey/fresco_n_cypress_tkey.fw"
  76. #endif
  77. #define TKEY_MODULE07_HWID 8
  78. #define TKEY_FW_PATH "/sdcard/cypress/fw.bin"
  79. #define TOUCHKEY_FW_UPDATEABLE_HW_REV 11
  80. #if defined(CONFIG_SEC_S_PROJECT)
  81. #define CYPRESS_RECENT_BACK_REPORT_FW_VER 0x0D
  82. #elif defined(CONFIG_SEC_FRESCO_PROJECT)
  83. #define CYPRESS_RECENT_BACK_REPORT_FW_VER 0x0B
  84. #else
  85. #define CYPRESS_RECENT_BACK_REPORT_FW_VER 0xFF
  86. #endif
  87. #ifdef TOUCHKEY_BOOSTER
  88. #include <linux/cpufreq.h>
  89. #define TKEY_BOOSTER_ON_TIME 500
  90. #define TKEY_BOOSTER_OFF_TIME 500
  91. #define TKEY_BOOSTER_CHG_TIME 130
  92. enum BOOST_LEVEL {
  93. TKEY_BOOSTER_DISABLE = 0,
  94. TKEY_BOOSTER_LEVEL1,
  95. TKEY_BOOSTER_LEVEL2,
  96. };
  97. #endif
  98. /* #define TK_USE_OPEN_DWORK */
  99. #ifdef TK_USE_OPEN_DWORK
  100. #define TK_OPEN_DWORK_TIME 10
  101. #endif
  102. #ifdef CONFIG_GLOVE_TOUCH
  103. #define TK_GLOVE_DWORK_TIME 300
  104. #endif
  105. //#define TKEY_GRIP_MODE
  106. #define TK_KEYPAD_ENABLE
  107. enum {
  108. FW_NONE = 0,
  109. FW_BUILT_IN,
  110. FW_HEADER,
  111. FW_IN_SDCARD,
  112. FW_EX_SDCARD,
  113. };
  114. /* header ver 1 */
  115. struct fw_image {
  116. u8 hdr_ver;
  117. u8 hdr_len;
  118. u16 first_fw_ver;
  119. u16 second_fw_ver;
  120. u16 third_ver;
  121. u32 fw_len;
  122. u16 checksum;
  123. u16 alignment_dummy;
  124. u8 data[0];
  125. } __attribute__ ((packed));
  126. enum {
  127. MODE_NORMAL = 0,
  128. MODE_GRIP,
  129. };
  130. #define TKEY_CMD_GRIP 0x80
  131. /*Parameters for i2c driver*/
  132. struct touchkey_i2c {
  133. struct i2c_client *client;
  134. struct input_dev *input_dev;
  135. struct completion init_done;
  136. #ifdef CONFIG_HAS_EARLYSUSPEND
  137. struct early_suspend early_suspend;
  138. #endif
  139. struct mutex lock;
  140. struct mutex i2c_lock;
  141. struct mutex irq_lock;
  142. struct wake_lock fw_wakelock;
  143. struct device *dev;
  144. int irq;
  145. int md_ver_ic; /*module ver*/
  146. int fw_ver_ic;
  147. int firmware_id;
  148. struct touchkey_platform_data *pdata;
  149. char *name;
  150. int (*power)(int on);
  151. int update_status;
  152. bool enabled;
  153. #ifdef TOUCHKEY_BOOSTER
  154. bool dvfs_lock_status;
  155. struct delayed_work work_dvfs_off;
  156. struct delayed_work work_dvfs_chg;
  157. struct mutex dvfs_lock;
  158. int dvfs_old_stauts;
  159. int dvfs_boost_mode;
  160. int dvfs_freq;
  161. #endif
  162. #ifdef TK_USE_OPEN_DWORK
  163. struct delayed_work open_work;
  164. #endif
  165. #ifdef CONFIG_GLOVE_TOUCH
  166. struct work_struct glove_change_work;
  167. int ic_mode;
  168. bool tsk_cmd_glove;
  169. bool tsk_enable_glove_mode;
  170. struct mutex tsk_glove_lock;
  171. #endif
  172. #ifdef TK_INFORM_CHARGER
  173. struct touchkey_callbacks callbacks;
  174. bool charging_mode;
  175. #endif
  176. #ifdef TKEY_FLIP_MODE
  177. bool enabled_flip;
  178. #endif
  179. #ifdef TKEY_GRIP_MODE
  180. bool grip_mode;
  181. u8 ic_mode;
  182. bool pwr_flag;
  183. struct mutex grip_mode_lock;
  184. #endif
  185. bool status_update;
  186. struct work_struct update_work;
  187. struct workqueue_struct *fw_wq;
  188. u8 fw_path;
  189. const struct firmware *firm_data;
  190. struct fw_image *fw_img;
  191. bool do_checksum;
  192. #ifdef TK_KEYPAD_ENABLE
  193. bool keypad_enable;
  194. #endif
  195. };
  196. extern struct class *sec_class;
  197. extern unsigned int system_rev;
  198. #endif /* _CYPRESS_TOUCHKEY_H */