Path: blob/master/drivers/gpu/drm/bridge/analogix/anx7625.h
26516 views
/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright(c) 2020, Analogix Semiconductor. All rights reserved.3*4*/56#ifndef __ANX7625_H__7#define __ANX7625_H__89#define ANX7625_DRV_VERSION "0.1.04"1011/* Loading OCM re-trying times */12#define OCM_LOADING_TIME 101314/********* ANX7625 Register **********/15#define TX_P0_ADDR 0x7016#define TX_P1_ADDR 0x7A17#define TX_P2_ADDR 0x721819#define RX_P0_ADDR 0x7e20#define RX_P1_ADDR 0x8421#define RX_P2_ADDR 0x542223#define RSVD_00_ADDR 0x0024#define RSVD_D1_ADDR 0xD125#define RSVD_60_ADDR 0x6026#define RSVD_39_ADDR 0x3927#define RSVD_7F_ADDR 0x7F2829#define TCPC_INTERFACE_ADDR 0x583031/* Clock frequency in Hz */32#define XTAL_FRQ (27 * 1000000)3334#define POST_DIVIDER_MIN 135#define POST_DIVIDER_MAX 1636#define PLL_OUT_FREQ_MIN 520000000UL37#define PLL_OUT_FREQ_MAX 730000000UL38#define PLL_OUT_FREQ_ABS_MIN 300000000UL39#define PLL_OUT_FREQ_ABS_MAX 800000000UL40#define MAX_UNSIGNED_24BIT 16777215UL4142/***************************************************************/43/* Register definition of device address 0x58 */4445#define PRODUCT_ID_L 0x0246#define PRODUCT_ID_H 0x034748#define INTR_ALERT_1 0xCC49#define INTR_SOFTWARE_INT BIT(3)50#define INTR_RECEIVED_MSG BIT(5)5152#define SYSTEM_STSTUS 0x4553#define INTERFACE_CHANGE_INT 0x4454#define HPD_STATUS_CHANGE 0x8055#define HPD_STATUS 0x805657/******** END of I2C Address 0x58 ********/5859/***************************************************************/60/* Register definition of device address 0x70 */61#define TX_HDCP_CTRL0 0x0162#define STORE_AN BIT(7)63#define RX_REPEATER BIT(6)64#define RE_AUTHEN BIT(5)65#define SW_AUTH_OK BIT(4)66#define HARD_AUTH_EN BIT(3)67#define ENC_EN BIT(2)68#define BKSV_SRM_PASS BIT(1)69#define KSVLIST_VLD BIT(0)7071#define SP_TX_WAIT_R0_TIME 0x4072#define SP_TX_WAIT_KSVR_TIME 0x4273#define SP_TX_SYS_CTRL1_REG 0x8074#define HDCP2TX_FW_EN BIT(4)7576#define SP_TX_LINK_BW_SET_REG 0xA077#define SP_TX_LANE_COUNT_SET_REG 0xA17879#define M_VID_0 0xC080#define M_VID_1 0xC181#define M_VID_2 0xC282#define N_VID_0 0xC383#define N_VID_1 0xC484#define N_VID_2 0xC58586#define KEY_START_ADDR 0x900087#define KEY_RESERVED 4168889#define HDCP14KEY_START_ADDR (KEY_START_ADDR + KEY_RESERVED)90#define HDCP14KEY_SIZE 6249192/***************************************************************/93/* Register definition of device address 0x72 */94#define AUX_RST 0x0495#define RST_CTRL2 0x079697#define SP_TX_TOTAL_LINE_STA_L 0x2498#define SP_TX_TOTAL_LINE_STA_H 0x2599#define SP_TX_ACT_LINE_STA_L 0x26100#define SP_TX_ACT_LINE_STA_H 0x27101#define SP_TX_V_F_PORCH_STA 0x28102#define SP_TX_V_SYNC_STA 0x29103#define SP_TX_V_B_PORCH_STA 0x2A104#define SP_TX_TOTAL_PIXEL_STA_L 0x2B105#define SP_TX_TOTAL_PIXEL_STA_H 0x2C106#define SP_TX_ACT_PIXEL_STA_L 0x2D107#define SP_TX_ACT_PIXEL_STA_H 0x2E108#define SP_TX_H_F_PORCH_STA_L 0x2F109#define SP_TX_H_F_PORCH_STA_H 0x30110#define SP_TX_H_SYNC_STA_L 0x31111#define SP_TX_H_SYNC_STA_H 0x32112#define SP_TX_H_B_PORCH_STA_L 0x33113#define SP_TX_H_B_PORCH_STA_H 0x34114115#define SP_TX_VID_CTRL 0x84116#define SP_TX_BPC_MASK 0xE0117#define SP_TX_BPC_6 0x00118#define SP_TX_BPC_8 0x20119#define SP_TX_BPC_10 0x40120#define SP_TX_BPC_12 0x60121122#define VIDEO_BIT_MATRIX_12 0x4c123124#define AUDIO_CHANNEL_STATUS_1 0xd0125#define AUDIO_CHANNEL_STATUS_2 0xd1126#define AUDIO_CHANNEL_STATUS_3 0xd2127#define AUDIO_CHANNEL_STATUS_4 0xd3128#define AUDIO_CHANNEL_STATUS_5 0xd4129#define AUDIO_CHANNEL_STATUS_6 0xd5130#define TDM_SLAVE_MODE 0x10131#define I2S_SLAVE_MODE 0x08132#define AUDIO_LAYOUT 0x01133134#define HPD_DET_TIMER_BIT0_7 0xea135#define HPD_DET_TIMER_BIT8_15 0xeb136#define HPD_DET_TIMER_BIT16_23 0xec137/* HPD debounce time 2ms for 27M clock */138#define HPD_TIME 54000139140#define AUDIO_CONTROL_REGISTER 0xe6141#define TDM_TIMING_MODE 0x08142143#define I2C_ADDR_72_DPTX 0x72144145#define HP_MIN 8146#define HBLANKING_MIN 80147#define SYNC_LEN_DEF 32148#define HFP_HBP_DEF ((HBLANKING_MIN - SYNC_LEN_DEF) / 2)149#define VIDEO_CONTROL_0 0x08150151#define ACTIVE_LINES_L 0x14152#define ACTIVE_LINES_H 0x15 /* Bit[7:6] are reserved */153#define VERTICAL_FRONT_PORCH 0x16154#define VERTICAL_SYNC_WIDTH 0x17155#define VERTICAL_BACK_PORCH 0x18156157#define HORIZONTAL_TOTAL_PIXELS_L 0x19158#define HORIZONTAL_TOTAL_PIXELS_H 0x1A /* Bit[7:6] are reserved */159#define HORIZONTAL_ACTIVE_PIXELS_L 0x1B160#define HORIZONTAL_ACTIVE_PIXELS_H 0x1C /* Bit[7:6] are reserved */161#define HORIZONTAL_FRONT_PORCH_L 0x1D162#define HORIZONTAL_FRONT_PORCH_H 0x1E /* Bit[7:4] are reserved */163#define HORIZONTAL_SYNC_WIDTH_L 0x1F164#define HORIZONTAL_SYNC_WIDTH_H 0x20 /* Bit[7:4] are reserved */165#define HORIZONTAL_BACK_PORCH_L 0x21166#define HORIZONTAL_BACK_PORCH_H 0x22 /* Bit[7:4] are reserved */167168/******** END of I2C Address 0x72 *********/169170/***************************************************************/171/* Register definition of device address 0x7a */172#define DP_TX_SWING_REG_CNT 0x14173#define DP_TX_LANE0_SWING_REG0 0x00174#define DP_TX_LANE1_SWING_REG0 0x14175/******** END of I2C Address 0x7a *********/176177/***************************************************************/178/* Register definition of device address 0x7e */179180#define I2C_ADDR_7E_FLASH_CONTROLLER 0x7E181182#define R_BOOT_RETRY 0x00183#define R_RAM_ADDR_H 0x01184#define R_RAM_ADDR_L 0x02185#define R_RAM_LEN_H 0x03186#define R_RAM_LEN_L 0x04187#define FLASH_LOAD_STA 0x05188#define FLASH_LOAD_STA_CHK BIT(7)189190#define R_RAM_CTRL 0x05191/* bit positions */192#define FLASH_DONE BIT(7)193#define BOOT_LOAD_DONE BIT(6)194#define CRC_OK BIT(5)195#define LOAD_DONE BIT(4)196#define O_RW_DONE BIT(3)197#define FUSE_BUSY BIT(2)198#define DECRYPT_EN BIT(1)199#define LOAD_START BIT(0)200201#define FLASH_ADDR_HIGH 0x0F202#define FLASH_ADDR_LOW 0x10203#define FLASH_LEN_HIGH 0x31204#define FLASH_LEN_LOW 0x32205#define R_FLASH_RW_CTRL 0x33206/* bit positions */207#define READ_DELAY_SELECT BIT(7)208#define GENERAL_INSTRUCTION_EN BIT(6)209#define FLASH_ERASE_EN BIT(5)210#define RDID_READ_EN BIT(4)211#define REMS_READ_EN BIT(3)212#define WRITE_STATUS_EN BIT(2)213#define FLASH_READ BIT(1)214#define FLASH_WRITE BIT(0)215216#define FLASH_BUF_BASE_ADDR 0x60217#define FLASH_BUF_LEN 0x20218219#define XTAL_FRQ_SEL 0x3F220/* bit field positions */221#define XTAL_FRQ_SEL_POS 5222/* bit field values */223#define XTAL_FRQ_19M2 (0 << XTAL_FRQ_SEL_POS)224#define XTAL_FRQ_27M (4 << XTAL_FRQ_SEL_POS)225226#define R_DSC_CTRL_0 0x40227#define READ_STATUS_EN 7228#define CLK_1MEG_RB 6 /* 1MHz clock reset; 0=reset, 0=reset release */229#define DSC_BIST_DONE 1 /* Bit[5:1]: 1=DSC MBIST pass */230#define DSC_EN 0x01 /* 1=DSC enabled, 0=DSC disabled */231232#define OCM_FW_VERSION 0x31233#define OCM_FW_REVERSION 0x32234235#define AP_AUX_ADDR_7_0 0x11236#define AP_AUX_ADDR_15_8 0x12237#define AP_AUX_ADDR_19_16 0x13238239/* Bit[0:3] AUX status, bit 4 op_en, bit 5 address only */240#define AP_AUX_CTRL_STATUS 0x14241#define AP_AUX_CTRL_OP_EN 0x10242#define AP_AUX_CTRL_ADDRONLY 0x20243244#define AP_AUX_BUFF_START 0x15245#define PIXEL_CLOCK_L 0x25246#define PIXEL_CLOCK_H 0x26247248#define AP_AUX_COMMAND 0x27 /* com+len */249#define LENGTH_SHIFT 4250#define DPCD_CMD(len, cmd) ((((len) - 1) << LENGTH_SHIFT) | (cmd))251252/* Bit 0&1: 3D video structure */253/* 0x01: frame packing, 0x02:Line alternative, 0x03:Side-by-side(full) */254#define AP_AV_STATUS 0x28255#define AP_VIDEO_CHG BIT(2)256#define AP_AUDIO_CHG BIT(3)257#define AP_MIPI_MUTE BIT(4) /* 1:MIPI input mute, 0: ummute */258#define AP_MIPI_RX_EN BIT(5) /* 1: MIPI RX input in 0: no RX in */259#define AP_DISABLE_PD BIT(6)260#define AP_DISABLE_DISPLAY BIT(7)261262#define GPIO_CTRL_2 0x49263#define HPD_SOURCE BIT(6)264265/***************************************************************/266/* Register definition of device address 0x84 */267#define MIPI_PHY_CONTROL_3 0x03268#define MIPI_HS_PWD_CLK 7269#define MIPI_HS_RT_CLK 6270#define MIPI_PD_CLK 5271#define MIPI_CLK_RT_MANUAL_PD_EN 4272#define MIPI_CLK_HS_MANUAL_PD_EN 3273#define MIPI_CLK_DET_DET_BYPASS 2274#define MIPI_CLK_MISS_CTRL 1275#define MIPI_PD_LPTX_CH_MANUAL_PD_EN 0276277#define MIPI_LANE_CTRL_0 0x05278#define MIPI_TIME_HS_PRPR 0x08279280/*281* After MIPI RX protocol layer received video frames,282* Protocol layer starts to reconstruct video stream from PHY283*/284#define MIPI_VIDEO_STABLE_CNT 0x0A285286#define MIPI_LANE_CTRL_10 0x0F287#define MIPI_DIGITAL_ADJ_1 0x1B288#define IVO_MID 0x26CF289290#define MIPI_PLL_M_NUM_23_16 0x1E291#define MIPI_PLL_M_NUM_15_8 0x1F292#define MIPI_PLL_M_NUM_7_0 0x20293#define MIPI_PLL_N_NUM_23_16 0x21294#define MIPI_PLL_N_NUM_15_8 0x22295#define MIPI_PLL_N_NUM_7_0 0x23296297#define MIPI_DIGITAL_PLL_6 0x2A298/* Bit[7:6]: VCO band control, only effective */299#define MIPI_M_NUM_READY 0x10300#define MIPI_N_NUM_READY 0x08301#define STABLE_INTEGER_CNT_EN 0x04302#define MIPI_PLL_TEST_BIT 0303/* Bit[1:0]: test point output select - */304/* 00: VCO power, 01: dvdd_pdt, 10: dvdd, 11: vcox */305306#define MIPI_DIGITAL_PLL_7 0x2B307#define MIPI_PLL_FORCE_N_EN 7308#define MIPI_PLL_FORCE_BAND_EN 6309310#define MIPI_PLL_VCO_TUNE_REG 4311/* Bit[5:4]: VCO metal capacitance - */312/* 00: +20% fast, 01: +10% fast (default), 10: typical, 11: -10% slow */313#define MIPI_PLL_VCO_TUNE_REG_VAL 0x30314315#define MIPI_PLL_PLL_LDO_BIT 2316/* Bit[3:2]: vco_v2i power - */317/* 00: 1.40V, 01: 1.45V (default), 10: 1.50V, 11: 1.55V */318#define MIPI_PLL_RESET_N 0x02319#define MIPI_FRQ_FORCE_NDET 0320321#define MIPI_ALERT_CLR_0 0x2D322#define HS_link_error_clear 7323/* This bit itself is S/C, and it clears 0x84:0x31[7] */324325#define MIPI_ALERT_OUT_0 0x31326#define check_sum_err_hs_sync 7327/* This bit is cleared by 0x84:0x2D[7] */328329#define MIPI_DIGITAL_PLL_8 0x33330#define MIPI_POST_DIV_VAL 4331/* N means divided by (n+1), n = 0~15 */332#define MIPI_EN_LOCK_FRZ 3333#define MIPI_FRQ_COUNTER_RST 2334#define MIPI_FRQ_SET_REG_8 1335/* Bit 0 is reserved */336337#define MIPI_DIGITAL_PLL_9 0x34338339#define MIPI_DIGITAL_PLL_16 0x3B340#define MIPI_FRQ_FREEZE_NDET 7341#define MIPI_FRQ_REG_SET_ENABLE 6342#define MIPI_REG_FORCE_SEL_EN 5343#define MIPI_REG_SEL_DIV_REG 4344#define MIPI_REG_FORCE_PRE_DIV_EN 3345/* Bit 2 is reserved */346#define MIPI_FREF_D_IND 1347#define REF_CLK_27000KHZ 1348#define REF_CLK_19200KHZ 0349#define MIPI_REG_PLL_PLL_TEST_ENABLE 0350351#define MIPI_DIGITAL_PLL_18 0x3D352#define FRQ_COUNT_RB_SEL 7353#define REG_FORCE_POST_DIV_EN 6354#define MIPI_DPI_SELECT 5355#define SELECT_DSI 1356#define SELECT_DPI 0357#define REG_BAUD_DIV_RATIO 0358359#define H_BLANK_L 0x3E360/* For DSC only */361#define H_BLANK_H 0x3F362/* For DSC only; note: bit[7:6] are reserved */363#define MIPI_SWAP 0x4A364#define MIPI_SWAP_CH0 7365#define MIPI_SWAP_CH1 6366#define MIPI_SWAP_CH2 5367#define MIPI_SWAP_CH3 4368#define MIPI_SWAP_CLK 3369/* Bit[2:0] are reserved */370371/******** END of I2C Address 0x84 *********/372373/* DPCD regs */374#define DPCD_DPCD_REV 0x00375#define DPCD_MAX_LINK_RATE 0x01376#define DPCD_MAX_LANE_COUNT 0x02377378/********* ANX7625 Register End **********/379380/***************** Display *****************/381enum audio_fs {382AUDIO_FS_441K = 0x00,383AUDIO_FS_48K = 0x02,384AUDIO_FS_32K = 0x03,385AUDIO_FS_882K = 0x08,386AUDIO_FS_96K = 0x0a,387AUDIO_FS_1764K = 0x0c,388AUDIO_FS_192K = 0x0e389};390391enum audio_wd_len {392AUDIO_W_LEN_16_20MAX = 0x02,393AUDIO_W_LEN_18_20MAX = 0x04,394AUDIO_W_LEN_17_20MAX = 0x0c,395AUDIO_W_LEN_19_20MAX = 0x08,396AUDIO_W_LEN_20_20MAX = 0x0a,397AUDIO_W_LEN_20_24MAX = 0x03,398AUDIO_W_LEN_22_24MAX = 0x05,399AUDIO_W_LEN_21_24MAX = 0x0d,400AUDIO_W_LEN_23_24MAX = 0x09,401AUDIO_W_LEN_24_24MAX = 0x0b402};403404#define I2S_CH_2 0x01405#define TDM_CH_4 0x03406#define TDM_CH_6 0x05407#define TDM_CH_8 0x07408409#define MAX_DPCD_BUFFER_SIZE 16410411#define ONE_BLOCK_SIZE 128412#define FOUR_BLOCK_SIZE (128 * 4)413414#define MAX_EDID_BLOCK 3415#define EDID_TRY_CNT 3416#define SUPPORT_PIXEL_CLOCK 300000417418/***************** Display End *****************/419420#define MAX_LANES_SUPPORT 4421422struct anx7625_platform_data {423struct gpio_desc *gpio_p_on;424struct gpio_desc *gpio_reset;425struct regulator_bulk_data supplies[3];426struct drm_bridge *panel_bridge;427int intp_irq;428int is_dpi;429int mipi_lanes;430int audio_en;431int dp_lane0_swing_reg_cnt;432u8 lane0_reg_data[DP_TX_SWING_REG_CNT];433int dp_lane1_swing_reg_cnt;434u8 lane1_reg_data[DP_TX_SWING_REG_CNT];435u32 low_power_mode;436struct device_node *mipi_host_node;437};438439struct anx7625_i2c_client {440struct i2c_client *tx_p0_client;441struct i2c_client *tx_p1_client;442struct i2c_client *tx_p2_client;443struct i2c_client *rx_p0_client;444struct i2c_client *rx_p1_client;445struct i2c_client *rx_p2_client;446struct i2c_client *tcpc_client;447};448449struct anx7625_data {450struct anx7625_platform_data pdata;451struct platform_device *audio_pdev;452int hpd_status;453int hpd_high_cnt;454int dp_en;455int hdcp_cp;456/* Lock for work queue */457struct mutex lock;458struct device *dev;459struct anx7625_i2c_client i2c;460struct i2c_client *last_client;461struct timer_list hdcp_timer;462const struct drm_edid *cached_drm_edid;463struct device *codec_dev;464hdmi_codec_plugged_cb plugged_cb;465struct work_struct work;466struct workqueue_struct *workqueue;467struct delayed_work hdcp_work;468struct workqueue_struct *hdcp_workqueue;469/* Lock for hdcp work queue */470struct mutex hdcp_wq_lock;471/* Lock for aux transfer and disable */472struct mutex aux_lock;473char edid_block;474struct display_timing dt;475u8 display_timing_valid;476struct drm_bridge bridge;477u8 bridge_attached;478struct drm_connector *connector;479struct mipi_dsi_device *dsi;480struct drm_dp_aux aux;481};482483#endif /* __ANX7625_H__ */484485486