Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: qcom: edp: Postpone clk_set_rate until the PLL is up

When the platform was booted with the involved clocks enabled the
clk_set_rate() of the link and pixel clocks will perculate to the
children, which will fail to update because the PHY driver has just shut
down the PLL.

Postpone the clock rate updates until the PLL is back online to avoid
reconfiguring the clocks while the PLL is not ticking.

Fixes: f199223cb490 ("phy: qcom: Introduce new eDP PHY driver")
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220805154432.546740-1-bjorn.andersson@linaro.org
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Bjorn Andersson and committed by
Vinod Koul
f2e35c75 0caffb26

+16 -12
+16 -12
drivers/phy/qualcomm/phy-qcom-edp.c
··· 410 410 return 0; 411 411 } 412 412 413 - static int qcom_edp_set_vco_div(const struct qcom_edp *edp) 413 + static int qcom_edp_set_vco_div(const struct qcom_edp *edp, unsigned long *pixel_freq) 414 414 { 415 415 const struct phy_configure_opts_dp *dp_opts = &edp->dp_opts; 416 - unsigned long pixel_freq; 417 416 u32 vco_div; 418 417 419 418 switch (dp_opts->link_rate) { 420 419 case 1620: 421 420 vco_div = 0x1; 422 - pixel_freq = 1620000000UL / 2; 421 + *pixel_freq = 1620000000UL / 2; 423 422 break; 424 423 425 424 case 2700: 426 425 vco_div = 0x1; 427 - pixel_freq = 2700000000UL / 2; 426 + *pixel_freq = 2700000000UL / 2; 428 427 break; 429 428 430 429 case 5400: 431 430 vco_div = 0x2; 432 - pixel_freq = 5400000000UL / 4; 431 + *pixel_freq = 5400000000UL / 4; 433 432 break; 434 433 435 434 case 8100: 436 435 vco_div = 0x0; 437 - pixel_freq = 8100000000UL / 6; 436 + *pixel_freq = 8100000000UL / 6; 438 437 break; 439 438 440 439 default: ··· 443 444 444 445 writel(vco_div, edp->edp + DP_PHY_VCO_DIV); 445 446 446 - clk_set_rate(edp->dp_link_hw.clk, dp_opts->link_rate * 100000); 447 - clk_set_rate(edp->dp_pixel_hw.clk, pixel_freq); 448 - 449 447 return 0; 450 448 } 451 449 ··· 451 455 const struct qcom_edp *edp = phy_get_drvdata(phy); 452 456 const struct qcom_edp_cfg *cfg = edp->cfg; 453 457 u32 bias0_en, drvr0_en, bias1_en, drvr1_en; 458 + unsigned long pixel_freq; 454 459 u8 ldo_config; 455 460 int timeout; 456 461 int ret; ··· 505 508 writel(0x01, edp->tx1 + TXn_TRAN_DRVR_EMP_EN); 506 509 writel(0x04, edp->tx1 + TXn_TX_BAND); 507 510 508 - ret = qcom_edp_set_vco_div(edp); 511 + ret = qcom_edp_set_vco_div(edp, &pixel_freq); 509 512 if (ret) 510 513 return ret; 511 514 ··· 571 574 572 575 writel(0x19, edp->edp + DP_PHY_CFG); 573 576 574 - return readl_poll_timeout(edp->edp + DP_PHY_STATUS, 575 - val, val & BIT(1), 500, 10000); 577 + ret = readl_poll_timeout(edp->edp + DP_PHY_STATUS, 578 + val, val & BIT(1), 500, 10000); 579 + if (ret) 580 + return ret; 581 + 582 + clk_set_rate(edp->dp_link_hw.clk, edp->dp_opts.link_rate * 100000); 583 + clk_set_rate(edp->dp_pixel_hw.clk, pixel_freq); 584 + 585 + return 0; 576 586 } 577 587 578 588 static int qcom_edp_phy_power_off(struct phy *phy)