public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Marcin Wojtas <mw@semihalf.com>
To: edk2-devel@lists.01.org
Cc: leif.lindholm@linaro.org, ard.biesheuvel@linaro.org,
	nadavh@marvell.com, mw@semihalf.com, jsd@semihalf.com,
	jaz@semihalf.com
Subject: [platforms: PATCH 4/6] Marvell/Library: ComPhyLib: Configure USB in ARM-TF
Date: Fri, 13 Jul 2018 16:09:42 +0200	[thread overview]
Message-ID: <1531490984-32491-5-git-send-email-mw@semihalf.com> (raw)
In-Reply-To: <1531490984-32491-1-git-send-email-mw@semihalf.com>

From: Grzegorz Jaszczyk <jaz@semihalf.com>

Replace the comphy initialization for USB with appropriate SMC call,
so the firmware will execute required serdes configuration.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
 Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c | 167 +-------------------
 1 file changed, 4 insertions(+), 163 deletions(-)

diff --git a/Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c b/Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c
index c46cad1..35ac459 100755
--- a/Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c
+++ b/Silicon/Marvell/Library/ComPhyLib/ComPhyCp110.c
@@ -100,168 +100,6 @@ COMPHY_MUX_DATA Cp110ComPhyPipeMuxData[] = {
 
 STATIC
 VOID
-ComPhyUsb3RFUConfiguration (
-  IN EFI_PHYSICAL_ADDRESS ComPhyAddr
-)
-{
-  UINT32 Mask, Data;
-
-  /* RFU configurations - hard reset ComPhy */
-  Mask = COMMON_PHY_CFG1_PWR_UP_MASK;
-  Data = 0x1 << COMMON_PHY_CFG1_PWR_UP_OFFSET;
-  Mask |= COMMON_PHY_CFG1_PIPE_SELECT_MASK;
-  Data |= 0x1 << COMMON_PHY_CFG1_PIPE_SELECT_OFFSET;
-  Mask |= COMMON_PHY_CFG1_PWR_ON_RESET_MASK;
-  Data |= 0x0 << COMMON_PHY_CFG1_PWR_ON_RESET_OFFSET;
-  Mask |= COMMON_PHY_CFG1_CORE_RSTN_MASK;
-  Data |= 0x0 << COMMON_PHY_CFG1_CORE_RSTN_OFFSET;
-  Mask |= COMMON_PHY_PHY_MODE_MASK;
-  Data |= 0x1 << COMMON_PHY_PHY_MODE_OFFSET;
-  RegSet (ComPhyAddr + COMMON_PHY_CFG1_REG, Data, Mask);
-
-  /* Release from hard reset */
-  Mask = COMMON_PHY_CFG1_PWR_ON_RESET_MASK;
-  Data = 0x1 << COMMON_PHY_CFG1_PWR_ON_RESET_OFFSET;
-  Mask |= COMMON_PHY_CFG1_CORE_RSTN_MASK;
-  Data |= 0x1 << COMMON_PHY_CFG1_CORE_RSTN_OFFSET;
-  RegSet (ComPhyAddr + COMMON_PHY_CFG1_REG, Data, Mask);
-
-  /* Wait 1ms - until band gap and ref clock ready */
-  MicroSecondDelay (1000);
-  MemoryFence ();
-}
-
-STATIC
-VOID
-ComPhyUsb3PhyConfiguration (
-  IN EFI_PHYSICAL_ADDRESS HpipeAddr
-)
-{
-  UINT32 Mask, Data;
-
-  /* Set PIPE soft reset */
-  Mask = HPIPE_RST_CLK_CTRL_PIPE_RST_MASK;
-  Data = 0x1 << HPIPE_RST_CLK_CTRL_PIPE_RST_OFFSET;
-
-  /* Set PHY Datapath width mode for V0 */
-  Mask |= HPIPE_RST_CLK_CTRL_FIXED_PCLK_MASK;
-  Data |= 0x0 << HPIPE_RST_CLK_CTRL_FIXED_PCLK_OFFSET;
-
-  /* Set Data bus width USB mode for V0 */
-  Mask |= HPIPE_RST_CLK_CTRL_PIPE_WIDTH_MASK;
-  Data |= 0x0 << HPIPE_RST_CLK_CTRL_PIPE_WIDTH_OFFSET;
-
-  /* Set CORE_CLK output frequency for 250Mhz */
-  Mask |= HPIPE_RST_CLK_CTRL_CORE_FREQ_SEL_MASK;
-  Data |= 0x0 << HPIPE_RST_CLK_CTRL_CORE_FREQ_SEL_OFFSET;
-  RegSet (HpipeAddr + HPIPE_RST_CLK_CTRL_REG, Data, Mask);
-
-  /* Set PLL ready delay for 0x2 */
-  RegSet (HpipeAddr + HPIPE_CLK_SRC_LO_REG,
-    0x2 << HPIPE_CLK_SRC_LO_PLL_RDY_DL_OFFSET,
-    HPIPE_CLK_SRC_LO_PLL_RDY_DL_MASK);
-
-  /* Set reference clock to come from group 1 - 25Mhz */
-  RegSet (HpipeAddr + HPIPE_MISC_REG, 0x0 << HPIPE_MISC_REFCLK_SEL_OFFSET,
-    HPIPE_MISC_REFCLK_SEL_MASK);
-
-  /* Set reference frequcency select - 0x2 */
-  Mask = HPIPE_PWR_PLL_REF_FREQ_MASK;
-  Data = 0x2 << HPIPE_PWR_PLL_REF_FREQ_OFFSET;
-
-  /* Set PHY mode to USB - 0x5 */
-  Mask |= HPIPE_PWR_PLL_PHY_MODE_MASK;
-  Data |= 0x5 << HPIPE_PWR_PLL_PHY_MODE_OFFSET;
-  RegSet (HpipeAddr + HPIPE_PWR_PLL_REG, Data, Mask);
-
-  /* Set the amount of time spent in the LoZ state - set for 0x7 */
-  RegSet (HpipeAddr + HPIPE_GLOBAL_PM_CTRL,
-    0x7 << HPIPE_GLOBAL_PM_RXDLOZ_WAIT_OFFSET,
-    HPIPE_GLOBAL_PM_RXDLOZ_WAIT_MASK);
-
-  /* Set max PHY generation setting - 5Gbps */
-  RegSet (HpipeAddr + HPIPE_INTERFACE_REG,
-    0x1 << HPIPE_INTERFACE_GEN_MAX_OFFSET, HPIPE_INTERFACE_GEN_MAX_MASK);
-
-  /* Set select Data width 20Bit (SEL_BITS[2:0]) */
-  RegSet (HpipeAddr + HPIPE_LOOPBACK_REG,
-    0x1 << HPIPE_LOOPBACK_SEL_OFFSET, HPIPE_LOOPBACK_SEL_MASK);
-}
-
-STATIC
-VOID
-ComPhyUsb3SetAnalogParameters (
-  IN EFI_PHYSICAL_ADDRESS HpipeAddr
-)
-{
-  UINT32 Data, Mask;
-
-  /* Set Pin DFE_PAT_DIS -> Bit[1]: PIN_DFE_PAT_DIS = 0x0 */
-  Mask = HPIPE_LANE_CFG4_DFE_CTRL_MASK;
-  Data = 0x1 << HPIPE_LANE_CFG4_DFE_CTRL_OFFSET;
-
-  /* Set Override PHY DFE control pins for 0x1 */
-  Mask |= HPIPE_LANE_CFG4_DFE_OVER_MASK;
-  Data |= 0x1 << HPIPE_LANE_CFG4_DFE_OVER_OFFSET;
-
-  /* Set Spread Spectrum Clock Enable fot 0x1 */
-  Mask |= HPIPE_LANE_CFG4_SSC_CTRL_MASK;
-  Data |= 0x1 << HPIPE_LANE_CFG4_SSC_CTRL_OFFSET;
-  RegSet (HpipeAddr + HPIPE_LANE_CFG4_REG, Data, Mask);
-}
-
-STATIC
-UINTN
-ComphyUsb3PowerUp (
-  UINT32 Lane,
-  EFI_PHYSICAL_ADDRESS HpipeBase,
-  EFI_PHYSICAL_ADDRESS ComPhyBase
-  )
-{
-  EFI_STATUS Status = EFI_SUCCESS;
-  UINT32 Data;
-  EFI_PHYSICAL_ADDRESS HpipeAddr = HPIPE_ADDR(HpipeBase, Lane);
-  EFI_PHYSICAL_ADDRESS ComPhyAddr = COMPHY_ADDR(ComPhyBase, Lane);
-
-  DEBUG((DEBUG_INFO, "ComPhy: stage: RFU configurations - hard reset ComPhy\n"));
-
-  ComPhyUsb3RFUConfiguration (ComPhyAddr);
-
-  /* Start ComPhy Configuration */
-  DEBUG((DEBUG_INFO, "stage: Comphy configuration\n"));
-
-  ComPhyUsb3PhyConfiguration (HpipeAddr);
-
-  /* Start analog paramters from ETP(HW) */
-  DEBUG((DEBUG_INFO, "ComPhy: stage: Analog paramters from ETP(HW)\n"));
-
-  ComPhyUsb3SetAnalogParameters (HpipeAddr);
-
-  DEBUG((DEBUG_INFO, "ComPhy: stage: Comphy power up\n"));
-
-  /* Release from PIPE soft reset */
-  RegSet (HpipeAddr + HPIPE_RST_CLK_CTRL_REG,
-    0x0 << HPIPE_RST_CLK_CTRL_PIPE_RST_OFFSET,
-    HPIPE_RST_CLK_CTRL_PIPE_RST_MASK);
-
-  /* Wait 15ms - for ComPhy calibration done */
-  MicroSecondDelay (15000);
-  MemoryFence ();
-
-  DEBUG((DEBUG_INFO, "ComPhy: stage: Check PLL\n"));
-
-  /* Read Lane status */
-  Data = MmioRead32 (HpipeAddr + HPIPE_LANE_STATUS0_REG);
-  if ((Data & HPIPE_LANE_STATUS0_PCLK_EN_MASK) == 0) {
-    DEBUG((DEBUG_ERROR, "ComPhy: HPIPE_LANE_STATUS0_PCLK_EN_MASK is 0\n"));
-    Status = EFI_D_ERROR;
-  }
-
-  return Status;
-}
-
-STATIC
-VOID
 ComPhySataMacPowerDown (
   IN EFI_PHYSICAL_ADDRESS SataBase
 )
@@ -528,7 +366,10 @@ ComPhyCp110Init (
       break;
     case COMPHY_TYPE_USB3_HOST0:
     case COMPHY_TYPE_USB3_HOST1:
-      Status = ComphyUsb3PowerUp(Lane, HpipeBaseAddr, ComPhyBaseAddr);
+      Status = ComPhySmc (MV_SIP_COMPHY_POWER_ON,
+                 PtrChipCfg->ComPhyBaseAddr,
+                 Lane,
+                 COMPHY_FW_MODE_FORMAT (COMPHY_USB3H_MODE));
       break;
     case COMPHY_TYPE_SGMII0:
     case COMPHY_TYPE_SGMII1:
-- 
2.7.4



  parent reply	other threads:[~2018-07-13 14:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 14:09 [platforms: PATCH 0/6] Armada7k8k ComPhy rework Marcin Wojtas
2018-07-13 14:09 ` [platforms: PATCH 1/6] Marvell/Library: ComPhyLib: Configure SATA, SGMII and SFI in ARM-TF Marcin Wojtas
2018-07-13 14:22   ` Ard Biesheuvel
2018-07-13 14:09 ` [platforms: PATCH 2/6] Marvell/Library: ComPhyLib: Configure PCIE " Marcin Wojtas
2018-07-25 10:01   ` Ard Biesheuvel
2018-07-25 10:32     ` Marcin Wojtas
2018-07-13 14:09 ` [platforms: PATCH 3/6] Marvell/Library: ComPhyLib: Configure RXAUI " Marcin Wojtas
2018-07-13 14:09 ` Marcin Wojtas [this message]
2018-07-13 14:09 ` [platforms: PATCH 5/6] Marvell/Library: ComPhyLib: Clean up the library after rework Marcin Wojtas
2018-07-13 14:09 ` [platforms: PATCH 6/6] Marvell/Library: ComPhyLib: Remove both PHY and PIPE selector config Marcin Wojtas
2018-07-25 10:02 ` [platforms: PATCH 0/6] Armada7k8k ComPhy rework Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1531490984-32491-5-git-send-email-mw@semihalf.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox