fsa9485.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /*
  2. * Copyright (C) 2010 Samsung Electronics
  3. * Minkyu Kang <mk7.kang@samsung.com>
  4. * Wonguk Jeong <wonguk.jeong@samsung.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. */
  21. #ifndef _FSA9485_H_
  22. #define _FSA9485_H_
  23. /* FSA9485 I2C registers */
  24. #define FSA9485_REG_DEVID 0x01
  25. #define FSA9485_REG_CTRL 0x02
  26. #define FSA9485_REG_INT1 0x03
  27. #define FSA9485_REG_INT2 0x04
  28. #define FSA9485_REG_INT1_MASK 0x05
  29. #define FSA9485_REG_INT2_MASK 0x06
  30. #define FSA9485_REG_ADC 0x07
  31. #define FSA9485_REG_TIMING1 0x08
  32. #define FSA9485_REG_TIMING2 0x09
  33. #define FSA9485_REG_DEV_T1 0x0a
  34. #define FSA9485_REG_DEV_T2 0x0b
  35. #define FSA9485_REG_BTN1 0x0c
  36. #define FSA9485_REG_BTN2 0x0d
  37. #define FSA9485_REG_CK 0x0e
  38. #define FSA9485_REG_CK_INT1 0x0f
  39. #define FSA9485_REG_CK_INT2 0x10
  40. #define FSA9485_REG_CK_INTMASK1 0x11
  41. #define FSA9485_REG_CK_INTMASK2 0x12
  42. #define FSA9485_REG_MANSW1 0x13
  43. #define FSA9485_REG_MANSW2 0x14
  44. #define FSA9485_REG_MANUAL_OVERRIDES1 0x1B
  45. #define FSA9485_REG_RESERVED_1D 0x1D
  46. #define FSA9485_REG_RESERVED_20 0x20
  47. /* Control */
  48. #define CON_SWITCH_OPEN (1 << 4)
  49. #define CON_RAW_DATA (1 << 3)
  50. #define CON_MANUAL_SW (1 << 2)
  51. #define CON_WAIT (1 << 1)
  52. #define CON_INT_MASK (1 << 0)
  53. #define CON_MASK (CON_SWITCH_OPEN | CON_RAW_DATA | \
  54. CON_MANUAL_SW | CON_WAIT)
  55. /* Device Type 1 */
  56. #define DEV_USB_OTG (1 << 7)
  57. #define DEV_DEDICATED_CHG (1 << 6)
  58. #define DEV_USB_CHG (1 << 5)
  59. #define DEV_CAR_KIT (1 << 4)
  60. #define DEV_UART (1 << 3)
  61. #define DEV_USB (1 << 2)
  62. #define DEV_AUDIO_2 (1 << 1)
  63. #define DEV_AUDIO_1 (1 << 0)
  64. #define DEV_T1_USB_MASK (DEV_USB_OTG | DEV_USB_CHG | DEV_USB)
  65. #define DEV_T1_UART_MASK (DEV_UART)
  66. #define DEV_T1_CHARGER_MASK (DEV_DEDICATED_CHG | DEV_CAR_KIT)
  67. /* Device Type 2 */
  68. #define DEV_MMDOCK (1<<12)
  69. #define DEV_INCOMPATIBLE (1 << 11)
  70. #define DEV_CHARGING_CABLE (1 << 10)
  71. #ifdef CONFIG_MUIC_FSA9485_SUPPORT_LANHUB
  72. #define DEV_LANHUB (1 << 9)
  73. #endif
  74. #define DEV_AUDIO_DOCK (1 << 8)
  75. #define DEV_SMARTDOCK (1 << 7)
  76. #define DEV_AV (1 << 6)
  77. #define DEV_TTY (1 << 5)
  78. #define DEV_PPD (1 << 4)
  79. #define DEV_JIG_UART_OFF (1 << 3)
  80. #define DEV_JIG_UART_ON (1 << 2)
  81. #define DEV_JIG_USB_OFF (1 << 1)
  82. #define DEV_JIG_USB_ON (1 << 0)
  83. #define DEV_T2_USB_MASK (DEV_JIG_USB_OFF | DEV_JIG_USB_ON)
  84. #define DEV_T2_UART_MASK (DEV_JIG_UART_OFF)
  85. #define DEV_T2_JIG_MASK (DEV_JIG_USB_OFF | DEV_JIG_USB_ON | \
  86. DEV_JIG_UART_OFF)
  87. /* Device Type 3 */
  88. #define DEV_MHL (1 << 0)
  89. #define DEV_VBUS_DEBOUNCE (1 << 1)
  90. #define DEV_NON_STANDARD (1 << 2)
  91. #define DEV_AV_VBUS (1 << 4)
  92. #define DEV_APPLE_CHARGER (1 << 5)
  93. #define DEV_U200_CHARGER (1 << 6)
  94. /*
  95. * Manual Switch
  96. * D- [7:5] / D+ [4:2]
  97. * 000: Open all / 001: USB / 010: AUDIO / 011: UART / 100: V_AUDIO
  98. */
  99. #define SW_VAUDIO ((4 << 5) | (4 << 2) | (1 << 1) | (1 << 0))
  100. #define SW_UART ((3 << 5) | (3 << 2))
  101. #define SW_AUDIO ((2 << 5) | (2 << 2) | (1 << 1) | (1 << 0))
  102. #define SW_DHOST ((1 << 5) | (1 << 2) | (1 << 1) | (1 << 0))
  103. #define SW_AUTO ((0 << 5) | (0 << 2))
  104. #define SW_USB_OPEN (1 << 0)
  105. #define SW_ALL_OPEN (0)
  106. /* Interrupt 1 */
  107. #define INT_DETACH (1 << 1)
  108. #define INT_ATTACH (1 << 0)
  109. #define ADC_GND 0x00
  110. #define ADC_MHL 0x01
  111. #define ADC_DOCK_PREV_KEY 0x04
  112. #define ADC_DOCK_NEXT_KEY 0x07
  113. #define ADC_DOCK_VOL_DN 0x0a
  114. #define ADC_DOCK_VOL_UP 0x0b
  115. #define ADC_DOCK_PLAY_PAUSE_KEY 0x0d
  116. #ifdef CONFIG_MUIC_FSA9485_SUPPORT_LANHUB
  117. #define ADC_LANHUB 0x13
  118. #endif
  119. #define ADC_CHARGING_CABLE 0x14
  120. #define ADC_MMDOCK 0x15
  121. #define ADC_CEA936ATYPE1_CHG 0x17
  122. #define ADC_JIG_USB_OFF 0x18
  123. #define ADC_JIG_USB_ON 0x19
  124. #define ADC_DESKDOCK 0x1a
  125. #define ADC_CEA936ATYPE2_CHG 0x1b
  126. #define ADC_JIG_UART_OFF 0x1c
  127. #define ADC_JIG_UART_ON 0x1d
  128. #define ADC_CARDOCK 0x1d
  129. #define ADC_OPEN 0x1f
  130. enum cable_type_t {
  131. CABLE_TYPE_NONE = 0,
  132. CABLE_TYPE_USB,
  133. CABLE_TYPE_AC,
  134. CABLE_TYPE_MISC,
  135. CABLE_TYPE_CARDOCK,
  136. #ifdef CONFIG_MUIC_FSA9485_SUPPORT_LANHUB
  137. CABLE_TYPE_LANHUB,
  138. #endif
  139. CABLE_TYPE_UARTOFF,
  140. CABLE_TYPE_JIG,
  141. CABLE_TYPE_UNKNOWN,
  142. CABLE_TYPE_CDP,
  143. CABLE_TYPE_SMART_DOCK,
  144. CABLE_TYPE_OTG,
  145. CABLE_TYPE_CHARGING_CABLE,
  146. CABLE_TYPE_AUDIO_DOCK,
  147. #ifdef CONFIG_WIRELESS_CHARGING
  148. CABLE_TYPE_WPC,
  149. #endif
  150. CABLE_TYPE_INCOMPATIBLE,
  151. CABLE_TYPE_DESK_DOCK,
  152. CABLE_TYPE_MM_DOCK,
  153. };
  154. enum {
  155. DOCK_KEY_NONE = 0,
  156. DOCK_KEY_VOL_UP_PRESSED,
  157. DOCK_KEY_VOL_UP_RELEASED,
  158. DOCK_KEY_VOL_DOWN_PRESSED,
  159. DOCK_KEY_VOL_DOWN_RELEASED,
  160. DOCK_KEY_PREV_PRESSED,
  161. DOCK_KEY_PREV_RELEASED,
  162. DOCK_KEY_PLAY_PAUSE_PRESSED,
  163. DOCK_KEY_PLAY_PAUSE_RELEASED,
  164. DOCK_KEY_NEXT_PRESSED,
  165. DOCK_KEY_NEXT_RELEASED,
  166. };
  167. enum {
  168. FSA9485_NONE = -1,
  169. FSA9485_DETACHED = 0,
  170. FSA9485_ATTACHED = 1
  171. };
  172. enum {
  173. FSA9485_MMDOCK_ATTACHED = 2
  174. };
  175. enum {
  176. FSA9485_DETACHED_DOCK = 0,
  177. FSA9485_ATTACHED_DESK_DOCK,
  178. FSA9485_ATTACHED_CAR_DOCK,
  179. FSA9485_ATTACHED_DESK_DOCK_NO_VBUS,
  180. };
  181. #define UART_SEL_SW 58
  182. struct fsa9485_platform_data {
  183. int gpio_int;
  184. u32 irq_gpio_flags;
  185. int gpio_sda;
  186. u32 sda_gpio_flags;
  187. int gpio_scl;
  188. u32 scl_gpio_flags;
  189. void (*cfg_gpio) (void);
  190. void (*otg_cb) (bool attached);
  191. void (*charge_cb) (bool attached);
  192. void (*usb_cb) (bool attached);
  193. void (*uart_cb) (bool attached);
  194. void (*charger_cb) (bool attached);
  195. void (*in_charger_cb) (bool attached);
  196. void (*jig_cb) (bool attached);
  197. void (*mhl_cb) (int attached);
  198. void (*reset_cb) (void);
  199. void (*set_init_flag) (void);
  200. void (*mhl_sel) (bool onoff);
  201. void (*dock_cb) (int attached);
  202. int (*dock_init) (void);
  203. void (*usb_cdp_cb) (bool attached);
  204. #ifdef CONFIG_MUIC_FSA9485_SUPPORT_LANHUB
  205. void (*lanhub_cb) (bool attached);
  206. void (*lanhubta_cb) (bool attached);
  207. #endif
  208. void (*smartdock_cb) (bool attached);
  209. void (*audio_dock_cb) (bool attached);
  210. void (*mmdock_cb) (bool attached);
  211. };
  212. enum {
  213. SWITCH_PORT_AUTO = 0,
  214. SWITCH_PORT_USB,
  215. SWITCH_PORT_AUDIO,
  216. SWITCH_PORT_UART,
  217. SWITCH_PORT_VAUDIO,
  218. SWITCH_PORT_USB_OPEN,
  219. SWITCH_PORT_ALL_OPEN,
  220. };
  221. extern void fsa9485_manual_switching(int path);
  222. extern void fsa9485_otg_detach(void);
  223. #if defined(CONFIG_MACH_AEGIS2)
  224. extern void fsa9485_checkandhookaudiodockfornoise(int value);
  225. #endif
  226. extern struct class *sec_class;
  227. extern struct fsa9485_platform_data fsa9485_pdata;
  228. extern int check_jig_state(void);
  229. extern int check_mmdock_connect(void);
  230. extern int poweroff_charging;
  231. #endif /* _FSA9485_H_ */