#define PCIE_BRG_RSTB BIT(2)
#define PCIE_PE_RSTB BIT(3)
+/*
+ * As described in the datasheet of MediaTek PCIe Gen3 controller, wait 10ms
+ * after setting PCIE_BRG_RSTB, and before accessing PCIe internal registers.
+ */
+#define PCIE_BRG_RST_RDY_MS 10
+
#define PCIE_LTSSM_STATUS_REG 0x150
#define PCIE_LTSSM_STATE_MASK GENMASK(28, 24)
#define PCIE_LTSSM_STATE(val) ((val & PCIE_LTSSM_STATE_MASK) >> 24)
return err;
}
+ /*
+ * Some of MediaTek's chips won't output REFCLK when PCIE_PHY_RSTB is
+ * asserted, we have to de-assert MAC & PHY & BRG reset signals first
+ * to allow the REFCLK to be stable. While PCIE_BRG_RSTB is asserted,
+ * there is a short period during which the PCIe internal register
+ * cannot be accessed, so we need to wait 10ms here.
+ */
+ msleep(PCIE_BRG_RST_RDY_MS);
+
+ if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
+ /* De-assert MAC, PHY and BRG reset signals */
+ val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB);
+ writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
+ }
+
/*
* Described in PCIe CEM specification revision 6.0.
*
msleep(PCIE_T_PVPERL_MS);
if (!(pcie->soc->flags & SKIP_PCIE_RSTB)) {
- /* De-assert reset signals */
- val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB |
- PCIE_PE_RSTB);
+ /* De-assert PERST# signal */
+ val &= ~PCIE_PE_RSTB;
writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
}