Skip to content

Commit a364d10

Browse files
jamesequinlanMani-Sadhasivam
authored andcommitted
PCI: brcmstb: Set MLW based on "num-lanes" DT property if present
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
1 parent dbb1258 commit a364d10

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_RC_PL_PHY_CTL_15 0x184c
5963
#define PCIE_RC_PL_PHY_CTL_15_DIS_PLL_PD_MASK 0x400000
6064
#define PCIE_RC_PL_PHY_CTL_15_PM_CLK_PERIOD_MASK 0xff
@@ -1072,7 +1076,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
10721076
void __iomem *base = pcie->base;
10731077
struct pci_host_bridge *bridge;
10741078
struct resource_entry *entry;
1075-
u32 tmp, burst, aspm_support;
1079+
u32 tmp, burst, aspm_support, num_lanes, num_lanes_cap;
10761080
u8 num_out_wins = 0;
10771081
int num_inbound_wins = 0;
10781082
int memc, ret;
@@ -1180,6 +1184,27 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
11801184
PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK);
11811185
writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
11821186

1187+
/* 'tmp' still holds the contents of PRIV1_LINK_CAPABILITY */
1188+
num_lanes_cap = u32_get_bits(tmp, PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_MAX_LINK_WIDTH_MASK);
1189+
num_lanes = 0;
1190+
1191+
/*
1192+
* Use hardware negotiated Max Link Width value by default. If the
1193+
* "num-lanes" DT property is present, assume that the chip's default
1194+
* link width capability information is incorrect/undesired and use the
1195+
* specified value instead.
1196+
*/
1197+
if (!of_property_read_u32(pcie->np, "num-lanes", &num_lanes) &&
1198+
num_lanes && num_lanes <= 4 && num_lanes_cap != num_lanes) {
1199+
u32p_replace_bits(&tmp, num_lanes,
1200+
PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_MAX_LINK_WIDTH_MASK);
1201+
writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
1202+
tmp = readl(base + PCIE_RC_PL_REG_PHY_CTL_1);
1203+
u32p_replace_bits(&tmp, 1,
1204+
PCIE_RC_PL_REG_PHY_CTL_1_REG_P2_POWERDOWN_ENA_NOSYNC_MASK);
1205+
writel(tmp, base + PCIE_RC_PL_REG_PHY_CTL_1);
1206+
}
1207+
11831208
/*
11841209
* For config space accesses on the RC, show the right class for
11851210
* a PCIe-PCIe bridge (the default setting is to be EP mode).

0 commit comments

Comments
 (0)