Skip to content

Commit 6cb8c1f

Browse files
stephan-ghvinodkoul
authored andcommitted
phy: qcom: qmp-pcie: Fix PHY initialization when powered down by firmware
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: [email protected] Fixes: 0cc22f5 ("phy: qcom: qmp-pcie: Add PHY register retention support") Signed-off-by: Stephan Gerhold <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://lore.kernel.org/r/20250821-phy-qcom-qmp-pcie-nocsr-fix-v3-1-4898db0cc07c@linaro.org Signed-off-by: Vinod Koul <[email protected]>
1 parent a22d3b0 commit 6cb8c1f

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,6 +3067,14 @@ struct qmp_pcie {
30673067
struct clk_fixed_rate aux_clk_fixed;
30683068
};
30693069

3070+
static bool qphy_checkbits(const void __iomem *base, u32 offset, u32 val)
3071+
{
3072+
u32 reg;
3073+
3074+
reg = readl(base + offset);
3075+
return (reg & val) == val;
3076+
}
3077+
30703078
static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val)
30713079
{
30723080
u32 reg;
@@ -4339,16 +4347,21 @@ static int qmp_pcie_init(struct phy *phy)
43394347
struct qmp_pcie *qmp = phy_get_drvdata(phy);
43404348
const struct qmp_phy_cfg *cfg = qmp->cfg;
43414349
void __iomem *pcs = qmp->pcs;
4342-
bool phy_initialized = !!(readl(pcs + cfg->regs[QPHY_START_CTRL]));
43434350
int ret;
43444351

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

0 commit comments

Comments
 (0)