Despite the fact, that SFI and RXAUI modes are present on supported feature list, their configuration was non existent and could not be executed. This patch adds the missing initialization sequences. Because ComPhySgmiiRFUPowerUp routine is common for SGMII, SFI and RXAUI, rename it and reuse for those modes.
Also add an option to use XFI mode (SFI @ 5156 MHz).
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Marcin Wojtas mw@semihalf.com --- Platforms/Marvell/Library/ComPhyLib/ComPhyCp110.c | 517 +++++++++++++++++++++- Platforms/Marvell/Library/ComPhyLib/ComPhyLib.c | 4 +- Platforms/Marvell/Library/ComPhyLib/ComPhyLib.h | 60 ++- 3 files changed, 573 insertions(+), 8 deletions(-)
diff --git a/Platforms/Marvell/Library/ComPhyLib/ComPhyCp110.c b/Platforms/Marvell/Library/ComPhyLib/ComPhyCp110.c index c012919..0e18222 100755 --- a/Platforms/Marvell/Library/ComPhyLib/ComPhyCp110.c +++ b/Platforms/Marvell/Library/ComPhyLib/ComPhyCp110.c @@ -1181,7 +1181,7 @@ ComPhySgmiiPhyConfiguration (
STATIC EFI_STATUS -ComPhySgmiiRFUPowerUp ( +ComPhyEthCommonRFUPowerUp ( IN EFI_PHYSICAL_ADDRESS SdIpAddr ) { @@ -1267,7 +1267,513 @@ ComPhySgmiiPowerUp (
DEBUG((DEBUG_INFO, "ComPhy: stage: RFU configurations - Power Up PLL,Tx,Rx\n"));
- Status = ComPhySgmiiRFUPowerUp (SdIpAddr); + Status = ComPhyEthCommonRFUPowerUp (SdIpAddr); + + return Status; +} + +STATIC +VOID +ComPhySfiRFUConfiguration ( + IN EFI_PHYSICAL_ADDRESS ComPhyAddr, + IN EFI_PHYSICAL_ADDRESS SdIpAddr +) +{ + UINT32 Mask, Data; + + Mask = COMMON_PHY_CFG1_PWR_UP_MASK; + Data = 0x1 << COMMON_PHY_CFG1_PWR_UP_OFFSET; + Mask |= COMMON_PHY_CFG1_PIPE_SELECT_MASK; + Data |= 0x0 << COMMON_PHY_CFG1_PIPE_SELECT_OFFSET; + RegSet (ComPhyAddr + COMMON_PHY_CFG1_REG, Data, Mask); + + /* Select Baud Rate of Comphy And PD_PLL/Tx/Rx */ + Mask = SD_EXTERNAL_CONFIG0_SD_PU_PLL_MASK; + Data = 0x0 << SD_EXTERNAL_CONFIG0_SD_PU_PLL_OFFSET; + Mask |= SD_EXTERNAL_CONFIG0_SD_PHY_GEN_RX_MASK; + Data |= 0xE << SD_EXTERNAL_CONFIG0_SD_PHY_GEN_RX_OFFSET; + Mask |= SD_EXTERNAL_CONFIG0_SD_PHY_GEN_TX_MASK; + Data |= 0xE << SD_EXTERNAL_CONFIG0_SD_PHY_GEN_TX_OFFSET; + Mask |= SD_EXTERNAL_CONFIG0_SD_PU_RX_MASK; + Data |= 0 << SD_EXTERNAL_CONFIG0_SD_PU_RX_OFFSET; + Mask |= SD_EXTERNAL_CONFIG0_SD_PU_TX_MASK; + Data |= 0 << SD_EXTERNAL_CONFIG0_SD_PU_TX_OFFSET; + Mask |= SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_MASK; + Data |= 0 << SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_OFFSET; + RegSet (SdIpAddr + SD_EXTERNAL_CONFIG0_REG, Data, Mask); + + /* Release from hard reset */ + Mask = SD_EXTERNAL_CONFIG1_RESET_IN_MASK; + Data = 0x0 << SD_EXTERNAL_CONFIG1_RESET_IN_OFFSET; + Mask |= SD_EXTERNAL_CONFIG1_RESET_CORE_MASK; + Data |= 0x0 << SD_EXTERNAL_CONFIG1_RESET_CORE_OFFSET; + Mask |= SD_EXTERNAL_CONFIG1_RF_RESET_IN_MASK; + Data |= 0x0 << SD_EXTERNAL_CONFIG1_RF_RESET_IN_OFFSET; + RegSet (SdIpAddr + SD_EXTERNAL_CONFIG1_REG, Data, Mask); + + Mask = SD_EXTERNAL_CONFIG1_RESET_IN_MASK; + Data = 0x1 << SD_EXTERNAL_CONFIG1_RESET_IN_OFFSET; + Mask |= SD_EXTERNAL_CONFIG1_RESET_CORE_MASK; + Data |= 0x1 << SD_EXTERNAL_CONFIG1_RESET_CORE_OFFSET; + RegSet (SdIpAddr + SD_EXTERNAL_CONFIG1_REG, Data, Mask); + + /* Wait 1ms - until band gap and ref clock ready */ + MicroSecondDelay (1000); + MemoryFence (); +} + +STATIC +VOID +ComPhySfiPhyConfiguration ( + IN EFI_PHYSICAL_ADDRESS HpipeAddr, + IN UINT32 SfiSpeed +) +{ + UINT32 Mask, Data; + + /* Set reference clock */ + Mask = HPIPE_MISC_ICP_FORCE_MASK; + Data = (SfiSpeed == PHY_SPEED_5_15625G) ? + (0x0 << HPIPE_MISC_ICP_FORCE_OFFSET) : + (0x1 << HPIPE_MISC_ICP_FORCE_OFFSET); + Mask |= HPIPE_MISC_REFCLK_SEL_MASK; + Data |= 0x0 << HPIPE_MISC_REFCLK_SEL_OFFSET; + RegSet (HpipeAddr + HPIPE_MISC_REG, Data, Mask); + + /* Power and PLL Control */ + Mask = HPIPE_PWR_PLL_REF_FREQ_MASK; + Data = 0x1 << HPIPE_PWR_PLL_REF_FREQ_OFFSET; + Mask |= HPIPE_PWR_PLL_PHY_MODE_MASK; + Data |= 0x4 << HPIPE_PWR_PLL_PHY_MODE_OFFSET; + RegSet (HpipeAddr + HPIPE_PWR_PLL_REG, Data, Mask); + + /* Loopback register */ + Mask = HPIPE_LOOPBACK_SEL_MASK; + Data = 0x1 << HPIPE_LOOPBACK_SEL_OFFSET; + RegSet (HpipeAddr + HPIPE_LOOPBACK_REG, Data, Mask); + + /* Rx control 1 */ + Mask = HPIPE_RX_CONTROL_1_RXCLK2X_SEL_MASK; + Data = 0x1 << HPIPE_RX_CONTROL_1_RXCLK2X_SEL_OFFSET; + Mask |= HPIPE_RX_CONTROL_1_CLK8T_EN_MASK; + Data |= 0x1 << HPIPE_RX_CONTROL_1_CLK8T_EN_OFFSET; + RegSet (HpipeAddr + HPIPE_RX_CONTROL_1_REG, Data, Mask); + + /* DTL Control */ + Mask = HPIPE_PWR_CTR_DTL_FLOOP_EN_MASK; + Data = 0x1 << HPIPE_PWR_CTR_DTL_FLOOP_EN_OFFSET; + RegSet (HpipeAddr + HPIPE_PWR_CTR_DTL_REG, Data, Mask); + + /* Transmitter/Receiver Speed Divider Force */ + if (SfiSpeed == PHY_SPEED_5_15625G) { + Mask = HPIPE_SPD_DIV_FORCE_RX_SPD_DIV_MASK; + Data = 1 << HPIPE_SPD_DIV_FORCE_RX_SPD_DIV_OFFSET; + Mask |= HPIPE_SPD_DIV_FORCE_RX_SPD_DIV_FORCE_MASK; + Data |= 1 << HPIPE_SPD_DIV_FORCE_RX_SPD_DIV_FORCE_OFFSET; + Mask |= HPIPE_SPD_DIV_FORCE_TX_SPD_DIV_MASK; + Data |= 1 << HPIPE_SPD_DIV_FORCE_TX_SPD_DIV_OFFSET; + Mask |= HPIPE_SPD_DIV_FORCE_TX_SPD_DIV_FORCE_MASK; + Data |= 1 << HPIPE_SPD_DIV_FORCE_TX_SPD_DIV_FORCE_OFFSET; + } else { + Mask = HPIPE_TXDIGCK_DIV_FORCE_MASK; + Data = 0x1 << HPIPE_TXDIGCK_DIV_FORCE_OFFSET; + } + RegSet (HpipeAddr + HPIPE_SPD_DIV_FORCE_REG, Data, Mask); +} + +STATIC +VOID +ComPhySfiSetAnalogParameters ( + IN EFI_PHYSICAL_ADDRESS HpipeAddr, + IN EFI_PHYSICAL_ADDRESS SdIpAddr, + IN UINT32 SfiSpeed +) +{ + UINT32 Mask, Data; + + /* SERDES External Configuration 2 */ + Mask = SD_EXTERNAL_CONFIG2_PIN_DFE_EN_MASK; + Data = 0x1 << SD_EXTERNAL_CONFIG2_PIN_DFE_EN_OFFSET; + RegSet (SdIpAddr + SD_EXTERNAL_CONFIG2_REG, Data, Mask); + + /* DFE Resolution control */ + Mask = HPIPE_DFE_RES_FORCE_MASK; + Data = 0x1 << HPIPE_DFE_RES_FORCE_OFFSET; + RegSet (HpipeAddr + HPIPE_DFE_REG0, Data, Mask); + + /* Generation 1 setting_0 */ + if (SfiSpeed == PHY_SPEED_5_15625G) { + Mask = HPIPE_G1_SET_0_G1_TX_EMPH1_MASK; + Data = 0x6 << HPIPE_G1_SET_0_G1_TX_EMPH1_OFFSET; + } else { + Mask = HPIPE_G1_SET_0_G1_TX_AMP_MASK; + Data = 0x1c << HPIPE_G1_SET_0_G1_TX_AMP_OFFSET; + Mask |= HPIPE_G1_SET_0_G1_TX_EMPH1_MASK; + Data |= 0xe << HPIPE_G1_SET_0_G1_TX_EMPH1_OFFSET; + } + RegSet (HpipeAddr + HPIPE_G1_SET_0_REG, Data, Mask); + + /* Generation 1 setting 2 */ + Mask = HPIPE_G1_SET_2_G1_TX_EMPH0_MASK; + Data = 0x0 << HPIPE_G1_SET_2_G1_TX_EMPH0_OFFSET; + Mask |= HPIPE_G1_SET_2_G1_TX_EMPH0_EN_MASK; + Data |= 0x1 << HPIPE_G1_SET_2_G1_TX_EMPH0_EN_OFFSET; + RegSet (HpipeAddr + HPIPE_G1_SET_2_REG, Data, Mask); + + /* Transmitter Slew Rate Control register */ + Mask = HPIPE_TX_REG1_TX_EMPH_RES_MASK; + Data = 0x3 << HPIPE_TX_REG1_TX_EMPH_RES_OFFSET; + Mask |= HPIPE_TX_REG1_SLC_EN_MASK; + Data |= 0x3f << HPIPE_TX_REG1_SLC_EN_OFFSET; + RegSet (HpipeAddr + HPIPE_TX_REG1_REG, Data, Mask); + + /* Impedance Calibration Control register */ + Mask = HPIPE_CAL_REG_1_EXT_TXIMP_MASK; + Data = 0xe << HPIPE_CAL_REG_1_EXT_TXIMP_OFFSET; + Mask |= HPIPE_CAL_REG_1_EXT_TXIMP_EN_MASK; + Data |= 0x1 << HPIPE_CAL_REG_1_EXT_TXIMP_EN_OFFSET; + RegSet (HpipeAddr + HPIPE_CAL_REG1_REG, Data, Mask); + + /* Generation 1 setting 5 */ + Mask = HPIPE_G1_SETTING_5_G1_ICP_MASK; + Data = 0 << HPIPE_G1_SETTING_5_G1_ICP_OFFSET; + RegSet (HpipeAddr + HPIPE_G1_SETTING_5_REG, Data, Mask); + + /* Generation 1 setting 1 */ + Mask = HPIPE_G1_SET_1_G1_RX_DFE_EN_MASK; + Data = 0x1 << HPIPE_G1_SET_1_G1_RX_DFE_EN_OFFSET; + if (SfiSpeed == PHY_SPEED_5_15625G) { + Mask |= HPIPE_G1_SET_1_G1_RX_SELMUPI_MASK; + Data |= 0x1 << HPIPE_G1_SET_1_G1_RX_SELMUPI_OFFSET; + Mask |= HPIPE_G1_SET_1_G1_RX_SELMUPP_MASK; + Data |= 0x1 << HPIPE_G1_SET_1_G1_RX_SELMUPP_OFFSET; + } else { + Mask |= HPIPE_G1_SET_1_G1_RX_SELMUPI_MASK; + Data |= 0x2 << HPIPE_G1_SET_1_G1_RX_SELMUPI_OFFSET; + Mask |= HPIPE_G1_SET_1_G1_RX_SELMUPP_MASK; + Data |= 0x2 << HPIPE_G1_SET_1_G1_RX_SELMUPP_OFFSET; + Mask |= HPIPE_G1_SET_1_G1_RX_SELMUFI_MASK; + Data |= 0x0 << HPIPE_G1_SET_1_G1_RX_SELMUFI_OFFSET; + Mask |= HPIPE_G1_SET_1_G1_RX_SELMUFF_MASK; + Data |= 0x1 << HPIPE_G1_SET_1_G1_RX_SELMUFF_OFFSET; + Mask |= HPIPE_G1_SET_1_G1_RX_DIGCK_DIV_MASK; + Data |= 0x3 << HPIPE_G1_SET_1_G1_RX_DIGCK_DIV_OFFSET; + } + RegSet (HpipeAddr + HPIPE_G1_SET_1_REG, Data, Mask); + + /* DFE Register 3 */ + Mask = HPIPE_DFE_F3_F5_DFE_EN_MASK; + Data = 0x0 << HPIPE_DFE_F3_F5_DFE_EN_OFFSET; + Mask |= HPIPE_DFE_F3_F5_DFE_CTRL_MASK; + Data |= 0x0 << HPIPE_DFE_F3_F5_DFE_CTRL_OFFSET; + RegSet (HpipeAddr + HPIPE_DFE_F3_F5_REG, Data, Mask); + + /* Generation 1 setting 4 */ + Mask = HPIPE_G1_SETTINGS_4_G1_DFE_RES_MASK; + Data = 0x1 << HPIPE_G1_SETTINGS_4_G1_DFE_RES_OFFSET; + RegSet (HpipeAddr + HPIPE_G1_SETTINGS_4_REG, Data, Mask); + + /* Generation 1 setting 3 */ + Mask = HPIPE_G1_SETTINGS_3_G1_FBCK_SEL_MASK; + Data = 0x1 << HPIPE_G1_SETTINGS_3_G1_FBCK_SEL_OFFSET; + if (SfiSpeed == PHY_SPEED_5_15625G) { + /* Force FFE (Feed Forward Equalization) to 5G */ + Mask |= HPIPE_G1_SETTINGS_3_G1_FFE_CAP_SEL_MASK; + Data |= 0xf << HPIPE_G1_SETTINGS_3_G1_FFE_CAP_SEL_OFFSET; + Mask |= HPIPE_G1_SETTINGS_3_G1_FFE_RES_SEL_MASK; + Data |= 0x4 << HPIPE_G1_SETTINGS_3_G1_FFE_RES_SEL_OFFSET; + Mask |= HPIPE_G1_SETTINGS_3_G1_FFE_SETTING_FORCE_MASK; + Data |= 0x1 << HPIPE_G1_SETTINGS_3_G1_FFE_SETTING_FORCE_OFFSET; + } + RegSet (HpipeAddr + HPIPE_G1_SETTINGS_3_REG, Data, Mask); + + /* Configure RX training timer */ + Mask = HPIPE_RX_TRAIN_TIMER_MASK; + Data = 0x13 << HPIPE_RX_TRAIN_TIMER_OFFSET; + RegSet (HpipeAddr + HPIPE_TX_TRAIN_CTRL_5_REG, Data, Mask); + + /* Enable TX train peak to peak hold */ + Mask = HPIPE_TX_TRAIN_P2P_HOLD_MASK; + Data = 0x1 << HPIPE_TX_TRAIN_P2P_HOLD_OFFSET; + RegSet (HpipeAddr + HPIPE_TX_TRAIN_CTRL_0_REG, Data, Mask); + + /* Configure TX preset index */ + Mask = HPIPE_TX_PRESET_INDEX_MASK; + Data = 0x2 << HPIPE_TX_PRESET_INDEX_OFFSET; + RegSet (HpipeAddr + HPIPE_TX_PRESET_INDEX_REG, Data, Mask); + + /* Disable pattern lock lost timeout */ + Mask = HPIPE_PATTERN_LOCK_LOST_TIMEOUT_EN_MASK; + Data = 0x0 << HPIPE_PATTERN_LOCK_LOST_TIMEOUT_EN_OFFSET; + RegSet (HpipeAddr + HPIPE_FRAME_DETECT_CTRL_3_REG, Data, Mask); + + /* Configure TX training pattern and TX training 16bit auto */ + Mask = HPIPE_TX_TRAIN_16BIT_AUTO_EN_MASK; + Data = 0x1 << HPIPE_TX_TRAIN_16BIT_AUTO_EN_OFFSET; + Mask |= HPIPE_TX_TRAIN_PAT_SEL_MASK; + Data |= 0x1 << HPIPE_TX_TRAIN_PAT_SEL_OFFSET; + RegSet (HpipeAddr + HPIPE_TX_TRAIN_REG, Data, Mask); + + /* Configure training pattern number */ + Mask = HPIPE_TRAIN_PAT_NUM_MASK; + Data = 0x88 << HPIPE_TRAIN_PAT_NUM_OFFSET; + RegSet (HpipeAddr + HPIPE_FRAME_DETECT_CTRL_0_REG, Data, Mask); + + /* Configure differential manchester encoder to ethernet mode */ + Mask = HPIPE_DME_ETHERNET_MODE_MASK; + Data = 0x1 << HPIPE_DME_ETHERNET_MODE_OFFSET; + RegSet (HpipeAddr + HPIPE_DME_REG, Data, Mask); + + /* Configure VDD Continuous Calibration */ + Mask = HPIPE_CAL_VDD_CONT_MODE_MASK; + Data = 0x1 << HPIPE_CAL_VDD_CONT_MODE_OFFSET; + RegSet (HpipeAddr + HPIPE_VDD_CAL_0_REG, Data, Mask); + + /* Trigger sampler enable pulse (by toggleing the bit) */ + Mask = HPIPE_RX_SAMPLER_OS_GAIN_MASK; + Data = 0x3 << HPIPE_RX_SAMPLER_OS_GAIN_OFFSET; + Mask |= HPIPE_SAMPLER_MASK; + Data |= 0x1 << HPIPE_SAMPLER_OFFSET; + RegSet (HpipeAddr + HPIPE_SAMPLER_N_PROC_CALIB_CTRL_REG, Data, Mask); + Mask = HPIPE_SAMPLER_MASK; + Data = 0x0 << HPIPE_SAMPLER_OFFSET; + RegSet (HpipeAddr + HPIPE_SAMPLER_N_PROC_CALIB_CTRL_REG, Data, Mask); + + /* Set External RX Regulator Control */ + Mask = HPIPE_EXT_SELLV_RXSAMPL_MASK; + Data = 0x1A << HPIPE_EXT_SELLV_RXSAMPL_OFFSET; + RegSet (HpipeAddr + HPIPE_VDD_CAL_CTRL_REG, Data, Mask); +} + +STATIC +EFI_STATUS +ComPhySfiPowerUp ( + IN UINT32 Lane, + IN EFI_PHYSICAL_ADDRESS HpipeBase, + IN EFI_PHYSICAL_ADDRESS ComPhyBase, + IN UINT32 SfiSpeed + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS HpipeAddr = HPIPE_ADDR(HpipeBase, Lane); + EFI_PHYSICAL_ADDRESS SdIpAddr = SD_ADDR(HpipeBase, Lane); + EFI_PHYSICAL_ADDRESS ComPhyAddr = COMPHY_ADDR(ComPhyBase, Lane); + + DEBUG((DEBUG_INFO, "ComPhy: stage: RFU configurations - hard reset ComPhy\n")); + + ComPhySfiRFUConfiguration (ComPhyAddr, SdIpAddr); + + DEBUG((DEBUG_INFO, "ComPhy: stage: ComPhy configuration\n")); + + ComPhySfiPhyConfiguration (HpipeAddr, SfiSpeed); + + DEBUG((DEBUG_INFO, "ComPhy: stage: Set analog paramters\n")); + + ComPhySfiSetAnalogParameters (HpipeAddr, SdIpAddr, SfiSpeed); + + DEBUG((DEBUG_INFO, "ComPhy: stage: RFU configurations - Power Up PLL,Tx,Rx\n")); + + Status = ComPhyEthCommonRFUPowerUp (SdIpAddr); + + return Status; +} + +STATIC +EFI_STATUS +ComPhyRxauiRFUConfiguration ( + IN UINT32 Lane, + IN EFI_PHYSICAL_ADDRESS ComPhyAddr, + IN EFI_PHYSICAL_ADDRESS SdIpAddr +) +{ + UINT32 Mask, Data; + + Mask = COMMON_PHY_CFG1_PWR_UP_MASK; + Data = 0x1 << COMMON_PHY_CFG1_PWR_UP_OFFSET; + Mask |= COMMON_PHY_CFG1_PIPE_SELECT_MASK; + Data |= 0x0 << COMMON_PHY_CFG1_PIPE_SELECT_OFFSET; + RegSet (ComPhyAddr + COMMON_PHY_CFG1_REG, Data, Mask); + + switch (Lane) { + case 2: + case 4: + RegSet ( + ComPhyAddr + COMMON_PHY_SD_CTRL1, + 0x1 << COMMON_PHY_SD_CTRL1_RXAUI0_OFFSET, + COMMON_PHY_SD_CTRL1_RXAUI0_MASK + ); + case 3: + case 5: + RegSet ( + ComPhyAddr + COMMON_PHY_SD_CTRL1, + 0x1 << COMMON_PHY_SD_CTRL1_RXAUI1_OFFSET, + COMMON_PHY_SD_CTRL1_RXAUI1_MASK + ); + break; + default: + DEBUG((DEBUG_ERROR, "RXAUI used on invalid lane %d\n", Lane)); + return EFI_INVALID_PARAMETER; + } + + /* Select Baud Rate of Comphy And PD_PLL/Tx/Rx */ + Mask = SD_EXTERNAL_CONFIG0_SD_PU_PLL_MASK; + Data = 0x0 << SD_EXTERNAL_CONFIG0_SD_PU_PLL_OFFSET; + Mask |= SD_EXTERNAL_CONFIG0_SD_PHY_GEN_RX_MASK; + Data |= 0xB << SD_EXTERNAL_CONFIG0_SD_PHY_GEN_RX_OFFSET; + Mask |= SD_EXTERNAL_CONFIG0_SD_PHY_GEN_TX_MASK; + Data |= 0xB << SD_EXTERNAL_CONFIG0_SD_PHY_GEN_TX_OFFSET; + Mask |= SD_EXTERNAL_CONFIG0_SD_PU_RX_MASK; + Data |= 0 << SD_EXTERNAL_CONFIG0_SD_PU_RX_OFFSET; + Mask |= SD_EXTERNAL_CONFIG0_SD_PU_TX_MASK; + Data |= 0 << SD_EXTERNAL_CONFIG0_SD_PU_TX_OFFSET; + Mask |= SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_MASK; + Data |= 0 << SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_OFFSET; + Mask |= SD_EXTERNAL_CONFIG0_MEDIA_MODE_MASK; + Data |= 0x1 << SD_EXTERNAL_CONFIG0_MEDIA_MODE_OFFSET; + RegSet (SdIpAddr + SD_EXTERNAL_CONFIG0_REG, Data, Mask); + + /* Release from hard reset */ + Mask = SD_EXTERNAL_CONFIG1_RESET_IN_MASK; + Data = 0x0 << SD_EXTERNAL_CONFIG1_RESET_IN_OFFSET; + Mask |= SD_EXTERNAL_CONFIG1_RESET_CORE_MASK; + Data |= 0x0 << SD_EXTERNAL_CONFIG1_RESET_CORE_OFFSET; + Mask |= SD_EXTERNAL_CONFIG1_RF_RESET_IN_MASK; + Data |= 0x0 << SD_EXTERNAL_CONFIG1_RF_RESET_IN_OFFSET; + RegSet (SdIpAddr + SD_EXTERNAL_CONFIG1_REG, Data, Mask); + + Mask = SD_EXTERNAL_CONFIG1_RESET_IN_MASK; + Data = 0x1 << SD_EXTERNAL_CONFIG1_RESET_IN_OFFSET; + Mask |= SD_EXTERNAL_CONFIG1_RESET_CORE_MASK; + Data |= 0x1 << SD_EXTERNAL_CONFIG1_RESET_CORE_OFFSET; + RegSet (SdIpAddr + SD_EXTERNAL_CONFIG1_REG, Data, Mask); + + /* Wait 1ms - until band gap and ref clock ready */ + MicroSecondDelay (1000); + MemoryFence (); + + return EFI_SUCCESS; +} + +STATIC +VOID +ComPhyRxauiPhyConfiguration ( + IN EFI_PHYSICAL_ADDRESS HpipeAddr +) +{ + UINT32 Mask, Data; + + /* Set reference clock */ + Mask = HPIPE_MISC_REFCLK_SEL_MASK; + Data = 0x0 << HPIPE_MISC_REFCLK_SEL_OFFSET; + RegSet (HpipeAddr + HPIPE_MISC_REG, Data, Mask); + + /* Power and PLL Control */ + Mask = HPIPE_PWR_PLL_REF_FREQ_MASK; + Data = 0x1 << HPIPE_PWR_PLL_REF_FREQ_OFFSET; + Mask |= HPIPE_PWR_PLL_PHY_MODE_MASK; + Data |= 0x4 << HPIPE_PWR_PLL_PHY_MODE_OFFSET; + RegSet (HpipeAddr + HPIPE_PWR_PLL_REG, Data, Mask); + + /* Loopback register */ + Mask = HPIPE_LOOPBACK_SEL_MASK; + Data = 0x1 << HPIPE_LOOPBACK_SEL_OFFSET; + RegSet (HpipeAddr + HPIPE_LOOPBACK_REG, Data, Mask); + + /* Rx control 1 */ + Mask = HPIPE_RX_CONTROL_1_RXCLK2X_SEL_MASK; + Data = 0x1 << HPIPE_RX_CONTROL_1_RXCLK2X_SEL_OFFSET; + Mask |= HPIPE_RX_CONTROL_1_CLK8T_EN_MASK; + Data |= 0x1 << HPIPE_RX_CONTROL_1_CLK8T_EN_OFFSET; + RegSet (HpipeAddr + HPIPE_RX_CONTROL_1_REG, Data, Mask); + + /* DTL Control */ + Mask = HPIPE_PWR_CTR_DTL_FLOOP_EN_MASK; + Data = 0x0 << HPIPE_PWR_CTR_DTL_FLOOP_EN_OFFSET; + RegSet (HpipeAddr + HPIPE_PWR_CTR_DTL_REG, Data, Mask); +} + +STATIC +VOID +ComPhyRxauiSetAnalogParameters ( + IN EFI_PHYSICAL_ADDRESS HpipeAddr, + IN EFI_PHYSICAL_ADDRESS SdIpAddr +) +{ + UINT32 Mask, Data; + + /* SERDES External Configuration 2 */ + Mask = SD_EXTERNAL_CONFIG2_PIN_DFE_EN_MASK; + Data = 0x1 << SD_EXTERNAL_CONFIG2_PIN_DFE_EN_OFFSET; + RegSet (SdIpAddr + SD_EXTERNAL_CONFIG2_REG, Data, Mask); + + /* DFE Resolution control */ + Mask = HPIPE_DFE_RES_FORCE_MASK; + Data = 0x1 << HPIPE_DFE_RES_FORCE_OFFSET; + RegSet (HpipeAddr + HPIPE_DFE_REG0, Data, Mask); + + /* Generation 1 setting_0 */ + Mask = HPIPE_G1_SET_0_G1_TX_EMPH1_MASK; + Data = 0xe << HPIPE_G1_SET_0_G1_TX_EMPH1_OFFSET; + RegSet (HpipeAddr + HPIPE_G1_SET_0_REG, Data, Mask); + + /* Generation 1 setting 1 */ + Mask = HPIPE_G1_SET_1_G1_RX_SELMUPI_MASK; + Data = 0x1 << HPIPE_G1_SET_1_G1_RX_SELMUPI_OFFSET; + Mask |= HPIPE_G1_SET_1_G1_RX_SELMUPP_MASK; + Data |= 0x1 << HPIPE_G1_SET_1_G1_RX_SELMUPP_OFFSET; + Mask |= HPIPE_G1_SET_1_G1_RX_DFE_EN_MASK; + Data |= 0x1 << HPIPE_G1_SET_1_G1_RX_DFE_EN_OFFSET; + RegSet (HpipeAddr + HPIPE_G1_SET_1_REG, Data, Mask); + + /* DFE Register 3 */ + Mask = HPIPE_DFE_F3_F5_DFE_EN_MASK; + Data = 0x0 << HPIPE_DFE_F3_F5_DFE_EN_OFFSET; + Mask |= HPIPE_DFE_F3_F5_DFE_CTRL_MASK; + Data |= 0x0 << HPIPE_DFE_F3_F5_DFE_CTRL_OFFSET; + RegSet (HpipeAddr + HPIPE_DFE_F3_F5_REG, Data, Mask); + + /* Generation 1 setting 4 */ + Mask = HPIPE_G1_SETTINGS_4_G1_DFE_RES_MASK; + Data = 0x1 << HPIPE_G1_SETTINGS_4_G1_DFE_RES_OFFSET; + RegSet (HpipeAddr + HPIPE_G1_SETTINGS_4_REG, Data, Mask); + + /* Generation 1 setting 3 */ + Mask = HPIPE_G1_SETTINGS_3_G1_FBCK_SEL_MASK; + Data = 0x1 << HPIPE_G1_SETTINGS_3_G1_FBCK_SEL_OFFSET; + RegSet (HpipeAddr + HPIPE_G1_SETTINGS_3_REG, Data, Mask); +} + +STATIC +EFI_STATUS +ComPhyRxauiPowerUp ( + IN UINT32 Lane, + IN EFI_PHYSICAL_ADDRESS HpipeBase, + IN EFI_PHYSICAL_ADDRESS ComPhyBase + ) +{ + EFI_STATUS Status; + EFI_PHYSICAL_ADDRESS HpipeAddr = HPIPE_ADDR(HpipeBase, Lane); + EFI_PHYSICAL_ADDRESS SdIpAddr = SD_ADDR(HpipeBase, Lane); + EFI_PHYSICAL_ADDRESS ComPhyAddr = COMPHY_ADDR(ComPhyBase, Lane); + + DEBUG((DEBUG_INFO, "ComPhy: stage: RFU configurations - hard reset ComPhy\n")); + + Status = ComPhyRxauiRFUConfiguration (Lane, ComPhyAddr, SdIpAddr); + if (EFI_ERROR(Status)) { + return Status; + } + + DEBUG((DEBUG_INFO, "ComPhy: stage: ComPhy configuration\n")); + + ComPhyRxauiPhyConfiguration (HpipeAddr); + + DEBUG((DEBUG_INFO, "ComPhy: stage: Set analog paramters\n")); + + ComPhyRxauiSetAnalogParameters (HpipeAddr, SdIpAddr); + + DEBUG((DEBUG_INFO, "ComPhy: stage: RFU configurations - Power Up PLL,Tx,Rx\n")); + + Status = ComPhyEthCommonRFUPowerUp (SdIpAddr);
return Status; } @@ -1374,6 +1880,13 @@ ComPhyCp110Init ( Status = ComPhySgmiiPowerUp(Lane, PtrComPhyMap->Speed, HpipeBaseAddr, ComPhyBaseAddr); break; + case PHY_TYPE_SFI: + Status = ComPhySfiPowerUp(Lane, HpipeBaseAddr, ComPhyBaseAddr, PtrComPhyMap->Speed); + break; + case PHY_TYPE_RXAUI0: + case PHY_TYPE_RXAUI1: + Status = ComPhyRxauiPowerUp(Lane, HpipeBaseAddr, ComPhyBaseAddr); + break; default: DEBUG((DEBUG_ERROR, "Unknown SerDes Type, skip initialize SerDes %d\n", Lane)); diff --git a/Platforms/Marvell/Library/ComPhyLib/ComPhyLib.c b/Platforms/Marvell/Library/ComPhyLib/ComPhyLib.c index 88680fc..477a71e 100644 --- a/Platforms/Marvell/Library/ComPhyLib/ComPhyLib.c +++ b/Platforms/Marvell/Library/ComPhyLib/ComPhyLib.c @@ -42,7 +42,7 @@ CHAR16 * TypeStringTable [] = {L"unconnected", L"PCIE0", L"PCIE1", L"PCIE2", L"XAUI3", L"RXAUI0", L"RXAUI1", L"SFI"};
CHAR16 * SpeedStringTable [] = {L"-", L"1.25 Gbps", L"1.5 Gbps", L"2.5 Gbps", - L"3.0 Gbps", L"3.125 Gbps", L"5 Gbps", + L"3.0 Gbps", L"3.125 Gbps", L"5 Gbps", L"5.156 Gbps", L"6 Gbps", L"6.25 Gbps", L"10.31 Gbps"};
CHIP_COMPHY_CONFIG ChipCfgTbl[] = { @@ -142,7 +142,7 @@ ParseSerdesSpeed ( { UINT32 i; UINT32 ValueTable [] = {0, 1250, 1500, 2500, 3000, 3125, - 5000, 6000, 6250, 10310}; + 5000, 5156, 6000, 6250, 10310};
for (i = 0; i < 10; i++) { if (Value == ValueTable[i]) { diff --git a/Platforms/Marvell/Library/ComPhyLib/ComPhyLib.h b/Platforms/Marvell/Library/ComPhyLib/ComPhyLib.h index b282de7..eee5a1f 100644 --- a/Platforms/Marvell/Library/ComPhyLib/ComPhyLib.h +++ b/Platforms/Marvell/Library/ComPhyLib/ComPhyLib.h @@ -80,10 +80,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define PHY_SPEED_3G 4 #define PHY_SPEED_3_125G 5 #define PHY_SPEED_5G 6 -#define PHY_SPEED_6G 7 -#define PHY_SPEED_6_25G 8 -#define PHY_SPEED_10_3125G 9 -#define PHY_SPEED_MAX 10 +#define PHY_SPEED_5_15625G 7 +#define PHY_SPEED_6G 8 +#define PHY_SPEED_6_25G 9 +#define PHY_SPEED_10_3125G 10 +#define PHY_SPEED_MAX 11 #define PHY_SPEED_INVALID 0xff
#define PHY_TYPE_UNCONNECTED 0 @@ -132,6 +133,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define SD_EXTERNAL_CONFIG0_SD_PU_TX_MASK (1 << SD_EXTERNAL_CONFIG0_SD_PU_TX_OFFSET) #define SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_OFFSET 14 #define SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_MASK (1 << SD_EXTERNAL_CONFIG0_HALF_BUS_MODE_OFFSET) +#define SD_EXTERNAL_CONFIG0_MEDIA_MODE_OFFSET 15 +#define SD_EXTERNAL_CONFIG0_MEDIA_MODE_MASK (0x1 << SD_EXTERNAL_CONFIG0_MEDIA_MODE_OFFSET)
#define SD_EXTERNAL_CONFIG1_REG 0x4 #define SD_EXTERNAL_CONFIG1_RESET_IN_OFFSET 3 @@ -168,6 +171,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define HPIPE_KVCO_CALIB_CTRL_MAX_PLL_OFFSET 12 #define HPIPE_KVCO_CALIB_CTRL_MAX_PLL_MASK (0x1 << HPIPE_KVCO_CALIB_CTRL_MAX_PLL_OFFSET)
+#define HPIPE_CAL_REG1_REG 0xc +#define HPIPE_CAL_REG_1_EXT_TXIMP_OFFSET 10 +#define HPIPE_CAL_REG_1_EXT_TXIMP_MASK (0x1f << HPIPE_CAL_REG_1_EXT_TXIMP_OFFSET) +#define HPIPE_CAL_REG_1_EXT_TXIMP_EN_OFFSET 15 +#define HPIPE_CAL_REG_1_EXT_TXIMP_EN_MASK (0x1 << HPIPE_CAL_REG_1_EXT_TXIMP_EN_OFFSET) + #define HPIPE_SQUELCH_FFE_SETTING_REG 0x018
#define HPIPE_DFE_REG0 0x01C @@ -278,6 +287,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define HPIPE_ISOLATE_MODE_GEN_TX_OFFSET 4 #define HPIPE_ISOLATE_MODE_GEN_TX_MASK (0xf << HPIPE_ISOLATE_MODE_GEN_TX_OFFSET)
+#define HPIPE_G1_SET_2_REG 0xf4 +#define HPIPE_G1_SET_2_G1_TX_EMPH0_OFFSET 0 +#define HPIPE_G1_SET_2_G1_TX_EMPH0_MASK (0xf << HPIPE_G1_SET_2_G1_TX_EMPH0_OFFSET) +#define HPIPE_G1_SET_2_G1_TX_EMPH0_EN_OFFSET 4 +#define HPIPE_G1_SET_2_G1_TX_EMPH0_EN_MASK (0x1 << HPIPE_G1_SET_2_G1_TX_EMPH0_MASK) + #define HPIPE_VTHIMPCAL_CTRL_REG 0x104
#define HPIPE_VDD_CAL_CTRL_REG 0x114 @@ -324,6 +339,18 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define HPIPE_PLLINTP_REG1 0x150
+#define HPIPE_SPD_DIV_FORCE_REG 0x154 +#define HPIPE_TXDIGCK_DIV_FORCE_OFFSET 7 +#define HPIPE_TXDIGCK_DIV_FORCE_MASK (0x1 << HPIPE_TXDIGCK_DIV_FORCE_OFFSET) +#define HPIPE_SPD_DIV_FORCE_RX_SPD_DIV_OFFSET 8 +#define HPIPE_SPD_DIV_FORCE_RX_SPD_DIV_MASK (0x3 << HPIPE_SPD_DIV_FORCE_RX_SPD_DIV_OFFSET) +#define HPIPE_SPD_DIV_FORCE_RX_SPD_DIV_FORCE_OFFSET 10 +#define HPIPE_SPD_DIV_FORCE_RX_SPD_DIV_FORCE_MASK (0x1 << HPIPE_SPD_DIV_FORCE_RX_SPD_DIV_FORCE_OFFSET) +#define HPIPE_SPD_DIV_FORCE_TX_SPD_DIV_OFFSET 13 +#define HPIPE_SPD_DIV_FORCE_TX_SPD_DIV_MASK (0x3 << HPIPE_SPD_DIV_FORCE_TX_SPD_DIV_OFFSET) +#define HPIPE_SPD_DIV_FORCE_TX_SPD_DIV_FORCE_OFFSET 15 +#define HPIPE_SPD_DIV_FORCE_TX_SPD_DIV_FORCE_MASK (0x1 << HPIPE_SPD_DIV_FORCE_TX_SPD_DIV_FORCE_OFFSET) + #define HPIPE_SAMPLER_N_PROC_CALIB_CTRL_REG 0x16C #define HPIPE_RX_SAMPLER_OS_GAIN_OFFSET 6 #define HPIPE_RX_SAMPLER_OS_GAIN_MASK (0x3 << HPIPE_RX_SAMPLER_OS_GAIN_OFFSET) @@ -336,6 +363,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define HPIPE_TX_REG1_SLC_EN_OFFSET 10 #define HPIPE_TX_REG1_SLC_EN_MASK (0x3f << HPIPE_TX_REG1_SLC_EN_OFFSET)
+#define HPIPE_TX_REG1_REG 0x174 +#define HPIPE_TX_REG1_TX_EMPH_RES_OFFSET 5 +#define HPIPE_TX_REG1_TX_EMPH_RES_MASK (0x3 << HPIPE_TX_REG1_TX_EMPH_RES_OFFSET) +#define HPIPE_TX_REG1_SLC_EN_OFFSET 10 +#define HPIPE_TX_REG1_SLC_EN_MASK (0x3f << HPIPE_TX_REG1_SLC_EN_OFFSET) + #define HPIPE_PWR_CTR_DTL_REG 0x184 #define HPIPE_PWR_CTR_DTL_SQ_DET_EN_OFFSET 0 #define HPIPE_PWR_CTR_DTL_SQ_DET_EN_MASK (0x1 << HPIPE_PWR_CTR_DTL_SQ_DET_EN_OFFSET) @@ -392,6 +425,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define HPIPE_PCIE_REG3 0x290
#define HPIPE_TX_TRAIN_CTRL_5_REG 0x2A4 +#define HPIPE_RX_TRAIN_TIMER_OFFSET 0 +#define HPIPE_RX_TRAIN_TIMER_MASK (0x3ff << HPIPE_RX_TRAIN_TIMER_OFFSET) #define HPIPE_TX_TRAIN_START_SQ_EN_OFFSET 11 #define HPIPE_TX_TRAIN_START_SQ_EN_MASK (0x1 << HPIPE_TX_TRAIN_START_SQ_EN_OFFSET) #define HPIPE_TX_TRAIN_START_FRM_DET_EN_OFFSET 12 @@ -406,6 +441,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define HPIPE_TX_TRAIN_CHK_INIT_MASK (0x1 << HPIPE_TX_TRAIN_CHK_INIT_OFFSET) #define HPIPE_TX_TRAIN_COE_FM_PIN_PCIE3_OFFSET 7 #define HPIPE_TX_TRAIN_COE_FM_PIN_PCIE3_MASK (0x1 << HPIPE_TX_TRAIN_COE_FM_PIN_PCIE3_OFFSET) +#define HPIPE_TX_TRAIN_16BIT_AUTO_EN_OFFSET 8 +#define HPIPE_TX_TRAIN_16BIT_AUTO_EN_MASK (0x1 << HPIPE_TX_TRAIN_16BIT_AUTO_EN_OFFSET) +#define HPIPE_TX_TRAIN_PAT_SEL_OFFSET 9 +#define HPIPE_TX_TRAIN_PAT_SEL_MASK (0x1 << HPIPE_TX_TRAIN_PAT_SEL_OFFSET)
#define HPIPE_CDR_CONTROL_REG 0x418 #define HPIPE_CDR_RX_MAX_DFE_ADAPT_1_OFFSET 12 @@ -438,6 +477,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define HPIPE_G1_SETTINGS_3_G1_FFE_LOAD_RES_LEVEL_MASK (0x3 << HPIPE_G1_SETTINGS_3_G1_FFE_LOAD_RES_LEVEL_OFFSET)
#define HPIPE_G1_SETTINGS_4_REG 0x444 +#define HPIPE_G1_SETTINGS_4_G1_DFE_RES_OFFSET 8 +#define HPIPE_G1_SETTINGS_4_G1_DFE_RES_MASK (0x3 << HPIPE_G1_SETTINGS_4_G1_DFE_RES_OFFSET) + #define HPIPE_G2_SETTINGS_3_REG 0x448
#define HPIPE_G2_SETTINGS_4_REG 0x44C @@ -482,6 +524,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define HPIPE_DFE_CTRL_28_PIPE4_OFFSET 7 #define HPIPE_DFE_CTRL_28_PIPE4_MASK (0x1 << HPIPE_DFE_CTRL_28_PIPE4_OFFSET)
+#define HPIPE_G1_SETTING_5_REG 0x538 +#define HPIPE_G1_SETTING_5_G1_ICP_OFFSET 0 +#define HPIPE_G1_SETTING_5_G1_ICP_MASK (0xf << HPIPE_G1_SETTING_5_G1_ICP_OFFSET) + #define HPIPE_G3_SETTING_5_REG 0x548 #define HPIPE_G3_SETTING_5_G3_ICP_OFFSET 0 #define HPIPE_G3_SETTING_5_G3_ICP_MASK (0xf << HPIPE_G3_SETTING_5_G3_ICP_OFFSET) @@ -571,6 +617,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define COMMON_SELECTOR_PHY_OFFSET 0x140 #define COMMON_SELECTOR_PIPE_OFFSET 0x144
+#define COMMON_PHY_SD_CTRL1 0x148 +#define COMMON_PHY_SD_CTRL1_RXAUI1_OFFSET 26 +#define COMMON_PHY_SD_CTRL1_RXAUI1_MASK (0x1 << COMMON_PHY_SD_CTRL1_RXAUI1_OFFSET) +#define COMMON_PHY_SD_CTRL1_RXAUI0_OFFSET 27 +#define COMMON_PHY_SD_CTRL1_RXAUI0_MASK (0x1 << COMMON_PHY_SD_CTRL1_RXAUI0_OFFSET) + /***** SATA registers *****/ #define SATA3_VENDOR_ADDRESS 0xA0 #define SATA3_VENDOR_ADDR_OFSSET 0