extcon-sm5502.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /*
  2. * sm5502.h
  3. *
  4. * Copyright (c) 2014 Samsung Electronics Co., Ltd
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. */
  11. #ifndef __LINUX_EXTCON_SM5502_H
  12. #define __LINUX_EXTCON_SM5502_H
  13. enum sm5502_types {
  14. TYPE_SM5502,
  15. };
  16. /* SM5502 registers */
  17. enum sm5502_reg {
  18. SM5502_REG_DEVICE_ID = 0x01,
  19. SM5502_REG_CONTROL,
  20. SM5502_REG_INT1,
  21. SM5502_REG_INT2,
  22. SM5502_REG_INTMASK1,
  23. SM5502_REG_INTMASK2,
  24. SM5502_REG_ADC,
  25. SM5502_REG_TIMING_SET1,
  26. SM5502_REG_TIMING_SET2,
  27. SM5502_REG_DEV_TYPE1,
  28. SM5502_REG_DEV_TYPE2,
  29. SM5502_REG_BUTTON1,
  30. SM5502_REG_BUTTON2,
  31. SM5502_REG_CAR_KIT_STATUS,
  32. SM5502_REG_RSVD1,
  33. SM5502_REG_RSVD2,
  34. SM5502_REG_RSVD3,
  35. SM5502_REG_RSVD4,
  36. SM5502_REG_MANUAL_SW1,
  37. SM5502_REG_MANUAL_SW2,
  38. SM5502_REG_DEV_TYPE3,
  39. SM5502_REG_RSVD5,
  40. SM5502_REG_RSVD6,
  41. SM5502_REG_RSVD7,
  42. SM5502_REG_RSVD8,
  43. SM5502_REG_RSVD9,
  44. SM5502_REG_RESET,
  45. SM5502_REG_RSVD10,
  46. SM5502_REG_RESERVED_ID1,
  47. SM5502_REG_RSVD11,
  48. SM5502_REG_RSVD12,
  49. SM5502_REG_RESERVED_ID2,
  50. SM5502_REG_RSVD13,
  51. SM5502_REG_OCP,
  52. SM5502_REG_RSVD14,
  53. SM5502_REG_RSVD15,
  54. SM5502_REG_RSVD16,
  55. SM5502_REG_RSVD17,
  56. SM5502_REG_RSVD18,
  57. SM5502_REG_RSVD19,
  58. SM5502_REG_RSVD20,
  59. SM5502_REG_RSVD21,
  60. SM5502_REG_RSVD22,
  61. SM5502_REG_RSVD23,
  62. SM5502_REG_RSVD24,
  63. SM5502_REG_RSVD25,
  64. SM5502_REG_RSVD26,
  65. SM5502_REG_RSVD27,
  66. SM5502_REG_RSVD28,
  67. SM5502_REG_RSVD29,
  68. SM5502_REG_RSVD30,
  69. SM5502_REG_RSVD31,
  70. SM5502_REG_RSVD32,
  71. SM5502_REG_RSVD33,
  72. SM5502_REG_RSVD34,
  73. SM5502_REG_RSVD35,
  74. SM5502_REG_RSVD36,
  75. SM5502_REG_RESERVED_ID3,
  76. SM5502_REG_END,
  77. };
  78. /* Define SM5502 MASK/SHIFT constant */
  79. #define SM5502_REG_DEVICE_ID_VENDOR_SHIFT 0
  80. #define SM5502_REG_DEVICE_ID_VERSION_SHIFT 3
  81. #define SM5502_REG_DEVICE_ID_VENDOR_MASK (0x3 << SM5502_REG_DEVICE_ID_VENDOR_SHIFT)
  82. #define SM5502_REG_DEVICE_ID_VERSION_MASK (0x1f << SM5502_REG_DEVICE_ID_VERSION_SHIFT)
  83. #define SM5502_REG_CONTROL_MASK_INT_SHIFT 0
  84. #define SM5502_REG_CONTROL_WAIT_SHIFT 1
  85. #define SM5502_REG_CONTROL_MANUAL_SW_SHIFT 2
  86. #define SM5502_REG_CONTROL_RAW_DATA_SHIFT 3
  87. #define SM5502_REG_CONTROL_SW_OPEN_SHIFT 4
  88. #define SM5502_REG_CONTROL_MASK_INT_MASK (0x1 << SM5502_REG_CONTROL_MASK_INT_SHIFT)
  89. #define SM5502_REG_CONTROL_WAIT_MASK (0x1 << SM5502_REG_CONTROL_WAIT_SHIFT)
  90. #define SM5502_REG_CONTROL_MANUAL_SW_MASK (0x1 << SM5502_REG_CONTROL_MANUAL_SW_SHIFT)
  91. #define SM5502_REG_CONTROL_RAW_DATA_MASK (0x1 << SM5502_REG_CONTROL_RAW_DATA_SHIFT)
  92. #define SM5502_REG_CONTROL_SW_OPEN_MASK (0x1 << SM5502_REG_CONTROL_SW_OPEN_SHIFT)
  93. #define SM5502_REG_INTM1_ATTACH_SHIFT 0
  94. #define SM5502_REG_INTM1_DETACH_SHIFT 1
  95. #define SM5502_REG_INTM1_KP_SHIFT 2
  96. #define SM5502_REG_INTM1_LKP_SHIFT 3
  97. #define SM5502_REG_INTM1_LKR_SHIFT 4
  98. #define SM5502_REG_INTM1_OVP_EVENT_SHIFT 5
  99. #define SM5502_REG_INTM1_OCP_EVENT_SHIFT 6
  100. #define SM5502_REG_INTM1_OVP_OCP_DIS_SHIFT 7
  101. #define SM5502_REG_INTM1_ATTACH_MASK (0x1 << SM5502_REG_INTM1_ATTACH_SHIFT)
  102. #define SM5502_REG_INTM1_DETACH_MASK (0x1 << SM5502_REG_INTM1_DETACH_SHIFT)
  103. #define SM5502_REG_INTM1_KP_MASK (0x1 << SM5502_REG_INTM1_KP_SHIFT)
  104. #define SM5502_REG_INTM1_LKP_MASK (0x1 << SM5502_REG_INTM1_LKP_SHIFT)
  105. #define SM5502_REG_INTM1_LKR_MASK (0x1 << SM5502_REG_INTM1_LKR_SHIFT)
  106. #define SM5502_REG_INTM1_OVP_EVENT_MASK (0x1 << SM5502_REG_INTM1_OVP_EVENT_SHIFT)
  107. #define SM5502_REG_INTM1_OCP_EVENT_MASK (0x1 << SM5502_REG_INTM1_OCP_EVENT_SHIFT)
  108. #define SM5502_REG_INTM1_OVP_OCP_DIS_MASK (0x1 << SM5502_REG_INTM1_OVP_OCP_DIS_SHIFT)
  109. #define SM5502_REG_INTM2_VBUS_DET_SHIFT 0
  110. #define SM5502_REG_INTM2_REV_ACCE_SHIFT 1
  111. #define SM5502_REG_INTM2_ADC_CHG_SHIFT 2
  112. #define SM5502_REG_INTM2_STUCK_KEY_SHIFT 3
  113. #define SM5502_REG_INTM2_STUCK_KEY_RCV_SHIFT 4
  114. #define SM5502_REG_INTM2_MHL_SHIFT 5
  115. #define SM5502_REG_INTM2_VBUS_DET_MASK (0x1 << SM5502_REG_INTM2_VBUS_DET_SHIFT)
  116. #define SM5502_REG_INTM2_REV_ACCE_MASK (0x1 << SM5502_REG_INTM2_REV_ACCE_SHIFT)
  117. #define SM5502_REG_INTM2_ADC_CHG_MASK (0x1 << SM5502_REG_INTM2_ADC_CHG_SHIFT)
  118. #define SM5502_REG_INTM2_STUCK_KEY_MASK (0x1 << SM5502_REG_INTM2_STUCK_KEY_SHIFT)
  119. #define SM5502_REG_INTM2_STUCK_KEY_RCV_MASK (0x1 << SM5502_REG_INTM2_STUCK_KEY_RCV_SHIFT)
  120. #define SM5502_REG_INTM2_MHL_MASK (0x1 << SM5502_REG_INTM2_MHL_SHIFT)
  121. #define SM5502_REG_ADC_SHIFT 0
  122. #define SM5502_REG_ADC_MASK (0x1f << SM5502_REG_ADC_SHIFT)
  123. #define SM5502_REG_TIMING_SET1_KEY_PRESS_SHIFT 4
  124. #define SM5502_REG_TIMING_SET1_KEY_PRESS_MASK (0xf << SM5502_REG_TIMING_SET1_KEY_PRESS_SHIFT)
  125. #define TIMING_KEY_PRESS_100MS 0x0
  126. #define TIMING_KEY_PRESS_200MS 0x1
  127. #define TIMING_KEY_PRESS_300MS 0x2
  128. #define TIMING_KEY_PRESS_400MS 0x3
  129. #define TIMING_KEY_PRESS_500MS 0x4
  130. #define TIMING_KEY_PRESS_600MS 0x5
  131. #define TIMING_KEY_PRESS_700MS 0x6
  132. #define TIMING_KEY_PRESS_800MS 0x7
  133. #define TIMING_KEY_PRESS_900MS 0x8
  134. #define TIMING_KEY_PRESS_1000MS 0x9
  135. #define SM5502_REG_TIMING_SET1_ADC_DET_SHIFT 0
  136. #define SM5502_REG_TIMING_SET1_ADC_DET_MASK (0xf << SM5502_REG_TIMING_SET1_ADC_DET_SHIFT)
  137. #define TIMING_ADC_DET_50MS 0x0
  138. #define TIMING_ADC_DET_100MS 0x1
  139. #define TIMING_ADC_DET_150MS 0x2
  140. #define TIMING_ADC_DET_200MS 0x3
  141. #define TIMING_ADC_DET_300MS 0x4
  142. #define TIMING_ADC_DET_400MS 0x5
  143. #define TIMING_ADC_DET_500MS 0x6
  144. #define TIMING_ADC_DET_600MS 0x7
  145. #define TIMING_ADC_DET_700MS 0x8
  146. #define TIMING_ADC_DET_800MS 0x9
  147. #define TIMING_ADC_DET_900MS 0xA
  148. #define TIMING_ADC_DET_1000MS 0xB
  149. #define SM5502_REG_TIMING_SET2_SW_WAIT_SHIFT 4
  150. #define SM5502_REG_TIMING_SET2_SW_WAIT_MASK (0xf << SM5502_REG_TIMING_SET2_SW_WAIT_SHIFT)
  151. #define TIMING_SW_WAIT_10MS 0x0
  152. #define TIMING_SW_WAIT_30MS 0x1
  153. #define TIMING_SW_WAIT_50MS 0x2
  154. #define TIMING_SW_WAIT_70MS 0x3
  155. #define TIMING_SW_WAIT_90MS 0x4
  156. #define TIMING_SW_WAIT_110MS 0x5
  157. #define TIMING_SW_WAIT_130MS 0x6
  158. #define TIMING_SW_WAIT_150MS 0x7
  159. #define TIMING_SW_WAIT_170MS 0x8
  160. #define TIMING_SW_WAIT_190MS 0x9
  161. #define TIMING_SW_WAIT_210MS 0xA
  162. #define SM5502_REG_TIMING_SET2_LONG_KEY_SHIFT 0
  163. #define SM5502_REG_TIMING_SET2_LONG_KEY_MASK (0xf << SM5502_REG_TIMING_SET2_LONG_KEY_SHIFT)
  164. #define TIMING_LONG_KEY_300MS 0x0
  165. #define TIMING_LONG_KEY_400MS 0x1
  166. #define TIMING_LONG_KEY_500MS 0x2
  167. #define TIMING_LONG_KEY_600MS 0x3
  168. #define TIMING_LONG_KEY_700MS 0x4
  169. #define TIMING_LONG_KEY_800MS 0x5
  170. #define TIMING_LONG_KEY_900MS 0x6
  171. #define TIMING_LONG_KEY_1000MS 0x7
  172. #define TIMING_LONG_KEY_1100MS 0x8
  173. #define TIMING_LONG_KEY_1200MS 0x9
  174. #define TIMING_LONG_KEY_1300MS 0xA
  175. #define TIMING_LONG_KEY_1400MS 0xB
  176. #define TIMING_LONG_KEY_1500MS 0xC
  177. #define SM5502_REG_DEV_TYPE1_AUDIO_TYPE1_SHIFT 0
  178. #define SM5502_REG_DEV_TYPE1_AUDIO_TYPE2_SHIFT 1
  179. #define SM5502_REG_DEV_TYPE1_USB_SDP_SHIFT 2
  180. #define SM5502_REG_DEV_TYPE1_UART_SHIFT 3
  181. #define SM5502_REG_DEV_TYPE1_CAR_KIT_CHARGER_SHIFT 4
  182. #define SM5502_REG_DEV_TYPE1_USB_CHG_SHIFT 5
  183. #define SM5502_REG_DEV_TYPE1_DEDICATED_CHG_SHIFT 6
  184. #define SM5502_REG_DEV_TYPE1_USB_OTG_SHIFT 7
  185. #define SM5502_REG_DEV_TYPE1_AUDIO_TYPE1_MASK (0x1 << SM5502_REG_DEV_TYPE1_AUDIO_TYPE1_SHIFT)
  186. #define SM5502_REG_DEV_TYPE1_AUDIO_TYPE1__MASK (0x1 << SM5502_REG_DEV_TYPE1_AUDIO_TYPE2_SHIFT)
  187. #define SM5502_REG_DEV_TYPE1_USB_SDP_MASK (0x1 << SM5502_REG_DEV_TYPE1_USB_SDP_SHIFT)
  188. #define SM5502_REG_DEV_TYPE1_UART_MASK (0x1 << SM5502_REG_DEV_TYPE1_UART_SHIFT)
  189. #define SM5502_REG_DEV_TYPE1_CAR_KIT_CHARGER_MASK (0x1 << SM5502_REG_DEV_TYPE1_CAR_KIT_CHARGER_SHIFT)
  190. #define SM5502_REG_DEV_TYPE1_USB_CHG_MASK (0x1 << SM5502_REG_DEV_TYPE1_USB_CHG_SHIFT)
  191. #define SM5502_REG_DEV_TYPE1_DEDICATED_CHG_MASK (0x1 << SM5502_REG_DEV_TYPE1_DEDICATED_CHG_SHIFT)
  192. #define SM5502_REG_DEV_TYPE1_USB_OTG_MASK (0x1 << SM5502_REG_DEV_TYPE1_USB_OTG_SHIFT)
  193. #define SM5502_REG_DEV_TYPE2_JIG_USB_ON_SHIFT 0
  194. #define SM5502_REG_DEV_TYPE2_JIG_USB_OFF_SHIFT 1
  195. #define SM5502_REG_DEV_TYPE2_JIG_UART_ON_SHIFT 2
  196. #define SM5502_REG_DEV_TYPE2_JIG_UART_OFF_SHIFT 3
  197. #define SM5502_REG_DEV_TYPE2_PPD_SHIFT 4
  198. #define SM5502_REG_DEV_TYPE2_TTY_SHIFT 5
  199. #define SM5502_REG_DEV_TYPE2_AV_CABLE_SHIFT 6
  200. #define SM5502_REG_DEV_TYPE2_JIG_USB_ON_MASK (0x1 << SM5502_REG_DEV_TYPE2_JIG_USB_ON_SHIFT)
  201. #define SM5502_REG_DEV_TYPE2_JIG_USB_OFF_MASK (0x1 << SM5502_REG_DEV_TYPE2_JIG_USB_OFF_SHIFT)
  202. #define SM5502_REG_DEV_TYPE2_JIG_UART_ON_MASK (0x1 << SM5502_REG_DEV_TYPE2_JIG_UART_ON_SHIFT)
  203. #define SM5502_REG_DEV_TYPE2_JIG_UART_OFF_MASK (0x1 << SM5502_REG_DEV_TYPE2_JIG_UART_OFF_SHIFT)
  204. #define SM5502_REG_DEV_TYPE2_PPD_MASK (0x1 << SM5502_REG_DEV_TYPE2_PPD_SHIFT)
  205. #define SM5502_REG_DEV_TYPE2_TTY_MASK (0x1 << SM5502_REG_DEV_TYPE2_TTY_SHIFT)
  206. #define SM5502_REG_DEV_TYPE2_AV_CABLE_MASK (0x1 << SM5502_REG_DEV_TYPE2_AV_CABLE_SHIFT)
  207. #define SM5502_REG_MANUAL_SW1_VBUSIN_SHIFT 0
  208. #define SM5502_REG_MANUAL_SW1_DP_SHIFT 2
  209. #define SM5502_REG_MANUAL_SW1_DM_SHIFT 5
  210. #define SM5502_REG_MANUAL_SW1_VBUSIN_MASK (0x3 << SM5502_REG_MANUAL_SW1_VBUSIN_SHIFT)
  211. #define SM5502_REG_MANUAL_SW1_DP_MASK (0x7 << SM5502_REG_MANUAL_SW1_DP_SHIFT)
  212. #define SM5502_REG_MANUAL_SW1_DM_MASK (0x7 << SM5502_REG_MANUAL_SW1_DM_SHIFT)
  213. #define VBUSIN_SWITCH_OPEN 0x0
  214. #define VBUSIN_SWITCH_VBUSOUT 0x1
  215. #define VBUSIN_SWITCH_MIC 0x2
  216. #define VBUSIN_SWITCH_VBUSOUT_WITH_USB 0x3
  217. #define DM_DP_CON_SWITCH_OPEN 0x0
  218. #define DM_DP_CON_SWITCH_USB 0x1
  219. #define DM_DP_CON_SWITCH_AUDIO 0x2
  220. #define DM_DP_CON_SWITCH_UART 0x3
  221. #define DM_DP_SWITCH_OPEN ((DM_DP_CON_SWITCH_OPEN <<SM5502_REG_MANUAL_SW1_DP_SHIFT) \
  222. | (DM_DP_CON_SWITCH_OPEN <<SM5502_REG_MANUAL_SW1_DM_SHIFT))
  223. #define DM_DP_SWITCH_USB ((DM_DP_CON_SWITCH_USB <<SM5502_REG_MANUAL_SW1_DP_SHIFT) \
  224. | (DM_DP_CON_SWITCH_USB <<SM5502_REG_MANUAL_SW1_DM_SHIFT))
  225. #define DM_DP_SWITCH_AUDIO ((DM_DP_CON_SWITCH_AUDIO <<SM5502_REG_MANUAL_SW1_DP_SHIFT) \
  226. | (DM_DP_CON_SWITCH_AUDIO <<SM5502_REG_MANUAL_SW1_DM_SHIFT))
  227. #define DM_DP_SWITCH_UART ((DM_DP_CON_SWITCH_UART <<SM5502_REG_MANUAL_SW1_DP_SHIFT) \
  228. | (DM_DP_CON_SWITCH_UART <<SM5502_REG_MANUAL_SW1_DM_SHIFT))
  229. /* SM5502 Interrupts */
  230. enum sm5502_irq {
  231. /* INT1 */
  232. SM5502_IRQ_INT1_ATTACH,
  233. SM5502_IRQ_INT1_DETACH,
  234. SM5502_IRQ_INT1_KP,
  235. SM5502_IRQ_INT1_LKP,
  236. SM5502_IRQ_INT1_LKR,
  237. SM5502_IRQ_INT1_OVP_EVENT,
  238. SM5502_IRQ_INT1_OCP_EVENT,
  239. SM5502_IRQ_INT1_OVP_OCP_DIS,
  240. /* INT2 */
  241. SM5502_IRQ_INT2_VBUS_DET,
  242. SM5502_IRQ_INT2_REV_ACCE,
  243. SM5502_IRQ_INT2_ADC_CHG,
  244. SM5502_IRQ_INT2_STUCK_KEY,
  245. SM5502_IRQ_INT2_STUCK_KEY_RCV,
  246. SM5502_IRQ_INT2_MHL,
  247. SM5502_IRQ_NUM,
  248. };
  249. #define SM5502_IRQ_INT1_ATTACH_MASK BIT(0)
  250. #define SM5502_IRQ_INT1_DETACH_MASK BIT(1)
  251. #define SM5502_IRQ_INT1_KP_MASK BIT(2)
  252. #define SM5502_IRQ_INT1_LKP_MASK BIT(3)
  253. #define SM5502_IRQ_INT1_LKR_MASK BIT(4)
  254. #define SM5502_IRQ_INT1_OVP_EVENT_MASK BIT(5)
  255. #define SM5502_IRQ_INT1_OCP_EVENT_MASK BIT(6)
  256. #define SM5502_IRQ_INT1_OVP_OCP_DIS_MASK BIT(7)
  257. #define SM5502_IRQ_INT2_VBUS_DET_MASK BIT(0)
  258. #define SM5502_IRQ_INT2_REV_ACCE_MASK BIT(1)
  259. #define SM5502_IRQ_INT2_ADC_CHG_MASK BIT(2)
  260. #define SM5502_IRQ_INT2_STUCK_KEY_MASK BIT(3)
  261. #define SM5502_IRQ_INT2_STUCK_KEY_RCV_MASK BIT(4)
  262. #define SM5502_IRQ_INT2_MHL_MASK BIT(5)
  263. #endif /* __LINUX_EXTCON_SM5502_H */