Skip to content

Commit b4e2b74

Browse files
jamesequinlangregkh
authored andcommitted
PCI: brcmstb: Set MLW based on "num-lanes" DT property if present
[ Upstream commit a364d10 ] By default, the driver relies on the default hardware defined value for the Max Link Width (MLW) capability. But if the "num-lanes" DT property is present, assume that the chip's default capability information is incorrect or undesired, and use the specified value instead. Signed-off-by: Jim Quinlan <james.quinlan@broadcom.com> [mani: reworded the description and comments] Signed-off-by: Manivannan Sadhasivam <mani@kernel.org> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Link: https://patch.msgid.link/20250530224035.41886-3-james.quinlan@broadcom.com Stable-dep-of: 9583f9d ("PCI: brcmstb: Fix disabling L0s capability") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 8d18563 commit b4e2b74

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

drivers/pci/controller/pcie-brcmstb.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#define PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK 0xffffff
4747

4848
#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY 0x04dc
49+
#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_MAX_LINK_WIDTH_MASK 0x1f0
4950
#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK 0xc00
5051

5152
#define PCIE_RC_CFG_PRIV1_ROOT_CAP 0x4f8
@@ -55,6 +56,9 @@
5556
#define PCIE_RC_DL_MDIO_WR_DATA 0x1104
5657
#define PCIE_RC_DL_MDIO_RD_DATA 0x1108
5758

59+
#define PCIE_RC_PL_REG_PHY_CTL_1 0x1804
60+
#define PCIE_RC_PL_REG_PHY_CTL_1_REG_P2_POWERDOWN_ENA_NOSYNC_MASK 0x8
61+
5862
#define PCIE_MISC_MISC_CTRL 0x4008
5963
#define PCIE_MISC_MISC_CTRL_PCIE_RCB_64B_MODE_MASK 0x80
6064
#define PCIE_MISC_MISC_CTRL_PCIE_RCB_MPS_MODE_MASK 0x400
@@ -1025,7 +1029,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
10251029
void __iomem *base = pcie->base;
10261030
struct pci_host_bridge *bridge;
10271031
struct resource_entry *entry;
1028-
u32 tmp, burst, aspm_support;
1032+
u32 tmp, burst, aspm_support, num_lanes, num_lanes_cap;
10291033
u8 num_out_wins = 0;
10301034
int num_inbound_wins = 0;
10311035
int memc, ret;
@@ -1133,6 +1137,27 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
11331137
PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK);
11341138
writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
11351139

1140+
/* 'tmp' still holds the contents of PRIV1_LINK_CAPABILITY */
1141+
num_lanes_cap = u32_get_bits(tmp, PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_MAX_LINK_WIDTH_MASK);
1142+
num_lanes = 0;
1143+
1144+
/*
1145+
* Use hardware negotiated Max Link Width value by default. If the
1146+
* "num-lanes" DT property is present, assume that the chip's default
1147+
* link width capability information is incorrect/undesired and use the
1148+
* specified value instead.
1149+
*/
1150+
if (!of_property_read_u32(pcie->np, "num-lanes", &num_lanes) &&
1151+
num_lanes && num_lanes <= 4 && num_lanes_cap != num_lanes) {
1152+
u32p_replace_bits(&tmp, num_lanes,
1153+
PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_MAX_LINK_WIDTH_MASK);
1154+
writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
1155+
tmp = readl(base + PCIE_RC_PL_REG_PHY_CTL_1);
1156+
u32p_replace_bits(&tmp, 1,
1157+
PCIE_RC_PL_REG_PHY_CTL_1_REG_P2_POWERDOWN_ENA_NOSYNC_MASK);
1158+
writel(tmp, base + PCIE_RC_PL_REG_PHY_CTL_1);
1159+
}
1160+
11361161
/*
11371162
* For config space accesses on the RC, show the right class for
11381163
* a PCIe-PCIe bridge (the default setting is to be EP mode).

0 commit comments

Comments
 (0)