Skip to content

Commit ac22507

Browse files
stephan-ghgregkh
authored andcommitted
phy: qcom: qmp-pcie: Fix PHY initialization when powered down by firmware
commit 6cb8c1f upstream. Commit 0cc22f5 ("phy: qcom: qmp-pcie: Add PHY register retention support") added support for using the "no_csr" reset to skip configuration of the PHY if the init sequence was already applied by the boot firmware. The expectation is that the PHY is only turned on/off by using the "no_csr" reset, instead of powering it down and re-programming it after a full reset. The boot firmware on X1E does not fully conform to this expectation: If the PCIe3 link fails to come up (e.g. because no PCIe card is inserted), the firmware powers down the PHY using the QPHY_PCS_POWER_DOWN_CONTROL register. The QPHY_START_CTRL register is kept as-is, so the driver assumes the PHY is already initialized and skips the configuration/power up sequence. The PHY won't come up again without clearing the QPHY_PCS_POWER_DOWN_CONTROL, so eventually initialization fails: qcom-qmp-pcie-phy 1be0000.phy: phy initialization timed-out phy phy-1be0000.phy.0: phy poweron failed --> -110 qcom-pcie 1bd0000.pcie: cannot initialize host qcom-pcie 1bd0000.pcie: probe with driver qcom-pcie failed with error -110 This can be reliably reproduced on the X1E CRD, QCP and Devkit when no card is inserted for PCIe3. Fix this by checking the QPHY_PCS_POWER_DOWN_CONTROL register in addition to QPHY_START_CTRL. If the PHY is powered down with the register, it doesn't conform to the expectations for using the "no_csr" reset, so we fully re-initialize with the normal reset sequence. Also check the register more carefully to ensure all of the bits we expect are actually set. A simple !!(readl()) is not enough, because the PHY might be only partially set up with some of the expected bits set. Cc: stable@vger.kernel.org Fixes: 0cc22f5 ("phy: qcom: qmp-pcie: Add PHY register retention support") Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Link: https://lore.kernel.org/r/20250821-phy-qcom-qmp-pcie-nocsr-fix-v3-1-4898db0cc07c@linaro.org Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6e44606 commit ac22507

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

drivers/phy/qualcomm/phy-qcom-qmp-pcie.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3064,6 +3064,14 @@ struct qmp_pcie {
30643064
struct clk_fixed_rate aux_clk_fixed;
30653065
};
30663066

3067+
static bool qphy_checkbits(const void __iomem *base, u32 offset, u32 val)
3068+
{
3069+
u32 reg;
3070+
3071+
reg = readl(base + offset);
3072+
return (reg & val) == val;
3073+
}
3074+
30673075
static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val)
30683076
{
30693077
u32 reg;
@@ -4332,16 +4340,21 @@ static int qmp_pcie_init(struct phy *phy)
43324340
struct qmp_pcie *qmp = phy_get_drvdata(phy);
43334341
const struct qmp_phy_cfg *cfg = qmp->cfg;
43344342
void __iomem *pcs = qmp->pcs;
4335-
bool phy_initialized = !!(readl(pcs + cfg->regs[QPHY_START_CTRL]));
43364343
int ret;
43374344

4338-
qmp->skip_init = qmp->nocsr_reset && phy_initialized;
43394345
/*
4340-
* We need to check the existence of init sequences in two cases:
4341-
* 1. The PHY doesn't support no_csr reset.
4342-
* 2. The PHY supports no_csr reset but isn't initialized by bootloader.
4343-
* As we can't skip init in these two cases.
4346+
* We can skip PHY initialization if all of the following conditions
4347+
* are met:
4348+
* 1. The PHY supports the nocsr_reset that preserves the PHY config.
4349+
* 2. The PHY was started (and not powered down again) by the
4350+
* bootloader, with all of the expected bits set correctly.
4351+
* In this case, we can continue without having the init sequence
4352+
* defined in the driver.
43444353
*/
4354+
qmp->skip_init = qmp->nocsr_reset &&
4355+
qphy_checkbits(pcs, cfg->regs[QPHY_START_CTRL], SERDES_START | PCS_START) &&
4356+
qphy_checkbits(pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], cfg->pwrdn_ctrl);
4357+
43454358
if (!qmp->skip_init && !cfg->tbls.serdes_num) {
43464359
dev_err(qmp->dev, "Init sequence not available\n");
43474360
return -ENODATA;

0 commit comments

Comments
 (0)