1 From fc6be080960bdd4cd109a7595fbffe94e5047bc4 Mon Sep 17 00:00:00 2001 2 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali@kernel.org> 3 Date: Thu, 11 Mar 2021 12:13:10 +0100 4 Subject: [PATCH 7/7] PCI: aardvark: Reset PCIe card and disable PHY at driver 5 unbind 6 MIME-Version: 1.0 7 Content-Type: text/plain; charset=UTF-8 8 Content-Transfer-Encoding: 8bit 9 10 When unbinding driver, assert PERST# signal which prepares PCIe card for 11 power down. Then disable link training and PHY. 12 13 Fixes: 526a76991b7b ("PCI: aardvark: Implement driver 'remove' function and allow to build it as module") 14 Signed-off-by: Pali Rohár <pali@kernel.org> 15 Signed-off-by: Marek Behún <kabel@kernel.org> 16 Cc: stable@vger.kernel.org 17 --- 18 drivers/pci/controller/pci-aardvark.c | 12 ++++++++++++ 19 1 file changed, 12 insertions(+) 20 21 diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c 22 index b3d89cb449b6..2a82c4652c28 100644 23 --- a/drivers/pci/controller/pci-aardvark.c 24 +++ b/drivers/pci/controller/pci-aardvark.c 25 @@ -1737,10 +1737,22 @@ static int advk_pcie_remove(struct platform_device *pdev) 26 /* Free config space for emulated root bridge */ 27 pci_bridge_emul_cleanup(&pcie->bridge); 28 29 + /* Assert PERST# signal which prepares PCIe card for power down */ 30 + if (pcie->reset_gpio) 31 + gpiod_set_value_cansleep(pcie->reset_gpio, 1); 32 + 33 + /* Disable link training */ 34 + val = advk_readl(pcie, PCIE_CORE_CTRL0_REG); 35 + val &= ~LINK_TRAINING_EN; 36 + advk_writel(pcie, val, PCIE_CORE_CTRL0_REG); 37 + 38 /* Disable outbound address windows mapping */ 39 for (i = 0; i < OB_WIN_COUNT; i++) 40 advk_pcie_disable_ob_win(pcie, i); 41 42 + /* Disable phy */ 43 + advk_pcie_disable_phy(pcie); 44 + 45 return 0; 46 } 47 48 -- 49 2.32.0 50