Skip to content

Commit 375ee44

Browse files
aford173vinodkoul
authored andcommitted
phy: freescale: fsl-samsung-hdmi: Simplify REG21_PMS_S_MASK lookup
The value of 'S' is writen to two places, PHY_REG3[7:4] and PHY_REG21[3:0]. There is a lookup table which contains the value of PHY_REG3. Rather than using a switch statement based on the pixel clock to search for the value of 'S' again, just shift the contents of PHY_REG3[7:4] >> 4 and place the value in PHY_REG21[3:0]. Doing this can eliminate an entire function. Signed-off-by: Adam Ford <[email protected]> Reviewed-by: Marco Felsch <[email protected]> Reviewed-by: Frieder Schrempf <[email protected]> Tested-by: Frieder Schrempf <[email protected]> Reviewed-by: Dominique Martinet <[email protected]> Tested-by: Dominique Martinet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 4a5a9e2 commit 375ee44

File tree

1 file changed

+4
-35
lines changed

1 file changed

+4
-35
lines changed

drivers/phy/freescale/phy-fsl-samsung-hdmi.c

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -364,40 +364,6 @@ to_fsl_samsung_hdmi_phy(struct clk_hw *hw)
364364
return container_of(hw, struct fsl_samsung_hdmi_phy, hw);
365365
}
366366

367-
static void
368-
fsl_samsung_hdmi_phy_configure_pixclk(struct fsl_samsung_hdmi_phy *phy,
369-
const struct phy_config *cfg)
370-
{
371-
u8 div = 0x1;
372-
373-
switch (cfg->pixclk) {
374-
case 22250000 ... 33750000:
375-
div = 0xf;
376-
break;
377-
case 35000000 ... 40000000:
378-
div = 0xb;
379-
break;
380-
case 43200000 ... 47500000:
381-
div = 0x9;
382-
break;
383-
case 50349650 ... 63500000:
384-
div = 0x7;
385-
break;
386-
case 67500000 ... 90000000:
387-
div = 0x5;
388-
break;
389-
case 94000000 ... 148500000:
390-
div = 0x3;
391-
break;
392-
case 154000000 ... 297000000:
393-
div = 0x1;
394-
break;
395-
}
396-
397-
writeb(REG21_SEL_TX_CK_INV | FIELD_PREP(REG21_PMS_S_MASK, div),
398-
phy->regs + PHY_REG(21));
399-
}
400-
401367
static void
402368
fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy,
403369
const struct phy_config *cfg)
@@ -466,7 +432,10 @@ static int fsl_samsung_hdmi_phy_configure(struct fsl_samsung_hdmi_phy *phy,
466432
for (i = 0; i < PHY_PLL_DIV_REGS_NUM; i++)
467433
writeb(cfg->pll_div_regs[i], phy->regs + PHY_REG(2) + i * 4);
468434

469-
fsl_samsung_hdmi_phy_configure_pixclk(phy, cfg);
435+
/* High nibble of pll_div_regs[1] contains S which also gets written to REG21 */
436+
writeb(REG21_SEL_TX_CK_INV | FIELD_PREP(REG21_PMS_S_MASK,
437+
cfg->pll_div_regs[1] >> 4), phy->regs + PHY_REG(21));
438+
470439
fsl_samsung_hdmi_phy_configure_pll_lock_det(phy, cfg);
471440

472441
writeb(REG33_FIX_DA | REG33_MODE_SET_DONE, phy->regs + PHY_REG(33));

0 commit comments

Comments
 (0)