Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1651761pxy; Thu, 6 May 2021 12:22:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrblWHw0C/TAIG2kkF9ek/z6tDFemHBsaKxKJmbCghUSgDshoi/syQYD9qiLXKH7fMiaG/ X-Received: by 2002:a63:1d46:: with SMTP id d6mr6056934pgm.60.1620328921683; Thu, 06 May 2021 12:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620328921; cv=none; d=google.com; s=arc-20160816; b=Ia+mGVj8fUwtY5tXwFCYyTAZCzPAdoibShmjSThDEgrZ3cZwqKotlmKp77LoCgINQ+ DOzLJGVQQr4vrmsPr+WqOqZXH+GF8g2NDpyfVYM4OoIR+ePtPr0XbCfdzODxtkUtoeqM pY1p9SSTZlDjXUcm5r4uAcXS+ytN/ACeR1g/i9IZtBCA5oJ/NWedUZh8wAhUwc4Fn9dG 1WsCdVkWGQIgZRhhHRxC7ppHb7On5Oi4hW9UfHbGcQ6BXXMuWKF2phs6jUQVLtGzYCZp 3Hw2AMQjb9JrSqQSXaHSkXgPHDB8mIazQsfym33hPGdom730KnDZMfBbg9RwaAHZIn0W d25w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aVhISHuU40y41hcPh9Ge1wnwQ2NdiyDHU1IMjZf7E94=; b=T4+2x1ueN90R8On/fDOs0/lRmH9rxvL/+k9ooHq/Bj468IPAhPAL4I43V/AY8NuOOZ Jn2hs7lThPYjZYi84dlnKUE/cxZcCz1nZkuGhykmVG45bi349TBSg9PWRDpaw++jh+dK Vt+Abd0R+ecq0R7RcYCCHUI/bucTbwmU/T5CFmFSsVsnd9AB8wut/DBTIh3fLqURXWc4 0xTo9G3ycoklY6GnUPSEYPnUDxwhr7cqpkV0gWb71wFBs+DAi8jJEnBHUNzj8r2SBdzD bmYtHrajkoWYqPDDMM+bqEMizdbj+8PiMNXcllPCtzbyarNSblmzNKqR7+ouGI3nacOJ 5BMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jseQYHW2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o27si3913541pgm.555.2021.05.06.12.21.49; Thu, 06 May 2021 12:22:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jseQYHW2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235398AbhEFPhj (ORCPT + 99 others); Thu, 6 May 2021 11:37:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:46318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235641AbhEFPdv (ORCPT ); Thu, 6 May 2021 11:33:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0A13B613ED; Thu, 6 May 2021 15:32:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620315173; bh=/5yIPTKEkWgY56kimWV9XM50Ciagid7BtB2KRODStO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jseQYHW2AX00bNRe4SOUilGmTtv0OoLzecty/ZBtsQrArq/n3dhHzEcZfvSA+gPif iHOqLDm6J+2aOTGDbqYAIrfFpc/XcU/II14gWpEwtfQwkH9UF/J6nvTUBgmCEfPcbD UuRFMWAAmRX/SFOWU64K2XBs6Rwl7Qz+6MZRECtaxK8yhydg5Thl05xxzhYaS/cte6 YnE5NL/8gkuNchVcP2Zy8gfHIovErlfDfcPHGi89LhuDmzdh5uU1F8848BwX3BpeeS ysxAF3/7oMREC+Q3OVnye88vOnSLag9o+iFbaZHOEidJyIBAUhLePcWaZdIE5dGeG4 QE5XnJ5JSHehA== Received: by pali.im (Postfix) id B56988A1; Thu, 6 May 2021 17:32:52 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Lorenzo Pieralisi , Thomas Petazzoni , Rob Herring , Bjorn Helgaas Cc: Russell King , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Remi Pommarel , Xogium , Tomasz Maciej Nowak , Marc Zyngier , linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 29/42] PCI: aardvark: Reset PCIe card and disable PHY when unbinding driver Date: Thu, 6 May 2021 17:31:40 +0200 Message-Id: <20210506153153.30454-30-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210506153153.30454-1-pali@kernel.org> References: <20210506153153.30454-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When unbinding driver, assert PERST# signal which prepares PCIe card for power down. Then disable link training and PHY. Signed-off-by: Pali Rohár Reviewed-by: Marek Behún Fixes: 526a76991b7b ("PCI: aardvark: Implement driver 'remove' function and allow to build it as module") --- drivers/pci/controller/pci-aardvark.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 4b531675db81..b1e6a8a839e0 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -1494,6 +1494,18 @@ static int advk_pcie_remove(struct platform_device *pdev) /* Free config space for emulated root bridge */ pci_bridge_emul_cleanup(&pcie->bridge); + /* Assert PERST# signal which prepares PCIe card for power down */ + if (pcie->reset_gpio) + gpiod_set_value_cansleep(pcie->reset_gpio, 1); + + /* Disable link training */ + val = advk_readl(pcie, PCIE_CORE_CTRL0_REG); + val &= ~LINK_TRAINING_EN; + advk_writel(pcie, val, PCIE_CORE_CTRL0_REG); + + /* Disable phy */ + advk_pcie_disable_phy(pcie); + return 0; } -- 2.20.1