5564a81
From patchwork Fri Jan 10 19:14:59 2020
5564a81
Content-Type: text/plain; charset="utf-8"
5564a81
MIME-Version: 1.0
5564a81
Content-Transfer-Encoding: 7bit
5564a81
X-Patchwork-Submitter: Vidya Sagar <vidyas@nvidia.com>
5564a81
X-Patchwork-Id: 1221384
5564a81
Return-Path: <linux-pci-owner@vger.kernel.org>
5564a81
X-Original-To: incoming@patchwork.ozlabs.org
5564a81
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
5564a81
Authentication-Results: ozlabs.org; spf=none (no SPF record)
5564a81
 smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67;
5564a81
 helo=vger.kernel.org;
5564a81
 envelope-from=linux-pci-owner@vger.kernel.org;
5564a81
 receiver=<UNKNOWN>)
5564a81
Authentication-Results: ozlabs.org;
5564a81
 dmarc=pass (p=none dis=none) header.from=nvidia.com
5564a81
Authentication-Results: ozlabs.org; dkim=pass (2048-bit key;
5564a81
 unprotected) header.d=nvidia.com header.i=@nvidia.com
5564a81
 header.a=rsa-sha256 header.s=n1 header.b=gf35ja2k; 
5564a81
 dkim-atps=neutral
5564a81
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
5564a81
 by ozlabs.org (Postfix) with ESMTP id 47vXkJ2PJMz9sPJ
5564a81
 for <incoming@patchwork.ozlabs.org>;
5564a81
 Sat, 11 Jan 2020 06:15:20 +1100 (AEDT)
5564a81
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
5564a81
 id S1728167AbgAJTPQ (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);
5564a81
 Fri, 10 Jan 2020 14:15:16 -0500
5564a81
Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:1668 "EHLO
5564a81
 hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
5564a81
 with ESMTP id S1727612AbgAJTPQ (ORCPT
5564a81
 <rfc822; linux-pci@vger.kernel.org>); Fri, 10 Jan 2020 14:15:16 -0500
5564a81
Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by
5564a81
 hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA)
5564a81
 id <B5e18cd310000>; Fri, 10 Jan 2020 11:14:57 -0800
5564a81
Received: from hqmail.nvidia.com ([172.20.161.6])
5564a81
 by hqpgpgate101.nvidia.com (PGP Universal service);
5564a81
 Fri, 10 Jan 2020 11:15:15 -0800
5564a81
X-PGP-Universal: processed;
5564a81
 by hqpgpgate101.nvidia.com on Fri, 10 Jan 2020 11:15:15 -0800
5564a81
Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL101.nvidia.com
5564a81
 (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3;
5564a81
 Fri, 10 Jan 2020 19:15:15 +0000
5564a81
Received: from HQMAIL107.nvidia.com (172.20.187.13) by HQMAIL109.nvidia.com
5564a81
 (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3;
5564a81
 Fri, 10 Jan 2020 19:15:14 +0000
5564a81
Received: from rnnvemgw01.nvidia.com (10.128.109.123) by HQMAIL107.nvidia.com
5564a81
 (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via
5564a81
 Frontend Transport; Fri, 10 Jan 2020 19:15:14 +0000
5564a81
Received: from vidyas-desktop.nvidia.com (Not Verified[10.24.37.48]) by
5564a81
 rnnvemgw01.nvidia.com with Trustwave SEG (v7, 5, 8, 10121)
5564a81
 id <B5e18cd3e0001>; Fri, 10 Jan 2020 11:15:14 -0800
5564a81
From: Vidya Sagar <vidyas@nvidia.com>
5564a81
To: <bhelgaas@google.com>, <lorenzo.pieralisi@arm.com>,
5564a81
 <rjw@rjwysocki.net>, <lenb@kernel.org>, <andrew.murray@arm.com>,
5564a81
 <treding@nvidia.com>, <jonathanh@nvidia.com>
5564a81
CC: <linux-tegra@vger.kernel.org>, <linux-pci@vger.kernel.org>,
5564a81
 <linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
5564a81
 <kthota@nvidia.com>, <mmaddireddy@nvidia.com>, <vidyas@nvidia.com>,
5564a81
 <sagar.tv@gmail.com>
5564a81
Subject: [PATCH V3 1/2] arm64: tegra: Re-order PCIe aperture mappings to
5564a81
 support ACPI boot
5564a81
Date: Sat, 11 Jan 2020 00:44:59 +0530
5564a81
Message-ID: <20200110191500.9538-2-vidyas@nvidia.com>
5564a81
X-Mailer: git-send-email 2.17.1
5564a81
In-Reply-To: <20200110191500.9538-1-vidyas@nvidia.com>
5564a81
References: <20200106082709.14370-1-vidyas@nvidia.com>
5564a81
 <20200110191500.9538-1-vidyas@nvidia.com>
5564a81
X-NVConfidentiality: public
5564a81
MIME-Version: 1.0
5564a81
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1;
5564a81
 t=1578683697; bh=A9295dTyR+j2yr8EqSviqtTgED4nGyVgvOv0oWR2ueU=;
5564a81
 h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer:
5564a81
 In-Reply-To:References:X-NVConfidentiality:MIME-Version:
5564a81
 Content-Type;
5564a81
 b=gf35ja2k7JnAqX+jyF1OxPVsYL5Fk4U+zYrMvTudBnjv0lLjB+7vnkXuO5FnSX28a
5564a81
 o2Mvk9yks+a7NYLZkVfmKCXKbeDNoGPlPSy+g8CAyeAd5u7leSGONsy5awV83vmud7
5564a81
 /KuuExw/Ko4JihAJdQ57/4EaaohgPWUNbodkmI5Wo0e7qyfgf5PvkAkwe1PdtgEKls
5564a81
 t9tsBwoqjGJn5WWPiQMaUZ8OHdSvPrUDuyKEFPjjr9IpczNvMzJE8SyHDZci42N+s+
5564a81
 f0iCjfLLhugetglYqrGi5j8eknYwfvMIV+vnkZj0dSmiS70Y1G31dVfgR/s3ueHnRy
5564a81
 jBNjNRTUtey9w==
5564a81
Sender: linux-pci-owner@vger.kernel.org
5564a81
Precedence: bulk
5564a81
List-ID: <linux-pci.vger.kernel.org>
5564a81
X-Mailing-List: linux-pci@vger.kernel.org
5564a81
5564a81
Re-order Tegra194's PCIe aperture mappings to have IO window moved to
5564a81
64-bit aperture and have the entire 32-bit aperture used for accessing
5564a81
the configuration space. This makes it to use the entire 32MB of the 32-bit
5564a81
aperture for ECAM purpose while booting through ACPI.
5564a81
5564a81
Signed-off-by: Vidya Sagar <vidyas@nvidia.com>
5564a81
---
5564a81
V3:
5564a81
* New change in this series
5564a81
5564a81
 arch/arm64/boot/dts/nvidia/tegra194.dtsi | 36 ++++++++++++------------
5564a81
 1 file changed, 18 insertions(+), 18 deletions(-)
5564a81
5564a81
diff --git a/arch/arm64/boot/dts/nvidia/tegra194.dtsi b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
5564a81
index ccac43be12ac..5d790ec5bdef 100644
5564a81
--- a/arch/arm64/boot/dts/nvidia/tegra194.dtsi
5564a81
+++ b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
5564a81
@@ -1247,9 +1247,9 @@
5564a81
 		nvidia,aspm-l0s-entrance-latency-us = <3>;
5564a81
 
5564a81
 		bus-range = <0x0 0xff>;
5564a81
-		ranges = <0x81000000 0x0  0x30100000 0x0  0x30100000 0x0 0x00100000   /* downstream I/O (1MB) */
5564a81
-			  0xc2000000 0x12 0x00000000 0x12 0x00000000 0x0 0x30000000   /* prefetchable memory (768MB) */
5564a81
-			  0x82000000 0x0  0x40000000 0x12 0x30000000 0x0 0x10000000>; /* non-prefetchable memory (256MB) */
5564a81
+		ranges = <0xc2000000 0x12 0x00000000 0x12 0x00000000 0x0 0x30000000   /* prefetchable memory (768MB) */
5564a81
+			  0x82000000 0x00 0x40000000 0x12 0x30000000 0x0 0x0fff0000   /* non-prefetchable memory (256MB - 64KB) */
5564a81
+			  0x81000000 0x00 0x00000000 0x12 0x3fff0000 0x0 0x00010000>; /* downstream I/O (64KB) */
5564a81
 	};
5564a81
 
5564a81
 	pcie@14120000 {
5564a81
@@ -1292,9 +1292,9 @@
5564a81
 		nvidia,aspm-l0s-entrance-latency-us = <3>;
5564a81
 
5564a81
 		bus-range = <0x0 0xff>;
5564a81
-		ranges = <0x81000000 0x0  0x32100000 0x0  0x32100000 0x0 0x00100000   /* downstream I/O (1MB) */
5564a81
-			  0xc2000000 0x12 0x40000000 0x12 0x40000000 0x0 0x30000000   /* prefetchable memory (768MB) */
5564a81
-			  0x82000000 0x0  0x40000000 0x12 0x70000000 0x0 0x10000000>; /* non-prefetchable memory (256MB) */
5564a81
+		ranges = <0xc2000000 0x12 0x40000000 0x12 0x40000000 0x0 0x30000000   /* prefetchable memory (768MB) */
5564a81
+			  0x82000000 0x00 0x40000000 0x12 0x70000000 0x0 0x0fff0000   /* non-prefetchable memory (256MB - 64KB) */
5564a81
+			  0x81000000 0x00 0x00000000 0x12 0x7fff0000 0x0 0x00010000>; /* downstream I/O (64KB) */
5564a81
 	};
5564a81
 
5564a81
 	pcie@14140000 {
5564a81
@@ -1337,9 +1337,9 @@
5564a81
 		nvidia,aspm-l0s-entrance-latency-us = <3>;
5564a81
 
5564a81
 		bus-range = <0x0 0xff>;
5564a81
-		ranges = <0x81000000 0x0  0x34100000 0x0  0x34100000 0x0 0x00100000   /* downstream I/O (1MB) */
5564a81
-			  0xc2000000 0x12 0x80000000 0x12 0x80000000 0x0 0x30000000   /* prefetchable memory (768MB) */
5564a81
-			  0x82000000 0x0  0x40000000 0x12 0xb0000000 0x0 0x10000000>; /* non-prefetchable memory (256MB) */
5564a81
+		ranges = <0xc2000000 0x12 0x80000000 0x12 0x80000000 0x0 0x30000000   /* prefetchable memory (768MB) */
5564a81
+			  0x82000000 0x00 0x40000000 0x12 0xb0000000 0x0 0x0fff0000   /* non-prefetchable memory (256MB - 64KB) */
5564a81
+			  0x81000000 0x00 0x00000000 0x12 0xbfff0000 0x0 0x00010000>; /* downstream I/O (64KB) */
5564a81
 	};
5564a81
 
5564a81
 	pcie@14160000 {
5564a81
@@ -1382,9 +1382,9 @@
5564a81
 		nvidia,aspm-l0s-entrance-latency-us = <3>;
5564a81
 
5564a81
 		bus-range = <0x0 0xff>;
5564a81
-		ranges = <0x81000000 0x0  0x36100000 0x0  0x36100000 0x0 0x00100000   /* downstream I/O (1MB) */
5564a81
-			  0xc2000000 0x14 0x00000000 0x14 0x00000000 0x3 0x40000000   /* prefetchable memory (13GB) */
5564a81
-			  0x82000000 0x0  0x40000000 0x17 0x40000000 0x0 0xc0000000>; /* non-prefetchable memory (3GB) */
5564a81
+		ranges = <0xc2000000 0x14 0x00000000 0x14 0x00000000 0x3 0x40000000   /* prefetchable memory (13GB) */
5564a81
+			  0x82000000 0x00 0x40000000 0x17 0x40000000 0x0 0xbfff0000   /* non-prefetchable memory (3GB - 64KB) */
5564a81
+			  0x81000000 0x00 0x00000000 0x17 0xffff0000 0x0 0x00010000>; /* downstream I/O (64KB) */
5564a81
 	};
5564a81
 
5564a81
 	pcie@14180000 {
5564a81
@@ -1427,9 +1427,9 @@
5564a81
 		nvidia,aspm-l0s-entrance-latency-us = <3>;
5564a81
 
5564a81
 		bus-range = <0x0 0xff>;
5564a81
-		ranges = <0x81000000 0x0  0x38100000 0x0  0x38100000 0x0 0x00100000   /* downstream I/O (1MB) */
5564a81
-			  0xc2000000 0x18 0x00000000 0x18 0x00000000 0x3 0x40000000   /* prefetchable memory (13GB) */
5564a81
-			  0x82000000 0x0  0x40000000 0x1b 0x40000000 0x0 0xc0000000>; /* non-prefetchable memory (3GB) */
5564a81
+		ranges = <0xc2000000 0x18 0x00000000 0x18 0x00000000 0x3 0x40000000   /* prefetchable memory (13GB) */
5564a81
+			  0x82000000 0x00 0x40000000 0x1b 0x40000000 0x0 0xbfff0000   /* non-prefetchable memory (3GB - 64KB) */
5564a81
+			  0x81000000 0x00 0x00000000 0x1b 0xffff0000 0x0 0x00010000>; /* downstream I/O (64KB) */
5564a81
 	};
5564a81
 
5564a81
 	pcie@141a0000 {
5564a81
@@ -1476,9 +1476,9 @@
5564a81
 		nvidia,aspm-l0s-entrance-latency-us = <3>;
5564a81
 
5564a81
 		bus-range = <0x0 0xff>;
5564a81
-		ranges = <0x81000000 0x0  0x3a100000 0x0  0x3a100000 0x0 0x00100000   /* downstream I/O (1MB) */
5564a81
-			  0xc2000000 0x1c 0x00000000 0x1c 0x00000000 0x3 0x40000000   /* prefetchable memory (13GB) */
5564a81
-			  0x82000000 0x0  0x40000000 0x1f 0x40000000 0x0 0xc0000000>; /* non-prefetchable memory (3GB) */
5564a81
+		ranges = <0xc2000000 0x1c 0x00000000 0x1c 0x00000000 0x3 0x40000000   /* prefetchable memory (13GB) */
5564a81
+			  0x82000000 0x00 0x40000000 0x1f 0x40000000 0x0 0xbfff0000   /* non-prefetchable memory (3GB - 64KB) */
5564a81
+			  0x81000000 0x00 0x00000000 0x1f 0xffff0000 0x0 0x00010000>; /* downstream I/O (64KB) */
5564a81
 	};
5564a81
 
81203d2
 	pcie_ep@14160000 {
5564a81
5564a81
From patchwork Fri Jan 10 19:15:00 2020
5564a81
Content-Type: text/plain; charset="utf-8"
5564a81
MIME-Version: 1.0
5564a81
Content-Transfer-Encoding: 7bit
5564a81
X-Patchwork-Submitter: Vidya Sagar <vidyas@nvidia.com>
5564a81
X-Patchwork-Id: 1221385
5564a81
Return-Path: <linux-pci-owner@vger.kernel.org>
5564a81
X-Original-To: incoming@patchwork.ozlabs.org
5564a81
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
5564a81
Authentication-Results: ozlabs.org; spf=none (no SPF record)
5564a81
 smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67;
5564a81
 helo=vger.kernel.org;
5564a81
 envelope-from=linux-pci-owner@vger.kernel.org;
5564a81
 receiver=<UNKNOWN>)
5564a81
Authentication-Results: ozlabs.org;
5564a81
 dmarc=pass (p=none dis=none) header.from=nvidia.com
5564a81
Authentication-Results: ozlabs.org; dkim=pass (2048-bit key;
5564a81
 unprotected) header.d=nvidia.com header.i=@nvidia.com
5564a81
 header.a=rsa-sha256 header.s=n1 header.b=KDh6KAfT; 
5564a81
 dkim-atps=neutral
5564a81
Received: from vger.kernel.org (vger.kernel.org [209.132.180.67])
5564a81
 by ozlabs.org (Postfix) with ESMTP id 47vXkS04dtz9sR0
5564a81
 for <incoming@patchwork.ozlabs.org>;
5564a81
 Sat, 11 Jan 2020 06:15:28 +1100 (AEDT)
5564a81
Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand
5564a81
 id S1728451AbgAJTPX (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);
5564a81
 Fri, 10 Jan 2020 14:15:23 -0500
5564a81
Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:9177 "EHLO
5564a81
 hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org
5564a81
 with ESMTP id S1727612AbgAJTPX (ORCPT
5564a81
 <rfc822; linux-pci@vger.kernel.org>); Fri, 10 Jan 2020 14:15:23 -0500
5564a81
Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by
5564a81
 hqnvemgate24.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA)
5564a81
 id <B5e18cd160001>; Fri, 10 Jan 2020 11:14:30 -0800
5564a81
Received: from hqmail.nvidia.com ([172.20.161.6])
5564a81
 by hqpgpgate101.nvidia.com (PGP Universal service);
5564a81
 Fri, 10 Jan 2020 11:15:21 -0800
5564a81
X-PGP-Universal: processed;
5564a81
 by hqpgpgate101.nvidia.com on Fri, 10 Jan 2020 11:15:21 -0800
5564a81
Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL111.nvidia.com
5564a81
 (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3;
5564a81
 Fri, 10 Jan 2020 19:15:21 +0000
5564a81
Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL109.nvidia.com
5564a81
 (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3;
5564a81
 Fri, 10 Jan 2020 19:15:21 +0000
5564a81
Received: from rnnvemgw01.nvidia.com (10.128.109.123) by HQMAIL109.nvidia.com
5564a81
 (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via
5564a81
 Frontend Transport; Fri, 10 Jan 2020 19:15:20 +0000
5564a81
Received: from vidyas-desktop.nvidia.com (Not Verified[10.24.37.48]) by
5564a81
 rnnvemgw01.nvidia.com with Trustwave SEG (v7, 5, 8, 10121)
5564a81
 id <B5e18cd440002>; Fri, 10 Jan 2020 11:15:20 -0800
5564a81
From: Vidya Sagar <vidyas@nvidia.com>
5564a81
To: <bhelgaas@google.com>, <lorenzo.pieralisi@arm.com>,
5564a81
 <rjw@rjwysocki.net>, <lenb@kernel.org>, <andrew.murray@arm.com>,
5564a81
 <treding@nvidia.com>, <jonathanh@nvidia.com>
5564a81
CC: <linux-tegra@vger.kernel.org>, <linux-pci@vger.kernel.org>,
5564a81
 <linux-acpi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
5564a81
 <kthota@nvidia.com>, <mmaddireddy@nvidia.com>, <vidyas@nvidia.com>,
5564a81
 <sagar.tv@gmail.com>
5564a81
Subject: [PATCH V3 2/2] PCI: Add MCFG quirks for Tegra194 host controllers
5564a81
Date: Sat, 11 Jan 2020 00:45:00 +0530
5564a81
Message-ID: <20200110191500.9538-3-vidyas@nvidia.com>
5564a81
X-Mailer: git-send-email 2.17.1
5564a81
In-Reply-To: <20200110191500.9538-1-vidyas@nvidia.com>
5564a81
References: <20200106082709.14370-1-vidyas@nvidia.com>
5564a81
 <20200110191500.9538-1-vidyas@nvidia.com>
5564a81
X-NVConfidentiality: public
5564a81
MIME-Version: 1.0
5564a81
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1;
5564a81
 t=1578683671; bh=6wJT/II+S2upRtJe41MS3kcnFzRRB57EIPkoU3txnnc=;
5564a81
 h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer:
5564a81
 In-Reply-To:References:X-NVConfidentiality:MIME-Version:
5564a81
 Content-Type;
5564a81
 b=KDh6KAfT+xBJE0n0yRibTvav8qocX0wdxtjjCMNH+VNrt1Gvwgt8htMQvTCpi08Hz
5564a81
 OLS6piubtsXb2Fk+J0rDcwmB2QM0YMKe6eA3DQkuJTPhl6PRxtvXdAYPfl/Z2pvG38
5564a81
 dq6SIor6Yw4e76ncsvt69w6UXoLZHF7AywICq0jGnmPjWoKDnjID3qKSj5/u7tE+/L
5564a81
 6hJUZ2QQebXRI17dRdfleyir+rRCS0wMl9tVNiAHplY3Wlxw895LJqvmVRZDVA+kg5
5564a81
 8DPKJY2JbazS6P4QcywESwuhDfejJGaJUz+1/6oSiHBMCI5OhfhFZ/lyTf0iZycdTQ
5564a81
 gnZUMkPu2QZOg==
5564a81
Sender: linux-pci-owner@vger.kernel.org
5564a81
Precedence: bulk
5564a81
List-ID: <linux-pci.vger.kernel.org>
5564a81
X-Mailing-List: linux-pci@vger.kernel.org
5564a81
5564a81
The PCIe controller in Tegra194 SoC is not completely ECAM-compliant.
5564a81
With the current hardware design limitations in place, ECAM can be enabled
5564a81
only for one controller (C5 controller to be precise) with bus numbers
5564a81
starting from 160 instead of 0. A different approach is taken to avoid this
5564a81
abnormal way of enabling ECAM for just one controller but to enable
5564a81
configuration space access for all the other controllers. In this approach,
5564a81
ops are added through MCFG quirk mechanism which access the configuration
5564a81
spaces by dynamically programming iATU (internal AddressTranslation Unit)
5564a81
to generate respective configuration accesses just like the way it is
5564a81
done in DesignWare core sub-system.
5564a81
5564a81
Signed-off-by: Vidya Sagar <vidyas@nvidia.com>
5564a81
Reported-by: kbuild test robot <lkp@intel.com>
5564a81
Acked-by: Thierry Reding <treding@nvidia.com>
5564a81
---
5564a81
V3:
5564a81
* Removed MCFG address hardcoding in pci_mcfg.c file
5564a81
* Started using 'dbi_base' for accessing root port's own config space
5564a81
* and using 'config_base' for accessing config space of downstream hierarchy
5564a81
5564a81
V2:
5564a81
* Fixed build issues reported by kbuild test bot
5564a81
5564a81
 drivers/acpi/pci_mcfg.c                    |   7 ++
5564a81
 drivers/pci/controller/dwc/Kconfig         |   3 +-
5564a81
 drivers/pci/controller/dwc/Makefile        |   2 +-
5564a81
 drivers/pci/controller/dwc/pcie-tegra194.c | 102 +++++++++++++++++++++
5564a81
 include/linux/pci-ecam.h                   |   1 +
5564a81
 5 files changed, 113 insertions(+), 2 deletions(-)
5564a81
5564a81
diff --git a/drivers/acpi/pci_mcfg.c b/drivers/acpi/pci_mcfg.c
5564a81
index 6b347d9920cc..707181408173 100644
5564a81
--- a/drivers/acpi/pci_mcfg.c
5564a81
+++ b/drivers/acpi/pci_mcfg.c
5564a81
@@ -116,6 +116,13 @@ static struct mcfg_fixup mcfg_quirks[] = {
5564a81
 	THUNDER_ECAM_QUIRK(2, 12),
5564a81
 	THUNDER_ECAM_QUIRK(2, 13),
5564a81
 
5564a81
+	{ "NVIDIA", "TEGRA194", 1, 0, MCFG_BUS_ANY, &tegra194_pcie_ops},
5564a81
+	{ "NVIDIA", "TEGRA194", 1, 1, MCFG_BUS_ANY, &tegra194_pcie_ops},
5564a81
+	{ "NVIDIA", "TEGRA194", 1, 2, MCFG_BUS_ANY, &tegra194_pcie_ops},
5564a81
+	{ "NVIDIA", "TEGRA194", 1, 3, MCFG_BUS_ANY, &tegra194_pcie_ops},
5564a81
+	{ "NVIDIA", "TEGRA194", 1, 4, MCFG_BUS_ANY, &tegra194_pcie_ops},
5564a81
+	{ "NVIDIA", "TEGRA194", 1, 5, MCFG_BUS_ANY, &tegra194_pcie_ops},
5564a81
+
5564a81
 #define XGENE_V1_ECAM_MCFG(rev, seg) \
5564a81
 	{"APM   ", "XGENE   ", rev, seg, MCFG_BUS_ANY, \
5564a81
 		&xgene_v1_pcie_ecam_ops }
5564a81
diff --git a/drivers/pci/controller/dwc/Kconfig b/drivers/pci/controller/dwc/Kconfig
5564a81
index 0830dfcfa43a..f5b9e75aceed 100644
5564a81
--- a/drivers/pci/controller/dwc/Kconfig
5564a81
+++ b/drivers/pci/controller/dwc/Kconfig
5564a81
@@ -255,7 +255,8 @@ config PCIE_TEGRA194
5564a81
 	select PHY_TEGRA194_P2U
5564a81
 	help
5564a81
 	  Say Y here if you want support for DesignWare core based PCIe host
5564a81
-	  controller found in NVIDIA Tegra194 SoC.
5564a81
+	  controller found in NVIDIA Tegra194 SoC. ACPI platforms with Tegra194
5564a81
+	  don't need to enable this.
5564a81
 
5564a81
 config PCIE_UNIPHIER
5564a81
 	bool "Socionext UniPhier PCIe controllers"
5564a81
diff --git a/drivers/pci/controller/dwc/Makefile b/drivers/pci/controller/dwc/Makefile
5564a81
index 8a637cfcf6e9..76a6c52b8500 100644
5564a81
--- a/drivers/pci/controller/dwc/Makefile
5564a81
+++ b/drivers/pci/controller/dwc/Makefile
5564a81
@@ -17,7 +17,6 @@ obj-$(CONFIG_PCIE_INTEL_GW) += pcie-intel-gw.o
5564a81
 obj-$(CONFIG_PCIE_KIRIN) += pcie-kirin.o
5564a81
 obj-$(CONFIG_PCIE_HISI_STB) += pcie-histb.o
5564a81
 obj-$(CONFIG_PCI_MESON) += pci-meson.o
5564a81
-obj-$(CONFIG_PCIE_TEGRA194) += pcie-tegra194.o
5564a81
 obj-$(CONFIG_PCIE_UNIPHIER) += pcie-uniphier.o
5564a81
 
5564a81
 # The following drivers are for devices that use the generic ACPI
5564a81
@@ -33,4 +32,5 @@ obj-$(CONFIG_PCIE_UNIPHIER) += pcie-uniphier.o
5564a81
 ifdef CONFIG_PCI
5564a81
 obj-$(CONFIG_ARM64) += pcie-al.o
5564a81
 obj-$(CONFIG_ARM64) += pcie-hisi.o
5564a81
+obj-$(CONFIG_ARM64) += pcie-tegra194.o
5564a81
 endif
5564a81
diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
5564a81
index cbe95f0ea0ca..660f55caa8be 100644
5564a81
--- a/drivers/pci/controller/dwc/pcie-tegra194.c
5564a81
+++ b/drivers/pci/controller/dwc/pcie-tegra194.c
5564a81
@@ -21,6 +21,8 @@
5564a81
 #include <linux/of_irq.h>
5564a81
 #include <linux/of_pci.h>
5564a81
 #include <linux/pci.h>
5564a81
+#include <linux/pci-acpi.h>
5564a81
+#include <linux/pci-ecam.h>
5564a81
 #include <linux/phy/phy.h>
5564a81
 #include <linux/pinctrl/consumer.h>
5564a81
 #include <linux/platform_device.h>
5564a81
@@ -285,6 +287,103 @@ struct tegra_pcie_dw {
5564a81
 	struct dentry *debugfs;
5564a81
 };
5564a81
 
5564a81
+#if defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS)
5564a81
+struct tegra194_pcie_acpi  {
5564a81
+	void __iomem *config_base;
5564a81
+	void __iomem *iatu_base;
5564a81
+	void __iomem *dbi_base;
5564a81
+};
5564a81
+
5564a81
+static int tegra194_acpi_init(struct pci_config_window *cfg)
5564a81
+{
5564a81
+	struct device *dev = cfg->parent;
5564a81
+	struct tegra194_pcie_acpi *pcie;
5564a81
+
5564a81
+	pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL);
5564a81
+	if (!pcie)
5564a81
+		return -ENOMEM;
5564a81
+
5564a81
+	pcie->config_base = cfg->win;
5564a81
+	pcie->iatu_base = cfg->win + SZ_256K;
5564a81
+	pcie->dbi_base = cfg->win + SZ_512K;
5564a81
+	cfg->priv = pcie;
5564a81
+
5564a81
+	return 0;
5564a81
+}
5564a81
+
5564a81
+static inline void atu_reg_write(struct tegra194_pcie_acpi *pcie, int index,
5564a81
+				 u32 val, u32 reg)
5564a81
+{
5564a81
+	u32 offset = PCIE_GET_ATU_OUTB_UNR_REG_OFFSET(index);
5564a81
+
5564a81
+	writel(val, pcie->iatu_base + offset + reg);
5564a81
+}
5564a81
+
5564a81
+static void program_outbound_atu(struct tegra194_pcie_acpi *pcie, int index,
5564a81
+				 int type, u64 cpu_addr, u64 pci_addr, u64 size)
5564a81
+{
5564a81
+	atu_reg_write(pcie, index, lower_32_bits(cpu_addr),
5564a81
+		      PCIE_ATU_LOWER_BASE);
5564a81
+	atu_reg_write(pcie, index, upper_32_bits(cpu_addr),
5564a81
+		      PCIE_ATU_UPPER_BASE);
5564a81
+	atu_reg_write(pcie, index, lower_32_bits(pci_addr),
5564a81
+		      PCIE_ATU_LOWER_TARGET);
5564a81
+	atu_reg_write(pcie, index, lower_32_bits(cpu_addr + size - 1),
5564a81
+		      PCIE_ATU_LIMIT);
5564a81
+	atu_reg_write(pcie, index, upper_32_bits(pci_addr),
5564a81
+		      PCIE_ATU_UPPER_TARGET);
5564a81
+	atu_reg_write(pcie, index, type, PCIE_ATU_CR1);
5564a81
+	atu_reg_write(pcie, index, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
5564a81
+}
5564a81
+
5564a81
+static void __iomem *tegra194_map_bus(struct pci_bus *bus,
5564a81
+				      unsigned int devfn, int where)
5564a81
+{
5564a81
+	struct pci_config_window *cfg = bus->sysdata;
5564a81
+	struct tegra194_pcie_acpi *pcie = cfg->priv;
5564a81
+	u32 busdev;
5564a81
+	int type;
5564a81
+
5564a81
+	if (bus->number < cfg->busr.start || bus->number > cfg->busr.end)
5564a81
+		return NULL;
5564a81
+
5564a81
+	if (bus->number == cfg->busr.start) {
5564a81
+		if (PCI_SLOT(devfn) == 0)
5564a81
+			return pcie->dbi_base + where;
5564a81
+		else
5564a81
+			return NULL;
5564a81
+	}
5564a81
+
5564a81
+	busdev = PCIE_ATU_BUS(bus->number) | PCIE_ATU_DEV(PCI_SLOT(devfn)) |
5564a81
+		 PCIE_ATU_FUNC(PCI_FUNC(devfn));
5564a81
+
5564a81
+	if (bus->parent->number == cfg->busr.start) {
5564a81
+		if (PCI_SLOT(devfn) == 0)
5564a81
+			type = PCIE_ATU_TYPE_CFG0;
5564a81
+		else
5564a81
+			return NULL;
5564a81
+	} else {
5564a81
+		type = PCIE_ATU_TYPE_CFG1;
5564a81
+	}
5564a81
+
5564a81
+	program_outbound_atu(pcie, PCIE_ATU_REGION_INDEX0, type,
5564a81
+			     cfg->res.start, busdev, SZ_256K);
5564a81
+	return (void __iomem *)(pcie->config_base + where);
5564a81
+}
5564a81
+
5564a81
+struct pci_ecam_ops tegra194_pcie_ops = {
5564a81
+	.bus_shift	= 20,
5564a81
+	.init		= tegra194_acpi_init,
5564a81
+	.pci_ops	= {
5564a81
+		.map_bus	= tegra194_map_bus,
5564a81
+		.read		= pci_generic_config_read,
5564a81
+		.write		= pci_generic_config_write,
5564a81
+	}
5564a81
+};
5564a81
+#endif /* defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS) */
5564a81
+
5564a81
+#ifdef CONFIG_PCIE_TEGRA194
5564a81
+
5564a81
 static inline struct tegra_pcie_dw *to_tegra_pcie(struct dw_pcie *pci)
5564a81
 {
5564a81
 	return container_of(pci, struct tegra_pcie_dw, pci);
5564a81
@@ -1728,3 +1827,6 @@ MODULE_DEVICE_TABLE(of, tegra_pcie_dw_of_match);
5564a81
 MODULE_AUTHOR("Vidya Sagar <vidyas@nvidia.com>");
5564a81
 MODULE_DESCRIPTION("NVIDIA PCIe host controller driver");
5564a81
 MODULE_LICENSE("GPL v2");
5564a81
+
5564a81
+#endif /* CONFIG_PCIE_TEGRA194 */
5564a81
+
5564a81
diff --git a/include/linux/pci-ecam.h b/include/linux/pci-ecam.h
5564a81
index a73164c85e78..6156140dcbb6 100644
5564a81
--- a/include/linux/pci-ecam.h
5564a81
+++ b/include/linux/pci-ecam.h
5564a81
@@ -57,6 +57,7 @@ extern struct pci_ecam_ops pci_thunder_ecam_ops; /* Cavium ThunderX 1.x */
5564a81
 extern struct pci_ecam_ops xgene_v1_pcie_ecam_ops; /* APM X-Gene PCIe v1 */
5564a81
 extern struct pci_ecam_ops xgene_v2_pcie_ecam_ops; /* APM X-Gene PCIe v2.x */
5564a81
 extern struct pci_ecam_ops al_pcie_ops; /* Amazon Annapurna Labs PCIe */
5564a81
+extern struct pci_ecam_ops tegra194_pcie_ops; /* Tegra194 PCIe */
5564a81
 #endif
5564a81
 
5564a81
 #ifdef CONFIG_PCI_HOST_COMMON