Skip to content

Commit 41bd136

Browse files
sjakhadecdnsgregkh
authored andcommitted
phy: cadence: Sierra: Fix to get correct parent for mux clocks
[ Upstream commit da08aab ] Fix get_parent() callback to return the correct index of the parent for PLL_CMNLC1 clock. Add a separate table of register values corresponding to the parent index for PLL_CMNLC1. Update set_parent() callback accordingly. Fixes: 28081b7 ("phy: cadence: Sierra: Model PLL_CMNLC and PLL_CMNLC1 as clocks (mux clocks)") Signed-off-by: Swapnil Jakhade <sjakhade@cadence.com> Reviewed-by: Aswath Govindraju <a-govindraju@ti.com> Link: https://lore.kernel.org/r/20211223060137.9252-12-sjakhade@cadence.com Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 949255b commit 41bd136

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

drivers/phy/cadence/phy-cadence-sierra.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ static const int pll_mux_parent_index[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
215215
[CMN_PLLLC1] = { PLL1_REFCLK, PLL0_REFCLK },
216216
};
217217

218-
static u32 cdns_sierra_pll_mux_table[] = { 0, 1 };
218+
static u32 cdns_sierra_pll_mux_table[][SIERRA_NUM_CMN_PLLC_PARENTS] = {
219+
[CMN_PLLLC] = { 0, 1 },
220+
[CMN_PLLLC1] = { 1, 0 },
221+
};
219222

220223
struct cdns_sierra_inst {
221224
struct phy *phy;
@@ -436,11 +439,25 @@ static const struct phy_ops ops = {
436439
static u8 cdns_sierra_pll_mux_get_parent(struct clk_hw *hw)
437440
{
438441
struct cdns_sierra_pll_mux *mux = to_cdns_sierra_pll_mux(hw);
442+
struct regmap_field *plllc1en_field = mux->plllc1en_field;
443+
struct regmap_field *termen_field = mux->termen_field;
439444
struct regmap_field *field = mux->pfdclk_sel_preg;
440445
unsigned int val;
446+
int index;
441447

442448
regmap_field_read(field, &val);
443-
return clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table, 0, val);
449+
450+
if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1])) {
451+
index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC1], 0, val);
452+
if (index == 1) {
453+
regmap_field_write(plllc1en_field, 1);
454+
regmap_field_write(termen_field, 1);
455+
}
456+
} else {
457+
index = clk_mux_val_to_index(hw, cdns_sierra_pll_mux_table[CMN_PLLLC], 0, val);
458+
}
459+
460+
return index;
444461
}
445462

446463
static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index)
@@ -458,7 +475,11 @@ static int cdns_sierra_pll_mux_set_parent(struct clk_hw *hw, u8 index)
458475
ret |= regmap_field_write(termen_field, 1);
459476
}
460477

461-
val = cdns_sierra_pll_mux_table[index];
478+
if (strstr(clk_hw_get_name(hw), clk_names[CDNS_SIERRA_PLL_CMNLC1]))
479+
val = cdns_sierra_pll_mux_table[CMN_PLLLC1][index];
480+
else
481+
val = cdns_sierra_pll_mux_table[CMN_PLLLC][index];
482+
462483
ret |= regmap_field_write(field, val);
463484

464485
return ret;
@@ -496,8 +517,8 @@ static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp,
496517
for (i = 0; i < num_parents; i++) {
497518
clk = sp->input_clks[pll_mux_parent_index[clk_index][i]];
498519
if (IS_ERR_OR_NULL(clk)) {
499-
dev_err(dev, "No parent clock for derived_refclk\n");
500-
return PTR_ERR(clk);
520+
dev_err(dev, "No parent clock for PLL mux clocks\n");
521+
return IS_ERR(clk) ? PTR_ERR(clk) : -ENOENT;
501522
}
502523
parent_names[i] = __clk_get_name(clk);
503524
}

0 commit comments

Comments
 (0)