Skip to content

Commit 687d6bc

Browse files
Sean Andersonvinodkoul
authored andcommitted
phy: zynqmp: Enable reference clock correctly
Lanes can use other lanes' reference clocks, as determined by refclk. Use refclk to determine the clock to enable/disable instead of always using the lane's own reference clock. This ensures the clock selected in xpsgtr_configure_pll is the one enabled. For the other half of the equation, always program REF_CLK_SEL even when we are selecting the lane's own clock. This ensures that Linux's idea of the reference clock matches the hardware. We use the "local" clock mux for this instead of going through the ref clock network. Fixes: 25d7008 ("phy: xilinx: phy-zynqmp: dynamic clock support for power-save") Signed-off-by: Sean Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 967969c commit 687d6bc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/phy/xilinx/phy-zynqmp.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080

8181
/* Reference clock selection parameters */
8282
#define L0_Ln_REF_CLK_SEL(n) (0x2860 + (n) * 4)
83-
#define L0_REF_CLK_SEL_MASK 0x8f
83+
#define L0_REF_CLK_LCL_SEL BIT(7)
84+
#define L0_REF_CLK_SEL_MASK 0x9f
8485

8586
/* Calibration digital logic parameters */
8687
#define L3_TM_CALIB_DIG19 0xec4c
@@ -349,11 +350,12 @@ static void xpsgtr_configure_pll(struct xpsgtr_phy *gtr_phy)
349350
PLL_FREQ_MASK, ssc->pll_ref_clk);
350351

351352
/* Enable lane clock sharing, if required */
352-
if (gtr_phy->refclk != gtr_phy->lane) {
353-
/* Lane3 Ref Clock Selection Register */
353+
if (gtr_phy->refclk == gtr_phy->lane)
354+
xpsgtr_clr_set(gtr_phy->dev, L0_Ln_REF_CLK_SEL(gtr_phy->lane),
355+
L0_REF_CLK_SEL_MASK, L0_REF_CLK_LCL_SEL);
356+
else
354357
xpsgtr_clr_set(gtr_phy->dev, L0_Ln_REF_CLK_SEL(gtr_phy->lane),
355358
L0_REF_CLK_SEL_MASK, 1 << gtr_phy->refclk);
356-
}
357359

358360
/* SSC step size [7:0] */
359361
xpsgtr_clr_set_phy(gtr_phy, L0_PLL_SS_STEP_SIZE_0_LSB,
@@ -573,7 +575,7 @@ static int xpsgtr_phy_init(struct phy *phy)
573575
mutex_lock(&gtr_dev->gtr_mutex);
574576

575577
/* Configure and enable the clock when peripheral phy_init call */
576-
if (clk_prepare_enable(gtr_dev->clk[gtr_phy->lane]))
578+
if (clk_prepare_enable(gtr_dev->clk[gtr_phy->refclk]))
577579
goto out;
578580

579581
/* Skip initialization if not required. */
@@ -625,7 +627,7 @@ static int xpsgtr_phy_exit(struct phy *phy)
625627
gtr_phy->skip_phy_init = false;
626628

627629
/* Ensure that disable clock only, which configure for lane */
628-
clk_disable_unprepare(gtr_dev->clk[gtr_phy->lane]);
630+
clk_disable_unprepare(gtr_dev->clk[gtr_phy->refclk]);
629631

630632
return 0;
631633
}

0 commit comments

Comments
 (0)