123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457 |
- /******************************************************************************/
- //!file cbus_drv.h
- //!brief CBUS Driver functions
- //
- /******************************************************************************/
- #ifndef __DRV_CBUS_H__
- #define __DRV_CBUS_H__
- #include "drv_types.h"
- #include "cbus_datatypes.h"
- #include "cbus_mid.h"
- #include "../sysreg.h"
- #include "../hdmi_mapping.h"
- //#include "reg_hdmirx_cbus_def.h"
- //------------------------------------------------------------------------------
- // Driver enums
- //------------------------------------------------------------------------------
- //------------------------------------------------------------------------------
- // CBUS Driver Manifest Constants
- //------------------------------------------------------------------------------
- // Version that this chip supports
- #define MHL_VER_MAJOR (0x02 << 4) // bits 4..7
- #define MHL_VER_MINOR 0x02 // bits 0..3
- #define MHL_VERSION (MHL_VER_MAJOR | MHL_VER_MINOR)
- #define CBUS_VER_MAJOR (0x01 << 4) // bits 4..7
- #define CBUS_VER_MINOR 0x00 // bits 0..3
- #define MHL_CBUS_VERSION (CBUS_VER_MAJOR | CBUS_VER_MINOR)
- #define MHL_DEV_CAT_SOURCE 0x00
- #define MHL_DEV_CAT_SINGLE_INPUT_SINK 0x01
- #define MHL_DEV_CAT_MULTIPLE_INPUT_SINK 0x02
- #define MHL_DEV_CAT_UNPOWERED_DONGLE 0x03
- #define MHL_DEV_CAT_SELF_POWERED_DONGLE 0x04
- #define MHL_DEV_CAT_HDCP_REPEATER 0x05
- #define MHL_DEV_CAT_OTHER 0x06
- #define MHL_POWER_SUPPLY_CAPACITY 16 // 160 mA current
- #define MHL_POWER_SUPPLY_PROVIDED 16 // 160mA 0r 0 for Wolverine.
- #define MHL_VIDEO_LINK_MODE_SUPORT 1 // Bit 0 = Supports RGB 4:4:4
- #define MHL_AUDIO_LINK_MODE_SUPORT 1 // Bit 0 = 2-Channel
- #define MHL_HDCP_STATUS 0 // Bits set dynamically
- // initialize MHL registers with the correct values
- #define MHL_DEV_STATE 0x00
- #define MHL_DEV_CAT_POW_PLIM 0x31 //MHL 2.0 Sink Type 900mA
- #define MHL_DEV_CAT_ADOPTER_ID_H 0x00 //Adopter ID:0000
- #define MHL_DEV_CAT_ADOPTER_ID_L 0x00
- #define MHL_VID_LINK_MODE 0x37//0x37 -> 0x3F for Support PP mode
- #define MHL_LINK_CLK_FREQUENCY 0x0F // Bits set dynamically
- #define MHL_FEATURE_SUPPORT 0x07 // Feature Support for RCP/RAP
- #define MHL_INT_STAT_SIZE 0x33 // Bits set dynamically
- #define MHL_DEV_SUPPORTS_DISPLAY_OUTPUT (0x01 << 0)
- #define MHL_DEV_SUPPORTS_VIDEO_OUTPUT (0x01 << 1)
- #define MHL_DEV_SUPPORTS_AUDIO_OUTPUT (0x01 << 2)
- #define MHL_DEV_SUPPORTS_MEDIA_HANDLING (0x01 << 3)
- #define MHL_DEV_SUPPORTS_TUNER (0x01 << 4)
- #define MHL_DEV_SUPPORTS_RECORDING (0x01 << 5)
- #define MHL_DEV_SUPPORTS_SPEAKERS (0x01 << 6)
- #define MHL_DEV_SUPPORTS_GUI (0x01 << 7)
- #define MHL_LOG_DEV_MAP (MHL_DEV_SUPPORTS_DISPLAY_OUTPUT)//
- #define MHL_BANDWIDTH_LIMIT 22 // 225 MHz
- /* HDMI MHL CBUS Interrupt start */
- /*
- *@Address: 0x1E290EE0[31:0]
- *@Range: 0~4294967295
- *@Default: 0
- *@Access: r
- *@Description:
- * Interrupt status
- * [31]:device_status3_intr, check 0033
- * [30]:device_status2_intr,check 0032
- * [29]:OTHR_cmd_intr, Check 0702[0]
- * [28]:msge_act_intr,
- * [27]:EDID_rd_intr, Check 0600
- * [26]:ucp_act_intr, Check 0F1A
- * [25]:ucp_cmd_intr, Check 0501
- * [24]:rcp_act_intr, Check 0F18
- */
- #define rcp_act_intr 0x01000000
- #define ucp_cmd_intr 0x02000000
- #define ucp_act_intr 0x04000000
- #define EDID_rd_intr 0x08000000
- #define msge_act_intr 0x10000000
- #define OTHR_cmd_intr 0x20000000
- #define device_status2_intr 0x40000000
- #define device_status3_intr 0x80000000
- /*
- * [23]:rcp_cmd_intr, Check 0401
- * [22]:rap_act_intr, Check 0308
- * [21]:rap_act_ack_intr, Check 0305
- * [20]:rap_cmd_intr, Check 0301
- * [19]:get_src3_err_intr, Check 0211
- * [18]:get_src1_err_intr, Check 0201
- * [17]:get_msc_err_intr, Check 01F1
- * [16]:get_ddc_err_intr, Check 01E1
- */
- #define get_ddc_err_intr 0x00010000
- #define get_msc_err_intr 0x00020000
- #define get_src1_err_intr 0x00040000
- #define get_src3_err_intr 0x00080000
- #define rap_cmd_intr 0x00100000
- #define rap_act_ack_intr 0x00200000
- #define rap_act_intr 0x00400000
- #define rcp_cmd_intr 0x00800000
- /*
- * [15]:get_ven_id_intr, Check 01D1
- * [14]:get_state_intr, Check 01C1
- * [13]:clr_hpd_intr, Check 01B1
- * [12]:set_hpd_intr, Check 01A1
- * [11]:reserved,
- * [10]:wrt_burst_intr, Check 0141
- * [9]:link_mode_intr, Check 0031
- * [8]:connected_rdy_intr, Check 0030
- */
- #define connected_rdy_intr 0x00000100
- #define link_mode_intr 0x00000200
- #define wrt_burst_intr 0x00000400
- #define reserved 0x00000800
- #define set_hpd_intr 0x00001000
- #define clr_hpd_intr 0x00002000
- #define get_state_intr 0x00004000
- #define get_ven_id_intr 0x00008000
- /*
- * [7]:wrt_stat_intr, Check 0111[3:0]
- * [6]:edid_chg_intr,
- * [5]:req_3d_intr, Check 0020
- * [4]:grt_wrt_intr, Check 0020
- * [3]:req_wrt_intr, Check 0020
- * [2]:dscr_chg_intr, Check 0020
- * [1]:dcap_chg_intr, Check 0020
- * [0]:red_devc_intr, Check 0103[3:0]
- */
- #define red_devc_intr 0x00000001
- #define dcap_chg_intr 0x00000002
- #define dscr_chg_intr 0x00000004
- #define req_wrt_intr 0x00000008
- #define grt_wrt_intr 0x00000010
- #define req_3d_intr 0x00000020
- #define edid_chg_intr 0x00000040
- #define wrt_stat_intr 0x00000080
- /*
- *@Address: 0x1E298034[0]wake up int.
- *@Address: 0x1E298034[1]discovery int.
- *@Address: 0x1E298034[2]connected int.
- *@Address: 0x1E298034[3]attach int.
- *@Address: 0x1E298034[4]detach int.
- *@Address: 0x1E298034[5]txff empty int.
- *@Address: 0x1E298034[6]txff prefull int.
- *@Address: 0x1E298034[7]rxff has data int.
- */
- #define wake_int 0x00000001
- #define discv_intr 0x00000002
- #define connt_intr 0x00000004
- #define attach_intr 0x00000008
- #define detach_intr 0x00000010
- #define txff_empty_intr 0x00000020
- #define txff_prefull_intr 0x00000040
- #define rxff_hv_data_intr 0x00000080
- #define src_discon_intr 0x00000100
- /* HDMI MHL CBUS Interrupt end */
- //------------------------------------------------------------------------------
- // CBUS Driver Structure
- //------------------------------------------------------------------------------
- typedef struct
- {
- CBUS_DRV_STATUS_e statusFlags;
- // CBUS transfer values read at last interrupt for each specific channel
- UINT32 CBUS_TRANS_INT_STATUS;
- UINT32 CBUS_LINK_INT_STATUS;
- BOOL Connected; //connected
- BOOL CableAttach;
- BOOL SrcPathEn; //Source's PATH_EN
- CbusMscSubCmd_t stMscSubCmd_R; //received MSC sub command
- //UINT8 RCP_ACT_NUM;
- //UINT8 RCP_CMD_CODE;
- MHL_RCP_CMD_e RCPK_CMD_CODE;
- MHL_RCPE_STATUS_e RCPE_STATUS_CODE;
-
- UINT8 RAP_CMD_CODE;
- UINT8 RAPK_CMD_CODE;
- UINT8 RAPK_STATUS_CODE;
-
- UINT8 UCP_ACT_NUM;
- UINT8 UCP_CMD_CODE;
- UINT8 UCPK_CMD_CODE;
- UINT8 UCPE_STATUS_CODE;
-
- UINT8 bReadDevCap_Offset;
- UINT8 bReadDevCap_Data;
- UINT8 AckWrtStatOffset;
- UINT8 AckWrtStatData;
-
- UINT8 msgData0;
- UINT8 msgData1;
-
- UINT8 MscFailReason; //msc command fail code
- MHL_DDC_CH_ERRCODE_e ddcAbortReason; //retrieve by GET_DDC_ERRORCODE
- MHL_MSC_CH_ERRCODE_e MscAbortReason; //retrieve by GET_MSC_ERRORCODE
- }CbusDrvInstanceData_t;
- void CbusDrvInitCbusRegsList(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvStatus
- // Description: Returns a status flag word containing CBUS driver-specific
- // information about the state of the device.
- // Parameters: none
- // Returns: status flags word for the CBUS Driver
- //------------------------------------------------------------------------------
- CBUS_DRV_STATUS_e CbusDrvStatus(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvInterruptStatusGet
- // Description: Returns the last Interrupt Status data retrieved by the CBUS ISR.
- // Parameters: pData - pointer to return data buffer(1 byte).
- // Returns: TRUE if new interrupt status data is available, FALSE if not.
- // pData - Destination for interrupt status data.
- //------------------------------------------------------------------------------
- void CbusDrvInterruptStatusGet(UINT32 *pData, UINT32 *pData2);
- //------------------------------------------------------------------------------
- // Function: CbusDrvInterruptStatusSet
- // Description: Clears the interrupt variable
- // Parameters: channel
- //------------------------------------------------------------------------------
- void CbusDrvInterruptStatusSet(UINT32 intBits, UINT32 intBits2);
- //------------------------------------------------------------------------------
- // Function: CbusDrvConnectedGet
- // Description: Returns the Connected Status retrieved by the CBUS ISR.
- // Parameters: pData - pointer to return data buffer(1 byte).
- // Returns: pData - Destination for bus status data.
- //------------------------------------------------------------------------------
- void CbusDrvConnectedGet(UINT8 *pData);
- //------------------------------------------------------------------------------
- // Function: CbusDrvSrcPathEnStatusGet
- // Description: Returns the SrcPathEn Status of DrvCbus
- // Parameters: None
- // Returns: SrcPathEn Status
- //------------------------------------------------------------------------------
- BOOL CbusDrvSrcPathEnStatusGet(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvMSCSubDataGet
- // Description: Returns the MSC sub-cmd and data bytes retrieved by the CBUS ISR.
- // Parameters: pbCmdType, pbData - pointer to return data
- // Returns: pbCmdType - the oldest received MSC sub-command type value
- // pbData - the oldest received MSC sub-command data value
- // return TRUE if data is available, otherwise return FALSE
- //------------------------------------------------------------------------------
- BOOL CbusDrvMSCSubDataGet(UINT8 *pbCmdType, UINT8 *pbData);
- //------------------------------------------------------------------------------
- // Function: CbusDrvMsgDataGet
- // Description: Returns the last MSG data retrieved by the CBUS ISR.
- // Parameters: pData - pointer to return data buffer(?? bytes).
- // Returns: TRUE if a new MSG data was available, FALSE if not.
- // pData - Destination for msg data.
- //------------------------------------------------------------------------------
- void CbusDrvMsgDataGet(UINT8 *pData, UINT8 *pData1);
- //------------------------------------------------------------------------------
- // Function: CbusDrvDevCapGet
- // Description: Returns the Device Capability data retrieved by the CBUS ISR.
- // Parameters: pOffset - return offset
- // pData - return fetched data
- //------------------------------------------------------------------------------
- void CbusDrvDevCapGet(UINT8 *pOffset, UINT8 *pData);
- //------------------------------------------------------------------------------
- // Function: CbusDrvDdcAbortReasonGet
- // Description: Returns the last DDC Abort reason received by the CBUS ISR.
- // Parameters: pData - pointer to return data buffer(1 byte).
- // Returns: pData - Destination for DDC Abort reason data.
- //------------------------------------------------------------------------------
- void CbusDrvDdcAbortReasonGet(UINT8 *pData);
- //------------------------------------------------------------------------------
- // Function: CbusDrvMscAbortReasonGet
- // Description: Returns the last MSC Abort reason received by the CBUS ISR.
- // Parameters: pData - pointer to return data buffer(1 byte).
- // Returns: pData - Destination for MSC Abort reason data.
- //------------------------------------------------------------------------------
- void CbusDrvMscAbortReasonGet(UINT8 *pData);
- //------------------------------------------------------------------------------
- // Function: CbusDrvMscFailReasonGet
- // Description: Returns the last MSC Fail reason received by the CBUS ISR.
- // Parameters: pData - pointer to return data buffer(1 byte).
- // Returns: pData - Destination for MSC Fail reason data.
- //------------------------------------------------------------------------------
- void CbusDrvMscFailReasonGet(UINT8 *pData);
- //------------------------------------------------------------------------------
- // Function: CbusDrvNackFromPeerGet
- // Description: checks if peer sent a NACK
- // Parameters: channel - CBus channel
- // Returns: TRUE if peer sent a NACK, FALSE if not.
- //------------------------------------------------------------------------------
- BOOL CbusDrvNackFromPeerGet(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvAbortFromPeerGet
- // Description: Returns the last MSC Abort received by the CBUS ISR.
- // Parameters: NONE
- // Returns: TRUE if a new MSC ABORT data was received, FALSE if not.
- //------------------------------------------------------------------------------
- BOOL CbusDrvAbortFromPeerGet(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvIneffectCodeFromPeerGet
- // Description: Returns the last MSC Ineffect Code received by the CBUS ISR.
- // Parameters: NONE
- // Returns: TRUE if a new MSC INEFFECT_CODE data was received, FALSE if not.
- //------------------------------------------------------------------------------
- BOOL CbusDrvIneffectCodeFromPeerGet(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvWrtBurstAckGet
- // Description: Returns if the peer is return ACK for WRITE_BURST
- // Returns: TRUE/FALSE
- //------------------------------------------------------------------------------
- BOOL CbusDrvWrtBurstAckGet(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvWrtStateAckGet
- // Description: Returns if the peer is return ACK for WRITE_STATE
- // Returns: TRUE/FALSE
- //------------------------------------------------------------------------------
- BOOL CbusDrvWrtStateAckGet(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvWrtStateAckInfoGet
- // Description: Returns if the peer is return ACK for WRITE_STATE
- // Returns: TRUE/FALSE
- //------------------------------------------------------------------------------
- BOOL CbusDrvWrtStateAckInfoGet(UINT8 *pOffset, UINT8 *pData);
- //------------------------------------------------------------------------------
- // Function: CbusDrvDevCapReadyGet
- // Description: Returns if the peer's device capability values are ready
- // Parameters: pData - pointer to return data buffer(1 byte).
- // Returns: TRUE/FALSE
- //------------------------------------------------------------------------------
- BOOL CbusDrvDevCapReadyGet(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvDevCapChangedGet
- // Description: Returns if the peer's device capability values are changed
- // Parameters: pData - pointer to return data buffer(1 byte).
- // Returns: TRUE/FALSE
- //------------------------------------------------------------------------------
- BOOL CbusDrvDevCapChangedGet(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvReqWrtGet
- // Description: Returns if the peer is requesting for scratchpad write permission
- // Parameters: channel
- // Returns: TRUE/FALSE
- //------------------------------------------------------------------------------
- BOOL CbusDrvReqWrtGet(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvGrtWrtGet
- // Description: Returns if the peer is requesting for scratchpad write permission
- // Parameters: channel
- // Returns: TRUE/FALSE
- //------------------------------------------------------------------------------
- BOOL CbusDrvGrtWrtGet(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvWriteCommand
- // Description: Write the specified Sideband Channel command to the CBUS.
- // Command can be a MSC_MSG command(RCP/MCW/RAP), or another command
- // such as READ_DEVCAP, GET_VENDOR_ID, SET_HPD, CLR_HPD, etc.
- //
- // Parameters: channel - CBUS channel to write
- // pReq - Pointer to a cbus_req_t structure containing the
- // command to write
- // Returns: TRUE - successful write
- // FALSE - write failed
- //------------------------------------------------------------------------------
- BOOL CbusDrvWriteCommand(cbus_req_t *pReq );
- //------------------------------------------------------------------------------
- // Function: CbusDrvInitialize
- // Description: Attempts to initialize the CBUS. If register reads return 0xFF,
- // it declares error in initialization.
- // Initializes discovery enabling registers and anything needed in
- // config register, interrupt masks.
- // Returns: TRUE if no problem
- //------------------------------------------------------------------------------
- BOOL CbusDrvInitialize(void);
- //------------------------------------------------------------------------------
- // Function: DrvMHLPortSelectBitsGet
- // Description: Reads the MHL selected port(s)bit-field. This is the value
- // downloaded from NVRAM at boot-up time.
- // Parameters: None
- // Returns: MHL selected port(s)bit-field.
- //
- //------------------------------------------------------------------------------
- UINT8 DrvMHLPortSelectBitsGet(void);
- //------------------------------------------------------------------------------
- // Function: CbusDrvSetSupportRcpKey
- // Description: Set supported RCP key
- //------------------------------------------------------------------------------
- void CbusDrvSetSupportRcpKey(void);
- #endif // __SI_DRV_CBUS_H__
|