From a85dfd17dd6dd02eed56a0cabb13dd61520e5f43 Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Thu, 4 Jul 2024 18:07:28 +0800 Subject: [PATCH] rockchip: fix reset pcie Signed-off-by: Tianling Shen (cherry picked from commit a3ac91322ecda0628704457f85916779c3919eb0) --- ...ockchip-Fix-initial-PERST-GPIO-value.patch | 76 +++++++++++++++++++ ...568-update-gicv3-its-and-pci-msi-map.patch | 4 +- ...dts-rockchip-rk3568-Add-xpcs-support.patch | 6 +- ...m64-dts-rockchip-rk356x-add-rng-node.patch | 2 +- 4 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 target/linux/rockchip/patches-5.15/114-PCI-dw-rockchip-Fix-initial-PERST-GPIO-value.patch diff --git a/target/linux/rockchip/patches-5.15/114-PCI-dw-rockchip-Fix-initial-PERST-GPIO-value.patch b/target/linux/rockchip/patches-5.15/114-PCI-dw-rockchip-Fix-initial-PERST-GPIO-value.patch new file mode 100644 index 0000000000..c56547da2f --- /dev/null +++ b/target/linux/rockchip/patches-5.15/114-PCI-dw-rockchip-Fix-initial-PERST-GPIO-value.patch @@ -0,0 +1,76 @@ +From c335ab00b0cd70707291efaf9ff48ebb69dcf667 Mon Sep 17 00:00:00 2001 +From: Niklas Cassel +Date: Wed, 17 Apr 2024 18:42:26 +0200 +Subject: [PATCH] PCI: dw-rockchip: Fix initial PERST# GPIO value +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +PERST# is active low according to the PCIe specification. + +However, the existing pcie-dw-rockchip.c driver does: + + gpiod_set_value(..., 0); msleep(100); gpiod_set_value(..., 1); + +when asserting + deasserting PERST#. + +This is of course wrong, but because all the device trees for this +compatible string have also incorrectly marked this GPIO as ACTIVE_HIGH: + + $ git grep -B 10 reset-gpios arch/arm64/boot/dts/rockchip/rk3568* + $ git grep -B 10 reset-gpios arch/arm64/boot/dts/rockchip/rk3588* + +The actual toggling of PERST# is correct, and we cannot change it anyway, +since that would break device tree compatibility. + +However, this driver does request the GPIO to be initialized as +GPIOD_OUT_HIGH, which does cause a silly sequence where PERST# gets +toggled back and forth for no good reason. + +Fix this by requesting the GPIO to be initialized as GPIOD_OUT_LOW (which +for this driver means PERST# asserted). + +This will avoid an unnecessary signal change where PERST# gets deasserted +(by devm_gpiod_get_optional()) and then gets asserted (by +rockchip_pcie_start_link()) just a few instructions later. + +Before patch, debug prints on EP side, when booting RC: + + [ 845.606810] pci: PERST# asserted by host! + [ 852.483985] pci: PERST# de-asserted by host! + [ 852.503041] pci: PERST# asserted by host! + [ 852.610318] pci: PERST# de-asserted by host! + +After patch, debug prints on EP side, when booting RC: + + [ 125.107921] pci: PERST# asserted by host! + [ 132.111429] pci: PERST# de-asserted by host! + +This extra, very short, PERST# assertion + deassertion has been reported to +cause issues with certain WLAN controllers, e.g. RTL8822CE. + +Fixes: 0e898eb8df4e ("PCI: rockchip-dwc: Add Rockchip RK356X host controller driver") +Link: https://lore.kernel.org/linux-pci/20240417164227.398901-1-cassel@kernel.org +Tested-by: Heiko Stuebner +Tested-by: Jianfeng Liu +Signed-off-by: Niklas Cassel +Signed-off-by: Krzysztof WilczyƄski +Signed-off-by: Bjorn Helgaas +Reviewed-by: Heiko Stuebner +Reviewed-by: Manivannan Sadhasivam +Cc: stable@vger.kernel.org # v5.15+ +--- + drivers/pci/controller/dwc/pcie-dw-rockchip.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c ++++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c +@@ -240,7 +240,7 @@ static int rockchip_pcie_resource_get(st + return PTR_ERR(rockchip->apb_base); + + rockchip->rst_gpio = devm_gpiod_get_optional(&pdev->dev, "reset", +- GPIOD_OUT_HIGH); ++ GPIOD_OUT_LOW); + if (IS_ERR(rockchip->rst_gpio)) + return PTR_ERR(rockchip->rst_gpio); + diff --git a/target/linux/rockchip/patches-5.15/703-arm64-rk3568-update-gicv3-its-and-pci-msi-map.patch b/target/linux/rockchip/patches-5.15/703-arm64-rk3568-update-gicv3-its-and-pci-msi-map.patch index adab795d05..b72a905f78 100644 --- a/target/linux/rockchip/patches-5.15/703-arm64-rk3568-update-gicv3-its-and-pci-msi-map.patch +++ b/target/linux/rockchip/patches-5.15/703-arm64-rk3568-update-gicv3-its-and-pci-msi-map.patch @@ -38,7 +38,7 @@ phy-names = "pcie-phy"; --- a/arch/arm64/boot/dts/rockchip/rk356x.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk356x.dtsi -@@ -315,14 +315,21 @@ +@@ -356,14 +356,21 @@ gic: interrupt-controller@fd400000 { compatible = "arm,gic-v3"; @@ -66,7 +66,7 @@ }; usb_host0_ehci: usb@fd800000 { -@@ -880,7 +887,7 @@ +@@ -921,7 +928,7 @@ num-ib-windows = <6>; num-ob-windows = <2>; max-link-speed = <2>; diff --git a/target/linux/rockchip/patches-5.15/711-arm64-dts-rockchip-rk3568-Add-xpcs-support.patch b/target/linux/rockchip/patches-5.15/711-arm64-dts-rockchip-rk3568-Add-xpcs-support.patch index 33b18fccb2..f46666e088 100644 --- a/target/linux/rockchip/patches-5.15/711-arm64-dts-rockchip-rk3568-Add-xpcs-support.patch +++ b/target/linux/rockchip/patches-5.15/711-arm64-dts-rockchip-rk3568-Add-xpcs-support.patch @@ -12,7 +12,7 @@ Signed-off-by: David Wu --- a/arch/arm64/boot/dts/rockchip/rk356x.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk356x.dtsi -@@ -222,6 +222,13 @@ +@@ -263,6 +263,13 @@ arm,no-tick-in-suspend; }; @@ -26,7 +26,7 @@ Signed-off-by: David Wu xin24m: xin24m { compatible = "fixed-clock"; clock-frequency = <24000000>; -@@ -376,6 +383,12 @@ +@@ -417,6 +424,12 @@ status = "disabled"; }; @@ -39,7 +39,7 @@ Signed-off-by: David Wu pmugrf: syscon@fdc20000 { compatible = "rockchip,rk3568-pmugrf", "syscon", "simple-mfd"; reg = <0x0 0xfdc20000 0x0 0x10000>; -@@ -623,11 +636,13 @@ +@@ -664,11 +677,13 @@ clocks = <&cru SCLK_GMAC1>, <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1_RX_TX>, <&cru CLK_MAC1_REFOUT>, <&cru ACLK_GMAC1>, <&cru PCLK_GMAC1>, diff --git a/target/linux/rockchip/patches-5.15/801-04-arm64-dts-rockchip-rk356x-add-rng-node.patch b/target/linux/rockchip/patches-5.15/801-04-arm64-dts-rockchip-rk356x-add-rng-node.patch index 8804756f9a..35fd3e5236 100644 --- a/target/linux/rockchip/patches-5.15/801-04-arm64-dts-rockchip-rk356x-add-rng-node.patch +++ b/target/linux/rockchip/patches-5.15/801-04-arm64-dts-rockchip-rk356x-add-rng-node.patch @@ -11,7 +11,7 @@ Signed-off-by: Lin Jinhan --- a/arch/arm64/boot/dts/rockchip/rk356x.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk356x.dtsi -@@ -1586,6 +1586,15 @@ +@@ -1627,6 +1627,15 @@ status = "disabled"; };