mediatek: fix PCIe #PERST being de-asserted too early
authorDaniel Golle <daniel@makrotopia.org>
Tue, 3 Oct 2023 01:32:35 +0000 (02:32 +0100)
committerChristian Marangi <ansuelsmth@gmail.com>
Tue, 3 Oct 2023 15:38:34 +0000 (17:38 +0200)
The driver for MediaTek gen3 PCIe hosts de-asserts all reset
signals at the same time using a single register write operation.
Delay the de-assertion of the #PERST signal by 100ms as some PCIe
devices fail to come up otherwise.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
target/linux/mediatek/patches-5.15/611-pcie-mediatek-gen3-PERST-for-100ms.patch [new file with mode: 0644]
target/linux/mediatek/patches-5.15/922-v6.1-PCI-mediatek-gen3-change-driver-name-to-mtk-pcie-gen.patch
target/linux/mediatek/patches-6.1/611-pcie-mediatek-gen3-PERST-for-100ms.patch [new file with mode: 0644]

diff --git a/target/linux/mediatek/patches-5.15/611-pcie-mediatek-gen3-PERST-for-100ms.patch b/target/linux/mediatek/patches-5.15/611-pcie-mediatek-gen3-PERST-for-100ms.patch
new file mode 100644 (file)
index 0000000..d526ade
--- /dev/null
@@ -0,0 +1,17 @@
+--- a/drivers/pci/controller/pcie-mediatek-gen3.c
++++ b/drivers/pci/controller/pcie-mediatek-gen3.c
+@@ -319,7 +319,13 @@ static int mtk_pcie_startup_port(struct
+       msleep(100);
+       /* De-assert reset signals */
+-      val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB);
++      val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB);
++      writel_relaxed(val, port->base + PCIE_RST_CTRL_REG);
++
++      msleep(100);
++
++      /* De-assert PERST# signals */
++      val &= ~(PCIE_PE_RSTB);
+       writel_relaxed(val, port->base + PCIE_RST_CTRL_REG);
+       /* Check if the link is up or not */
index 44aed2207d564cdd08b8472d00b1ae35825533c8..f026f5573ce1775ad838bb8d111ef7b8f14074b8 100644 (file)
@@ -9,7 +9,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 
 --- a/drivers/pci/controller/pcie-mediatek-gen3.c
 +++ b/drivers/pci/controller/pcie-mediatek-gen3.c
-@@ -1025,7 +1025,7 @@ static struct platform_driver mtk_pcie_d
+@@ -1031,7 +1031,7 @@ static struct platform_driver mtk_pcie_d
        .probe = mtk_pcie_probe,
        .remove = mtk_pcie_remove,
        .driver = {
diff --git a/target/linux/mediatek/patches-6.1/611-pcie-mediatek-gen3-PERST-for-100ms.patch b/target/linux/mediatek/patches-6.1/611-pcie-mediatek-gen3-PERST-for-100ms.patch
new file mode 100644 (file)
index 0000000..f88efc0
--- /dev/null
@@ -0,0 +1,19 @@
+--- a/drivers/pci/controller/pcie-mediatek-gen3.c
++++ b/drivers/pci/controller/pcie-mediatek-gen3.c
+@@ -350,9 +350,15 @@ static int mtk_pcie_startup_port(struct
+       msleep(100);
+       /* De-assert reset signals */
+-      val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB);
++      val &= ~(PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB);
+       writel_relaxed(val, pcie->base + PCIE_RST_CTRL_REG);
++      msleep(100);
++
++      /* De-assert PERST# signals */
++      val &= ~(PCIE_PE_RSTB);
++      writel_relaxed(val, port->base + PCIE_RST_CTRL_REG);
++
+       /* Check if the link is up or not */
+       err = readl_poll_timeout(pcie->base + PCIE_LINK_STATUS_REG, val,
+                                !!(val & PCIE_PORT_LINKUP), 20,