linux/drivers/gpu/drm/rockchip/cdn-dp-reg.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd
 * Author: Chris Zhong <[email protected]>
 */

#ifndef _CDN_DP_REG_H
#define _CDN_DP_REG_H

#include <linux/bitops.h>

#define ADDR_IMEM
#define ADDR_DMEM

/* APB CFG addr */
#define APB_CTRL
#define XT_INT_CTRL
#define MAILBOX_FULL_ADDR
#define MAILBOX_EMPTY_ADDR
#define MAILBOX0_WR_DATA
#define MAILBOX0_RD_DATA
#define KEEP_ALIVE
#define VER_L
#define VER_H
#define VER_LIB_L_ADDR
#define VER_LIB_H_ADDR
#define SW_DEBUG_L
#define SW_DEBUG_H
#define MAILBOX_INT_MASK
#define MAILBOX_INT_STATUS
#define SW_CLK_L
#define SW_CLK_H
#define SW_EVENTS0
#define SW_EVENTS1
#define SW_EVENTS2
#define SW_EVENTS3
#define XT_OCD_CTRL
#define APB_INT_MASK
#define APB_STATUS_MASK

/* audio decoder addr */
#define AUDIO_SRC_CNTL
#define AUDIO_SRC_CNFG
#define COM_CH_STTS_BITS
#define STTS_BIT_CH(x)
#define SPDIF_CTRL_ADDR
#define SPDIF_CH1_CS_3100_ADDR
#define SPDIF_CH1_CS_6332_ADDR
#define SPDIF_CH1_CS_9564_ADDR
#define SPDIF_CH1_CS_12796_ADDR
#define SPDIF_CH1_CS_159128_ADDR
#define SPDIF_CH1_CS_191160_ADDR
#define SPDIF_CH2_CS_3100_ADDR
#define SPDIF_CH2_CS_6332_ADDR
#define SPDIF_CH2_CS_9564_ADDR
#define SPDIF_CH2_CS_12796_ADDR
#define SPDIF_CH2_CS_159128_ADDR
#define SPDIF_CH2_CS_191160_ADDR
#define SMPL2PKT_CNTL
#define SMPL2PKT_CNFG
#define FIFO_CNTL
#define FIFO_STTS

/* source pif addr */
#define SOURCE_PIF_WR_ADDR
#define SOURCE_PIF_WR_REQ
#define SOURCE_PIF_RD_ADDR
#define SOURCE_PIF_RD_REQ
#define SOURCE_PIF_DATA_WR
#define SOURCE_PIF_DATA_RD
#define SOURCE_PIF_FIFO1_FLUSH
#define SOURCE_PIF_FIFO2_FLUSH
#define SOURCE_PIF_STATUS
#define SOURCE_PIF_INTERRUPT_SOURCE
#define SOURCE_PIF_INTERRUPT_MASK
#define SOURCE_PIF_PKT_ALLOC_REG
#define SOURCE_PIF_PKT_ALLOC_WR_EN
#define SOURCE_PIF_SW_RESET

/* bellow registers need access by mailbox */
/* source car addr */
#define SOURCE_HDTX_CAR
#define SOURCE_DPTX_CAR
#define SOURCE_PHY_CAR
#define SOURCE_CEC_CAR
#define SOURCE_CBUS_CAR
#define SOURCE_PKT_CAR
#define SOURCE_AIF_CAR
#define SOURCE_CIPHER_CAR
#define SOURCE_CRYPTO_CAR

/* clock meters addr */
#define CM_CTRL
#define CM_I2S_CTRL
#define CM_SPDIF_CTRL
#define CM_VID_CTRL
#define CM_LANE_CTRL
#define I2S_NM_STABLE
#define I2S_NCTS_STABLE
#define SPDIF_NM_STABLE
#define SPDIF_NCTS_STABLE
#define NMVID_MEAS_STABLE
#define I2S_MEAS
#define SPDIF_MEAS
#define NMVID_MEAS

/* source vif addr */
#define BND_HSYNC2VSYNC
#define HSYNC2VSYNC_F1_L1
#define HSYNC2VSYNC_F2_L1
#define HSYNC2VSYNC_STATUS
#define HSYNC2VSYNC_POL_CTRL

/* dptx phy addr */
#define DP_TX_PHY_CONFIG_REG
#define DP_TX_PHY_SW_RESET
#define DP_TX_PHY_SCRAMBLER_SEED
#define DP_TX_PHY_TRAINING_01_04
#define DP_TX_PHY_TRAINING_05_08
#define DP_TX_PHY_TRAINING_09_10
#define TEST_COR

/* dptx hpd addr */
#define HPD_IRQ_DET_MIN_TIMER
#define HPD_IRQ_DET_MAX_TIMER
#define HPD_UNPLGED_DET_MIN_TIMER
#define HPD_STABLE_TIMER
#define HPD_FILTER_TIMER
#define HPD_EVENT_MASK
#define HPD_EVENT_DET

/* dpyx framer addr */
#define DP_FRAMER_GLOBAL_CONFIG
#define DP_SW_RESET
#define DP_FRAMER_TU
#define DP_FRAMER_PXL_REPR
#define DP_FRAMER_SP
#define AUDIO_PACK_CONTROL
#define DP_VC_TABLE(x)
#define DP_VB_ID
#define DP_MTPH_LVP_CONTROL
#define DP_MTPH_SYMBOL_VALUES
#define DP_MTPH_ECF_CONTROL
#define DP_MTPH_ACT_CONTROL
#define DP_MTPH_STATUS
#define DP_INTERRUPT_SOURCE
#define DP_INTERRUPT_MASK
#define DP_FRONT_BACK_PORCH
#define DP_BYTE_COUNT

/* dptx stream addr */
#define MSA_HORIZONTAL_0
#define MSA_HORIZONTAL_1
#define MSA_VERTICAL_0
#define MSA_VERTICAL_1
#define MSA_MISC
#define STREAM_CONFIG
#define AUDIO_PACK_STATUS
#define VIF_STATUS
#define PCK_STUFF_STATUS_0
#define PCK_STUFF_STATUS_1
#define INFO_PACK_STATUS
#define RATE_GOVERNOR_STATUS
#define DP_HORIZONTAL
#define DP_VERTICAL_0
#define DP_VERTICAL_1
#define DP_BLOCK_SDP

/* dptx glbl addr */
#define DPTX_LANE_EN
#define DPTX_ENHNCD
#define DPTX_INT_MASK
#define DPTX_INT_STATUS

/* dp aux addr */
#define DP_AUX_HOST_CONTROL
#define DP_AUX_INTERRUPT_SOURCE
#define DP_AUX_INTERRUPT_MASK
#define DP_AUX_SWAP_INVERSION_CONTROL
#define DP_AUX_SEND_NACK_TRANSACTION
#define DP_AUX_CLEAR_RX
#define DP_AUX_CLEAR_TX
#define DP_AUX_TIMER_STOP
#define DP_AUX_TIMER_CLEAR
#define DP_AUX_RESET_SW
#define DP_AUX_DIVIDE_2M
#define DP_AUX_TX_PREACHARGE_LENGTH
#define DP_AUX_FREQUENCY_1M_MAX
#define DP_AUX_FREQUENCY_1M_MIN
#define DP_AUX_RX_PRE_MIN
#define DP_AUX_RX_PRE_MAX
#define DP_AUX_TIMER_PRESET
#define DP_AUX_NACK_FORMAT
#define DP_AUX_TX_DATA
#define DP_AUX_RX_DATA
#define DP_AUX_TX_STATUS
#define DP_AUX_RX_STATUS
#define DP_AUX_RX_CYCLE_COUNTER
#define DP_AUX_MAIN_STATES
#define DP_AUX_MAIN_TIMER
#define DP_AUX_AFE_OUT

/* crypto addr */
#define CRYPTO_HDCP_REVISION
#define HDCP_CRYPTO_CONFIG
#define CRYPTO_INTERRUPT_SOURCE
#define CRYPTO_INTERRUPT_MASK
#define CRYPTO22_CONFIG
#define CRYPTO22_STATUS
#define SHA_256_DATA_IN
#define SHA_256_DATA_OUT_(x)
#define AES_32_KEY_(x)
#define AES_32_DATA_IN
#define AES_32_DATA_OUT_(x)
#define CRYPTO14_CONFIG
#define CRYPTO14_STATUS
#define CRYPTO14_PRNM_OUT
#define CRYPTO14_KM_0
#define CRYPTO14_KM_1
#define CRYPTO14_AN_0
#define CRYPTO14_AN_1
#define CRYPTO14_YOUR_KSV_0
#define CRYPTO14_YOUR_KSV_1
#define CRYPTO14_MI_0
#define CRYPTO14_MI_1
#define CRYPTO14_TI_0
#define CRYPTO14_KI_0
#define CRYPTO14_KI_1
#define CRYPTO14_BLOCKS_NUM
#define CRYPTO14_KEY_MEM_DATA_0
#define CRYPTO14_KEY_MEM_DATA_1
#define CRYPTO14_SHA1_MSG_DATA
#define CRYPTO14_SHA1_V_VALUE_(x)
#define TRNG_CTRL
#define TRNG_DATA_RDY
#define TRNG_DATA

/* cipher addr */
#define HDCP_REVISION
#define INTERRUPT_SOURCE
#define INTERRUPT_MASK
#define HDCP_CIPHER_CONFIG
#define AES_128_KEY_0
#define AES_128_KEY_1
#define AES_128_KEY_2
#define AES_128_KEY_3
#define AES_128_RANDOM_0
#define AES_128_RANDOM_1
#define CIPHER14_KM_0
#define CIPHER14_KM_1
#define CIPHER14_STATUS
#define CIPHER14_RI_PJ_STATUS
#define CIPHER_MODE
#define CIPHER14_AN_0
#define CIPHER14_AN_1
#define CIPHER22_AUTH
#define CIPHER14_R0_DP_STATUS
#define CIPHER14_BOOTSTRAP

#define DPTX_FRMR_DATA_CLK_RSTN_EN
#define DPTX_FRMR_DATA_CLK_EN
#define DPTX_PHY_DATA_RSTN_EN
#define DPTX_PHY_DATA_CLK_EN
#define DPTX_PHY_CHAR_RSTN_EN
#define DPTX_PHY_CHAR_CLK_EN
#define SOURCE_AUX_SYS_CLK_RSTN_EN
#define SOURCE_AUX_SYS_CLK_EN
#define DPTX_SYS_CLK_RSTN_EN
#define DPTX_SYS_CLK_EN
#define CFG_DPTX_VIF_CLK_RSTN_EN
#define CFG_DPTX_VIF_CLK_EN

#define SOURCE_PHY_RSTN_EN
#define SOURCE_PHY_CLK_EN

#define SOURCE_PKT_SYS_RSTN_EN
#define SOURCE_PKT_SYS_CLK_EN
#define SOURCE_PKT_DATA_RSTN_EN
#define SOURCE_PKT_DATA_CLK_EN

#define SPDIF_CDR_CLK_RSTN_EN
#define SPDIF_CDR_CLK_EN
#define SOURCE_AIF_SYS_RSTN_EN
#define SOURCE_AIF_SYS_CLK_EN
#define SOURCE_AIF_CLK_RSTN_EN
#define SOURCE_AIF_CLK_EN

#define SOURCE_CIPHER_SYSTEM_CLK_RSTN_EN
#define SOURCE_CIPHER_SYS_CLK_EN
#define SOURCE_CIPHER_CHAR_CLK_RSTN_EN
#define SOURCE_CIPHER_CHAR_CLK_EN

#define SOURCE_CRYPTO_SYS_CLK_RSTN_EN
#define SOURCE_CRYPTO_SYS_CLK_EN

#define APB_IRAM_PATH
#define APB_DRAM_PATH
#define APB_XT_RESET

#define MAILBOX_INT_MASK_BIT
#define PIF_INT_MASK_BIT
#define ALL_INT_MASK

/* mailbox */
#define MB_OPCODE_ID
#define MB_MODULE_ID
#define MB_SIZE_MSB_ID
#define MB_SIZE_LSB_ID
#define MB_DATA_ID

#define MB_MODULE_ID_DP_TX
#define MB_MODULE_ID_HDCP_TX
#define MB_MODULE_ID_HDCP_RX
#define MB_MODULE_ID_HDCP_GENERAL
#define MB_MODULE_ID_GENERAL

/* general opcode */
#define GENERAL_MAIN_CONTROL
#define GENERAL_TEST_ECHO
#define GENERAL_BUS_SETTINGS
#define GENERAL_TEST_ACCESS

#define DPTX_SET_POWER_MNG
#define DPTX_SET_HOST_CAPABILITIES
#define DPTX_GET_EDID
#define DPTX_READ_DPCD
#define DPTX_WRITE_DPCD
#define DPTX_ENABLE_EVENT
#define DPTX_WRITE_REGISTER
#define DPTX_READ_REGISTER
#define DPTX_WRITE_FIELD
#define DPTX_TRAINING_CONTROL
#define DPTX_READ_EVENT
#define DPTX_READ_LINK_STAT
#define DPTX_SET_VIDEO
#define DPTX_SET_AUDIO
#define DPTX_GET_LAST_AUX_STAUS
#define DPTX_SET_LINK_BREAK_POINT
#define DPTX_FORCE_LANES
#define DPTX_HPD_STATE

#define FW_STANDBY
#define FW_ACTIVE

#define DPTX_EVENT_ENABLE_HPD
#define DPTX_EVENT_ENABLE_TRAINING

#define LINK_TRAINING_NOT_ACTIVE
#define LINK_TRAINING_RUN
#define LINK_TRAINING_RESTART

#define CONTROL_VIDEO_IDLE
#define CONTROL_VIDEO_VALID

#define TU_CNT_RST_EN
#define VIF_BYPASS_INTERLACE
#define INTERLACE_FMT_DET
#define INTERLACE_DTCT_WIN

#define DP_FRAMER_SP_INTERLACE_EN
#define DP_FRAMER_SP_HSP
#define DP_FRAMER_SP_VSP

/* capability */
#define AUX_HOST_INVERT
#define FAST_LT_SUPPORT
#define FAST_LT_NOT_SUPPORT
#define LANE_MAPPING_NORMAL
#define LANE_MAPPING_FLIPPED
#define ENHANCED
#define SCRAMBLER_EN

#define FULL_LT_STARTED
#define FASE_LT_STARTED
#define CLK_RECOVERY_FINISHED
#define EQ_PHASE_FINISHED
#define FASE_LT_START_FINISHED
#define CLK_RECOVERY_FAILED
#define EQ_PHASE_FAILED
#define FASE_LT_FAILED

#define DPTX_HPD_EVENT
#define DPTX_TRAINING_EVENT
#define HDCP_TX_STATUS_EVENT
#define HDCP2_TX_IS_KM_STORED_EVENT
#define HDCP2_TX_STORE_KM_EVENT
#define HDCP_TX_IS_RECEIVER_ID_VALID_EVENT

#define TU_SIZE
#define CDN_DP_MAX_LINK_RATE

/* audio */
#define AUDIO_PACK_EN
#define SAMPLING_FREQ(x)
#define ORIGINAL_SAMP_FREQ(x)
#define SYNC_WR_TO_CH_ZERO
#define I2S_DEC_START
#define AUDIO_SW_RST
#define SMPL2PKT_EN
#define MAX_NUM_CH(x)
#define NUM_OF_I2S_PORTS(x)
#define AUDIO_TYPE_LPCM
#define CFG_SUB_PCKT_NUM(x)
#define AUDIO_CH_NUM(x)
#define TRANS_SMPL_WIDTH_16
#define TRANS_SMPL_WIDTH_24
#define TRANS_SMPL_WIDTH_32
#define I2S_DEC_PORT_EN(x)
#define SPDIF_ENABLE
#define SPDIF_AVG_SEL
#define SPDIF_JITTER_BYPASS
#define SPDIF_FIFO_MID_RANGE(x)
#define SPDIF_JITTER_THRSH(x)
#define SPDIF_JITTER_AVG_WIN(x)

/* Reference cycles when using lane clock as reference */
#define LANE_REF_CYC

enum voltage_swing_level {};

enum pre_emphasis_level {};

enum pattern_set {};

enum vic_color_depth {};

enum vic_bt_type {};

void cdn_dp_clock_reset(struct cdn_dp_device *dp);

void cdn_dp_set_fw_clk(struct cdn_dp_device *dp, unsigned long clk);
int cdn_dp_load_firmware(struct cdn_dp_device *dp, const u32 *i_mem,
			 u32 i_size, const u32 *d_mem, u32 d_size);
int cdn_dp_set_firmware_active(struct cdn_dp_device *dp, bool enable);
int cdn_dp_set_host_cap(struct cdn_dp_device *dp, u8 lanes, bool flip);
int cdn_dp_event_config(struct cdn_dp_device *dp);
u32 cdn_dp_get_event(struct cdn_dp_device *dp);
int cdn_dp_get_hpd_status(struct cdn_dp_device *dp);
int cdn_dp_dpcd_write(struct cdn_dp_device *dp, u32 addr, u8 value);
int cdn_dp_dpcd_read(struct cdn_dp_device *dp, u32 addr, u8 *data, u16 len);
int cdn_dp_get_edid_block(void *dp, u8 *edid,
			  unsigned int block, size_t length);
int cdn_dp_train_link(struct cdn_dp_device *dp);
int cdn_dp_set_video_status(struct cdn_dp_device *dp, int active);
int cdn_dp_config_video(struct cdn_dp_device *dp);
int cdn_dp_audio_stop(struct cdn_dp_device *dp, struct audio_info *audio);
int cdn_dp_audio_mute(struct cdn_dp_device *dp, bool enable);
int cdn_dp_audio_config(struct cdn_dp_device *dp, struct audio_info *audio);
#endif /* _CDN_DP_REG_H */