Skip to content

Commit d16d400

Browse files
srevinodkoul
authored andcommitted
phy: rockchip: naneng-combphy: Fix mux on rk3588
The pcie1l0_sel and pcie1l1_sel bits in PCIESEL_CON configure the mux for PCIe1L0 and PCIe1L1 to either the PIPE Combo PHYs or the PCIe3 PHY. Thus this configuration interfers with the data-lanes configuration done by the PCIe3 PHY. RK3588 has three Combo PHYs. The first one has a dedicated PCIe controller and is not affected by this. For the other two Combo PHYs, there is one mux for each of them. pcie1l0_sel selects if PCIe 1L0 is muxed to Combo PHY 1 when bit is set to 0 or to the PCIe3 PHY when bit is set to 1. pcie1l1_sel selects if PCIe 1L1 is muxed to Combo PHY 2 when bit is set to 0 or to the PCIe3 PHY when bit is set to 1. Currently the code always muxes 1L0 and 1L1 to the Combi PHYs once one of them is being used in PCIe mode. This is obviously wrong when at least one of the ports should be muxed to the PCIe3 PHY. Fix this by introducing Combo PHY identification and then only setting up the required bit. Fixes: a03c442 ("phy: rockchip: Add naneng combo phy support for RK3588") Reported-by: Michal Tomek <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]> Reviewed-by: Heiko Stuebner <[email protected]> Link: https://lore.kernel.org/r/20240404-rk3588-pcie-bifurcation-fixes-v1-3-9907136eeafd@kernel.org Signed-off-by: Vinod Koul <[email protected]>
1 parent 55491a5 commit d16d400

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

drivers/phy/rockchip/phy-rockchip-naneng-combphy.c

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,15 @@ struct rockchip_combphy_grfcfg {
125125
};
126126

127127
struct rockchip_combphy_cfg {
128+
unsigned int num_phys;
129+
unsigned int phy_ids[3];
128130
const struct rockchip_combphy_grfcfg *grfcfg;
129131
int (*combphy_cfg)(struct rockchip_combphy_priv *priv);
130132
};
131133

132134
struct rockchip_combphy_priv {
133135
u8 type;
136+
int id;
134137
void __iomem *mmio;
135138
int num_clks;
136139
struct clk_bulk_data *clks;
@@ -320,7 +323,7 @@ static int rockchip_combphy_probe(struct platform_device *pdev)
320323
struct rockchip_combphy_priv *priv;
321324
const struct rockchip_combphy_cfg *phy_cfg;
322325
struct resource *res;
323-
int ret;
326+
int ret, id;
324327

325328
phy_cfg = of_device_get_match_data(dev);
326329
if (!phy_cfg) {
@@ -338,6 +341,15 @@ static int rockchip_combphy_probe(struct platform_device *pdev)
338341
return ret;
339342
}
340343

344+
/* find the phy-id from the io address */
345+
priv->id = -ENODEV;
346+
for (id = 0; id < phy_cfg->num_phys; id++) {
347+
if (res->start == phy_cfg->phy_ids[id]) {
348+
priv->id = id;
349+
break;
350+
}
351+
}
352+
341353
priv->dev = dev;
342354
priv->type = PHY_NONE;
343355
priv->cfg = phy_cfg;
@@ -562,6 +574,12 @@ static const struct rockchip_combphy_grfcfg rk3568_combphy_grfcfgs = {
562574
};
563575

564576
static const struct rockchip_combphy_cfg rk3568_combphy_cfgs = {
577+
.num_phys = 3,
578+
.phy_ids = {
579+
0xfe820000,
580+
0xfe830000,
581+
0xfe840000,
582+
},
565583
.grfcfg = &rk3568_combphy_grfcfgs,
566584
.combphy_cfg = rk3568_combphy_cfg,
567585
};
@@ -578,8 +596,14 @@ static int rk3588_combphy_cfg(struct rockchip_combphy_priv *priv)
578596
rockchip_combphy_param_write(priv->phy_grf, &cfg->con1_for_pcie, true);
579597
rockchip_combphy_param_write(priv->phy_grf, &cfg->con2_for_pcie, true);
580598
rockchip_combphy_param_write(priv->phy_grf, &cfg->con3_for_pcie, true);
581-
rockchip_combphy_param_write(priv->pipe_grf, &cfg->pipe_pcie1l0_sel, true);
582-
rockchip_combphy_param_write(priv->pipe_grf, &cfg->pipe_pcie1l1_sel, true);
599+
switch (priv->id) {
600+
case 1:
601+
rockchip_combphy_param_write(priv->pipe_grf, &cfg->pipe_pcie1l0_sel, true);
602+
break;
603+
case 2:
604+
rockchip_combphy_param_write(priv->pipe_grf, &cfg->pipe_pcie1l1_sel, true);
605+
break;
606+
}
583607
break;
584608
case PHY_TYPE_USB3:
585609
/* Set SSC downward spread spectrum */
@@ -736,6 +760,12 @@ static const struct rockchip_combphy_grfcfg rk3588_combphy_grfcfgs = {
736760
};
737761

738762
static const struct rockchip_combphy_cfg rk3588_combphy_cfgs = {
763+
.num_phys = 3,
764+
.phy_ids = {
765+
0xfee00000,
766+
0xfee10000,
767+
0xfee20000,
768+
},
739769
.grfcfg = &rk3588_combphy_grfcfgs,
740770
.combphy_cfg = rk3588_combphy_cfg,
741771
};

0 commit comments

Comments
 (0)