Skip to content

Commit dc6061e

Browse files
committed
Merge branch 'pci/controller/brcmstb'
- Add optional DT 'num-lanes' property and if present, use it to override the Maximum Link Width advertised in Link Capabilities (Jim Quinlan) * pci/controller/brcmstb: PCI: brcmstb: Replace open coded value with PCIE_T_RRS_READY_MS MAINTAINERS: Drop Nicolas from maintaining pcie-brcmstb PCI: brcmstb: Set MLW based on "num-lanes" DT property if present dt-bindings: PCI: brcm,stb-pcie: Add num-lanes property
2 parents 480b315 + e8e7c1e commit dc6061e

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ properties:
107107
- const: bridge
108108
- const: swinit
109109

110+
num-lanes:
111+
default: 1
112+
maximum: 4
113+
110114
required:
111115
- compatible
112116
- reg

MAINTAINERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5085,7 +5085,6 @@ F: include/linux/platform_data/brcmnand.h
50855085

50865086
BROADCOM STB PCIE DRIVER
50875087
M: Jim Quinlan <[email protected]>
5088-
M: Nicolas Saenz Julienne <[email protected]>
50895088
M: Florian Fainelli <[email protected]>
50905089
R: Broadcom internal kernel review list <[email protected]>
50915090

drivers/pci/controller/pcie-brcmstb.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#define PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK 0xffffff
4848

4949
#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY 0x04dc
50+
#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_MAX_LINK_WIDTH_MASK 0x1f0
5051
#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK 0xc00
5152

5253
#define PCIE_RC_CFG_PRIV1_ROOT_CAP 0x4f8
@@ -56,6 +57,9 @@
5657
#define PCIE_RC_DL_MDIO_WR_DATA 0x1104
5758
#define PCIE_RC_DL_MDIO_RD_DATA 0x1108
5859

60+
#define PCIE_RC_PL_REG_PHY_CTL_1 0x1804
61+
#define PCIE_RC_PL_REG_PHY_CTL_1_REG_P2_POWERDOWN_ENA_NOSYNC_MASK 0x8
62+
5963
#define PCIE_RC_PL_PHY_CTL_15 0x184c
6064
#define PCIE_RC_PL_PHY_CTL_15_DIS_PLL_PD_MASK 0x400000
6165
#define PCIE_RC_PL_PHY_CTL_15_PM_CLK_PERIOD_MASK 0xff
@@ -1071,7 +1075,7 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
10711075
void __iomem *base = pcie->base;
10721076
struct pci_host_bridge *bridge;
10731077
struct resource_entry *entry;
1074-
u32 tmp, burst, aspm_support;
1078+
u32 tmp, burst, aspm_support, num_lanes, num_lanes_cap;
10751079
u8 num_out_wins = 0;
10761080
int num_inbound_wins = 0;
10771081
int memc, ret;
@@ -1179,6 +1183,27 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
11791183
PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK);
11801184
writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
11811185

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

1335-
/*
1336-
* Wait for 100ms after PERST# deassertion; see PCIe CEM specification
1337-
* sections 2.2, PCIe r5.0, 6.6.1.
1338-
*/
1339-
msleep(100);
1360+
msleep(PCIE_RESET_CONFIG_WAIT_MS);
13401361

13411362
/*
13421363
* Give the RC/EP even more time to wake up, before trying to

0 commit comments

Comments
 (0)