diff options
author | Niklas Cassel <[email protected]> | 2024-04-17 18:42:26 +0200 |
---|---|---|
committer | Bjorn Helgaas <[email protected]> | 2024-07-09 18:28:40 -0500 |
commit | 28b8d7793b8573563b3d45321376f36168d77b1e (patch) | |
tree | b2f15c6acacc06ec4681e3db01918215f8b691e8 | |
parent | 206c4f778b3c7c8950f5c6be518e0a113102a13e (diff) |
PCI: dw-rockchip: Fix initial PERST# GPIO value
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/[email protected]
Tested-by: Heiko Stuebner <[email protected]>
Tested-by: Jianfeng Liu <[email protected]>
Signed-off-by: Niklas Cassel <[email protected]>
Signed-off-by: Krzysztof WilczyĆski <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
Reviewed-by: Heiko Stuebner <[email protected]>
Reviewed-by: Manivannan Sadhasivam <[email protected]>
Cc: [email protected] # v5.15+
-rw-r--r-- | drivers/pci/controller/dwc/pcie-dw-rockchip.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/pci/controller/dwc/pcie-dw-rockchip.c b/drivers/pci/controller/dwc/pcie-dw-rockchip.c index a13ca83ce260..61b1acba7182 100644 --- a/drivers/pci/controller/dwc/pcie-dw-rockchip.c +++ b/drivers/pci/controller/dwc/pcie-dw-rockchip.c @@ -245,7 +245,7 @@ static int rockchip_pcie_resource_get(struct platform_device *pdev, "failed to map apb registers\n"); rockchip->rst_gpio = devm_gpiod_get_optional(&pdev->dev, "reset", - GPIOD_OUT_HIGH); + GPIOD_OUT_LOW); if (IS_ERR(rockchip->rst_gpio)) return dev_err_probe(&pdev->dev, PTR_ERR(rockchip->rst_gpio), "failed to get reset gpio\n"); |