extcon-rt8973a.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. * rt8973a.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_RT8973A_H
  12. #define __LINUX_EXTCON_RT8973A_H
  13. enum rt8973a_types {
  14. TYPE_RT8973A,
  15. };
  16. /* RT8973A registers */
  17. enum rt8973A_reg {
  18. RT8973A_REG_DEVICE_ID = 0x1,
  19. RT8973A_REG_CONTROL1,
  20. RT8973A_REG_INT1,
  21. RT8973A_REG_INT2,
  22. RT8973A_REG_INTM1,
  23. RT8973A_REG_INTM2,
  24. RT8973A_REG_ADC,
  25. RT8973A_REG_RSVD_1,
  26. RT8973A_REG_RSVD_2,
  27. RT8973A_REG_DEV1,
  28. RT8973A_REG_DEV2,
  29. RT8973A_REG_RSVD_3,
  30. RT8973A_REG_RSVD_4,
  31. RT8973A_REG_RSVD_5,
  32. RT8973A_REG_RSVD_6,
  33. RT8973A_REG_RSVD_7,
  34. RT8973A_REG_RSVD_8,
  35. RT8973A_REG_RSVD_9,
  36. RT8973A_REG_MANUAL_SW1,
  37. RT8973A_REG_MANUAL_SW2,
  38. RT8973A_REG_RSVD_10,
  39. RT8973A_REG_RSVD_11,
  40. RT8973A_REG_RSVD_12,
  41. RT8973A_REG_RSVD_13,
  42. RT8973A_REG_RSVD_14,
  43. RT8973A_REG_RSVD_15,
  44. RT8973A_REG_RESET,
  45. RT8973A_REG_END,
  46. };
  47. /* Define RT8973A MASK/SHIFT constant */
  48. #define RT8973A_REG_DEVICE_ID_VENDOR_SHIFT 0
  49. #define RT8973A_REG_DEVICE_ID_VERSION_SHIFT 3
  50. #define RT8973A_REG_DEVICE_ID_VENDOR_MASK (0x7 << RT8973A_REG_DEVICE_ID_VENDOR_SHIFT)
  51. #define RT8973A_REG_DEVICE_ID_VERSION_MASK (0x1f << RT8973A_REG_DEVICE_ID_VERSION_SHIFT)
  52. #define RT8973A_REG_CONTROL1_INTM_SHIFT 0
  53. #define RT8973A_REG_CONTROL1_AUTO_CONFIG_SHIFT 2
  54. #define RT8973A_REG_CONTROL1_I2C_RST_EN_SHIFT 3
  55. #define RT8973A_REG_CONTROL1_SWITCH_OPEN_SHIFT 4
  56. #define RT8973A_REG_CONTROL1_CHGTYP_SHIFT 5
  57. #define RT8973A_REG_CONTROL1_USB_CHD_EN_SHIFT 6
  58. #define RT8973A_REG_CONTROL1_ADC_EN_SHIFT 7
  59. #define RT8973A_REG_CONTROL1_INTM_MASK (0x1 << RT8973A_REG_CONTROL1_INTM_SHIFT)
  60. #define RT8973A_REG_CONTROL1_AUTO_CONFIG_MASK (0x1 << RT8973A_REG_CONTROL1_AUTO_CONFIG_SHIFT)
  61. #define RT8973A_REG_CONTROL1_I2C_RST_EN_MASK (0x1 << RT8973A_REG_CONTROL1_I2C_RST_EN_SHIFT)
  62. #define RT8973A_REG_CONTROL1_SWITCH_OPEN_MASK (0x1 << RT8973A_REG_CONTROL1_SWITCH_OPEN_SHIFT)
  63. #define RT8973A_REG_CONTROL1_CHGTYP_MASK (0x1 << RT8973A_REG_CONTROL1_CHGTYP_SHIFT)
  64. #define RT8973A_REG_CONTROL1_USB_CHD_EN_MASK (0x1 << RT8973A_REG_CONTROL1_USB_CHD_EN_SHIFT)
  65. #define RT8973A_REG_CONTROL1_ADC_EN_MASK (0x1 << RT8973A_REG_CONTROL1_ADC_EN_SHIFT)
  66. #define RT9873A_REG_INTM1_ATTACH_SHIFT 0
  67. #define RT9873A_REG_INTM1_DETACH_SHIFT 1
  68. #define RT9873A_REG_INTM1_CHGDET_SHIFT 2
  69. #define RT9873A_REG_INTM1_DCD_T_SHIFT 3
  70. #define RT9873A_REG_INTM1_OVP_SHIFT 4
  71. #define RT9873A_REG_INTM1_CONNECT_SHIFT 5
  72. #define RT9873A_REG_INTM1_ADC_CHG_SHIFT 6
  73. #define RT9873A_REG_INTM1_OTP_SHIFT 7
  74. #define RT9873A_REG_INTM1_ATTACH_MASK (0x1 << RT9873A_REG_INTM1_ATTACH_SHIFT)
  75. #define RT9873A_REG_INTM1_DETACH_MASK (0x1 << RT9873A_REG_INTM1_DETACH_SHIFT)
  76. #define RT9873A_REG_INTM1_CHGDET_MASK (0x1 << RT9873A_REG_INTM1_CHGDET_SHIFT)
  77. #define RT9873A_REG_INTM1_DCD_T_MASK (0x1 << RT9873A_REG_INTM1_DCD_T_SHIFT)
  78. #define RT9873A_REG_INTM1_OVP_MASK (0x1 << RT9873A_REG_INTM1_OVP_SHIFT)
  79. #define RT9873A_REG_INTM1_CONNECT_MASK (0x1 << RT9873A_REG_INTM1_CONNECT_SHIFT)
  80. #define RT9873A_REG_INTM1_ADC_CHG_MASK (0x1 << RT9873A_REG_INTM1_ADC_CHG_SHIFT)
  81. #define RT9873A_REG_INTM1_OTP_MASK (0x1 << RT9873A_REG_INTM1_OTP_SHIFT)
  82. #define RT9873A_REG_INTM2_UVLO_SHIFT 1
  83. #define RT9873A_REG_INTM2_POR_SHIFT 2
  84. #define RT9873A_REG_INTM2_OTP_FET_SHIFT 3
  85. #define RT9873A_REG_INTM2_OVP_FET_SHIFT 4
  86. #define RT9873A_REG_INTM2_OCP_LATCH_SHIFT 5
  87. #define RT9873A_REG_INTM2_OCP_SHIFT 6
  88. #define RT9873A_REG_INTM2_OVP_OCP_SHIFT 7
  89. #define RT9873A_REG_INTM2_UVLO_MASK (0x1 << RT9873A_REG_INTM2_UVLO_SHIFT)
  90. #define RT9873A_REG_INTM2_POR_MASK (0x1 << RT9873A_REG_INTM2_POR_SHIFT)
  91. #define RT9873A_REG_INTM2_OTP_FET_MASK (0x1 << RT9873A_REG_INTM2_OTP_FET_SHIFT)
  92. #define RT9873A_REG_INTM2_OVP_FET_MASK (0x1 << RT9873A_REG_INTM2_OVP_FET_SHIFT)
  93. #define RT9873A_REG_INTM2_OCP_LATCH_MASK (0x1 << RT9873A_REG_INTM2_OCP_LATCH_SHIFT)
  94. #define RT9873A_REG_INTM2_OCP_MASK (0x1 << RT9873A_REG_INTM2_OCP_SHIFT)
  95. #define RT9873A_REG_INTM2_OVP_OCP_MASK (0x1 << RT9873A_REG_INTM2_OVP_OCP_SHIFT)
  96. #define RT8973A_REG_ADC_SHIFT 0
  97. #define RT8973A_REG_ADC_MASK (0x1f << RT8973A_REG_ADC_SHIFT)
  98. #define RT8973A_REG_DEV1_OTG_SHIFT 0
  99. #define RT8973A_REG_DEV1_SDP_SHIFT 2
  100. #define RT8973A_REG_DEV1_UART_SHIFT 3
  101. #define RT8973A_REG_DEV1_CAR_KIT_TYPE1_SHIFT 4
  102. #define RT8973A_REG_DEV1_CDPORT_SHIFT 5
  103. #define RT8973A_REG_DEV1_DCPORT_SHIFT 6
  104. #define RT8973A_REG_DEV1_OTG_MASK (0x1 << RT8973A_REG_DEV1_OTG_SHIFT)
  105. #define RT8973A_REG_DEV1_SDP_MASK (0x1 << RT8973A_REG_DEV1_SDP_SHIFT)
  106. #define RT8973A_REG_DEV1_UART_MASK (0x1 << RT8973A_REG_DEV1_UART_SHIFT)
  107. #define RT8973A_REG_DEV1_CAR_KIT_TYPE1_MASK (0x1 << RT8973A_REG_DEV1_CAR_KIT_TYPE1_SHIFT)
  108. #define RT8973A_REG_DEV1_CDPORT_MASK (0x1 << RT8973A_REG_DEV1_CDPORT_SHIFT)
  109. #define RT8973A_REG_DEV1_DCPORT_MASK (0x1 << RT8973A_REG_DEV1_DCPORT_SHIFT)
  110. #define RT8973A_REG_DEV1_USB_MASK (RT8973A_REG_DEV1_SDP_MASK \
  111. | RT8973A_REG_DEV1_CDPORT_MASK)
  112. #define RT8973A_REG_DEV2_JIG_USB_ON_SHIFT 0
  113. #define RT8973A_REG_DEV2_JIG_USB_OFF_SHIFT 1
  114. #define RT8973A_REG_DEV2_JIG_UART_ON_SHIFT 2
  115. #define RT8973A_REG_DEV2_JIG_UART_OFF_SHIFT 3
  116. #define RT8973A_REG_DEV2_JIG_USB_ON_MASK (0x1 << RT8973A_REG_DEV2_JIG_USB_ON_SHIFT)
  117. #define RT8973A_REG_DEV2_JIG_USB_OFF_MASK (0x1 << RT8973A_REG_DEV2_JIG_USB_OFF_SHIFT)
  118. #define RT8973A_REG_DEV2_JIG_UART_ON_MASK (0x1 << RT8973A_REG_DEV2_JIG_UART_ON_SHIFT)
  119. #define RT8973A_REG_DEV2_JIG_UART_OFF_MASK (0x1 << RT8973A_REG_DEV2_JIG_UART_OFF_SHIFT)
  120. #define RT8973A_REG_MANUAL_SW1_DP_SHIFT 2
  121. #define RT8973A_REG_MANUAL_SW1_DM_SHIFT 5
  122. #define RT8973A_REG_MANUAL_SW1_DP_MASK (0x7 << RT8973A_REG_MANUAL_SW1_DP_SHIFT)
  123. #define RT8973A_REG_MANUAL_SW1_DM_MASK (0x7 << RT8973A_REG_MANUAL_SW1_DM_SHIFT)
  124. #define DM_DP_CON_SWITCH_OPEN 0x0
  125. #define DM_DP_CON_SWITCH_USB 0x1
  126. #define DM_DP_CON_SWITCH_UART 0x3
  127. #define DM_DP_SWITCH_OPEN ((DM_DP_CON_SWITCH_OPEN << RT8973A_REG_MANUAL_SW1_DP_SHIFT) \
  128. | (DM_DP_CON_SWITCH_OPEN << RT8973A_REG_MANUAL_SW1_DM_SHIFT))
  129. #define DM_DP_SWITCH_USB ((DM_DP_CON_SWITCH_USB << RT8973A_REG_MANUAL_SW1_DP_SHIFT) \
  130. | (DM_DP_CON_SWITCH_USB << RT8973A_REG_MANUAL_SW1_DM_SHIFT))
  131. #define DM_DP_SWITCH_UART ((DM_DP_CON_SWITCH_UART << RT8973A_REG_MANUAL_SW1_DP_SHIFT) \
  132. | (DM_DP_CON_SWITCH_UART << RT8973A_REG_MANUAL_SW1_DM_SHIFT))
  133. #define RT8973A_REG_MANUAL_SW2_FET_ON_SHIFT 0
  134. #define RT8973A_REG_MANUAL_SW2_JIG_ON_SHIFT 2
  135. #define RT8973A_REG_MANUAL_SW2_BOOT_SW_SHIFT 3
  136. #define RT8973A_REG_MANUAL_SW2_FET_ON_MASK (0x1 << RT8973A_REG_MANUAL_SW2_FET_ON_SHIFT)
  137. #define RT8973A_REG_MANUAL_SW2_JIG_ON_MASK (0x1 << RT8973A_REG_MANUAL_SW2_JIG_ON_SHIFT)
  138. #define RT8973A_REG_MANUAL_SW2_BOOT_SW_MASK (0x1 << RT8973A_REG_MANUAL_SW2_BOOT_SW_SHIFT)
  139. #define RT8973A_REG_MANUAL_SW2_FET_ON 0
  140. #define RT8973A_REG_MANUAL_SW2_FET_OFF 0x1
  141. #define RT8973A_REG_MANUAL_SW2_JIG_OFF 0
  142. #define RT8973A_REG_MANUAL_SW2_JIG_ON 0x1
  143. #define RT8973A_REG_MANUAL_SW2_BOOT_SW_ON 0
  144. #define RT8973A_REG_MANUAL_SW2_BOOT_SW_OFF 0x1
  145. #define RT8973A_REG_RESET_SHIFT 0
  146. #define RT8973A_REG_RESET_MASK (0x1 << RT8973A_REG_RESET_SHIFT)
  147. #define RT8973A_REG_RESET 0x1
  148. /* RT8973A Interrupts */
  149. enum rt8973a_irq {
  150. /* Interrupt1*/
  151. RT8973A_INT1_ATTACH,
  152. RT8973A_INT1_DETACH,
  153. RT8973A_INT1_CHGDET,
  154. RT8973A_INT1_DCD_T,
  155. RT8973A_INT1_OVP,
  156. RT8973A_INT1_CONNECT,
  157. RT8973A_INT1_ADC_CHG,
  158. RT8973A_INT1_OTP,
  159. /* Interrupt2*/
  160. RT8973A_INT2_UVLO,
  161. RT8973A_INT2_POR,
  162. RT8973A_INT2_OTP_FET,
  163. RT8973A_INT2_OVP_FET,
  164. RT8973A_INT2_OCP_LATCH,
  165. RT8973A_INT2_OCP,
  166. RT8973A_INT2_OVP_OCP,
  167. RT8973A_NUM,
  168. };
  169. #define RT8973A_INT1_ATTACH_MASK BIT(0)
  170. #define RT8973A_INT1_DETACH_MASK BIT(1)
  171. #define RT8973A_INT1_CHGDET_MASK BIT(2)
  172. #define RT8973A_INT1_DCD_T_MASK BIT(3)
  173. #define RT8973A_INT1_OVP_MASK BIT(4)
  174. #define RT8973A_INT1_CONNECT_MASK BIT(5)
  175. #define RT8973A_INT1_ADC_CHG_MASK BIT(6)
  176. #define RT8973A_INT1_OTP_MASK BIT(7)
  177. #define RT8973A_INT2_UVLOT_MASK BIT(0)
  178. #define RT8973A_INT2_POR_MASK BIT(1)
  179. #define RT8973A_INT2_OTP_FET_MASK BIT(2)
  180. #define RT8973A_INT2_OVP_FET_MASK BIT(3)
  181. #define RT8973A_INT2_OCP_LATCH_MASK BIT(4)
  182. #define RT8973A_INT2_OCP_MASK BIT(5)
  183. #define RT8973A_INT2_OVP_OCP_MASK BIT(6)
  184. #endif /* __LINUX_EXTCON_RT8973A_H */