|
47 | 47 | #define PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK 0xffffff
|
48 | 48 |
|
49 | 49 | #define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY 0x04dc
|
| 50 | +#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_MAX_LINK_WIDTH_MASK 0x1f0 |
50 | 51 | #define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK 0xc00
|
51 | 52 |
|
52 | 53 | #define PCIE_RC_CFG_PRIV1_ROOT_CAP 0x4f8
|
|
56 | 57 | #define PCIE_RC_DL_MDIO_WR_DATA 0x1104
|
57 | 58 | #define PCIE_RC_DL_MDIO_RD_DATA 0x1108
|
58 | 59 |
|
| 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 | + |
59 | 63 | #define PCIE_RC_PL_PHY_CTL_15 0x184c
|
60 | 64 | #define PCIE_RC_PL_PHY_CTL_15_DIS_PLL_PD_MASK 0x400000
|
61 | 65 | #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)
|
1071 | 1075 | void __iomem *base = pcie->base;
|
1072 | 1076 | struct pci_host_bridge *bridge;
|
1073 | 1077 | struct resource_entry *entry;
|
1074 |
| - u32 tmp, burst, aspm_support; |
| 1078 | + u32 tmp, burst, aspm_support, num_lanes, num_lanes_cap; |
1075 | 1079 | u8 num_out_wins = 0;
|
1076 | 1080 | int num_inbound_wins = 0;
|
1077 | 1081 | int memc, ret;
|
@@ -1179,6 +1183,27 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
|
1179 | 1183 | PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK);
|
1180 | 1184 | writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY);
|
1181 | 1185 |
|
| 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 | + |
1182 | 1207 | /*
|
1183 | 1208 | * For config space accesses on the RC, show the right class for
|
1184 | 1209 | * 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)
|
1332 | 1357 | if (ret)
|
1333 | 1358 | return ret;
|
1334 | 1359 |
|
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); |
1340 | 1361 |
|
1341 | 1362 | /*
|
1342 | 1363 | * Give the RC/EP even more time to wake up, before trying to
|
|
0 commit comments