cbus_drv.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. /******************************************************************************/
  2. //!file cbus_drv.h
  3. //!brief CBUS Driver functions
  4. //
  5. /******************************************************************************/
  6. #ifndef __DRV_CBUS_H__
  7. #define __DRV_CBUS_H__
  8. #include "drv_types.h"
  9. #include "cbus_datatypes.h"
  10. #include "cbus_mid.h"
  11. #include "../sysreg.h"
  12. #include "../hdmi_mapping.h"
  13. //#include "reg_hdmirx_cbus_def.h"
  14. //------------------------------------------------------------------------------
  15. // Driver enums
  16. //------------------------------------------------------------------------------
  17. //------------------------------------------------------------------------------
  18. // CBUS Driver Manifest Constants
  19. //------------------------------------------------------------------------------
  20. // Version that this chip supports
  21. #define MHL_VER_MAJOR (0x02 << 4) // bits 4..7
  22. #define MHL_VER_MINOR 0x02 // bits 0..3
  23. #define MHL_VERSION (MHL_VER_MAJOR | MHL_VER_MINOR)
  24. #define CBUS_VER_MAJOR (0x01 << 4) // bits 4..7
  25. #define CBUS_VER_MINOR 0x00 // bits 0..3
  26. #define MHL_CBUS_VERSION (CBUS_VER_MAJOR | CBUS_VER_MINOR)
  27. #define MHL_DEV_CAT_SOURCE 0x00
  28. #define MHL_DEV_CAT_SINGLE_INPUT_SINK 0x01
  29. #define MHL_DEV_CAT_MULTIPLE_INPUT_SINK 0x02
  30. #define MHL_DEV_CAT_UNPOWERED_DONGLE 0x03
  31. #define MHL_DEV_CAT_SELF_POWERED_DONGLE 0x04
  32. #define MHL_DEV_CAT_HDCP_REPEATER 0x05
  33. #define MHL_DEV_CAT_OTHER 0x06
  34. #define MHL_POWER_SUPPLY_CAPACITY 16 // 160 mA current
  35. #define MHL_POWER_SUPPLY_PROVIDED 16 // 160mA 0r 0 for Wolverine.
  36. #define MHL_VIDEO_LINK_MODE_SUPORT 1 // Bit 0 = Supports RGB 4:4:4
  37. #define MHL_AUDIO_LINK_MODE_SUPORT 1 // Bit 0 = 2-Channel
  38. #define MHL_HDCP_STATUS 0 // Bits set dynamically
  39. // initialize MHL registers with the correct values
  40. #define MHL_DEV_STATE 0x00
  41. #define MHL_DEV_CAT_POW_PLIM 0x31 //MHL 2.0 Sink Type 900mA
  42. #define MHL_DEV_CAT_ADOPTER_ID_H 0x00 //Adopter ID:0000
  43. #define MHL_DEV_CAT_ADOPTER_ID_L 0x00
  44. #define MHL_VID_LINK_MODE 0x37//0x37 -> 0x3F for Support PP mode
  45. #define MHL_LINK_CLK_FREQUENCY 0x0F // Bits set dynamically
  46. #define MHL_FEATURE_SUPPORT 0x07 // Feature Support for RCP/RAP
  47. #define MHL_INT_STAT_SIZE 0x33 // Bits set dynamically
  48. #define MHL_DEV_SUPPORTS_DISPLAY_OUTPUT (0x01 << 0)
  49. #define MHL_DEV_SUPPORTS_VIDEO_OUTPUT (0x01 << 1)
  50. #define MHL_DEV_SUPPORTS_AUDIO_OUTPUT (0x01 << 2)
  51. #define MHL_DEV_SUPPORTS_MEDIA_HANDLING (0x01 << 3)
  52. #define MHL_DEV_SUPPORTS_TUNER (0x01 << 4)
  53. #define MHL_DEV_SUPPORTS_RECORDING (0x01 << 5)
  54. #define MHL_DEV_SUPPORTS_SPEAKERS (0x01 << 6)
  55. #define MHL_DEV_SUPPORTS_GUI (0x01 << 7)
  56. #define MHL_LOG_DEV_MAP (MHL_DEV_SUPPORTS_DISPLAY_OUTPUT)//
  57. #define MHL_BANDWIDTH_LIMIT 22 // 225 MHz
  58. /* HDMI MHL CBUS Interrupt start */
  59. /*
  60. *@Address: 0x1E290EE0[31:0]
  61. *@Range: 0~4294967295
  62. *@Default: 0
  63. *@Access: r
  64. *@Description:
  65. * Interrupt status
  66. * [31]:device_status3_intr, check 0033
  67. * [30]:device_status2_intr,check 0032
  68. * [29]:OTHR_cmd_intr, Check 0702[0]
  69. * [28]:msge_act_intr,
  70. * [27]:EDID_rd_intr, Check 0600
  71. * [26]:ucp_act_intr, Check 0F1A
  72. * [25]:ucp_cmd_intr, Check 0501
  73. * [24]:rcp_act_intr, Check 0F18
  74. */
  75. #define rcp_act_intr 0x01000000
  76. #define ucp_cmd_intr 0x02000000
  77. #define ucp_act_intr 0x04000000
  78. #define EDID_rd_intr 0x08000000
  79. #define msge_act_intr 0x10000000
  80. #define OTHR_cmd_intr 0x20000000
  81. #define device_status2_intr 0x40000000
  82. #define device_status3_intr 0x80000000
  83. /*
  84. * [23]:rcp_cmd_intr, Check 0401
  85. * [22]:rap_act_intr, Check 0308
  86. * [21]:rap_act_ack_intr, Check 0305
  87. * [20]:rap_cmd_intr, Check 0301
  88. * [19]:get_src3_err_intr, Check 0211
  89. * [18]:get_src1_err_intr, Check 0201
  90. * [17]:get_msc_err_intr, Check 01F1
  91. * [16]:get_ddc_err_intr, Check 01E1
  92. */
  93. #define get_ddc_err_intr 0x00010000
  94. #define get_msc_err_intr 0x00020000
  95. #define get_src1_err_intr 0x00040000
  96. #define get_src3_err_intr 0x00080000
  97. #define rap_cmd_intr 0x00100000
  98. #define rap_act_ack_intr 0x00200000
  99. #define rap_act_intr 0x00400000
  100. #define rcp_cmd_intr 0x00800000
  101. /*
  102. * [15]:get_ven_id_intr, Check 01D1
  103. * [14]:get_state_intr, Check 01C1
  104. * [13]:clr_hpd_intr, Check 01B1
  105. * [12]:set_hpd_intr, Check 01A1
  106. * [11]:reserved,
  107. * [10]:wrt_burst_intr, Check 0141
  108. * [9]:link_mode_intr, Check 0031
  109. * [8]:connected_rdy_intr, Check 0030
  110. */
  111. #define connected_rdy_intr 0x00000100
  112. #define link_mode_intr 0x00000200
  113. #define wrt_burst_intr 0x00000400
  114. #define reserved 0x00000800
  115. #define set_hpd_intr 0x00001000
  116. #define clr_hpd_intr 0x00002000
  117. #define get_state_intr 0x00004000
  118. #define get_ven_id_intr 0x00008000
  119. /*
  120. * [7]:wrt_stat_intr, Check 0111[3:0]
  121. * [6]:edid_chg_intr,
  122. * [5]:req_3d_intr, Check 0020
  123. * [4]:grt_wrt_intr, Check 0020
  124. * [3]:req_wrt_intr, Check 0020
  125. * [2]:dscr_chg_intr, Check 0020
  126. * [1]:dcap_chg_intr, Check 0020
  127. * [0]:red_devc_intr, Check 0103[3:0]
  128. */
  129. #define red_devc_intr 0x00000001
  130. #define dcap_chg_intr 0x00000002
  131. #define dscr_chg_intr 0x00000004
  132. #define req_wrt_intr 0x00000008
  133. #define grt_wrt_intr 0x00000010
  134. #define req_3d_intr 0x00000020
  135. #define edid_chg_intr 0x00000040
  136. #define wrt_stat_intr 0x00000080
  137. /*
  138. *@Address: 0x1E298034[0]wake up int.
  139. *@Address: 0x1E298034[1]discovery int.
  140. *@Address: 0x1E298034[2]connected int.
  141. *@Address: 0x1E298034[3]attach int.
  142. *@Address: 0x1E298034[4]detach int.
  143. *@Address: 0x1E298034[5]txff empty int.
  144. *@Address: 0x1E298034[6]txff prefull int.
  145. *@Address: 0x1E298034[7]rxff has data int.
  146. */
  147. #define wake_int 0x00000001
  148. #define discv_intr 0x00000002
  149. #define connt_intr 0x00000004
  150. #define attach_intr 0x00000008
  151. #define detach_intr 0x00000010
  152. #define txff_empty_intr 0x00000020
  153. #define txff_prefull_intr 0x00000040
  154. #define rxff_hv_data_intr 0x00000080
  155. /* HDMI MHL CBUS Interrupt end */
  156. //------------------------------------------------------------------------------
  157. // CBUS Driver Structure
  158. //------------------------------------------------------------------------------
  159. typedef struct
  160. {
  161. CBUS_DRV_STATUS_e statusFlags;
  162. // CBUS transfer values read at last interrupt for each specific channel
  163. UINT32 CBUS_TRANS_INT_STATUS;
  164. UINT32 CBUS_LINK_INT_STATUS;
  165. BOOL Connected; //connected
  166. BOOL SrcPathEn; //Source's PATH_EN
  167. CbusMscSubCmd_t stMscSubCmd_R; //received MSC sub command
  168. //UINT8 RCP_ACT_NUM;
  169. //UINT8 RCP_CMD_CODE;
  170. MHL_RCP_CMD_e RCPK_CMD_CODE;
  171. MHL_RCPE_STATUS_e RCPE_STATUS_CODE;
  172. UINT8 RAP_CMD_CODE;
  173. UINT8 RAPK_CMD_CODE;
  174. UINT8 RAPK_STATUS_CODE;
  175. UINT8 UCP_ACT_NUM;
  176. UINT8 UCP_CMD_CODE;
  177. UINT8 UCPK_CMD_CODE;
  178. UINT8 UCPE_STATUS_CODE;
  179. UINT8 bReadDevCap_Offset;
  180. UINT8 bReadDevCap_Data;
  181. UINT8 AckWrtStatOffset;
  182. UINT8 AckWrtStatData;
  183. UINT8 msgData0;
  184. UINT8 msgData1;
  185. UINT8 MscFailReason; //msc command fail code
  186. MHL_DDC_CH_ERRCODE_e ddcAbortReason; //retrieve by GET_DDC_ERRORCODE
  187. MHL_MSC_CH_ERRCODE_e MscAbortReason; //retrieve by GET_MSC_ERRORCODE
  188. }CbusDrvInstanceData_t;
  189. void CbusDrvInitCbusRegsList(void);
  190. //------------------------------------------------------------------------------
  191. // Function: CbusDrvStatus
  192. // Description: Returns a status flag word containing CBUS driver-specific
  193. // information about the state of the device.
  194. // Parameters: none
  195. // Returns: status flags word for the CBUS Driver
  196. //------------------------------------------------------------------------------
  197. CBUS_DRV_STATUS_e CbusDrvStatus(void);
  198. //------------------------------------------------------------------------------
  199. // Function: CbusDrvInterruptStatusGet
  200. // Description: Returns the last Interrupt Status data retrieved by the CBUS ISR.
  201. // Parameters: pData - pointer to return data buffer(1 byte).
  202. // Returns: TRUE if new interrupt status data is available, FALSE if not.
  203. // pData - Destination for interrupt status data.
  204. //------------------------------------------------------------------------------
  205. void CbusDrvInterruptStatusGet(UINT32 *pData, UINT32 *pData2);
  206. //------------------------------------------------------------------------------
  207. // Function: CbusDrvInterruptStatusSet
  208. // Description: Clears the interrupt variable
  209. // Parameters: channel
  210. //------------------------------------------------------------------------------
  211. void CbusDrvInterruptStatusSet(UINT32 intBits, UINT32 intBits2);
  212. //------------------------------------------------------------------------------
  213. // Function: CbusDrvConnectedGet
  214. // Description: Returns the Connected Status retrieved by the CBUS ISR.
  215. // Parameters: pData - pointer to return data buffer(1 byte).
  216. // Returns: pData - Destination for bus status data.
  217. //------------------------------------------------------------------------------
  218. void CbusDrvConnectedGet(UINT8 *pData);
  219. //------------------------------------------------------------------------------
  220. // Function: CbusDrvSrcPathEnStatusGet
  221. // Description: Returns the SrcPathEn Status of DrvCbus
  222. // Parameters: None
  223. // Returns: SrcPathEn Status
  224. //------------------------------------------------------------------------------
  225. BOOL CbusDrvSrcPathEnStatusGet(void);
  226. //------------------------------------------------------------------------------
  227. // Function: CbusDrvMSCSubDataGet
  228. // Description: Returns the MSC sub-cmd and data bytes retrieved by the CBUS ISR.
  229. // Parameters: pbCmdType, pbData - pointer to return data
  230. // Returns: pbCmdType - the oldest received MSC sub-command type value
  231. // pbData - the oldest received MSC sub-command data value
  232. // return TRUE if data is available, otherwise return FALSE
  233. //------------------------------------------------------------------------------
  234. BOOL CbusDrvMSCSubDataGet(UINT8 *pbCmdType, UINT8 *pbData);
  235. //------------------------------------------------------------------------------
  236. // Function: CbusDrvMsgDataGet
  237. // Description: Returns the last MSG data retrieved by the CBUS ISR.
  238. // Parameters: pData - pointer to return data buffer(?? bytes).
  239. // Returns: TRUE if a new MSG data was available, FALSE if not.
  240. // pData - Destination for msg data.
  241. //------------------------------------------------------------------------------
  242. void CbusDrvMsgDataGet(UINT8 *pData, UINT8 *pData1);
  243. //------------------------------------------------------------------------------
  244. // Function: CbusDrvDevCapGet
  245. // Description: Returns the Device Capability data retrieved by the CBUS ISR.
  246. // Parameters: pOffset - return offset
  247. // pData - return fetched data
  248. //------------------------------------------------------------------------------
  249. void CbusDrvDevCapGet(UINT8 *pOffset, UINT8 *pData);
  250. //------------------------------------------------------------------------------
  251. // Function: CbusDrvDdcAbortReasonGet
  252. // Description: Returns the last DDC Abort reason received by the CBUS ISR.
  253. // Parameters: pData - pointer to return data buffer(1 byte).
  254. // Returns: pData - Destination for DDC Abort reason data.
  255. //------------------------------------------------------------------------------
  256. void CbusDrvDdcAbortReasonGet(UINT8 *pData);
  257. //------------------------------------------------------------------------------
  258. // Function: CbusDrvMscAbortReasonGet
  259. // Description: Returns the last MSC Abort reason received by the CBUS ISR.
  260. // Parameters: pData - pointer to return data buffer(1 byte).
  261. // Returns: pData - Destination for MSC Abort reason data.
  262. //------------------------------------------------------------------------------
  263. void CbusDrvMscAbortReasonGet(UINT8 *pData);
  264. //------------------------------------------------------------------------------
  265. // Function: CbusDrvMscFailReasonGet
  266. // Description: Returns the last MSC Fail reason received by the CBUS ISR.
  267. // Parameters: pData - pointer to return data buffer(1 byte).
  268. // Returns: pData - Destination for MSC Fail reason data.
  269. //------------------------------------------------------------------------------
  270. void CbusDrvMscFailReasonGet(UINT8 *pData);
  271. //------------------------------------------------------------------------------
  272. // Function: CbusDrvNackFromPeerGet
  273. // Description: checks if peer sent a NACK
  274. // Parameters: channel - CBus channel
  275. // Returns: TRUE if peer sent a NACK, FALSE if not.
  276. //------------------------------------------------------------------------------
  277. BOOL CbusDrvNackFromPeerGet(void);
  278. //------------------------------------------------------------------------------
  279. // Function: CbusDrvAbortFromPeerGet
  280. // Description: Returns the last MSC Abort received by the CBUS ISR.
  281. // Parameters: NONE
  282. // Returns: TRUE if a new MSC ABORT data was received, FALSE if not.
  283. //------------------------------------------------------------------------------
  284. BOOL CbusDrvAbortFromPeerGet(void);
  285. //------------------------------------------------------------------------------
  286. // Function: CbusDrvIneffectCodeFromPeerGet
  287. // Description: Returns the last MSC Ineffect Code received by the CBUS ISR.
  288. // Parameters: NONE
  289. // Returns: TRUE if a new MSC INEFFECT_CODE data was received, FALSE if not.
  290. //------------------------------------------------------------------------------
  291. BOOL CbusDrvIneffectCodeFromPeerGet(void);
  292. //------------------------------------------------------------------------------
  293. // Function: CbusDrvWrtBurstAckGet
  294. // Description: Returns if the peer is return ACK for WRITE_BURST
  295. // Returns: TRUE/FALSE
  296. //------------------------------------------------------------------------------
  297. BOOL CbusDrvWrtBurstAckGet(void);
  298. //------------------------------------------------------------------------------
  299. // Function: CbusDrvWrtStateAckGet
  300. // Description: Returns if the peer is return ACK for WRITE_STATE
  301. // Returns: TRUE/FALSE
  302. //------------------------------------------------------------------------------
  303. BOOL CbusDrvWrtStateAckGet(void);
  304. //------------------------------------------------------------------------------
  305. // Function: CbusDrvWrtStateAckInfoGet
  306. // Description: Returns if the peer is return ACK for WRITE_STATE
  307. // Returns: TRUE/FALSE
  308. //------------------------------------------------------------------------------
  309. BOOL CbusDrvWrtStateAckInfoGet(UINT8 *pOffset, UINT8 *pData);
  310. //------------------------------------------------------------------------------
  311. // Function: CbusDrvDevCapReadyGet
  312. // Description: Returns if the peer's device capability values are ready
  313. // Parameters: pData - pointer to return data buffer(1 byte).
  314. // Returns: TRUE/FALSE
  315. //------------------------------------------------------------------------------
  316. BOOL CbusDrvDevCapReadyGet(void);
  317. //------------------------------------------------------------------------------
  318. // Function: CbusDrvDevCapChangedGet
  319. // Description: Returns if the peer's device capability values are changed
  320. // Parameters: pData - pointer to return data buffer(1 byte).
  321. // Returns: TRUE/FALSE
  322. //------------------------------------------------------------------------------
  323. BOOL CbusDrvDevCapChangedGet(void);
  324. //------------------------------------------------------------------------------
  325. // Function: CbusDrvReqWrtGet
  326. // Description: Returns if the peer is requesting for scratchpad write permission
  327. // Parameters: channel
  328. // Returns: TRUE/FALSE
  329. //------------------------------------------------------------------------------
  330. BOOL CbusDrvReqWrtGet(void);
  331. //------------------------------------------------------------------------------
  332. // Function: CbusDrvGrtWrtGet
  333. // Description: Returns if the peer is requesting for scratchpad write permission
  334. // Parameters: channel
  335. // Returns: TRUE/FALSE
  336. //------------------------------------------------------------------------------
  337. BOOL CbusDrvGrtWrtGet(void);
  338. //------------------------------------------------------------------------------
  339. // Function: CbusDrvWriteCommand
  340. // Description: Write the specified Sideband Channel command to the CBUS.
  341. // Command can be a MSC_MSG command(RCP/MCW/RAP), or another command
  342. // such as READ_DEVCAP, GET_VENDOR_ID, SET_HPD, CLR_HPD, etc.
  343. //
  344. // Parameters: channel - CBUS channel to write
  345. // pReq - Pointer to a cbus_req_t structure containing the
  346. // command to write
  347. // Returns: TRUE - successful write
  348. // FALSE - write failed
  349. //------------------------------------------------------------------------------
  350. BOOL CbusDrvWriteCommand(cbus_req_t *pReq );
  351. //------------------------------------------------------------------------------
  352. // Function: CbusDrvInitialize
  353. // Description: Attempts to initialize the CBUS. If register reads return 0xFF,
  354. // it declares error in initialization.
  355. // Initializes discovery enabling registers and anything needed in
  356. // config register, interrupt masks.
  357. // Returns: TRUE if no problem
  358. //------------------------------------------------------------------------------
  359. BOOL CbusDrvInitialize(void);
  360. //------------------------------------------------------------------------------
  361. // Function: DrvMHLPortSelectBitsGet
  362. // Description: Reads the MHL selected port(s)bit-field. This is the value
  363. // downloaded from NVRAM at boot-up time.
  364. // Parameters: None
  365. // Returns: MHL selected port(s)bit-field.
  366. //
  367. //------------------------------------------------------------------------------
  368. UINT8 DrvMHLPortSelectBitsGet(void);
  369. //------------------------------------------------------------------------------
  370. // Function: CbusDrvSetSupportRcpKey
  371. // Description: Set supported RCP key
  372. //------------------------------------------------------------------------------
  373. void CbusDrvSetSupportRcpKey(void);
  374. #endif // __SI_DRV_CBUS_H__