[PATCH 05/11] phy: qcom: qmp-pcie: Add PCIe endpoint mode support
Krishna Chaitanya Chundru
krishna.chundru at oss.qualcomm.com
Sat Nov 21 18:56:18 PST 2026
The register initialization sequence differs slightly between root
complex and endpoint mode. Add a .set_mode() op that records the
requested PCIe submode, and an optional per-config tbls_ep delta that is
applied as a second qmp_configure() pass over the pll_common/txrxz/pcs
blocks when the PHY was put into endpoint mode before power-on.
Configs that do not provide tbls_ep are unaffected and continue to
program only the root-complex tables.
Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru at oss.qualcomm.com>
---
drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c | 26 +++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c
index ccdb7748a9e1..21cf6adf7d60 100644
--- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c
+++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie-multiphy.c
@@ -13,6 +13,7 @@
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/phy/pcie.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/pm_domain.h>
@@ -89,6 +90,7 @@ struct qmp_phy_cfg_tbls {
struct qmp_phy_cfg {
const struct qmp_pcie_offsets *offsets;
const struct qmp_phy_cfg_tbls tbls;
+ const struct qmp_phy_cfg_tbls *tbls_ep;
const struct qmp_phy_init_tbl * const *pll_tbls;
const int *pll_nums;
bool port_split;
@@ -121,6 +123,7 @@ struct qmp_pcie {
struct reset_control_bulk_data *nocsr_resets;
struct regulator_bulk_data *vregs;
struct device **pd_devs;
+ bool is_ep;
};
struct qmp_pcie_multiphy {
@@ -930,6 +933,7 @@ static void qmp_pcie_init_port_registers(struct qmp_pcie *qmp)
const struct qmp_phy_cfg *cfg = qmp->cfg;
const struct qmp_pcie_offsets *offs = cfg->offsets;
const struct qmp_phy_cfg_tbls *tbls = &cfg->tbls;
+ const struct qmp_phy_cfg_tbls *ep_tbls = qmp->is_ep ? cfg->tbls_ep : NULL;
int i;
for (i = 0; i < cfg->num_regs; i++) {
@@ -957,6 +961,15 @@ static void qmp_pcie_init_port_registers(struct qmp_pcie *qmp)
qmp_configure(qmp->dev, port + offs->pcs_lanez,
tbls->pcs_lanez, tbls->pcs_lanez_num);
+ if (ep_tbls) {
+ qmp_configure(qmp->dev, port + offs->pll,
+ ep_tbls->pll_common, ep_tbls->pll_common_num);
+ qmp_configure(qmp->dev, port + offs->txrxz,
+ ep_tbls->txrxz, ep_tbls->txrxz_num);
+ qmp_configure(qmp->dev, port + offs->pcs,
+ ep_tbls->pcs, ep_tbls->pcs_num);
+ }
+
if (cfg->port_split)
qmp_configure(qmp->dev, port + offs->txrxz,
tbls->port_split_post_cfg, tbls->port_split_post_cfg_num);
@@ -1179,9 +1192,22 @@ static int qmp_pcie_disable(struct phy *phy)
return qmp_pcie_exit(phy);
}
+static int qmp_pcie_set_mode(struct phy *phy, enum phy_mode mode, int submode)
+{
+ struct qmp_pcie *qmp = phy_get_drvdata(phy);
+
+ if (mode != PHY_MODE_PCIE)
+ return -EINVAL;
+
+ qmp->is_ep = (submode == PHY_MODE_PCIE_EP);
+
+ return 0;
+}
+
static const struct phy_ops qmp_pcie_phy_ops = {
.power_on = qmp_pcie_enable,
.power_off = qmp_pcie_disable,
+ .set_mode = qmp_pcie_set_mode,
.owner = THIS_MODULE,
};
--
2.34.1
More information about the linux-phy
mailing list