Skip to content

Commit 1bb63cb

Browse files
committed
PCI: pcie-brcmstb: optionally extend Tperst_clk time
Some endpoints need longer than the minimum Tperst_clk time of 100us that the PCIe specification allows for, as they may need to sequence internal resets off the stable output of internal PLLs prior to removal of fundamental reset. PCIe switches are an especially bad case, in some cases requiring up to 100 milliseconds for stable downstream link behaviour. Parse the DT property brcm,tperst-clk-ms and use this to hold PERST# low during brcm_pcie_start_link(). The BRCM RC typically outputs 200us of stable refclk before deasserting PERST#. By masking/forcing the output signal while deasserting the internal reset, the effect is to extend the length of time that the refclk is active and stable before PERST# is released. The TX lanes will enter the Polling state before PERST# is released, but this appears to be harmless. Signed-off-by: Jonathan Bell <[email protected]>
1 parent bcbcae4 commit 1bb63cb

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

drivers/pci/controller/pcie-brcmstb.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI + ((win) * 8)
135135

136136
#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK 0x2
137+
#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_PERST_ASSERT_MASK 0x8
137138
#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_L1SS_ENABLE_MASK 0x200000
138139
#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK 0x08000000
139140
#define PCIE_BMIPS_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK 0x00800000
@@ -360,6 +361,7 @@ struct brcm_pcie {
360361
struct subdev_regulators *sr;
361362
bool ep_wakeup_capable;
362363
const struct pcie_cfg_data *cfg;
364+
u32 tperst_clk_ms;
363365
};
364366

365367
static inline bool is_bmips(const struct brcm_pcie *pcie)
@@ -1475,13 +1477,32 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie)
14751477
u16 nlw, cls, lnksta, tmp16;
14761478
bool ssc_good = false;
14771479
int ret, i;
1480+
u32 tmp;
14781481

14791482
/* Limit the generation if specified */
14801483
if (pcie->gen)
14811484
brcm_pcie_set_gen(pcie, pcie->gen);
14821485

14831486
/* Unassert the fundamental reset */
1484-
ret = pcie->cfg->perst_set(pcie, 0);
1487+
if (pcie->tperst_clk_ms) {
1488+
/*
1489+
* Increase Tperst_clk time by forcing PERST# output low while
1490+
* the internal reset is released, so the PLL generates stable
1491+
* refclk output further in advance of PERST# deassertion.
1492+
*/
1493+
tmp = readl(pcie->base + HARD_DEBUG(pcie));
1494+
u32p_replace_bits(&tmp, 1, PCIE_MISC_HARD_PCIE_HARD_DEBUG_PERST_ASSERT_MASK);
1495+
writel(tmp, pcie->base + HARD_DEBUG(pcie));
1496+
1497+
ret = pcie->cfg->perst_set(pcie, 0);
1498+
fsleep(pcie->tperst_clk_ms * USEC_PER_MSEC);
1499+
1500+
tmp = readl(pcie->base + HARD_DEBUG(pcie));
1501+
u32p_replace_bits(&tmp, 0, PCIE_MISC_HARD_PCIE_HARD_DEBUG_PERST_ASSERT_MASK);
1502+
writel(tmp, pcie->base + HARD_DEBUG(pcie));
1503+
} else {
1504+
ret = pcie->cfg->perst_set(pcie, 0);
1505+
}
14851506
if (ret)
14861507
return ret;
14871508

@@ -2046,6 +2067,8 @@ static int brcm_pcie_probe(struct platform_device *pdev)
20462067
pcie->ssc = !(pcie->cfg->quirks & CFG_QUIRK_NO_SSC) &&
20472068
of_property_read_bool(np, "brcm,enable-ssc");
20482069

2070+
of_property_read_u32(np, "brcm,tperst-clk-ms", &pcie->tperst_clk_ms);
2071+
20492072
pcie->rescal = devm_reset_control_get_optional_shared(&pdev->dev, "rescal");
20502073
if (IS_ERR(pcie->rescal))
20512074
return PTR_ERR(pcie->rescal);

0 commit comments

Comments
 (0)