Skip to content

Commit f8020df

Browse files
mtdev79vinodkoul
authored andcommitted
phy: rockchip-snps-pcie3: fix bifurcation on rk3588
So far all RK3588 boards use fully aggregated PCIe. CM3588 is one of the few boards using this feature and apparently it is broken. The PHY offers the following mapping options: port 0 lane 0 - always mapped to controller 0 (4L) port 0 lane 1 - to controller 0 or 2 (1L0) port 1 lane 0 - to controller 0 or 1 (2L) port 1 lane 1 - to controller 0, 1 or 3 (1L1) The data-lanes DT property maps these as follows: 0 = no controller (unsupported by the HW) 1 = 4L 2 = 2L 3 = 1L0 4 = 1L1 That allows the following configurations with first column being the mainline data-lane mapping, second column being the downstream name, third column being PCIE3PHY_GRF_CMN_CON0 and PHP_GRF_PCIESEL register values and final column being the user visible lane setup: <1 1 1 1> = AGGREG = [4 0] = x4 (aggregation) <1 1 2 2> = NANBNB = [0 0] = x2 x2 (no bif.) <1 3 2 2> = NANBBI = [1 1] = x2 x1x1 (bif. of port 0) <1 1 2 4> = NABINB = [2 2] = x1x1 x2 (bif. of port 1) <1 3 2 4> = NABIBI = [3 3] = x1x1 x1x1 (bif. of both ports) The driver currently does not program PHP_GRF_PCIESEL correctly, which is fixed by this patch. As a side-effect the new logic is much simpler than the old logic. Fixes: 2e9bffc ("phy: rockchip: Support PCIe v3") Signed-off-by: Michal Tomek <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]> Acked-by: Heiko Stuebner <[email protected]> Link: https://lore.kernel.org/r/20240404-rk3588-pcie-bifurcation-fixes-v1-1-9907136eeafd@kernel.org Signed-off-by: Vinod Koul <[email protected]>
1 parent 3a16101 commit f8020df

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

drivers/phy/rockchip/phy-rockchip-snps-pcie3.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,36 +132,28 @@ static const struct rockchip_p3phy_ops rk3568_ops = {
132132
static int rockchip_p3phy_rk3588_init(struct rockchip_p3phy_priv *priv)
133133
{
134134
u32 reg = 0;
135-
u8 mode = 0;
135+
u8 mode = RK3588_LANE_AGGREGATION; /* default */
136136
int ret;
137137

138138
/* Deassert PCIe PMA output clamp mode */
139139
regmap_write(priv->phy_grf, RK3588_PCIE3PHY_GRF_CMN_CON0, BIT(8) | BIT(24));
140140

141141
/* Set bifurcation if needed */
142142
for (int i = 0; i < priv->num_lanes; i++) {
143-
if (!priv->lanes[i])
144-
mode |= (BIT(i) << 3);
145-
146143
if (priv->lanes[i] > 1)
147-
mode |= (BIT(i) >> 1);
148-
}
149-
150-
if (!mode)
151-
reg = RK3588_LANE_AGGREGATION;
152-
else {
153-
if (mode & (BIT(0) | BIT(1)))
154-
reg |= RK3588_BIFURCATION_LANE_0_1;
155-
156-
if (mode & (BIT(2) | BIT(3)))
157-
reg |= RK3588_BIFURCATION_LANE_2_3;
144+
mode &= ~RK3588_LANE_AGGREGATION;
145+
if (priv->lanes[i] == 3)
146+
mode |= RK3588_BIFURCATION_LANE_0_1;
147+
if (priv->lanes[i] == 4)
148+
mode |= RK3588_BIFURCATION_LANE_2_3;
158149
}
159150

151+
reg = mode;
160152
regmap_write(priv->phy_grf, RK3588_PCIE3PHY_GRF_CMN_CON0, (0x7<<16) | reg);
161153

162154
/* Set pcie1ln_sel in PHP_GRF_PCIESEL_CON */
163155
if (!IS_ERR(priv->pipe_grf)) {
164-
reg = (mode & (BIT(6) | BIT(7))) >> 6;
156+
reg = mode & 3;
165157
if (reg)
166158
regmap_write(priv->pipe_grf, PHP_GRF_PCIESEL_CON,
167159
(reg << 16) | reg);

0 commit comments

Comments
 (0)