From patchwork Mon Jan 8 11:05:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 760889 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2042.outbound.protection.partner.outlook.cn [139.219.17.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8107314A87; Mon, 8 Jan 2024 11:06:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KJXTxR1SH9bN2hfr1cDTbI932U+AUzGtWDUzmb80+/Bp38FRbhduz6bO+Hpo1ly+WEhHT3fMI5GH/ybKCfFVaqBtCf64yyknM6nDXJsEqnsEodkPincZsIcoSz1RIfEPGoZb9pbxJnyiylgj7pyrm0/Fk0jOn84BmwA4YbngsW1zukrQT+6pv7XjhkSBkarLHbhysXrhzVUpfMw4+gglGXfpzyw4N/phJzFqZPl5LEquopwmxZ8Cps2lXGgTJXc7mAsgcCJBvtN0uflrsgEE6nRSndRQpkwd4msvUfX6hSUQtIEds+AUeCh36zuywWVyJpP53vfAx+BCf5rU3AesXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mDUYi15QkcRDF9tWQLyEsrLGA70ww2ACaNBKCRL7qf0=; b=S/DQo4FCMdJExd0h+WKjeG1y6mJH1/HUletr1xDxhXceBlLQ7OxU3VDqnUuyAkEsM3433VIkMqiEpzw2k7HOEkAxzf4UaAiFoqUc1BBmk0TfEEl6vwR4dmdcc6CGtoxRXuQXrw5wlC7BaTeYdZSkXfT++HxUB8fCVygcz2ltAcQGYCubHfx+AsopXBYaqNxS8wsyxACD1416ntKVvXZMainrSJTnuWwxaG0Q7cq0UsBVfBJhPbVHC8I85yIWKDVAvOJm6UkpA0bEdvQH+ftYHeezj7IrBPJGiQnLDoNTvl5xUJv6WQEumVUrAslNCSA9ABa5aDa72+h9tdXG+mA/ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (10.43.107.79) by SHXPR01MB0701.CHNPR01.prod.partner.outlook.cn (10.43.107.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:26 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:26 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 02/22] PCI: microchip: Move pcie-microchip-host.c to plda directory Date: Mon, 8 Jan 2024 19:05:52 +0800 Message-Id: <20240108110612.19048-3-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0701:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e2ed726-5bdc-4c0c-bab8-08dc1039db8d X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GS+Zo01bPiD24/5D/ZOHP9yx9/pHVWwavdKVc9nxwcfthq2+xxRc4Wm0Ass8RhNI5obdKd1o8Vva4a7nnSoHQOGvDfO7raXW48w/pj5fz+1hhA+dykHXLt+X0rKoZZZGAZwf4KWoOMgZsPMJQGAxrf5suJscqYVs9LgJ7hwCAVbFsAXwiaotVGSqG0IO0XauLEcnAfNPANyZq1hAfSIrwogg8StQ50btci7h3CDZxIGPlbMdqZdp+CTklV5JPznwRjpsLkRMMFsUDmopR852Kyji0JME6C3+nSS2Rm8pGwxmv4tlSJa6DGv3OqGhtOvTJ8Hz5iP04BNkclSaPiglghz5h8W5HuThZCcER2s4gNb95crNd0p4ZsxdYJ/yTxbVIxZDPX9OvXCX95hirpFFX9m+ozJngqUt8954no/44CdmpMYYar/t8HXEOIDbHLIfpBiv+AjRaI2IZBqaI5NPh/DSuhyaPWfEF1NlYJR+KuCUyqDV2a/WyCc4g72c2AJfN9ssiUS8Nk0TbVJfT39d9LkmZGzQD44IxtMguKjfHSE= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(39830400003)(346002)(366004)(396003)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(7416002)(5660300002)(4326008)(2906002)(44832011)(8676002)(8936002)(54906003)(110136005)(66946007)(66556008)(66476007)(41320700001)(508600001)(38350700005)(6666004)(52116002)(2616005)(36756003)(107886003)(26005)(1076003)(41300700001)(40180700001)(83380400001)(38100700002)(40160700002)(86362001)(45080400002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fvd0XiE30q6lmrX8GndatvpkEtlRRCdBXP4XHfTi/645E88gYXn85yTuDg8VgfqSmx5gtdieFUUa0QOE4GWhEF2H1h/9GfMG3cj9ucFsfcvhb6xjeWD81yNGpKlPgLVD6aoxoXT9SxAU1Irc8xw0WqIfUcAVCouYfPG+i2jTnKU7pNpmbJjX5AknG4N+pIehpFqqR6MyYrDJ+UM2zQhjI44CylW76/oY9Cf3VzFNkCyeOhg/QOdK3eDCqR0+SNvZUX3lz3w2rWa0v2g3Sqh1IZKoLWDl/HrpYUIfGf/LcjgMIaLHJ0gS1hhwSsN1rXgHXqxU4jvMkbN/YRIhOdBiyCXpq8bmbBqyCZHD73uSOm/CT7TVSby6NoJRvmF/Qzz/v5VK66q/JQFpPAZ0u6qebFFQwY5n5NdJC2QqpZDeSdO1PhrWZbZGaQvb0HLmLE5S4NHfzZ86oYM1tS/DxweDKSpS4B5YW0ST4BxAkMCcsAm2npE3nwgWvUucEk9vc2nyDrVWsZ7ruDJ/wN4Tq4M9iUinxr+e3RxOaiNeik3zIBbr2m5wq9CsV6I1OTgPYLfdG/FAV2lyxIYwyxpd0DNTqyhCdX0RZeeQDj3TPunahU3GeTXKxzTm44kXgsr/h4te8S1I0NwA1Aw71E+RRqnstE7tDjjgEM5UKWar1g2CWg0dUD/WOzAnq+Br5gEul/d+9TD1KCboFm2wsvLGT2mg/sOvDkgYBoVUbArL9ZHscaIg9A0LHbYX2TCgTiOJqHfQFkA/FavBWcEC6BBHAEiCB8wb+WjSSWjAl/+fwl7wKodumV0tQdvWyPO9SzA/sWD7CKspmFkPkM3MsbmWfMPJGej6/ikLYUw4zpGMMuWck++8x8oy1PP9IaNLbxW2ngpOBzxAu7ZcZtMMlUDfIq0TvE72P0hyZfWH84m6ruwpJR85c/I1Bs85YJ0Mf3WT7qXUawoU+7jQTrbnTV99D8Z8v47JX6nzEadgUeEjjD1UWbsjkC7t0XTl9ihbABEGvB0DKkGxbekYRHf/NHeceR35Bev/O27Imx4BvVZDjz8IGj0n2SzIm5vqfCxrOVhoSS+0nz/iEQ42xbKOX23HtJw8yamhgWDx9f6pY17rj3Emt7mwttJsgsy4hH/LqpHbx2qjsGokYx/xeEahXqp571teNOHgqwZVnG1k3D/v0Nk7NoOW95PPtDz9+AoKPN674qjXyC6zkNNb6s4ou4Qwznj05Az/wnl+EYe7eo5MHNrMbNHVAY6/tPBaAvqEae6jARwCtCem0Ay2KgLcuixGnKJg16O4E9SYPAEM0SGB8yapfacCBLqqhaDeHPfzny/Gh7+nxCIY4cpzt2RboLpDCVGDijkmCUa0I+gITzwqbdqmkxUmoG1DuCMCITBo3681zacFQqyIZagxja1My89UWSEvqb/Bqrk/6d5YjxAgpX2+bu8DcQtnhjmvdtlqPxtWHa0M/cY9UzvnpUJeJ2iywoxpWv0cfDjv6JKUdWqD3rstAcgFn23sziv79Yh5YrFZe5MzlT6mM/+cYD3gq7iF5yojAA7GzjnpzYH4r2kWf/EWmPULpA1L9ZAG1Z+cg50VS2gfHA4Aydqd+WTno9H9/MLG6A== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e2ed726-5bdc-4c0c-bab8-08dc1039db8d X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:26.3834 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8pbzYQIymXzdkZ+CUofXY81hYUUI1qvwQJ02K/akrqOIuDpscSiX1yFhWT58MbUQ6nUlyd7+IDAXO9gUwGerEiA58oHx/6oVQPw3Zrn5w34= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0701 For Microchip Polarfire PCIe host is PLDA XpressRich IP, move to plda directory. Prepare for refactoring the codes. Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- MAINTAINERS | 4 ++-- drivers/pci/controller/Kconfig | 9 +-------- drivers/pci/controller/Makefile | 2 +- drivers/pci/controller/plda/Kconfig | 14 ++++++++++++++ drivers/pci/controller/plda/Makefile | 2 ++ .../controller/{ => plda}/pcie-microchip-host.c | 2 +- 6 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 drivers/pci/controller/plda/Kconfig create mode 100644 drivers/pci/controller/plda/Makefile rename drivers/pci/controller/{ => plda}/pcie-microchip-host.c (99%) diff --git a/MAINTAINERS b/MAINTAINERS index a7c4cf8201e0..1a2a4d2fab74 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16789,7 +16789,7 @@ M: Daire McNamara L: linux-pci@vger.kernel.org S: Supported F: Documentation/devicetree/bindings/pci/microchip* -F: drivers/pci/controller/*microchip* +F: drivers/pci/controller/plda/*microchip* PCIE DRIVER FOR QUALCOMM MSM M: Manivannan Sadhasivam @@ -18587,7 +18587,7 @@ F: drivers/char/hw_random/mpfs-rng.c F: drivers/clk/microchip/clk-mpfs*.c F: drivers/i2c/busses/i2c-microchip-corei2c.c F: drivers/mailbox/mailbox-mpfs.c -F: drivers/pci/controller/pcie-microchip-host.c +F: drivers/pci/controller/plda/pcie-microchip-host.c F: drivers/pwm/pwm-microchip-core.c F: drivers/reset/reset-mpfs.c F: drivers/rtc/rtc-mpfs.c diff --git a/drivers/pci/controller/Kconfig b/drivers/pci/controller/Kconfig index e534c02ee34f..4d2c188f5835 100644 --- a/drivers/pci/controller/Kconfig +++ b/drivers/pci/controller/Kconfig @@ -215,14 +215,6 @@ config PCIE_MT7621 help This selects a driver for the MediaTek MT7621 PCIe Controller. -config PCIE_MICROCHIP_HOST - tristate "Microchip AXI PCIe controller" - depends on PCI_MSI && OF - select PCI_HOST_COMMON - help - Say Y here if you want kernel to support the Microchip AXI PCIe - Host Bridge driver. - config PCI_HYPERV_INTERFACE tristate "Microsoft Hyper-V PCI Interface" depends on ((X86 && X86_64) || ARM64) && HYPERV && PCI_MSI @@ -356,4 +348,5 @@ config PCIE_XILINX_CPM source "drivers/pci/controller/cadence/Kconfig" source "drivers/pci/controller/dwc/Kconfig" source "drivers/pci/controller/mobiveil/Kconfig" +source "drivers/pci/controller/plda/Kconfig" endmenu diff --git a/drivers/pci/controller/Makefile b/drivers/pci/controller/Makefile index f2b19e6174af..038ccbd9e3ba 100644 --- a/drivers/pci/controller/Makefile +++ b/drivers/pci/controller/Makefile @@ -33,7 +33,6 @@ obj-$(CONFIG_PCIE_ROCKCHIP_EP) += pcie-rockchip-ep.o obj-$(CONFIG_PCIE_ROCKCHIP_HOST) += pcie-rockchip-host.o obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o obj-$(CONFIG_PCIE_MEDIATEK_GEN3) += pcie-mediatek-gen3.o -obj-$(CONFIG_PCIE_MICROCHIP_HOST) += pcie-microchip-host.o obj-$(CONFIG_VMD) += vmd.o obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o obj-$(CONFIG_PCI_LOONGSON) += pci-loongson.o @@ -44,6 +43,7 @@ obj-$(CONFIG_PCIE_MT7621) += pcie-mt7621.o # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW obj-y += dwc/ obj-y += mobiveil/ +obj-y += plda/ # The following drivers are for devices that use the generic ACPI diff --git a/drivers/pci/controller/plda/Kconfig b/drivers/pci/controller/plda/Kconfig new file mode 100644 index 000000000000..5cb3be4fc98c --- /dev/null +++ b/drivers/pci/controller/plda/Kconfig @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0 + +menu "PLDA-based PCIe controllers" + depends on PCI + +config PCIE_MICROCHIP_HOST + tristate "Microchip AXI PCIe controller" + depends on PCI_MSI && OF + select PCI_HOST_COMMON + help + Say Y here if you want kernel to support the Microchip AXI PCIe + Host Bridge driver. + +endmenu diff --git a/drivers/pci/controller/plda/Makefile b/drivers/pci/controller/plda/Makefile new file mode 100644 index 000000000000..e1a265cbf91c --- /dev/null +++ b/drivers/pci/controller/plda/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PCIE_MICROCHIP_HOST) += pcie-microchip-host.o diff --git a/drivers/pci/controller/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c similarity index 99% rename from drivers/pci/controller/pcie-microchip-host.c rename to drivers/pci/controller/plda/pcie-microchip-host.c index 137fb8570ba2..cb09a8137e25 100644 --- a/drivers/pci/controller/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -18,7 +18,7 @@ #include #include -#include "../pci.h" +#include "../../pci.h" /* Number of MSI IRQs */ #define MC_MAX_NUM_MSI_IRQS 32 From patchwork Mon Jan 8 11:05:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 760888 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2042.outbound.protection.partner.outlook.cn [139.219.17.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DEAA20323; Mon, 8 Jan 2024 11:06:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BODUrkhU0N/ylHT5ewSAdQkJg1O9VA0c+jhv0rAv3ulmjoEAu10aiON2BjNY96RhZk6aAX7g2V6DuxhlyiSSc6+3Rgi/41TjuZx29TFOBwvasEZm3nzge+8EazyYSgBly7UHT6Zl4ckdHO2oExArh/0F06EhWm+0Es0aSekhXyqEY2AyTL8URNcalEY+WuLxyB98wMv9rnlUEup1QokhO+3D939DR0ySmqYriSoKy5b8TewOf2PxQJjJ1qw+9B0NpPTXYLCKN+1zC7LY6CEJBfnI+OloMoru9U8gNuM/CD+2SCjROnPThaAk8sF0sGy2GuSfJc34w2Edp21w22Q1mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qx5Yb/mH7vkRlelY89RpGgyd0V1vSjgcQXjlTiRgDK8=; b=WbqQBrxfT8esIYdtfth1tyjgsq/IUpqysX6T5pamjz+aLq8C3Mm7CiPBlGzNcmtS3neOctDJt4tDCbtUuHd7cLEM/VQYnVaO7DLw1R5c0dusQXRFnkvhKuRZzImnm/Bbsx3Mh0CKKtGFH76HuEYeErWp3xUmsrB8+sWUfmdklkd5HBjTfq0/eX2mMNGxiaOJ/gGNfnpTdum3svjzvWHwBkoPjvgan66mKdHkwjq3pqSoevHs44Uc+3D0JjHOLxyXMa+QcwIsUvzbQc1JePkc9R720/g6NmEYqzPll4xv8SusHnhUGfYoxGlZMdicNjpGMqfsVWezydU0yCzsyeYscA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (10.43.107.79) by SHXPR01MB0701.CHNPR01.prod.partner.outlook.cn (10.43.107.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:30 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:30 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 04/22] PCI: microchip: Add bridge_addr field to struct mc_pcie Date: Mon, 8 Jan 2024 19:05:54 +0800 Message-Id: <20240108110612.19048-5-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0701:EE_ X-MS-Office365-Filtering-Correlation-Id: d69c881f-2a77-45d9-e1d4-08dc1039dde8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LlRXAkzP6esPo1JGDsT8mo4Zym+dzUuuZEFWIjkP3a4XiGaHHXjBPnmHhQjEFko17uczJWPGNV7d9G26XnxtaAm58XX5FpdRbY+p8N04LOyXwngSCDCiipXwg1a5gGkHt8BdQ+1HSFnxqEPrvvMpFnLqaVt+dgoyLIlj7OCgu7aV684i9C2u74xBM8puOamwZ0kmh3x9fMzHy1EiVtK/YvGgjrzNoGHrVmEn0enMcAq38Y1u952CgJcDDzfU/dNlixksPUFiGxrR6tYAb10bPrGCNACWdkAmL9mtqeA34RzIVLDm1ywKHv96v8ivWjJ/0VB+KsLwhs8T4d4KU3U3d5ljYhvTisJvkCq7tU9FLVUYpyRBCEdGUwSahgnWOltoVNDFqIbaHwK576kZIsCBlihqV64O3QfilrsQN397DOifSc+9dglbrIihv1xqL8lzBQBZPe9SBNwsazF3wDn0QydgHc6+bohb8Rr6Ezeixq/f0JdZICpHwqqhTOYHqIjwWafcCpQQLxqefZfqDkWg3XktKaEvw+WCijn1HpEylcTZyc9RWx/czL2YJub2+ZdM X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(39830400003)(346002)(366004)(396003)(136003)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(7416002)(5660300002)(4326008)(2906002)(44832011)(8676002)(8936002)(54906003)(110136005)(66946007)(66556008)(66476007)(41320700001)(508600001)(38350700005)(6666004)(52116002)(2616005)(36756003)(107886003)(26005)(1076003)(41300700001)(40180700001)(83380400001)(38100700002)(40160700002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BJJopD0hd92xIXw1XeoVFqXZVytQ621YN99/G1hklruIsgCXu5eMeGCUyi9aeVUM3G6ZgG3D+qRyqkQYe9Em/rD3WZ4oiwr3g9qfRun3khuMl6dJ7sbSUgMIuBhGU4dFi7o/x+9zRTcydsVbOW2DFcOgCxJRE+5R+jZg1leIR+qeSctBy99MOtI/obIbjeQvftwNt/K7+S8W+ZbvhoQhK62fCNnHa2A/M6NSCBUopEaQVeDQr/EZbtbCr3wdirlR46mOVMuMDKxuJdcM25F2FWLcqiNgePXxkfLqRlWVzMVb2lEAVcKHP8pfGUHfCsaR4ofdE0V8/eV2lrxz1dvh7j6x1zjepvALYMhkJBlbAR6cKg/0z4fsjI5trgWUQFER+gnX5KK6/UephwjWSP+YixCkkTIWQtTsMe4rEuUyeTX/QCGC5gOljWzvrO76B/X3UMqxjRufMg6D6TT3hDusaim64YpAwj7QDP2N3wE6tJZiP4Wa6mL4F1TlicqkNQ3gqA1aXHtXDlL3kN+/tn9IlviRwyZKYqBQ5+5ef0xCol18W0d2wzy5lXNJHigZdqBoW2XulVSQW+6NBJQ43/vg/emuyIdIro+okXZYaqGXmOPRJjZiZnyP771z/vpIq1xC90OiqDpaxJUdxDkvREO0o9SdNKJAm90PuuXRhscWm2yBfXbyjHB9eFqaOoH/2hCnKmWBYMko3gD2E3aDOHxMWcd2Z2LstLiS021i20CBKtyza1mLfuJw+IC7Q7hwI+CBGTqJY+OfZHFJhlaOumgQ7VBmt761fk31jlTNNS7/FhR6L2VEgfNXzTawZLNiK56v7VKwGmExE9nEhqe4G/R6b3mQNdrQYm43AhlFhOiNcIDaVkMIkYGjQEQYixO47PCXFtK9VeD176gP2IhbafWxQJG2XJdp0QpI/wqlQvbadxfrovhxXNedEsur6LFFvoFIiHM+ord/14dHDo28OmmHUCz3PFcrJEuONanzIXCNyPCoOTItsvrlsLBTd4Jnzty0NcAfzAK0OS4Zt5klsBt5gibbERCULMcZjlkhfSj9ywD27AVZS+X2llKzYT4L6jgDYNG/WRvCMxgCvhQOp7a92ZHUHhSJ0MWgMemis4ISD/yL/fk89AM/MDwFbJnTTWAvHaX1ChiDaep6uSqiqrtV7xRHVDqSsboOXnpg0lsBUkkFjysaajZObxfsUaL6MXjjQcfLdfmWGVF5UOpVed6l0q7sE4wdFcO5PZJVQDfnsNCwhrzl0t0WLZKMRHIxTwUmzHyJnVU1wJCbiaWI6RiQw+h4crOh1YhLDRKucgIXs2ZAYJiWZqIBIKX21GeUw/7Fn790hP96RQSiOTy3nfNpffZqgNNRTaw82LKPOXxzn/J4OISUtShfHrKEsME1SgNelUe/2yEPV9SwrXjsZDMLmfj03r+3ePej6OAbEy7ZIj1/46v872GJLIAyeV15w5fE5P3ivoQdC1prfMnyDdmDgMCsLhdqwoCUScmtYmCqtR5VQs+JRbs7uIQYYmM4zxtfMfzw8LTpnZdc8MukVMuJ0JQnZlGvChfykgIDU4bjbovIeHWjFYUnUjWPMs5PD1HmJQNNzNyaPHX2NXiTjYycDQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: d69c881f-2a77-45d9-e1d4-08dc1039dde8 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:30.3311 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4owNnNre7KIBa3J+FQS69MsqZukZf09dBStXuzILp/AcW8MWsqn9lF2aWPrIzP96wnIU4+Oj4GCoZo1ZAQmg9wfkhOgdiGG+vwhVxk3mPA4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0701 For bridge address base is common PLDA field, Add this to struct mc_pcie first. INTx and MSI codes interrupts codes will get the bridge base address from port->bridge_addr. These codes will be changed to common codes. axi_base_addr is Microchip its own data. Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index d9030d550482..c55ede80a6d0 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -195,6 +195,7 @@ struct mc_pcie { struct irq_domain *event_domain; raw_spinlock_t lock; struct mc_msi msi; + void __iomem *bridge_addr; }; struct cause { @@ -339,8 +340,7 @@ static void mc_handle_msi(struct irq_desc *desc) struct irq_chip *chip = irq_desc_get_chip(desc); struct device *dev = port->dev; struct mc_msi *msi = &port->msi; - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; unsigned long status; u32 bit; int ret; @@ -365,8 +365,7 @@ static void mc_handle_msi(struct irq_desc *desc) static void mc_msi_bottom_irq_ack(struct irq_data *data) { struct mc_pcie *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; u32 bitpos = data->hwirq; writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI); @@ -488,8 +487,7 @@ static void mc_handle_intx(struct irq_desc *desc) struct mc_pcie *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); struct device *dev = port->dev; - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; unsigned long status; u32 bit; int ret; @@ -514,8 +512,7 @@ static void mc_handle_intx(struct irq_desc *desc) static void mc_ack_intx_irq(struct irq_data *data) { struct mc_pcie *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); writel_relaxed(mask, bridge_base_addr + ISTATUS_LOCAL); @@ -524,8 +521,7 @@ static void mc_ack_intx_irq(struct irq_data *data) static void mc_mask_intx_irq(struct irq_data *data) { struct mc_pcie *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; unsigned long flags; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); u32 val; @@ -540,8 +536,7 @@ static void mc_mask_intx_irq(struct irq_data *data) static void mc_unmask_intx_irq(struct irq_data *data) { struct mc_pcie *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; unsigned long flags; u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); u32 val; @@ -896,8 +891,7 @@ static void mc_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, static int mc_pcie_setup_windows(struct platform_device *pdev, struct mc_pcie *port) { - void __iomem *bridge_base_addr = - port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + void __iomem *bridge_base_addr = port->bridge_addr; struct pci_host_bridge *bridge = platform_get_drvdata(pdev); struct resource_entry *entry; u64 pci_addr; @@ -1081,6 +1075,7 @@ static int mc_host_probe(struct platform_device *pdev) mc_disable_interrupts(port); bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; + port->bridge_addr = bridge_base_addr; /* Allow enabling MSI by disabling MSI-X */ val = readl(bridge_base_addr + PCIE_PCI_IRQ_DW0); From patchwork Mon Jan 8 11:05:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 760881 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2048.outbound.protection.partner.outlook.cn [139.219.17.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F186C224E9; Mon, 8 Jan 2024 11:39:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fnll+4r0l1nTz0/+ZOCrXR9lHwxEXMt+zIkUynhmrcLQkzEvuY2upGaGwYH1e7IMSBcBfmBV9rST05Rfe/GnUL8B+Bxb5YXLZ1LPJdzFDuGUOCxax+xSoMxdLDWABbiO+PlS4Qzjpf+idf+tBefCh9Tm/vbelChcLzCH6QJpAXgpFgoHyAj9UuZQsoa8+dPd05SmDdW+KhvFUy4cv071kkmMRxcIXoSz9zXzArSmSDLfvP2lPtEucafYs12M5B1ldARjum+5lqurCrZjjFEqWjLC/KdVVPTWdunCRsQ105VKvQlBLB1YVJvJph/YhTRWjaMKN34bcsyJUHLQ/YwgxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Pc2T6SbVvFNGAc7jANlqkHZ/EYw1YXpAsFWAuojjcfk=; b=nEBWNET509afv5ZYoZzR+tMBQPNby11dT4b+qDRZKul9Headx+bGwNbuG3DwzQq73SPTDmmFcXGovZbT5P9Y03iK23bNfGpOI/v9zh+NWFZ4K3cESBvBWPX3oxZTaVThyPkSf9yb3iDdV5eRdrN3IhCtn9kiAXy6tqt7/ImTXPMu87D7kqJSKayEyTLxrJHN5zQfZzRtB7wYgSr8l/lMzgoGRqTd63JSvl6sGu38T+qTpKZrtRcEgCvP+qJGt8il+65ukQVG97f/TO9wNEeuYcejaNzccg8/2u7Y+8qLZZMHNHZXEbQ3QzsMqSjy2DV7Z6bpJRbt0fmw/0RIvNqu7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:36 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:36 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 07/22] PCI: microchip: Rename two setup functions Date: Mon, 8 Jan 2024 19:05:57 +0800 Message-Id: <20240108110612.19048-8-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: d990fe60-f60a-4683-a69f-08dc1039e16b X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3Tsa9W6i36SJnTtdqbz0/lMWP5ZMfpA0HL++t0pzkQUdAs8DbDTdRiJtqOMxPApzapHkSeQ1xCHrJHkG430u6b3Y95L5Tbx0o2JAThtrfsRKCRgPNMRBT6KcYVIo1IfZl4AvA1S0b1r6VtbTvVUprHB467Kg/yqad80tBFI/CiyhY82b0SWCVo4j+nPF7ueBio4GKUhejcj+wLeC1RGk7nfmgF4pJM/nX3JTAIjKoQVvXznF3Ll8/qyPHchF35rrSamnlT8WwusXz9ijJg5Vj+BXiCUzJYnZoWsjyLz0B6sj8+j26SHIZQpw4OqTBP0SKTLIARJQymMJQfrdzGr1XeoAur7noQSu9wRcyY96b34WZQxc5+bXJJrJyUeR9bhcuRxnkVbA/1mECEAzPAJ+7slW/loZFfofHRe+oC3qlUVGGPunb1xgYODYbbzKcbARF+snqHsnVnkMmXeFHoCfm4n0hgKxIFOsTX6NSyXvSbthJp2zBppYk2cL+RF8A51orLEamo7Z7/muAk3H3ArQv7uv/M3OGSbtexJ9XuRPV4MsL9cmEoJUVSNrLrdfm1Fk X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9J8nJdbFmKRHmMiEOlE9U/xzcszmKAWOVwA6kmfFJDkRjCmH172SmOGBqPuzd5GFiBbRqPqRcc5IE1Wz3T3oCk7Z84O5A1ItYNO/AkUAAdaOmKFsMhU14rwTauQwV9Gb+5JiT+X1V7DFyYUbM3CQQA77j/nfvbbukaM4wvh0Gwo/YM5WrD3Gte4VsTx/2sxwEK7A/ZF35K4TPFYirgFiaNll0YX9aoXpdAjeZI7T7RXQSinTUcKkWhMhiI9qsN69AFDjdvdaKNnKi64GxkkjcXj7iQIVdsSAcwUm5/V0pJMLP7vog9OuiGj35HIHY67MtMljadNsmbZL20pusjn67AokIUV9EAHXTBLII9lo8snJGXSDiBrD46GBjCaVKa47TSIG2WRIUxRuyrQBqOR+EQr3v6/YKrb/usHMlbkyS5cnMtxOE4W2JqlIMYBhLBs5gALwjTcRW8egQHBGJgvLNyTVzqOO0dHauUGWcM5N/mw1kYHJ53cryAAKZWDmWrT9UdaP1WO8iToPV54jHyAXswrbBIJAy44vrVhMTlj6CcZVcLPULwfpa2Oqk0pFBJ9uEPF1H9YxSqxB1X5hIC1Ikim8l2iHwnqzKM5MQ4sO0m2a+8yBhy3gGCWkT9fYKAIjxeyLzhC0RrzIXtTBOCS48rz+Ii6bWUnA5VPYCIPkUjyqNKjUtWPe5vn46vSbwxgBzpV1JT+3Tth3x2BhtgmKDH3EPlRcsMY/zBkGrpxRQSIuk7tQam9yDrlxyWpIu64IDZPJXk65zq9MQXmEHZudYDd0BB+3Oq/nuW6GXhXPgg6osT3uuvl3p1veQmqftFAoKI1d92KXuOpCbdP8r9+v0Tzl3+yB/cY7p/DmlvqAFRmVrjl5U6d7swrskGlXbeGW7HkYkSNWF/cv+OG5lGMq4c5IqPCJAPdZ9Yyv241TdIjgaMTYk4wODeT606yd/u8b+Auf8kY++3wtmvn+Nnwdr4CDfVaaWu7oU7ri5hzoBCtKUa5aLjtzCImjbgly3J+FB7R16iHcW86Y7ERThC7/7pP5OAgF+OTQy6NO9+Q4aL1zK0JPZgn7K+FBCM0gHhKsKA9jiuMxrWrSxgFoZJoPAsGsBeubPqtjtQ5/0QJ6r8Lg93/k+g6Ao4etm8QjcA//yMwf2wOVIQXJlBf3OH6NVujCo1U39lTtOySVi7WULxf6xi0DE/tjWYYrADGxcGK318FMZQk+FPmuOm8TeG+1c9jpXBqtlwpsrgOmUU9tlXg64ty9Qy7fI40JTdT4bJGEpUzhlH02jaeYiuYe3h1Gf8NzsOcIRqHoyw+QPEIhgznGL9ob82VkUK3eyg4XB1oUKIOWHIYwEDFXIJynnEVTAXHQ/XBWS5FvU++rer0rR2/mVISqdEw/TWfwIikfM0Lq/PNVU1Hv1YdAiWTHUPrmaAvYHXXipGGS2p2/0nViWWoB23bs4H2HrwcZCZ3Hzy5L2Z6/RSh2zX67Hxy2vONnL31XefXhWq3EJBCHgbPIz4naggNJk/Ir8AJKe+3jvMoz6Zwtk1f1BrlkG/SVhzA6aw+nMDRs3yOar0SYzoJqLZm4rt/1TXCcGroMoWpW3XP075Fr8eDp3fWYOupZiLXj9A== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: d990fe60-f60a-4683-a69f-08dc1039e16b X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:36.2244 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UPo3ikEas0OCFUubGrjmdRLi1bT1F/tREpoAqxff8zYAZv0B3LQiBA6Qcy0ttYQGxfWjl9sXybJ4v9xAzAZ9BGBOJPk0CBeKTXzYHQ9zPkc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 Rename two setup functions to plda prefix. Prepare to re-use these two setup function. For two setup functions names are similar, rename mc_pcie_setup_windows() to plda_pcie_setup_iomems(). Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index a554a56cc0e8..9b367927cd32 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -838,9 +838,9 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) return mc_allocate_msi_domains(port); } -static void mc_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, - phys_addr_t axi_addr, phys_addr_t pci_addr, - size_t size) +static void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, + phys_addr_t axi_addr, phys_addr_t pci_addr, + size_t size) { u32 atr_sz = ilog2(size) - 1; u32 val; @@ -876,8 +876,8 @@ static void mc_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, writel(0, bridge_base_addr + ATR0_PCIE_WIN0_SRC_ADDR); } -static int mc_pcie_setup_windows(struct platform_device *pdev, - struct plda_pcie_rp *port) +static int plda_pcie_setup_iomems(struct platform_device *pdev, + struct plda_pcie_rp *port) { void __iomem *bridge_base_addr = port->bridge_addr; struct pci_host_bridge *bridge = platform_get_drvdata(pdev); @@ -888,9 +888,9 @@ static int mc_pcie_setup_windows(struct platform_device *pdev, resource_list_for_each_entry(entry, &bridge->windows) { if (resource_type(entry->res) == IORESOURCE_MEM) { pci_addr = entry->res->start - entry->offset; - mc_pcie_setup_window(bridge_base_addr, index, - entry->res->start, pci_addr, - resource_size(entry->res)); + plda_pcie_setup_window(bridge_base_addr, index, + entry->res->start, pci_addr, + resource_size(entry->res)); index++; } } @@ -1023,15 +1023,15 @@ static int mc_platform_init(struct pci_config_window *cfg) int ret; /* Configure address translation table 0 for PCIe config space */ - mc_pcie_setup_window(bridge_base_addr, 0, cfg->res.start, - cfg->res.start, - resource_size(&cfg->res)); + plda_pcie_setup_window(bridge_base_addr, 0, cfg->res.start, + cfg->res.start, + resource_size(&cfg->res)); /* Need some fixups in config space */ mc_pcie_enable_msi(port, cfg->win); /* Configure non-config space outbound ranges */ - ret = mc_pcie_setup_windows(pdev, &port->plda); + ret = plda_pcie_setup_iomems(pdev, &port->plda); if (ret) return ret; From patchwork Mon Jan 8 11:05:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 760878 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2089.outbound.protection.partner.outlook.cn [139.219.146.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43AB544C8D; Mon, 8 Jan 2024 13:40:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b7S/yH5ofnUibDxx4aetjwq5fpHYBXvQe1l07zae+lEVRlFIyiqI1uEJYW0oZx7MxI/o8itOW4gkeuIs/6P36gwlHKnoTE6nGPC0Fx/KGwXKX3XX/bdI78hvEuROSTK92ogsSiHO5YZlcQdsEfPWZlBC6z8HXL9daAyQ32C6VQEIuAXF4A49E/CSqK/iA9gs9qd9rL6McuHAfYdbVsdbxVXfDTUAsUm/+19Yy3nt2BKtlJ/U9HaEMQlUPG5BraXvjdOHu2fTOWgJRPXhK4u9ykA3AuvVVE/F2ebZUgZOsIyId/AwBQmwve1K/bBGLPU5JY35+jex2K1r9re44HhXxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H1L2zCinMaKZ61leC9g0xpthGdFxAFSQ7l+a9Zn1/VQ=; b=bbqixbJzxBdoyVWW9AJa6mcPHO8DLYo0Yf/2yy/Yh76JuUigcFx8gh5e0k1mVTcKFjMjI2UXwWmaGOHrXLKkHY/EScxaG3jqAzN0IDawLp96DKvagjmCVSdTosUqeGreUbGJjZvyQ4XCGkiTXwqbNVpiv4U5+m8W5+lCX2ZpJ+5hKu0FqpN7ihVb+9TrYl1bUMwyXGNUTlYKEuYx775I+NUJSk7IGqcyEvJcyU+g5x18DGoabRxSPTyU2QJfxEW0lB/CWnJdrs3wBDSOxCtXa+8Rdfuyajjps86z8qm5VfFCS5aGXzELQppd6V8f2sLJDH3FZr5zPdsGTVy2TGVTvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:38 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:38 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 08/22] PCI: microchip: Change the argument of plda_pcie_setup_iomems() Date: Mon, 8 Jan 2024 19:05:58 +0800 Message-Id: <20240108110612.19048-9-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 85a1babd-467a-44a9-a6b7-08dc1039e295 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lqApmGxLXWnlSVfl4w2R8KyOgqza8qlFmj1qrjukCYWfxbanHlUY8mYASdc2Lmbjrg3QMuk8by+eQiPHL/iyaL8hpkmetAs+eXXehocwO7TFUTO9WARdwsjiY2YY48Ph2jp/Ioyte3PGje0wVhwx3GdGZ7hRWucyo1e/kdtLn/0l9W76eyLhxr7JHtQ/Ll7UtghMzr6ylaTaifEWBdWKMxOb5LFZDese76OFrpRMy/BH+Kj6qmj1JahBzXzER+64ORabBe7G77aq/+7Sa2CUApvgVyePrmcI5EGORT/Qzjqk7QujJ97ggbbfe37s4lfoSAVY9aNkA1MzNqyPWB8P+ZmgYpxytZwDcQ2gUg4HcHGxrppH3nGiX86GSG7wRH+ukbbCvOo7AxoiuRDMn6jD0CIqqB0n2ys9MZSr/Nag/fKvZ87A3QCn3Xw/aDfsYvZ6TxWAaP+D50QbunVBrWaxk7iRvzcVolxALG8NaDsdZVja4PnhlfyHOMSdda3NW1uZS0gdbzwvzGf8gfW2re3CsCUX7YITsPAs/sEZMArrbXRT3pU29o6Y+OK4WaeTI9J/ X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Lun/eo3MEVjzpcU+1qQJPXUk/LHhiIFlfgnvun1a8eeARf0B4Gn8OvQlDYc103szhJ1VVTK1z08WiVUls8nixYcXBEA4X5eFjngvQ3o1xdtc87KjB7sz0rSVZzUYHblKVn3cB4/wdois/k5IamrOfh09OyLLS1jNhMSj9UP/fL5p/UkQdlPQiVoHoqM/wwGWbGY1fuu13s7+n4+BMiPNr5a8pXhJK9dxuCoduKU3LdwYpnlF7Ej8vQoPWeY+PLEv56e5rckoE2q+ppsoyrQWUGlUazt9tBY3gZgz1Py5Vj2w0j1Q6wgObKrGbIodc9fDvwIaSOYYw7Pfvv1hpNiaAIucfNTuCFh5yaEjwTzhhhka+/NflRNxeQ8yyCAYf2ktCk0f0We7j5iMsfOaRXX3QJrCV6uyx5H9HpjrJyojUNrt95H9ya5hyFbPJljLF0F8IdegcIGu/QfcT3I2cLn31Pmb6GsLUfgly0+ogiMK/zHBs6Qw5TYbLbHC9chJjcGHUBm3pxN4XYAFNvl6Qy2AOt3WGYFwoUsARjo8UfBjm1UhDYm42fvFcU9pot9FxG7aw7xePE7qEzG05ZqWeKmmJPJtjfmudXPzwcF/Z63Q6ZSyNfnn3uezyJHhMyk8n3k6FPBtBaPhcl7ivcjvBwW2fRTcqWeU9+9iRBV4hPn/S6wHOO6IDoCDzB1W6gYyNvb/vZPXdpkK1vLE56JYoZJD4tqNe7/hMDeA6B0oDt83XWMg39Bv0V+j+TGBgP/ludk7++Ok01wm1Q+XjDD+aVkMrTNp9adB7C2qEPKW6zr+SN6G+iTl4wzTweDrloZKqZ31jWAQwZdGRDgvR50D1Ud3Z9ZygJ1FANv2mzKPzor8qCaZhRr4TxDd0kji0Vz+Qdaotumidd1hVtAFMc4uxUCKY9ttX+lWkaJDWoB3xqm/ca1zYk6ftU2O4mbApIrIyrfP0skUdmcqdIrI3CcIikAQQkGqLTq5CD30cmpn5+hZ/SIExk2Du+yeptby2XRrRwgIrORjpOtXGk5m2H/uzjQmO+/i2ttdlpVI3FJhSktNC1zbQRr3esztyH94kLCbyL8C56Fr4oZaJBDMcXw5r2px0kZ3oVqWpFNb1n+9TSNhKy5cT5zGc7NA1j2ezqlCDpRDbCnpeRczX34H5g5g8eA0OTD5yXToQ+5we0D/y5qRI09D0Yt2Qa/SFm8D7SNNsmhJidOtcwL2/PjiAjOf/5CBXEXI4diswKfYLSTni90vFk0jZQeNx1Z1HotHlA8bxao/CoscZe2q3lJz8SwahAdI11hVC5pBNGncWm2NYGeohQsF7kMFc6jqqequnlUgHf4IlLFrGcv/ZFJpz60/p9/EbtLFlpwWFI+vm5AcyWZIt5GMsf/YJEe8UBu11EzWUBqH8Cfs2mFExnqd2uZbe/CKjE4YaFxcTTZRb/+IMLSa1VpRY9cr1uuJxI5oastAWMvhtTJZ9V6+JmAtmhYjKZY/3ZpXPrBWUpJlTMjc10W2dSefzQt6/H4MSVL0heRgPxn0VcEOEynpMTx5T+RLGfrOWUvJiO6tpabZxg1d4QDON/byr9dzfBq4SvJMuo4xjruclyZs+meQodaZO+pKJRDGAQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85a1babd-467a-44a9-a6b7-08dc1039e295 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:38.1278 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r4RgA0aNN2ayus94RNdHAZ7pmffkjX5wZfEcrvaoPLa4NqKorSt/KX/++vLwKxBoSYbSoJGCI+AbgB9co1WvqhhWKRsL0vre/r6s2ma/fzk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 If other vendor do not select PCI_HOST_COMMON, the driver data is not struct pci_host_bridge. Move calling platform_get_drvdata() to mc_platform_init(). Signed-off-by: Minda Chen Reviewed-by: Conor Dooley --- drivers/pci/controller/plda/pcie-microchip-host.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 9b367927cd32..805870aed61d 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -876,11 +876,10 @@ static void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, writel(0, bridge_base_addr + ATR0_PCIE_WIN0_SRC_ADDR); } -static int plda_pcie_setup_iomems(struct platform_device *pdev, +static int plda_pcie_setup_iomems(struct pci_host_bridge *bridge, struct plda_pcie_rp *port) { void __iomem *bridge_base_addr = port->bridge_addr; - struct pci_host_bridge *bridge = platform_get_drvdata(pdev); struct resource_entry *entry; u64 pci_addr; u32 index = 1; @@ -1018,6 +1017,7 @@ static int mc_platform_init(struct pci_config_window *cfg) { struct device *dev = cfg->parent; struct platform_device *pdev = to_platform_device(dev); + struct pci_host_bridge *bridge = platform_get_drvdata(pdev); void __iomem *bridge_base_addr = port->axi_base_addr + MC_PCIE_BRIDGE_ADDR; int ret; @@ -1031,7 +1031,7 @@ static int mc_platform_init(struct pci_config_window *cfg) mc_pcie_enable_msi(port, cfg->win); /* Configure non-config space outbound ranges */ - ret = plda_pcie_setup_iomems(pdev, &port->plda); + ret = plda_pcie_setup_iomems(bridge, &port->plda); if (ret) return ret; From patchwork Mon Jan 8 11:06:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 760887 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2040.outbound.protection.partner.outlook.cn [139.219.146.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7598B14266; Mon, 8 Jan 2024 11:07:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eypf3qPsGGFKm6B1Ru1MzSqnv/buIzNEq9hILanx8IwVBwQvGlCGWU81qsOk1HrATjPsM6wP6LThlzkz9nIQlXEyn9AXg7w13BS/zw+FoV5wFSjhHfrLmWmSBD8/10YxkyWNYbbi/iP6kPLGsA85+20ebZIrRLhHCaGBwDIKIZ/v0OS8thZR5qxrC0NOBQP0M1k34/mGUihO3v86DypLXmmNQya4So3nNVCgxaNHVXlmCVJrorf+MVpRKyVxjbK2c78S01cMqYhx0pYKlMeLHSO6OKoIN8vZPa7h+Sq7A6Uu67Xf/teY8pLeU8IcZkL1ev4HQMMONl9qxjVr70v7Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=SvgzgZ+kCWJDW3yTlipB4uET3HJVJTZKxQ2LjTr36CU=; b=SCv5BMYTAsZKEPVEGGSXrTvauB4PbQ/dQTi69Hcuv/9KwvWdCAkMoASL0ZXr2w1AKpJga6aUzcB6eQykT/b6aibYykxco0UsqMzLVblClhAHY1BpVwvzN0dpTnQCpMFTbdB/0FVaFMWIFuIDi91T21PtA/b3/FulXSDTA+hYGQWlKFmWq20Y9awDjM5KrwfadLFIi5jQ1epTCfgO+b43jG/prQTpDHu9lyofr/ArZYcQGdqF+t0a6ogCOcCkniTssaF5GnrCPL3bHDxWeJ7svQEfZvoOXVC3CYO492aNVnVtMbPnHW+ejqgtkzPrpwLyRuCJlqpZUsbr+HGniuFLKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:42 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:42 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 10/22] PCI: microchip: Rename interrupt related functions Date: Mon, 8 Jan 2024 19:06:00 +0800 Message-Id: <20240108110612.19048-11-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 441e78fd-4514-4e35-e258-08dc1039e4e4 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wxLDWAIy91dvjeXDLx+/cCftpWcJfEvA6ejWwtjcca6LhQS4TcXTcS2RyOIJUJ4jr8HLHoF5wbX2cMSy5rB421AhDcTTJDGKdef6cRxRj2m8XYMwTL9/Ji5mb9vU2toBF1J14GYBcLkR9ItxPczIsWDDDNOvipl/kbAyl4zhC90Tt6DC6AuAZKwbHdhqiE8Ci90yyr6FjdIUhVCCUZOCRHbgdf6bkPR+xvyhRq/awjyhrUpUChHFgYYkzVmxGcxv74yeJJARraSuGDHuXT5W24VHLmjd56mqREvtKKu3NmF5PuplBrSzK9NTL2IO3z2bWR/mrpsl21PZ8Q8XksAS4CK2zGQHLM2nJ1rObF/8QdgBN3Hofcefoiz/pjhYsFYZNvXXopAcPzhhJxAvp8BCS4b7gh3kUZ179N+biPbbtMf0sNZDfoLloQw2BbPbm+kc8vWBFIX/MQsqQzTvkWUw2izFzIGif7IElZJS6AZMvRN0PS5DNOJpGpHxavYppGUI21PsdyRE7+fe6suJSlVFB6+okl1xrYxt/RxnkIEdYAbjUPOYWKXVUcMGfuMa7YC1 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(30864003)(40180700001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: daMhXwQJZXUwh+QDvbK80okkUEjyPK50764vop5ZXLaheiH6MsV277uxMCgWmNUfrTa++/7tTRwjz76HT1p6MeKAc9DbQJYiWyBIg0xStx1XC/krJr7iBvU/MSg7bSUVM1Dac4cGa5e+YKLvklhi1tmzALh3LDGdLLxfgc77MGFjGqX2ARAu2T7hbWj37hF7B9EkEYC1wnIF1YWtDaBl7GG7e4o1J72IXuzs1u5vi2pXksh54WmYjvZp5sW4nKH0vyfBtpKrAYxwrYTEuyAikjj6jcfXzgGARVBH7r7m2uZxPZ9E8VooqOU9ULMKigdm/A2lNQpxzOJ2dObdwlJdFW4/32/GDIfsb9M1GthBsTy5f5Pp8Z00zGvEewWD9zdbgkT2WQVh1mgupttBYs7ieSRJzd93PDQpClpuy/3Knp5kTyLw/ZQCIdfXzUCRHHMss/3Qg3juZTxNwsN2tFv876+eisIm0NGzr/ESowKTGkiNXrtreYLL7z1cA5/3KBM+FoSxOF4YEhzEmwHj3QguS7e+kTA2gg5H38tcJXX19RCt1OVusXPKtL/0Lf9/YPZA/E1tg/808VGpwzu/0Tem+2QQ+REs8j3qKE5VVNw8v4cgMFOMgcSJrsQhN0bz8SvCyN8h8ji0BwV5lC0+EUcoMzb0NVdVKzWs18expO3P9vDHChFrwlEUP7dYJQBNGvpXsyJvYMjYWesiWewsys94KO9d9AXtwWCV9FzcvEwqZ6W45Mqo+gYJbJErkx5vM0cHGhVMEC+szBmtetBhqsDMow3KkLX7WJVeCb/9ay8x0lXUDcaV5SjAe5KgVcbImfPA75TQhbsYZ3P0UlCDDmrISh1e7bMQI6UiR7afn2900EL5bzBPLH8j0pZrEBVgWaUJjChM7VpiTNWQhQRSn27Zpb+/+9+X2InzD6JL3nINyUdKUGrBsYDkSuuyp/5V3rb9tAjqljV+MkohOCA0dPKTOWB4bV+tXostzGqJ7CWZNoZ3sOLF7PVCEaoPUEb6QmXWamJ9m56zm0UjZA6nP6U5uVClYPSZ1PQbW3eQCPQPpePkhjDG0kIrD5qUEFF4XASS34EUFkq0Xcn2Fo7dJhTpJAnqbTT4oj7ZFuAmbgolE0kdou2F0g3Ossn29MgNYuIxp+b4Yi9wCVFHXZlYEQCrXqcZx+NyXsaJvgXbgGJ9aftIzZMNea7mIGEBH/n4iCWLC6f8Ft+6HkElfm8APw8HLLAuBCO/1OOzPmLo/PugnFqowWNr4paWeZHPcRBvYjt8vbHmmJm1WPdmn0GDmxedxHWT3jjEPSfIhHd5ptHSgYkYBuEINc9ROV5sl09nqkFAU7hg7U/s4Vpo8g1xF7pAeeHZL6ZEVQHe7Jhbw61s/TWEuDGpYR7qLbsrpu430l1/RwB57ua8ra5+NJersv/1excoRHrniw1hChqvPEKZMMBVekzGTXCgP60IoiEEdhMqL59Jjp1UW/iDWNCTDjmM3WU2GTAz8te1cHGeUwSRDFwQcHZ3BhZYE/GbZA+kfuQtc+s5dc16InHgzcPXjjgzLR6JI8B5Z2c+eGnhHIRjlOk7+123BtrvQq73skjK+UTxIUaK5aLoCkbm/0SRptMMlg== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 441e78fd-4514-4e35-e258-08dc1039e4e4 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:42.0764 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iF2lk3YNWagGba0I7iwJoZiIUxU6WE16Ty3lqK6W4CImE12QsYMCyZ4wm3QCkz2METwZTTZU93DKlRiWuC6UmUITblrDYvBIy+OeCjOEFkY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 Rename mc_* to plda_* for IRQ functions and related IRQ domain ops data instances. MSI, INTx interrupt code and IRQ init code are all can be re-used. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 109 +++++++++--------- 1 file changed, 57 insertions(+), 52 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 573ad31c578a..18bc352db389 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -318,7 +318,7 @@ static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *ecam) ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_ADDRESS_HI); } -static void mc_handle_msi(struct irq_desc *desc) +static void plda_handle_msi(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); @@ -346,7 +346,7 @@ static void mc_handle_msi(struct irq_desc *desc) chained_irq_exit(chip, desc); } -static void mc_msi_bottom_irq_ack(struct irq_data *data) +static void plda_msi_bottom_irq_ack(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; @@ -355,7 +355,7 @@ static void mc_msi_bottom_irq_ack(struct irq_data *data) writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI); } -static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) +static void plda_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); phys_addr_t addr = port->msi.vector_phy; @@ -368,21 +368,23 @@ static void mc_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) (int)data->hwirq, msg->address_hi, msg->address_lo); } -static int mc_msi_set_affinity(struct irq_data *irq_data, - const struct cpumask *mask, bool force) +static int plda_msi_set_affinity(struct irq_data *irq_data, + const struct cpumask *mask, bool force) { return -EINVAL; } -static struct irq_chip mc_msi_bottom_irq_chip = { - .name = "Microchip MSI", - .irq_ack = mc_msi_bottom_irq_ack, - .irq_compose_msi_msg = mc_compose_msi_msg, - .irq_set_affinity = mc_msi_set_affinity, +static struct irq_chip plda_msi_bottom_irq_chip = { + .name = "PLDA MSI", + .irq_ack = plda_msi_bottom_irq_ack, + .irq_compose_msi_msg = plda_compose_msi_msg, + .irq_set_affinity = plda_msi_set_affinity, }; -static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, - unsigned int nr_irqs, void *args) +static int plda_irq_msi_domain_alloc(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs, + void *args) { struct plda_pcie_rp *port = domain->host_data; struct plda_msi *msi = &port->msi; @@ -397,7 +399,7 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, set_bit(bit, msi->used); - irq_domain_set_info(domain, virq, bit, &mc_msi_bottom_irq_chip, + irq_domain_set_info(domain, virq, bit, &plda_msi_bottom_irq_chip, domain->host_data, handle_edge_irq, NULL, NULL); mutex_unlock(&msi->lock); @@ -405,8 +407,9 @@ static int mc_irq_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, return 0; } -static void mc_irq_msi_domain_free(struct irq_domain *domain, unsigned int virq, - unsigned int nr_irqs) +static void plda_irq_msi_domain_free(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs) { struct irq_data *d = irq_domain_get_irq_data(domain, virq); struct plda_pcie_rp *port = irq_data_get_irq_chip_data(d); @@ -423,24 +426,24 @@ static void mc_irq_msi_domain_free(struct irq_domain *domain, unsigned int virq, } static const struct irq_domain_ops msi_domain_ops = { - .alloc = mc_irq_msi_domain_alloc, - .free = mc_irq_msi_domain_free, + .alloc = plda_irq_msi_domain_alloc, + .free = plda_irq_msi_domain_free, }; -static struct irq_chip mc_msi_irq_chip = { - .name = "Microchip PCIe MSI", +static struct irq_chip plda_msi_irq_chip = { + .name = "PLDA PCIe MSI", .irq_ack = irq_chip_ack_parent, .irq_mask = pci_msi_mask_irq, .irq_unmask = pci_msi_unmask_irq, }; -static struct msi_domain_info mc_msi_domain_info = { +static struct msi_domain_info plda_msi_domain_info = { .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | MSI_FLAG_PCI_MSIX), - .chip = &mc_msi_irq_chip, + .chip = &plda_msi_irq_chip, }; -static int mc_allocate_msi_domains(struct plda_pcie_rp *port) +static int plda_allocate_msi_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); @@ -455,7 +458,8 @@ static int mc_allocate_msi_domains(struct plda_pcie_rp *port) return -ENOMEM; } - msi->msi_domain = pci_msi_create_irq_domain(fwnode, &mc_msi_domain_info, + msi->msi_domain = pci_msi_create_irq_domain(fwnode, + &plda_msi_domain_info, msi->dev_domain); if (!msi->msi_domain) { dev_err(dev, "failed to create MSI domain\n"); @@ -466,7 +470,7 @@ static int mc_allocate_msi_domains(struct plda_pcie_rp *port) return 0; } -static void mc_handle_intx(struct irq_desc *desc) +static void plda_handle_intx(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); struct irq_chip *chip = irq_desc_get_chip(desc); @@ -493,7 +497,7 @@ static void mc_handle_intx(struct irq_desc *desc) chained_irq_exit(chip, desc); } -static void mc_ack_intx_irq(struct irq_data *data) +static void plda_ack_intx_irq(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; @@ -502,7 +506,7 @@ static void mc_ack_intx_irq(struct irq_data *data) writel_relaxed(mask, bridge_base_addr + ISTATUS_LOCAL); } -static void mc_mask_intx_irq(struct irq_data *data) +static void plda_mask_intx_irq(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; @@ -517,7 +521,7 @@ static void mc_mask_intx_irq(struct irq_data *data) raw_spin_unlock_irqrestore(&port->lock, flags); } -static void mc_unmask_intx_irq(struct irq_data *data) +static void plda_unmask_intx_irq(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); void __iomem *bridge_base_addr = port->bridge_addr; @@ -532,24 +536,24 @@ static void mc_unmask_intx_irq(struct irq_data *data) raw_spin_unlock_irqrestore(&port->lock, flags); } -static struct irq_chip mc_intx_irq_chip = { - .name = "Microchip PCIe INTx", - .irq_ack = mc_ack_intx_irq, - .irq_mask = mc_mask_intx_irq, - .irq_unmask = mc_unmask_intx_irq, +static struct irq_chip plda_intx_irq_chip = { + .name = "PLDA PCIe INTx", + .irq_ack = plda_ack_intx_irq, + .irq_mask = plda_mask_intx_irq, + .irq_unmask = plda_unmask_intx_irq, }; -static int mc_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) +static int plda_pcie_intx_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) { - irq_set_chip_and_handler(irq, &mc_intx_irq_chip, handle_level_irq); + irq_set_chip_and_handler(irq, &plda_intx_irq_chip, handle_level_irq); irq_set_chip_data(irq, domain->host_data); return 0; } static const struct irq_domain_ops intx_domain_ops = { - .map = mc_pcie_intx_map, + .map = plda_pcie_intx_map, }; static inline u32 reg_to_event(u32 reg, struct event_map field) @@ -609,7 +613,7 @@ static u32 local_events(struct mc_pcie *port) return val; } -static u32 get_events(struct plda_pcie_rp *port) +static u32 mc_get_events(struct plda_pcie_rp *port) { struct mc_pcie *mc_port = container_of(port, struct mc_pcie, plda); u32 events = 0; @@ -638,7 +642,7 @@ static irqreturn_t mc_event_handler(int irq, void *dev_id) return IRQ_HANDLED; } -static void mc_handle_event(struct irq_desc *desc) +static void plda_handle_event(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); unsigned long events; @@ -647,7 +651,7 @@ static void mc_handle_event(struct irq_desc *desc) chained_irq_enter(chip, desc); - events = get_events(port); + events = mc_get_events(port); for_each_set_bit(bit, &events, NUM_EVENTS) generic_handle_domain_irq(port->event_domain, bit); @@ -741,8 +745,8 @@ static struct irq_chip mc_event_irq_chip = { .irq_unmask = mc_unmask_event_irq, }; -static int mc_pcie_event_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) +static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) { irq_set_chip_and_handler(irq, &mc_event_irq_chip, handle_level_irq); irq_set_chip_data(irq, domain->host_data); @@ -750,8 +754,8 @@ static int mc_pcie_event_map(struct irq_domain *domain, unsigned int irq, return 0; } -static const struct irq_domain_ops event_domain_ops = { - .map = mc_pcie_event_map, +static const struct irq_domain_ops plda_event_domain_ops = { + .map = plda_pcie_event_map, }; static inline void mc_pcie_deinit_clk(void *data) @@ -799,7 +803,7 @@ static int mc_pcie_init_clks(struct device *dev) return 0; } -static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) +static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; struct device_node *node = dev->of_node; @@ -813,7 +817,8 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) } port->event_domain = irq_domain_add_linear(pcie_intc_node, NUM_EVENTS, - &event_domain_ops, port); + &plda_event_domain_ops, + port); if (!port->event_domain) { dev_err(dev, "failed to get event domain\n"); of_node_put(pcie_intc_node); @@ -835,7 +840,7 @@ static int mc_pcie_init_irq_domains(struct plda_pcie_rp *port) of_node_put(pcie_intc_node); raw_spin_lock_init(&port->lock); - return mc_allocate_msi_domains(port); + return plda_allocate_msi_domains(port); } static inline void mc_clear_secs(struct mc_pcie *port) @@ -898,14 +903,14 @@ static void mc_disable_interrupts(struct mc_pcie *port) writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST); } -static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port) +static int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port) { struct device *dev = &pdev->dev; int irq; int i, intx_irq, msi_irq, event_irq; int ret; - ret = mc_pcie_init_irq_domains(port); + ret = plda_pcie_init_irq_domains(port); if (ret) { dev_err(dev, "failed creating IRQ domains\n"); return ret; @@ -938,7 +943,7 @@ static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp } /* Plug the INTx chained handler */ - irq_set_chained_handler_and_data(intx_irq, mc_handle_intx, port); + irq_set_chained_handler_and_data(intx_irq, plda_handle_intx, port); msi_irq = irq_create_mapping(port->event_domain, EVENT_LOCAL_PM_MSI_INT_MSI); @@ -946,10 +951,10 @@ static int mc_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp return -ENXIO; /* Plug the MSI chained handler */ - irq_set_chained_handler_and_data(msi_irq, mc_handle_msi, port); + irq_set_chained_handler_and_data(msi_irq, plda_handle_msi, port); /* Plug the main event chained handler */ - irq_set_chained_handler_and_data(irq, mc_handle_event, port); + irq_set_chained_handler_and_data(irq, plda_handle_event, port); return 0; } @@ -977,7 +982,7 @@ static int mc_platform_init(struct pci_config_window *cfg) return ret; /* Address translation is up; safe to enable interrupts */ - ret = mc_init_interrupts(pdev, &port->plda); + ret = plda_init_interrupts(pdev, &port->plda); if (ret) return ret; From patchwork Mon Jan 8 11:06:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 760880 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2062.outbound.protection.partner.outlook.cn [139.219.17.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 393E02575A; Mon, 8 Jan 2024 11:41:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PZEPKMo6gnsGBfIXXwHZOAR1FgavqhtO8x5OKmCK3LXfKvic4dCUv0C6mPZlmDf/jKF0P3BC+zt0y2FrrBRQmFGxonwlPe/16dTC7we6pFqP8uBvZT16yqo9iDmXMrgcRKskbzFQXdvW16YFrV5jCBcQmpOHkWbDDrezUc0KEkD8A6bq5jqOgb8V9ghaBHKZDRcgFRb5hUkgp/aYjl9YDLkLE+2/IwLn2iX126sOLcDE3v8y6XIm8hATMifj6siA9+si940Po54FVrxyQg0bCOcXnl0ep6A7PilmSNX+wx3r8QG3+rwgyIXW5t8+Z/HQUaNWLQUBEaKRpj89RrJjJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nkG8h4qt+ikCnMOfDNuKvK03jp9mjC84c+mENU+9eY0=; b=R4t5KlfvB22hH1J/QoCrx1Abb4s+cNZYRembb/a63sNmM6Q8WocNl4Jsb6+FQG2Mmnai5tPf9wgi6lXyJVWjBoZIVJg9LabSnQe7rR1GwFxAav7b6RbKZ1W1VT8EMIyBc9I4T2hlxPFg0HHqMn7pU80jQm120o3+7QFqSNPw7/2lYOwczWINi0PRrdwTe9x4Jmq4FXCaBOV2nboHxIMHXM7VnODNeah7sPFZ3IfrgkX4uiNMQZnKuwG/8ttWd0nChGXpYKh4ym2tfHSxIlPemqkArmOWscWjL7oX0AlzfDOeJ8VAsNirb/ReGrZhnJi+lWYXrjJbGG1Ljo6o0Fn/1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:48 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:48 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 13/22] PCI: microchip: Add INTx and MSI event num to struct plda_event Date: Mon, 8 Jan 2024 19:06:03 +0800 Message-Id: <20240108110612.19048-14-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 7269e5c9-e233-40bd-ce10-08dc1039e86e X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AFncDXgSIhPMe+9mfYBofhNjpJwrumPujnht0XZjJyU6aOgZSawepop0Fa7dJApkQVmt/KxkthMwfxaMPk4yUHFJnItaj4ELhWuVWqOfc7+f6WoU7cUAiR2PBk/v/hYO+Tw6+IiQUH2iUn962/pn7ki0fzr6GdDjZd4oQ8TPY6vuUTJf3HUpEocxZpOgjuZHot7VhCQGkv928Zq0PWpG4WhFlrZ+dyk+wIrFF+WQvRGsUcKwinLm7Xo6z0Ot/kjK4E8ubc1//q9JYp6IqlpvW0sIlI22Xb3VN+laG22+CzB9Tg/dQtbE8uGFcM8h3I+Sm/F8mS3KSUZ3FW2jyfu1r2XXlTn8i5qqX/j/A7ecIMcy11b2UXISLXzx8dGYYfQcgFIq4uKp/48VRHHhoPwqPsRXpjLstUk8EpurKACZbbegC3usjhz37WrUnDpBsjkD5wPLKxBwhRsiXllw0D8wAY8HipgpsOzjs8F2pr+Q9yfGp/9WdL5vADDOdhFE4TboQd3gtbR6QIsvwNjkTMFBIyU/in+ZxrVOr8/ujME2Vq0xdFwesvgk18b580LpWI3o X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lDELTZ3+VelIhNr7grYYxVwp2bUBxwpJ2rE/WkOhcuMmLH2K4lcOqBbSx/3zLqAW8BNQV5UTcuVUivZQypLhqP5h2MZERIOcrzaEAgroEFO29q8BFnSBprP4wzjBkOSSpeSUfQcbysSgl8fSv8kr5nBObYC6BCUCCKsu59UyzM+zw6k1jFnjzQ7TKqHrVNymN6gAm5uLqdeuqZZB631+BNFpmJp5hUgICWjv7U3O/ejNiIbjDF8biB79hjqYmlI/6cKt2rpLDz8g1qih55Gq8bQz7avalT0JsRe/2MXD+9Zp/CrzvfSqZzJycoI7bI6msYJtwcFfjfKLSJn2DhWVN4xPk5RRZAe0kAot6zCQTc34WtRjtmfJ4DZUJm7J4NxTJuNAiFaoMPBb8cxqdkROC+Xbcjqtxo0A9e+NQKEilHL44eUAGUm/qKB/9o1RWlRHL0UxxBkWytZvQBmE3zp3C/SbF4oM4dzp92efcCnVcZe1I1474TKktNvAy09GpVS7rRJ8M+lV2W1CeZFNnvJ33tYSSUo/0utewehduFfhY7JNpEUa03KT01cIKsnyfC4B2fkyE4kSZwSNsIw/RBm76Bn97FGKtQEurMx/7tr3VBAIIC0h5oAIDmCzIecIqZzzZung2QNZcstYrjU2vuefhi81KyBfkCvLvTsIxP09kfRq77VyZBmrCZqL+vulIkgTLYGIFh/CPdtvQry5q/El+2lQ3kv/ksTrJ8hDqxlCdtlvuSoRsJOcUXSQZENV0jQ1dozKX5p/qf7lQeBxjuOeKj1e+U1Z00ySzykKrLioyMWVnTkSekZ+1a9B5KyGufiw/f7riWyNu6Eg/TzGlUPVjVm1gpqdeP3483IO9NqVqmd5mnP3R1mi60gMBy0x5QJNkFxWlUFFJNsXk3SGtfwUlI/eorb+K7bkifMixuulHB58/WvCdPx8V2Ni1GWuDjrMYS5KmUJavBr/NWph9XxjRJQInHqjApZyOE8wK1QMvelQJ/TGndn6pG8tJtWtWGRasmyTZANmA/2H2xZQlRt0c9z7C/U0wpMYEGHlOsrwfIzupmQ15L6Cjx7gBd7/ltkK5rfglK9UJt1g3uYoUBcm06VG4HVDABz2GgJ8v6SoYXRs+mzOTvoPlFnHaiGkRUEIkmywZ5N0VNo4qXNnEciguhT8hI7L2rGiLMBS18+1hLl+rwHE9R/KaZG5b178oatw8IRapeCSneZOz9+msrVJgsVBxgOyvZiAkTbSEprI9FMTXjwmAIfy+qgQP8K5cnNNWBhBt9mTbe4wjBctBpBPRdMdqrElpMsXu8IYshUi8SSJheYctuTWMdVOEu0AlZwnlcJha3VMD+BD7pjQ+FdiOvlGhTSu5L1OEbXBu2ikpftPqrVukXB1RFSdGszJORq696E9FM6Ni5MZ6HsiNCev1pO72gGxWhIjUckWiGDzCMM9zKVmHa19uBBO1zFh6R88CMvbVWCu14yRk1fEEl/0tmUClJRPY0Iye+EslGy/hj0BnywcV4oZK9kT2QoFyFdnDEfzFc/zC/4ncpMsstO3+g7NKlkmwosocF8+6wfS/a/P8pcB9jB5Vzl4npDRSXgDf9OAlkRZKAmVSiYy81VOJA== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7269e5c9-e233-40bd-ce10-08dc1039e86e X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:47.9513 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5Hg3acHJr0DoczAsZG2NqSsmutA8k90L5Ou8Un1gmktmcUl5WqiiXsMAgZDJZME+iZL1+n1vqfzs1VrjPfyWYuRZeEDUooEZ+wpEIfJVK0o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 The INTx and MSI interrupt event num is different in Microchip and StarFive platform. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- drivers/pci/controller/plda/pcie-microchip-host.c | 6 ++++-- drivers/pci/controller/plda/pcie-plda.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index bf5ce33ee275..8a51d3aa7e88 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -817,6 +817,8 @@ static int mc_request_event_irq(struct plda_pcie_rp *plda, int event_irq, static const struct plda_event mc_event = { .request_event_irq = mc_request_event_irq, + .intx_event = EVENT_LOCAL_PM_MSI_INT_INTX, + .msi_event = EVENT_LOCAL_PM_MSI_INT_MSI, }; static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) @@ -960,7 +962,7 @@ static int plda_init_interrupts(struct platform_device *pdev, } intx_irq = irq_create_mapping(port->event_domain, - EVENT_LOCAL_PM_MSI_INT_INTX); + event->intx_event); if (!intx_irq) { dev_err(dev, "failed to map INTx interrupt\n"); return -ENXIO; @@ -970,7 +972,7 @@ static int plda_init_interrupts(struct platform_device *pdev, irq_set_chained_handler_and_data(intx_irq, plda_handle_intx, port); msi_irq = irq_create_mapping(port->event_domain, - EVENT_LOCAL_PM_MSI_INT_MSI); + event->msi_event); if (!msi_irq) return -ENXIO; diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 16b81b23c213..0efe64d5f688 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -130,6 +130,8 @@ struct plda_pcie_rp { struct plda_event { int (*request_event_irq)(struct plda_pcie_rp *pcie, int event_irq, int event); + int intx_event; + int msi_event; }; void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, From patchwork Mon Jan 8 11:06:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 760886 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2050.outbound.protection.partner.outlook.cn [139.219.146.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BE6F81426F; Mon, 8 Jan 2024 11:10:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DO3/KZJ0ej4TjUHBdZ0yRwqRkGMDn1FVm3cCd0RIuNVo2q4rQQ0URJGQIbK7GR368HAb8QnbRno+j/pDYvU8sczUJT6gpXxf10SZ8fdZBpGVTJ3u1wJlQPZSGQYESICERtOgcCYuIVrZNeN9q63sWQuOg402PpGoJD5MLZf+tMUhuPsTCfrOfIMuui1Aq1Odz6gJy3n5yQKVOkGGF334H+GpZ9Gi/qTMeMipS9vb8IIzamjhdi9ybR10C5q+hsQfV99di/swBezGUqLpIdHLMcwONgx8Ip0b64xHPcE5f4rx0Iwtk/td2NZ+m28xvAU+n16Wl8kVO4FHu+H+QFNoZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7MZHud6DOJtHq48cZ3FRIwx5aCvi4W9JCy0s5IDEiPo=; b=avTgESNSHBSAEBV8EZ9D1poqZzsebloDpVzynWEyILmTRgLI9rFHuiyHojxQyupm/LkDLV9dAseSh9o/ohg6C0Wz4R8nX1ChNO7dHMGiPcD+rR//1eROiooSD6Ew30saXV/nmvwzPmAr/9Oui0QW75/+J8MNqg0mwXuZ2lbaC7+JMtA2CpRdCjpIakIyPWsTcVg79NZO34xYED7B3HAHiPZv4qWRjMZB/FoGR4ogAwE1voKj7kKutPsMu6xmifcbA/TMlX4lYUyrpQrwCK+yUkvwg8T4J+ZwcfN8dsRVnD1lQVXyJgjGZGDlWaL5mEVbPcflU0XaW1q1N1MwbEiwlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:50 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:49 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 14/22] PCI: microchip: Add get_events() callback and add PLDA get_event() Date: Mon, 8 Jan 2024 19:06:04 +0800 Message-Id: <20240108110612.19048-15-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e7bb5f3-f1e8-4b32-098b-08dc1039e994 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q2xb0/IrYH/URU2UW9oK4R9fCBNF7RVROCWAoy8Z4WqFtyRBEnWfzXyAmqZnuKM9ERT5I7osCJ9mwftxl2Z/fD43ZZL0mOJpn9EPz1TPgM/6QCrPYtvZj0AJkAytF6dn8DOcmsF+sQccHFVNROJ1b/3OP6/ZMuIgoOFIU3uCWf9SAstn0M2aRjgi0x03dnMQO0EDCP83tk4EPol6XC8ZnKWcKGdsaUbjXirBMrTng/v8YWHTfvNYqH0Mv1EOkBVTy9kqWTJrRQfMX1lX7O7nI1uDg1T1Lqd9GDOB7Teg5x/gGup+N0S5i2fdpb8FuSNCdrzqxeydQ9aK8YpXPN8fiTr9HujVs7/wUmBy7QtZcTzCPAOPUb7ann4cJMoMLz5V/awy1iUW+0oEJjbI3s6xVgbbhBAbKb7l0ql1cxFynuIOm+S94w9b55xahE3Mh/ngm7PcXgWPxC2zVMUEMihkWwAbNm51G9dvOoh+ztrPc7+2w9c94whmEjk+Af5HxZbeJWxTOox3cXDmT4QA3YRKla/Z01+20q49RykYTG7jbd51xmPwmMmKVbb6li1/9pKL X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y8Q7fC0zRsLwGsIBCiTFPKOZQ7U2QMIn4LY/Mzi1oYq4t1iiOn3ZdhDNg7pBo5kdknWaj7bFckUp+xoIjc4iJB7weLzBWDu343npfyqbhxEp08w2JqD73voANVtxl/1CoYUc9SMVc77HlczJedXv5Koiv6C0KuxFAz55P1QxJjbj3bg40NV2iw5gwwB60lbAVM6YpAxiI7WBBiLfAmcW1JL9jJXB913moJJpC1JbOJxx40WXs0Gbs1RSxtqX1g7sc9R6MTH09t5/OZW8jfxDTbYLdvms6aTKS0FPiqcYFB2TurQBAMf/gB1M7VYWmh0uoQCcyIs5YJMu3haR9byEwLkMijIb8eQ9mXZQTa0VdGYctci9RZtBVEjIO4ua9GPiDdpuzWT/m0f+jMz9ce0C8jwnEbDW70Q15Y3+y4rkbTekpml+V0pL9sXekOR6XaieOICdt7ljoRyLTQkQEjoEo8C5Jt8yVGvQizBfL6Q9Prt/NDr5jB3bSY1idI5OX7Pp8m9crAB6FM7EKHOp3yX4O7jMH/9/o+L26yfPLop+6ndo/n/xWD5UBEu9YxURj0qW0+ltyJDheLontmZxvN4heeBvpyB1XyyqLB/28wsuRozXLfamjcjNMtM8tAo2c3MQ4+eza+m2YoqvCitBWDPkwd8Zsz0ILbWygJXpB+lFPfPOq9JRVJNaVubPiZ4svrvQCki9wb2Ohv9vRwA1/9JYHMIhp2p0JnpUv1dsPLNPue51yT3CHJPs/5ZYWxx2SdBYEmLB31P67nC0m/m08DgWQQhDTQ5zPmEhJWQLN0cKAKjtqBSjERCK6BPGNTwNP7trx9kbg7NRpqcC06wrqXUkmGbCzxwNCGJgk3sFBW0n8oAnKLHRHf0XVNFqDUy8wPFQ+bvamx5aOltxD44IN0g56PyHFYdn2TXgpuv3bQ6fhwni+z68uykEoQZ5atF6NZBLUR88HWLVG0ftksGHbbFOmPrMpYV0VmHCYWMUN55Hq4j5ylNrdf7tsyVZ9ZJWOjRXl9Q7cmzdOX8ufS99ayEd7A6Gn6nvKdDE0sJocMdCVko9vV/nlfjutYwK2vJjMN1KUozmlI95Ie02yBP7SrcbK+frfUrGnAY/z8gIDCfpXujI5m8WbLnaR6WeO9WiuRhdTDYXgLZiJzdGqRba/Ilwdod+x+usWAkfWbsCTplNfDp+IlEfw5MuRlFv2uW43Mq98HdtXiubLSnIfPif4A8Lk09ogMlptammGiXZdNOI3vDbcScT9aFamYy4lA4ythC4nPanUWN5Gz/oTJLp8ScPsPVHncXkqfm51h62V75wp2MCTnlkM0aq7aAFnIgmwmQEqYGI1W5YzOkcBhR2ZeEQasW47qekwNqCLSmO17jPMX7C/eKqpnNOAWDeTq4ct+Hmi3YA/VID6UQ/TqCHKzY8sd/2Iten4BAJnC1lsIbkyU201v6a/6bbG3Xcb68ti4NmdUJLzQPWR4AcyHYK3yb5QHG8vREPON/Pg/+Z5v7jWdXnjjP7y71cizcv2AnsBBf//ckF0TqPh2VL/XUwR2BuSDa2bQZZe2ZZujipE70iGP3hk8ocmsDyoTU6JnHwulcsoNMmiONt81/D5UDhPw+hiw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e7bb5f3-f1e8-4b32-098b-08dc1039e994 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:49.9173 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 45qgO6nBlIqYv860XjADsVQ/RU1daaLyT0X0lyHxal4fyvXjcAzMckGBpGanKzIu2WKFnx9C3OAKwQBWonHCE/WGhNvjQp8hHhB22sIi4eg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 As PLDA dts binding doc(Documentation/devicetree/bindings/pci/ plda,xpressrich3-axi-common.yaml) showes, PLDA PCIe contains an interrupt controller. PolarFire implements its own PCIe interrupts, additional to the regular PCIe interrupts, due to lack of an MSI controller, so the interrupt to event number mapping is different to the PLDA regular interrupts, necessitating a custom get_events() implementation. Microchip Polarfire PCIe additional intrerrupts: EVENT_PCIE_L2_EXIT EVENT_PCIE_HOTRST_EXIT EVENT_PCIE_DLUP_EXIT EVENT_SEC_TX_RAM_SEC_ERR EVENT_SEC_RX_RAM_SEC_ERR .... plda_get_events() adds interrupt register to PLDA local event num mapping codes. All The PLDA interrupts can be seen in new added graph. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 35 ++++++++++++++++++- drivers/pci/controller/plda/pcie-plda.h | 32 +++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 8a51d3aa7e88..b3df373a2141 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -626,6 +626,26 @@ static u32 mc_get_events(struct plda_pcie_rp *port) return events; } +static u32 plda_get_events(struct plda_pcie_rp *port) +{ + u32 events, val, origin; + + origin = readl_relaxed(port->bridge_addr + ISTATUS_LOCAL); + + /* MSI event and sys events */ + val = (origin & SYS_AND_MSI_MASK) >> PM_MSI_INT_MSI_SHIFT; + events = val << (PM_MSI_INT_MSI_SHIFT - PCI_NUM_INTX + 1); + + /* INTx events */ + if (origin & PM_MSI_INT_INTX_MASK) + events |= BIT(PM_MSI_INT_INTX_SHIFT); + + /* remains are same with register */ + events |= origin & GENMASK(P_ATR_EVT_DOORBELL_SHIFT, 0); + + return events; +} + static irqreturn_t mc_event_handler(int irq, void *dev_id) { struct plda_pcie_rp *port = dev_id; @@ -656,7 +676,7 @@ static void plda_handle_event(struct irq_desc *desc) chained_irq_enter(chip, desc); - events = mc_get_events(port); + events = port->event_ops->get_events(port); for_each_set_bit(bit, &events, port->num_events) generic_handle_domain_irq(port->event_domain, bit); @@ -750,6 +770,10 @@ static struct irq_chip mc_event_irq_chip = { .irq_unmask = mc_unmask_event_irq, }; +static const struct plda_event_ops plda_event_ops = { + .get_events = plda_get_events, +}; + static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, irq_hw_number_t hwirq) { @@ -815,6 +839,10 @@ static int mc_request_event_irq(struct plda_pcie_rp *plda, int event_irq, 0, event_cause[event].sym, plda); } +static const struct plda_event_ops mc_event_ops = { + .get_events = mc_get_events, +}; + static const struct plda_event mc_event = { .request_event_irq = mc_request_event_irq, .intx_event = EVENT_LOCAL_PM_MSI_INT_INTX, @@ -931,6 +959,9 @@ static int plda_init_interrupts(struct platform_device *pdev, int i, intx_irq, msi_irq, event_irq; int ret; + if (!port->event_ops) + port->event_ops = &plda_event_ops; + ret = plda_pcie_init_irq_domains(port); if (ret) { dev_err(dev, "failed creating IRQ domains\n"); @@ -1007,6 +1038,8 @@ static int mc_platform_init(struct pci_config_window *cfg) if (ret) return ret; + port->plda.event_ops = &mc_event_ops; + /* Address translation is up; safe to enable interrupts */ ret = plda_init_interrupts(pdev, &port->plda, &mc_event); if (ret) diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 0efe64d5f688..9db92ccf286c 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -58,6 +58,7 @@ #define PM_MSI_INT_EVENTS_SHIFT 30 #define PM_MSI_INT_SYS_ERR_MASK 0x80000000u #define PM_MSI_INT_SYS_ERR_SHIFT 31 +#define SYS_AND_MSI_MASK GENMASK(31, 28) #define NUM_LOCAL_EVENTS 15 #define ISTATUS_LOCAL 0x184 #define IMASK_HOST 0x188 @@ -108,6 +109,36 @@ enum plda_int_event { #define PLDA_MAX_INT_NUM (PLDA_NUM_DMA_EVENTS + PLDA_INT_EVENT_NUM) +/* + * PLDA interrupt register + * + * 31 27 23 15 7 0 + * +--+--+--+-+------+-+-+-+-+-+-+-+-+-----------+-----------+ + * |12|11|10|9| intx |7|6|5|4|3|2|1|0| DMA error | DMA end | + * +--+--+--+-+------+-+-+-+-+-+-+-+-+-----------+-----------+ + * bit 0-7 DMA interrupt end : reserved for vendor implement + * bit 8-15 DMA error : reserved for vendor implement + * 0: AXI post error (PLDA_AXI_POST_ERR) + * 1: AXI fetch error (PLDA_AXI_FETCH_ERR) + * 2: AXI discard error (PLDA_AXI_DISCARD_ERR) + * 3: AXI doorbell (PLDA_PCIE_DOORBELL) + * 4: PCIe post error (PLDA_PCIE_POST_ERR) + * 5: PCIe fetch error (PLDA_PCIE_FETCH_ERR) + * 6: PCIe discard error (PLDA_PCIE_DISCARD_ERR) + * 7: PCIe doorbell (PLDA_PCIE_DOORBELL) + * 8: 4 INTx interruts (PLDA_INTX) + * 9: MSI interrupt (PLDA_MSI) + * 10: AER event (PLDA_AER_EVENT) + * 11: PM/LTR/Hotplug (PLDA_MISC_EVENTS) + * 12: System error (PLDA_SYS_ERR) + */ + +struct plda_pcie_rp; + +struct plda_event_ops { + u32 (*get_events)(struct plda_pcie_rp *pcie); +}; + struct plda_msi { struct mutex lock; /* Protect used bitmap */ struct irq_domain *msi_domain; @@ -123,6 +154,7 @@ struct plda_pcie_rp { struct irq_domain *event_domain; raw_spinlock_t lock; struct plda_msi msi; + const struct plda_event_ops *event_ops; void __iomem *bridge_addr; int num_events; }; From patchwork Mon Jan 8 11:06:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 760877 Received: from CHN02-BJS-obe.outbound.protection.partner.outlook.cn (mail-bjschn02on2052.outbound.protection.partner.outlook.cn [139.219.17.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C49F44C99; Mon, 8 Jan 2024 13:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XY9yY9B+1of/zjhl6bhPgVKCwDcUACdDnrzv5SwkRYJgM7wBTwTQt7oL6MmvaqWgdfYQ+/VljuQIYNYPlz97wk9LU+ypW34/LsgPv428eDuX7fZDcxlBoeIQ+QONxYovPUczWNnuGSOcsP/MXaaY7lI4yRxP1F0tC9IXLNihZh8E8R2STx35NjLvyjAAme61KKgj8/6SodvJS6D1dHt2xXL9h/2g6ysu4X9Mlhzsioto8Maxe0hgDyOBrUN29bY/nqTnTkVScuNDRC36gP+pNvm9BCRNXnzee/UO9++7fKFkIv99CJv8PgAAdSNtdtAOZT6hPD93XOF31pGy8y98MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=f/ryPNdgWx646DZhCAUX6Zmi0rAUhEAjWZ0SJhEa4W0=; b=lZ3dI79/7wNxMHx7a/3CVPzBQQ9CrifH+FOm0mQ4Jq6+gpKkJnR9tgFmlP+Io46HZ1kArSHWqY754LH/vl9zq2T9ogIy20VFlNlAIaan5vqWLrDNh6G4LuJKJ7efarhbm8tm37uVzkxmLhKIVKHbCbHVQX6L+LUkqP4ih5ScyWkOg19A0HNbIcGmAbAMWxh7tMevVvQr1rUPvuAcsikP/5ZeG2LihhUmCMzb1nszBZq9XkehttGYoSNTbJVPadfE7fOJHlJbs02UVAG4gpiza/PSGVNyBixAh3zcpsL5B6Qbzzim/brCaF1vCAtB4SdN0tn/5cTDx79lSLoRNQ95Zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:53 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:53 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 16/22] PCI: microchip: Move IRQ functions to pcie-plda-host.c Date: Mon, 8 Jan 2024 19:06:06 +0800 Message-Id: <20240108110612.19048-17-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 67122e59-4a15-49f1-09ae-08dc1039ebe8 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UGIKaEps5ml5qkJQgR3EhaH0+8uROna/jvQoXmGpOF17AkIYCwFxr1rxBb9v7UftmMLokJ3Ot10LGU1iw+6mUNGmutHW0PG4drZHTUinZbiuVA89Q7N5hXy/T7W3guFBi+6ANY5kXgDbiOGGCw/uXzSw9ExkqvzwZeazQm7ThPv7NLABYqfMunTcYA6i+e95YH6R9a1WTb07ZoWDCSTmH/eZE2KKxVpwM3DI9mjkT9dNgtF+fkKIpDS1Oz2f3j+tAhiF0LF4lXxQPT3OeavZ/kAgiwqjRPTeKNuab7QOywcAu0STARNtv5LSb98V5Y0w/iYAlHvL/hn01XudM9/n9VomyJxdfPysCKaNqv9jXUKN90agZDuXiSKt7Khx81aJo7PS9CMhtgbU47rus8bADABf5kyFtizjYbmyXTK0dmezIDLr87GqlUMGO4mWSKHZ+BIEr/tHzDCudq+xh/EHQ9wXsdWd6J7mSMXl5j2QUWneDynOZk/1J168pyI7b2EZ9aUP26tyEHiJZXo6pdoK30W4pIhnuuNGn2MQl2No2QdRhRaENv08lSaDFaOxJCkE X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(30864003)(40180700001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hd86GMfxy3Oa0Bk+3+dTJAF/E0XKZaL84bKhKIKlvvQOFqaiWmFiQZ7g8IVvhnTUbygANUHTa7A3kR9hPanLNKx+iQZKyZ2m7YE6zgg/n4HVrnsHV92ZVYktN9JnRUByHm7Do0rmkjDLAazlQhKpUCEpynmGXrON+sCq3oqcBjGD8LaPd8mS/fREdssPwR1bgHgrbU8+RcAaiZRavAwK/KxUW6n1u18OB8h/bGl9am/UMVSkmglPyfti9ARkkCj9D+JoXNl1E+bHWIxTkzyToeVTquri7Jb2zP3pizxAR5V4R14SPbOP+yZ+z8N5O8bwjonJpatE4r7hSCvjwvNu5afM3ZbH5Iag1xf9SAS/tZRrjSUAnqTQRrWEZpZDE0FRmD+RDsOSNPqRyuq+S4G8nIElzaw7JBg9YEG6Abx/WplGXSR2WX+K6IjusogEe5eQk+HiZlvsdIgLvuQgQwvt8aKshq7lFY3kosFGTBYUmlPDolxgrwkMXNn5r1LrxmQt9HS6FD5SF9uFmulfiGStU28vNjFtn+pBVvdvtgnVn1OAP83v1tT6RYJ7QBoRNHVga3fhW0kindyZi/EmVmtb81sH5ThIOUk1LtV/NbxOZBrYGAT4d2gZWMfWFtq0XaR5ZMrHjfH5iNwaIDHwm2plUHeQChYTIr35VF7IBQgL2ujJMl4wN2PBhyRbPAmkFtOOlilSpdNrOHQCjQ4OFFlulWdmp0T1v8BfTxXOaYZUIUC582fbYKOp6bV8cQKUec/9dWmLGanfyIZ+EOoc54aZPamlXxa+0unYdmzC+jrL4OcJbEk+FINXwJOZFJ/YibVlCDgqfSjcNthPYfEdiUYES11XmyF/qmOYiNQBQxF2vDD4JExTVRVto/7lRWIoQDJkChJWMNmiJzAPXeywEFPZGE5y1Z5pO/ck14pVDfuyoqCQDEImJ8tHZytEmQV8ye5BGN3Jwz3hroyuJybME4SI+ZChbDRMZ0TmxZWBVg7JXc6h+/YrZcGvef9GUuKTI+E+cwzgKgJkCzKWTMNGSHPHgWRDHPZI48okdUqDsN8OQwb4WncyoFhR/FhoAiF/1e1qqOoYl2B5S23ZgpY6KiOrDb1XXio8yQJ5JsRsRz40ixNYM3zPCibfKgio4dWUu6XkGRHdHtvbXxjWa0UFPlSxGID0lViEg9UvFl/RiR1PkEX8QWrRsN3efB5yNe3OktybCkBn8PbunetL08S4RF4FUy7Cu8qBH9tqCTuwAPCkiyk/27+PXTkuJnXPHR/RECwlTjQrzAskBm+df16kAxzVPVjxw4nsPKkdzcpkq0oPqnTZAcLhzjhX9ir1km5Ec1ed2MZEVuWToeY6CJ9+UHmq4ycF2BaGUpkZOZp8yzZqHcDwfc4WfMzKatZnjAkuquojyvlaMNQcmN5GB96+PUhe0bblxFxEnjhOHx2lPWKmnayklwgebcxpQvr+rPvfaELnwv9YWWqcDKfKkmB+I6kVJLGV3hlw6B6mHnFYwR+UQ4Mbc+M1cboQdp9GbfrcF0u2SyLEnzmD8/rs3ADhF4JtjMJH8Pc/lmNnpigbbxgD7Wb0UCEWjPoPrYXezNLtaPhV0K1qNI+PJt5HQHXU29h+cg== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67122e59-4a15-49f1-09ae-08dc1039ebe8 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:53.8461 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 27nQ6v8ZJ1uDc0bRvuxG5wrZ+HF8pnBVzdo7TQeU9pXeS3I5G48JwyU7gQyE1BX+CrXfsyEeO6lO5Wjwva4B+C3McJU5RPZRV1FqV/S6sMc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 Move IRQ related functions to pcie-plda-host.c for re-use these codes. Now Refactoring codes complete. Including MSI, INTx, event interrupts and IRQ init functions. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 467 ----------------- drivers/pci/controller/plda/pcie-plda-host.c | 472 ++++++++++++++++++ drivers/pci/controller/plda/pcie-plda.h | 3 + 3 files changed, 475 insertions(+), 467 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index beaf5c27da84..105964306b71 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -318,244 +318,6 @@ static void mc_pcie_enable_msi(struct mc_pcie *port, void __iomem *ecam) ecam + MC_MSI_CAP_CTRL_OFFSET + PCI_MSI_ADDRESS_HI); } -static void plda_handle_msi(struct irq_desc *desc) -{ - struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); - struct irq_chip *chip = irq_desc_get_chip(desc); - struct device *dev = port->dev; - struct plda_msi *msi = &port->msi; - void __iomem *bridge_base_addr = port->bridge_addr; - unsigned long status; - u32 bit; - int ret; - - chained_irq_enter(chip, desc); - - status = readl_relaxed(bridge_base_addr + ISTATUS_LOCAL); - if (status & PM_MSI_INT_MSI_MASK) { - writel_relaxed(status & PM_MSI_INT_MSI_MASK, bridge_base_addr + ISTATUS_LOCAL); - status = readl_relaxed(bridge_base_addr + ISTATUS_MSI); - for_each_set_bit(bit, &status, msi->num_vectors) { - ret = generic_handle_domain_irq(msi->dev_domain, bit); - if (ret) - dev_err_ratelimited(dev, "bad MSI IRQ %d\n", - bit); - } - } - - chained_irq_exit(chip, desc); -} - -static void plda_msi_bottom_irq_ack(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = port->bridge_addr; - u32 bitpos = data->hwirq; - - writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI); -} - -static void plda_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - phys_addr_t addr = port->msi.vector_phy; - - msg->address_lo = lower_32_bits(addr); - msg->address_hi = upper_32_bits(addr); - msg->data = data->hwirq; - - dev_dbg(port->dev, "msi#%x address_hi %#x address_lo %#x\n", - (int)data->hwirq, msg->address_hi, msg->address_lo); -} - -static int plda_msi_set_affinity(struct irq_data *irq_data, - const struct cpumask *mask, bool force) -{ - return -EINVAL; -} - -static struct irq_chip plda_msi_bottom_irq_chip = { - .name = "PLDA MSI", - .irq_ack = plda_msi_bottom_irq_ack, - .irq_compose_msi_msg = plda_compose_msi_msg, - .irq_set_affinity = plda_msi_set_affinity, -}; - -static int plda_irq_msi_domain_alloc(struct irq_domain *domain, - unsigned int virq, - unsigned int nr_irqs, - void *args) -{ - struct plda_pcie_rp *port = domain->host_data; - struct plda_msi *msi = &port->msi; - unsigned long bit; - - mutex_lock(&msi->lock); - bit = find_first_zero_bit(msi->used, msi->num_vectors); - if (bit >= msi->num_vectors) { - mutex_unlock(&msi->lock); - return -ENOSPC; - } - - set_bit(bit, msi->used); - - irq_domain_set_info(domain, virq, bit, &plda_msi_bottom_irq_chip, - domain->host_data, handle_edge_irq, NULL, NULL); - - mutex_unlock(&msi->lock); - - return 0; -} - -static void plda_irq_msi_domain_free(struct irq_domain *domain, - unsigned int virq, - unsigned int nr_irqs) -{ - struct irq_data *d = irq_domain_get_irq_data(domain, virq); - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(d); - struct plda_msi *msi = &port->msi; - - mutex_lock(&msi->lock); - - if (test_bit(d->hwirq, msi->used)) - __clear_bit(d->hwirq, msi->used); - else - dev_err(port->dev, "trying to free unused MSI%lu\n", d->hwirq); - - mutex_unlock(&msi->lock); -} - -static const struct irq_domain_ops msi_domain_ops = { - .alloc = plda_irq_msi_domain_alloc, - .free = plda_irq_msi_domain_free, -}; - -static struct irq_chip plda_msi_irq_chip = { - .name = "PLDA PCIe MSI", - .irq_ack = irq_chip_ack_parent, - .irq_mask = pci_msi_mask_irq, - .irq_unmask = pci_msi_unmask_irq, -}; - -static struct msi_domain_info plda_msi_domain_info = { - .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | - MSI_FLAG_PCI_MSIX), - .chip = &plda_msi_irq_chip, -}; - -static int plda_allocate_msi_domains(struct plda_pcie_rp *port) -{ - struct device *dev = port->dev; - struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); - struct plda_msi *msi = &port->msi; - - mutex_init(&port->msi.lock); - - msi->dev_domain = irq_domain_add_linear(NULL, msi->num_vectors, - &msi_domain_ops, port); - if (!msi->dev_domain) { - dev_err(dev, "failed to create IRQ domain\n"); - return -ENOMEM; - } - - msi->msi_domain = pci_msi_create_irq_domain(fwnode, - &plda_msi_domain_info, - msi->dev_domain); - if (!msi->msi_domain) { - dev_err(dev, "failed to create MSI domain\n"); - irq_domain_remove(msi->dev_domain); - return -ENOMEM; - } - - return 0; -} - -static void plda_handle_intx(struct irq_desc *desc) -{ - struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); - struct irq_chip *chip = irq_desc_get_chip(desc); - struct device *dev = port->dev; - void __iomem *bridge_base_addr = port->bridge_addr; - unsigned long status; - u32 bit; - int ret; - - chained_irq_enter(chip, desc); - - status = readl_relaxed(bridge_base_addr + ISTATUS_LOCAL); - if (status & PM_MSI_INT_INTX_MASK) { - status &= PM_MSI_INT_INTX_MASK; - status >>= PM_MSI_INT_INTX_SHIFT; - for_each_set_bit(bit, &status, PCI_NUM_INTX) { - ret = generic_handle_domain_irq(port->intx_domain, bit); - if (ret) - dev_err_ratelimited(dev, "bad INTx IRQ %d\n", - bit); - } - } - - chained_irq_exit(chip, desc); -} - -static void plda_ack_intx_irq(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = port->bridge_addr; - u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); - - writel_relaxed(mask, bridge_base_addr + ISTATUS_LOCAL); -} - -static void plda_mask_intx_irq(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = port->bridge_addr; - unsigned long flags; - u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); - u32 val; - - raw_spin_lock_irqsave(&port->lock, flags); - val = readl_relaxed(bridge_base_addr + IMASK_LOCAL); - val &= ~mask; - writel_relaxed(val, bridge_base_addr + IMASK_LOCAL); - raw_spin_unlock_irqrestore(&port->lock, flags); -} - -static void plda_unmask_intx_irq(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - void __iomem *bridge_base_addr = port->bridge_addr; - unsigned long flags; - u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); - u32 val; - - raw_spin_lock_irqsave(&port->lock, flags); - val = readl_relaxed(bridge_base_addr + IMASK_LOCAL); - val |= mask; - writel_relaxed(val, bridge_base_addr + IMASK_LOCAL); - raw_spin_unlock_irqrestore(&port->lock, flags); -} - -static struct irq_chip plda_intx_irq_chip = { - .name = "PLDA PCIe INTx", - .irq_ack = plda_ack_intx_irq, - .irq_mask = plda_mask_intx_irq, - .irq_unmask = plda_unmask_intx_irq, -}; - -static int plda_pcie_intx_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - irq_set_chip_and_handler(irq, &plda_intx_irq_chip, handle_level_irq); - irq_set_chip_data(irq, domain->host_data); - - return 0; -} - -static const struct irq_domain_ops intx_domain_ops = { - .map = plda_pcie_intx_map, -}; - static inline u32 reg_to_event(u32 reg, struct event_map field) { return (reg & field.reg_mask) ? BIT(field.event_bit) : 0; @@ -626,26 +388,6 @@ static u32 mc_get_events(struct plda_pcie_rp *port) return events; } -static u32 plda_get_events(struct plda_pcie_rp *port) -{ - u32 events, val, origin; - - origin = readl_relaxed(port->bridge_addr + ISTATUS_LOCAL); - - /* MSI event and sys events */ - val = (origin & SYS_AND_MSI_MASK) >> PM_MSI_INT_MSI_SHIFT; - events = val << (PM_MSI_INT_MSI_SHIFT - PCI_NUM_INTX + 1); - - /* INTx events */ - if (origin & PM_MSI_INT_INTX_MASK) - events |= BIT(PM_MSI_INT_INTX_SHIFT); - - /* remains are same with register */ - events |= origin & GENMASK(P_ATR_EVT_DOORBELL_SHIFT, 0); - - return events; -} - static irqreturn_t mc_event_handler(int irq, void *dev_id) { struct plda_pcie_rp *port = dev_id; @@ -662,28 +404,6 @@ static irqreturn_t mc_event_handler(int irq, void *dev_id) return IRQ_HANDLED; } -static irqreturn_t plda_event_handler(int irq, void *dev_id) -{ - return IRQ_HANDLED; -} - -static void plda_handle_event(struct irq_desc *desc) -{ - struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); - unsigned long events; - u32 bit; - struct irq_chip *chip = irq_desc_get_chip(desc); - - chained_irq_enter(chip, desc); - - events = port->event_ops->get_events(port); - - for_each_set_bit(bit, &events, port->num_events) - generic_handle_domain_irq(port->event_domain, bit); - - chained_irq_exit(chip, desc); -} - static void mc_ack_event_irq(struct irq_data *data) { struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); @@ -770,83 +490,6 @@ static struct irq_chip mc_event_irq_chip = { .irq_unmask = mc_unmask_event_irq, }; -static u32 plda_hwirq_to_mask(int hwirq) -{ - u32 mask; - - /* hwirq 23 - 0 are the same with register */ - if (hwirq < EVENT_PM_MSI_INT_INTX) - mask = BIT(hwirq); - else if (hwirq == EVENT_PM_MSI_INT_INTX) - mask = PM_MSI_INT_INTX_MASK; - else - mask = BIT(hwirq + PCI_NUM_INTX - 1); - - return mask; -} - -static void plda_ack_event_irq(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - - writel_relaxed(plda_hwirq_to_mask(data->hwirq), - port->bridge_addr + ISTATUS_LOCAL); -} - -static void plda_mask_event_irq(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - u32 mask, val; - - mask = plda_hwirq_to_mask(data->hwirq); - - raw_spin_lock(&port->lock); - val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); - val &= ~mask; - writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); - raw_spin_unlock(&port->lock); -} - -static void plda_unmask_event_irq(struct irq_data *data) -{ - struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); - u32 mask, val; - - mask = plda_hwirq_to_mask(data->hwirq); - - raw_spin_lock(&port->lock); - val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); - val |= mask; - writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); - raw_spin_unlock(&port->lock); -} - -static struct irq_chip plda_event_irq_chip = { - .name = "PLDA PCIe EVENT", - .irq_ack = plda_ack_event_irq, - .irq_mask = plda_mask_event_irq, - .irq_unmask = plda_unmask_event_irq, -}; - -static const struct plda_event_ops plda_event_ops = { - .get_events = plda_get_events, -}; - -static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, - irq_hw_number_t hwirq) -{ - struct plda_pcie_rp *port = (void *)domain->host_data; - - irq_set_chip_and_handler(irq, port->event_irq_chip, handle_level_irq); - irq_set_chip_data(irq, domain->host_data); - - return 0; -} - -static const struct irq_domain_ops plda_event_domain_ops = { - .map = plda_pcie_event_map, -}; - static inline void mc_pcie_deinit_clk(void *data) { struct clk *clk = data; @@ -909,47 +552,6 @@ static const struct plda_event mc_event = { .msi_event = EVENT_LOCAL_PM_MSI_INT_MSI, }; -static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) -{ - struct device *dev = port->dev; - struct device_node *node = dev->of_node; - struct device_node *pcie_intc_node; - - /* Setup INTx */ - pcie_intc_node = of_get_next_child(node, NULL); - if (!pcie_intc_node) { - dev_err(dev, "failed to find PCIe Intc node\n"); - return -EINVAL; - } - - port->event_domain = irq_domain_add_linear(pcie_intc_node, - port->num_events, - &plda_event_domain_ops, - port); - if (!port->event_domain) { - dev_err(dev, "failed to get event domain\n"); - of_node_put(pcie_intc_node); - return -ENOMEM; - } - - irq_domain_update_bus_token(port->event_domain, DOMAIN_BUS_NEXUS); - - port->intx_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, - &intx_domain_ops, port); - if (!port->intx_domain) { - dev_err(dev, "failed to get an INTx IRQ domain\n"); - of_node_put(pcie_intc_node); - return -ENOMEM; - } - - irq_domain_update_bus_token(port->intx_domain, DOMAIN_BUS_WIRED); - - of_node_put(pcie_intc_node); - raw_spin_lock_init(&port->lock); - - return plda_allocate_msi_domains(port); -} - static inline void mc_clear_secs(struct mc_pcie *port) { void __iomem *ctrl_base_addr = port->axi_base_addr + MC_PCIE_CTRL_ADDR; @@ -1010,75 +612,6 @@ static void mc_disable_interrupts(struct mc_pcie *port) writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST); } -static int plda_init_interrupts(struct platform_device *pdev, - struct plda_pcie_rp *port, - const struct plda_event *event) -{ - struct device *dev = &pdev->dev; - int irq; - int i, intx_irq, msi_irq, event_irq; - int ret; - - if (!port->event_ops) - port->event_ops = &plda_event_ops; - - if (!port->event_irq_chip) - port->event_irq_chip = &plda_event_irq_chip; - - ret = plda_pcie_init_irq_domains(port); - if (ret) { - dev_err(dev, "failed creating IRQ domains\n"); - return ret; - } - - irq = platform_get_irq(pdev, 0); - if (irq < 0) - return -ENODEV; - - for (i = 0; i < port->num_events; i++) { - event_irq = irq_create_mapping(port->event_domain, i); - if (!event_irq) { - dev_err(dev, "failed to map hwirq %d\n", i); - return -ENXIO; - } - - if (event->request_event_irq) - ret = event->request_event_irq(port, event_irq, i); - else - ret = devm_request_irq(dev, event_irq, - plda_event_handler, - 0, NULL, port); - - if (ret) { - dev_err(dev, "failed to request IRQ %d\n", event_irq); - return ret; - } - } - - intx_irq = irq_create_mapping(port->event_domain, - event->intx_event); - if (!intx_irq) { - dev_err(dev, "failed to map INTx interrupt\n"); - return -ENXIO; - } - - /* Plug the INTx chained handler */ - irq_set_chained_handler_and_data(intx_irq, plda_handle_intx, port); - - msi_irq = irq_create_mapping(port->event_domain, - event->msi_event); - if (!msi_irq) - return -ENXIO; - - /* Plug the MSI chained handler */ - irq_set_chained_handler_and_data(msi_irq, plda_handle_msi, port); - - /* Plug the main event chained handler */ - irq_set_chained_handler_and_data(irq, plda_handle_event, port); - - return 0; -} - static int mc_platform_init(struct pci_config_window *cfg) { struct device *dev = cfg->parent; diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c index 40139d998568..98c51e594efe 100644 --- a/drivers/pci/controller/plda/pcie-plda-host.c +++ b/drivers/pci/controller/plda/pcie-plda-host.c @@ -7,11 +7,483 @@ * Author: Daire McNamara */ +#include +#include +#include #include #include #include "pcie-plda.h" +static void plda_handle_msi(struct irq_desc *desc) +{ + struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); + struct irq_chip *chip = irq_desc_get_chip(desc); + struct device *dev = port->dev; + struct plda_msi *msi = &port->msi; + void __iomem *bridge_base_addr = port->bridge_addr; + unsigned long status; + u32 bit; + int ret; + + chained_irq_enter(chip, desc); + + status = readl_relaxed(bridge_base_addr + ISTATUS_LOCAL); + if (status & PM_MSI_INT_MSI_MASK) { + writel_relaxed(status & PM_MSI_INT_MSI_MASK, + bridge_base_addr + ISTATUS_LOCAL); + status = readl_relaxed(bridge_base_addr + ISTATUS_MSI); + for_each_set_bit(bit, &status, msi->num_vectors) { + ret = generic_handle_domain_irq(msi->dev_domain, bit); + if (ret) + dev_err_ratelimited(dev, "bad MSI IRQ %d\n", + bit); + } + } + + chained_irq_exit(chip, desc); +} + +static void plda_msi_bottom_irq_ack(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + void __iomem *bridge_base_addr = port->bridge_addr; + u32 bitpos = data->hwirq; + + writel_relaxed(BIT(bitpos), bridge_base_addr + ISTATUS_MSI); +} + +static void plda_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + phys_addr_t addr = port->msi.vector_phy; + + msg->address_lo = lower_32_bits(addr); + msg->address_hi = upper_32_bits(addr); + msg->data = data->hwirq; + + dev_dbg(port->dev, "msi#%x address_hi %#x address_lo %#x\n", + (int)data->hwirq, msg->address_hi, msg->address_lo); +} + +static int plda_msi_set_affinity(struct irq_data *irq_data, + const struct cpumask *mask, bool force) +{ + return -EINVAL; +} + +static struct irq_chip plda_msi_bottom_irq_chip = { + .name = "PLDA MSI", + .irq_ack = plda_msi_bottom_irq_ack, + .irq_compose_msi_msg = plda_compose_msi_msg, + .irq_set_affinity = plda_msi_set_affinity, +}; + +static int plda_irq_msi_domain_alloc(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs, + void *args) +{ + struct plda_pcie_rp *port = domain->host_data; + struct plda_msi *msi = &port->msi; + unsigned long bit; + + mutex_lock(&msi->lock); + bit = find_first_zero_bit(msi->used, msi->num_vectors); + if (bit >= msi->num_vectors) { + mutex_unlock(&msi->lock); + return -ENOSPC; + } + + set_bit(bit, msi->used); + + irq_domain_set_info(domain, virq, bit, &plda_msi_bottom_irq_chip, + domain->host_data, handle_edge_irq, NULL, NULL); + + mutex_unlock(&msi->lock); + + return 0; +} + +static void plda_irq_msi_domain_free(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs) +{ + struct irq_data *d = irq_domain_get_irq_data(domain, virq); + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(d); + struct plda_msi *msi = &port->msi; + + mutex_lock(&msi->lock); + + if (test_bit(d->hwirq, msi->used)) + __clear_bit(d->hwirq, msi->used); + else + dev_err(port->dev, "trying to free unused MSI%lu\n", d->hwirq); + + mutex_unlock(&msi->lock); +} + +static const struct irq_domain_ops msi_domain_ops = { + .alloc = plda_irq_msi_domain_alloc, + .free = plda_irq_msi_domain_free, +}; + +static struct irq_chip plda_msi_irq_chip = { + .name = "PLDA PCIe MSI", + .irq_ack = irq_chip_ack_parent, + .irq_mask = pci_msi_mask_irq, + .irq_unmask = pci_msi_unmask_irq, +}; + +static struct msi_domain_info plda_msi_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | + MSI_FLAG_PCI_MSIX), + .chip = &plda_msi_irq_chip, +}; + +static int plda_allocate_msi_domains(struct plda_pcie_rp *port) +{ + struct device *dev = port->dev; + struct fwnode_handle *fwnode = of_node_to_fwnode(dev->of_node); + struct plda_msi *msi = &port->msi; + + mutex_init(&port->msi.lock); + + msi->dev_domain = irq_domain_add_linear(NULL, msi->num_vectors, + &msi_domain_ops, port); + if (!msi->dev_domain) { + dev_err(dev, "failed to create IRQ domain\n"); + return -ENOMEM; + } + + msi->msi_domain = pci_msi_create_irq_domain(fwnode, + &plda_msi_domain_info, + msi->dev_domain); + if (!msi->msi_domain) { + dev_err(dev, "failed to create MSI domain\n"); + irq_domain_remove(msi->dev_domain); + return -ENOMEM; + } + + return 0; +} + +static void plda_handle_intx(struct irq_desc *desc) +{ + struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); + struct irq_chip *chip = irq_desc_get_chip(desc); + struct device *dev = port->dev; + void __iomem *bridge_base_addr = port->bridge_addr; + unsigned long status; + u32 bit; + int ret; + + chained_irq_enter(chip, desc); + + status = readl_relaxed(bridge_base_addr + ISTATUS_LOCAL); + if (status & PM_MSI_INT_INTX_MASK) { + status &= PM_MSI_INT_INTX_MASK; + status >>= PM_MSI_INT_INTX_SHIFT; + for_each_set_bit(bit, &status, PCI_NUM_INTX) { + ret = generic_handle_domain_irq(port->intx_domain, bit); + if (ret) + dev_err_ratelimited(dev, "bad INTx IRQ %d\n", + bit); + } + } + + chained_irq_exit(chip, desc); +} + +static void plda_ack_intx_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + void __iomem *bridge_base_addr = port->bridge_addr; + u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); + + writel_relaxed(mask, bridge_base_addr + ISTATUS_LOCAL); +} + +static void plda_mask_intx_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + void __iomem *bridge_base_addr = port->bridge_addr; + unsigned long flags; + u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); + u32 val; + + raw_spin_lock_irqsave(&port->lock, flags); + val = readl_relaxed(bridge_base_addr + IMASK_LOCAL); + val &= ~mask; + writel_relaxed(val, bridge_base_addr + IMASK_LOCAL); + raw_spin_unlock_irqrestore(&port->lock, flags); +} + +static void plda_unmask_intx_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + void __iomem *bridge_base_addr = port->bridge_addr; + unsigned long flags; + u32 mask = BIT(data->hwirq + PM_MSI_INT_INTX_SHIFT); + u32 val; + + raw_spin_lock_irqsave(&port->lock, flags); + val = readl_relaxed(bridge_base_addr + IMASK_LOCAL); + val |= mask; + writel_relaxed(val, bridge_base_addr + IMASK_LOCAL); + raw_spin_unlock_irqrestore(&port->lock, flags); +} + +static struct irq_chip plda_intx_irq_chip = { + .name = "PLDA PCIe INTx", + .irq_ack = plda_ack_intx_irq, + .irq_mask = plda_mask_intx_irq, + .irq_unmask = plda_unmask_intx_irq, +}; + +static int plda_pcie_intx_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) +{ + irq_set_chip_and_handler(irq, &plda_intx_irq_chip, handle_level_irq); + irq_set_chip_data(irq, domain->host_data); + + return 0; +} + +static const struct irq_domain_ops intx_domain_ops = { + .map = plda_pcie_intx_map, +}; + +static u32 plda_get_events(struct plda_pcie_rp *port) +{ + u32 events, val, origin; + + origin = readl_relaxed(port->bridge_addr + ISTATUS_LOCAL); + + /* MSI event and sys events */ + val = (origin & SYS_AND_MSI_MASK) >> PM_MSI_INT_MSI_SHIFT; + events = val << (PM_MSI_INT_MSI_SHIFT - PCI_NUM_INTX + 1); + + /* INTx events */ + if (origin & PM_MSI_INT_INTX_MASK) + events |= BIT(PM_MSI_INT_INTX_SHIFT); + + /* remains are same with register */ + events |= origin & GENMASK(P_ATR_EVT_DOORBELL_SHIFT, 0); + + return events; +} + +static irqreturn_t plda_event_handler(int irq, void *dev_id) +{ + return IRQ_HANDLED; +} + +static void plda_handle_event(struct irq_desc *desc) +{ + struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); + unsigned long events; + u32 bit; + struct irq_chip *chip = irq_desc_get_chip(desc); + + chained_irq_enter(chip, desc); + + events = port->event_ops->get_events(port); + + for_each_set_bit(bit, &events, port->num_events) + generic_handle_domain_irq(port->event_domain, bit); + + chained_irq_exit(chip, desc); +} + +static u32 plda_hwirq_to_mask(int hwirq) +{ + u32 mask; + + /* hwirq 23 - 0 are the same with register */ + if (hwirq < EVENT_PM_MSI_INT_INTX) + mask = BIT(hwirq); + else if (hwirq == EVENT_PM_MSI_INT_INTX) + mask = PM_MSI_INT_INTX_MASK; + else + mask = BIT(hwirq + PCI_NUM_INTX - 1); + + return mask; +} + +static void plda_ack_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + + writel_relaxed(plda_hwirq_to_mask(data->hwirq), + port->bridge_addr + ISTATUS_LOCAL); +} + +static void plda_mask_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + u32 mask, val; + + mask = plda_hwirq_to_mask(data->hwirq); + + raw_spin_lock(&port->lock); + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); + val &= ~mask; + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); + raw_spin_unlock(&port->lock); +} + +static void plda_unmask_event_irq(struct irq_data *data) +{ + struct plda_pcie_rp *port = irq_data_get_irq_chip_data(data); + u32 mask, val; + + mask = plda_hwirq_to_mask(data->hwirq); + + raw_spin_lock(&port->lock); + val = readl_relaxed(port->bridge_addr + IMASK_LOCAL); + val |= mask; + writel_relaxed(val, port->bridge_addr + IMASK_LOCAL); + raw_spin_unlock(&port->lock); +} + +static struct irq_chip plda_event_irq_chip = { + .name = "PLDA PCIe EVENT", + .irq_ack = plda_ack_event_irq, + .irq_mask = plda_mask_event_irq, + .irq_unmask = plda_unmask_event_irq, +}; + +static const struct plda_event_ops plda_event_ops = { + .get_events = plda_get_events, +}; + +static int plda_pcie_event_map(struct irq_domain *domain, unsigned int irq, + irq_hw_number_t hwirq) +{ + struct plda_pcie_rp *port = (void *)domain->host_data; + + irq_set_chip_and_handler(irq, port->event_irq_chip, handle_level_irq); + irq_set_chip_data(irq, domain->host_data); + + return 0; +} + +static const struct irq_domain_ops plda_event_domain_ops = { + .map = plda_pcie_event_map, +}; + +static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) +{ + struct device *dev = port->dev; + struct device_node *node = dev->of_node; + struct device_node *pcie_intc_node; + + /* Setup INTx */ + pcie_intc_node = of_get_next_child(node, NULL); + if (!pcie_intc_node) { + dev_err(dev, "failed to find PCIe Intc node\n"); + return -EINVAL; + } + + port->event_domain = irq_domain_add_linear(pcie_intc_node, + port->num_events, + &plda_event_domain_ops, + port); + if (!port->event_domain) { + dev_err(dev, "failed to get event domain\n"); + of_node_put(pcie_intc_node); + return -ENOMEM; + } + + irq_domain_update_bus_token(port->event_domain, DOMAIN_BUS_NEXUS); + + port->intx_domain = irq_domain_add_linear(pcie_intc_node, PCI_NUM_INTX, + &intx_domain_ops, port); + if (!port->intx_domain) { + dev_err(dev, "failed to get an INTx IRQ domain\n"); + of_node_put(pcie_intc_node); + return -ENOMEM; + } + + irq_domain_update_bus_token(port->intx_domain, DOMAIN_BUS_WIRED); + + of_node_put(pcie_intc_node); + raw_spin_lock_init(&port->lock); + + return plda_allocate_msi_domains(port); +} + +int plda_init_interrupts(struct platform_device *pdev, + struct plda_pcie_rp *port, + const struct plda_event *event) +{ + struct device *dev = &pdev->dev; + int irq; + int i, intx_irq, msi_irq, event_irq; + int ret; + + if (!port->event_ops) + port->event_ops = &plda_event_ops; + + if (!port->event_irq_chip) + port->event_irq_chip = &plda_event_irq_chip; + + ret = plda_pcie_init_irq_domains(port); + if (ret) { + dev_err(dev, "failed creating IRQ domains\n"); + return ret; + } + + irq = platform_get_irq(pdev, 0); + if (irq < 0) + return -ENODEV; + + for (i = 0; i < port->num_events; i++) { + event_irq = irq_create_mapping(port->event_domain, i); + if (!event_irq) { + dev_err(dev, "failed to map hwirq %d\n", i); + return -ENXIO; + } + + if (event->request_event_irq) + ret = event->request_event_irq(port, event_irq, i); + else + ret = devm_request_irq(dev, event_irq, + plda_event_handler, + 0, NULL, port); + + if (ret) { + dev_err(dev, "failed to request IRQ %d\n", event_irq); + return ret; + } + } + + intx_irq = irq_create_mapping(port->event_domain, + event->intx_event); + if (!intx_irq) { + dev_err(dev, "failed to map INTx interrupt\n"); + return -ENXIO; + } + + /* Plug the INTx chained handler */ + irq_set_chained_handler_and_data(intx_irq, plda_handle_intx, port); + + msi_irq = irq_create_mapping(port->event_domain, + event->msi_event); + if (!msi_irq) + return -ENXIO; + + /* Plug the MSI chained handler */ + irq_set_chained_handler_and_data(msi_irq, plda_handle_msi, port); + + /* Plug the main event chained handler */ + irq_set_chained_handler_and_data(irq, plda_handle_event, port); + + return 0; +} +EXPORT_SYMBOL_GPL(plda_init_interrupts); + void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, phys_addr_t axi_addr, phys_addr_t pci_addr, size_t size) diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index a3ce01735bea..6672a231a4bc 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -169,6 +169,9 @@ struct plda_event { int msi_event; }; +int plda_init_interrupts(struct platform_device *pdev, + struct plda_pcie_rp *port, + const struct plda_event *event); void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, phys_addr_t axi_addr, phys_addr_t pci_addr, size_t size); From patchwork Mon Jan 8 11:06:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 760883 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2054.outbound.protection.partner.outlook.cn [139.219.146.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 053FB22065; Mon, 8 Jan 2024 11:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WhRWu3ETNsVVYYFb+ne7/tHCmGKTZsc1Hhvkn1fLqNYPnyqZr+KrgmxRDCkIUNp1NIIMHGfgMt9lwl/5LS1w92HLiVZCUw+nT0uDv9JZE9rY2EU2k6M+0yxMejzTrdkl0TKnavwaqiXzxI5o7XO8HaFLpO+Qbf9eejbBBi70A7Pxb1/B7nXi4jCZujItLr3eQqeJUu6opGwWi6y8A13Y50lOxwO1Uea9CtszABeBi3WRul1GfMZ52greZs0xslX6sJeA9P4VdONj+EfdftrsdtcMw+UGmA7WDVPnG7CRwsPrbdOK5Uq2LI2AcnYAVi+hHDbv0eOaCjKX7qkJXgKfnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=K4MD2usSBbRdsd/hhE4tw5xP1KyGga5Ecw5HSB56sQQ=; b=ZUhQWQlBkwKkVtiyD37bqg7+1jeAuSEjCC/PkIkNlvqoVkebET6k0wdLWxyi1Z69XtDNLUh10YO8S+yqSmr5qUmZ9yX4a8Qtuc1piRRCwE2+rzmw5XgJblhYYTyyQ5C2ozcMUuZeP7Xc5BaSDRHHcytcxs/daGThL8LnY46Knr0HiPVf3CO8gakMLO7I1gBtUKsyWHvIc758uun1otz29PkO2WIjTV3d65v0YtlgRl6werl+RMkQo+xlPp/l/kw99wSGCgXuKIdHrh9QrNsyWIKv8JRNWo5RI7a1Vm8oFR/1ATCWI5MK5/g6rDMlQb9Rref303NXmJCACJIQ9TaywQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:55 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:55 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 17/22] pci: plda: Add event bitmap field to struct plda_pcie_rp Date: Mon, 8 Jan 2024 19:06:07 +0800 Message-Id: <20240108110612.19048-18-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 820ef93e-0853-4224-ce5a-08dc1039ed16 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q5Ei0ykGaYbqehL/3sj55/l/M2yq15Q3WZRrjgC9Sq+tZcaMzBr93xdM/qkhlMBO+jvqioUQBQ2dL9TkDVWHCNdXDCpZw7qBX4apF6eUxskB1YIhDdRf6NYCM7GZSYGgz54yEoeDb9I2wCtjh5GgH0IcF7AY8f/1xLMK5gKN7L/haT9y2tz2pq0ZUBfkvPber5K1GMnWR46cyRa5jfJkIC8DyvgbH2/SpyjYu41ockiCVS/DfJnhMAEAB8X3qzSOVd3oZ2BrlfPzH6Uukg4gR3gR7d20jxi02NDONQPS7RCNSOyetmozfYh8Fafk5juN1rnjrpF1bTYkTCy6AOmHaXEgCVqC4qz5YAiKUgtMMj3DoEQrN7JhDx/y/5eWQvx8o3m6tMayfRVBHbN+bVrfsRGJcS/fbGn+BK4vaJGrxxFQE/hyyz/ErIkHfNcDnfULpH46GZ/8vjnjtw47+Q1UB2D17btAQBiLDZKt8NeXqq+ZWKKDeOJHJVhYV4yTlpX/Hm9dI5ezM86agEMR/P32440Yxws7S/TWb/CA6ui+ruJ9O82J86TnzkZjx3aprazd X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PRvcDt+P4cCs5MBqAw6VZlBZhlKb/Sx9ZRtfELKd0/yuCwoGMSss8pE8NefoIxl/8j5uSgqJf0P+qtopbjQyj4lw832KBiIO/Hv2C/Ew8pB7PSVhbhI889n8Kf/+eEyfEtVAfCtGoUfyiNcZPQwHXtdzQEtddFD2mSnvhESX+7UVAjZ3byAZMB3Bzs9kAG4UeoA/E7q1MtXLUNrPhTSlehbck8OjhSioves7KtBR8Hl04qZ2Lzdpl4r3siIGysaHJLo0+5jC1pcuGVZ6zil05xAhGodHvy9ZDgcMEcIlGyC4FUtzdMRV0IuCgHjcqGwkR9hUlmC4oFCyX0wmhqqT3QUOaW3cvBjMbu1Ynz9UVGZySJAUsCB4nDkCW6Y2kcs3aDNpN2MzA/UVHkT+jbIlqFoMMEE34v/A4UBHCT+u30yzLet3ETNcpzvizxhAcMzXbdpoE61IR1sYNxz4wEfpGObRJ+NedCeHoH4WKDVDJAOG8nl3+M5/cCzH8LjsPlyuGp+HUK832hP513/YL/ZXeaedL0IxZ+zlJKgDQYaCK6gIf5rG5dU1/hanB9NkKRbggfxw4qGyFbmlTfqkkT71fWEqJkEjp0eV64IC/0dkxyttU4GEPo3xUxikLsQkTjlq0nnJsPrcxtzbOtbQNfjkrtnWWmNxEup4q+CpD1cUPSrhQVEvSE+T0gDACLMf4k1MkWBgZKg5ThoT4QiIJYZ64q+e91seXetm37VQOpNCeOWxuCv8sBUCyrLOr5AtVsj2Db4CMvY2MGvt6KSR8ixVB0QXdk0B5f7x1wx4qE8sk39Ql1HDjrUL8cxU9pSbk3PaXTduxzHiQ2tIx5Sar7DFo4ODJhi7GO+xrm4JZHpaWSHrcbC3jMfdI4yJqfSyL79YitSdDay2HjLCvfAtLrCMn9V1q+hp+imxeVyETACk0JtWJexgICz4iPhDR91LhlXAMs75fV1CFNYPCxUajHuXKtcxVXtsY/8SJ9EpbOISAfFy4/KAkI2R0zM3HUpzEIZGQszWB+8SfsyfQQx7D5Kqx/E4tCMm26QiazZcxI1Q22x3ft9kjIwBi4jEtl4fMQ4OyGm/7XKjwv8a08n5MImJtOa3IS/gGb+jHG5y9ORplsMy2t+J7LjBoQ/cRlnKv2lY/2tXYpB9DbQtcucim0fgOBfjRfHpV73SS01UGPeA8tEdI5nB+goUGCUEalnjxbC25v1ovQhW3yNxreKEqm+0zcnmQZRlFxbYwv1tN1NZljUFWTiVXUsDCJfqHH5/ljNlKqfqtdpZR2Z5MpcLPUhGt8frEL2FZvXIuaXuP1HT2zx3hOI7TvVxvKOqisJWyKv/AKXFIeRTs13L22gME4Y3w5tGRGXRNiyoQ2/lfT5d8DvEagi/jlLtu4tLS9gE4wEQdrCC36i5+/+VM0Psq8/bLwZovPu5WEi9XE6FoGmb46JyxfFjsonJgqFT7dIRZk+LcuSHVchXXD94fJhANfjyNQq9qRkxiohLrR6fCrFQll5PIgto/LJXXptkNzpha33GSK0VcFev6jKvPBEltkXAxjxFATmrFC1bc5LIEzUHaTeyoEDRGpG30YNwbWTzrOr5ibvLMjCRWvX08fjNi/BF3g== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 820ef93e-0853-4224-ce5a-08dc1039ed16 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:55.8195 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cPFmXoSY1P0ZMBj6/Zn6goBsx2474dtYrofyKDxB7rNSb/NtN3RPjhRN9XtrY9SVvpYWtsr8m8FGMpJHqUok5O6C+47HljMksYck1RnWUTs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 For PLDA DMA interrupts are not all implemented. The non-implemented interrupts should be masked. So add a bitmap field to mask the non- implemented interrupts. Signed-off-by: Minda Chen --- drivers/pci/controller/plda/pcie-microchip-host.c | 1 + drivers/pci/controller/plda/pcie-plda-host.c | 6 ++++-- drivers/pci/controller/plda/pcie-plda.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 105964306b71..48f60a04b740 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -636,6 +636,7 @@ static int mc_platform_init(struct pci_config_window *cfg) port->plda.event_ops = &mc_event_ops; port->plda.event_irq_chip = &mc_event_irq_chip; + port->plda.events_bitmap = GENMASK(NUM_EVENTS - 1, 0); /* Address translation is up; safe to enable interrupts */ ret = plda_init_interrupts(pdev, &port->plda, &mc_event); diff --git a/drivers/pci/controller/plda/pcie-plda-host.c b/drivers/pci/controller/plda/pcie-plda-host.c index 98c51e594efe..a040e7e5492f 100644 --- a/drivers/pci/controller/plda/pcie-plda-host.c +++ b/drivers/pci/controller/plda/pcie-plda-host.c @@ -290,6 +290,7 @@ static void plda_handle_event(struct irq_desc *desc) events = port->event_ops->get_events(port); + events &= port->events_bitmap; for_each_set_bit(bit, &events, port->num_events) generic_handle_domain_irq(port->event_domain, bit); @@ -420,8 +421,9 @@ int plda_init_interrupts(struct platform_device *pdev, { struct device *dev = &pdev->dev; int irq; - int i, intx_irq, msi_irq, event_irq; + int intx_irq, msi_irq, event_irq; int ret; + u32 i; if (!port->event_ops) port->event_ops = &plda_event_ops; @@ -439,7 +441,7 @@ int plda_init_interrupts(struct platform_device *pdev, if (irq < 0) return -ENODEV; - for (i = 0; i < port->num_events; i++) { + for_each_set_bit(i, &port->events_bitmap, port->num_events) { event_irq = irq_create_mapping(port->event_domain, i); if (!event_irq) { dev_err(dev, "failed to map hwirq %d\n", i); diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 6672a231a4bc..443109d04d59 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -159,6 +159,7 @@ struct plda_pcie_rp { const struct plda_event_ops *event_ops; const struct irq_chip *event_irq_chip; void __iomem *bridge_addr; + unsigned long events_bitmap; int num_events; }; From patchwork Mon Jan 8 11:06:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 760882 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2089.outbound.protection.partner.outlook.cn [139.219.146.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55BE814A99; Mon, 8 Jan 2024 11:24:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GJK/3IReauIRjNz6iNidDSYr4W7vENhrhIG+SvqBJLV9U41tH4x9hexcXl4QrbxAPexV3Gbr1IFMbH09ouxRvNl0C9deNrhp9YfMN18mynVm8yf4XgKpsDyPUT6b4RdXZHqN6AhCIpt/aPX9ax4PoUQ1qW0lfpCa/MLx+IEqHQf9afmNdpP3bxmG8JVpSaDUhwhaI107G8/Rk6cslyH1oGa7QBqF9IWOjea8EC4PfBnjIY6kE7JVnJk9QsRuf3w6yqaBcK+0tNMliPEWzGS75H6TNl/wYl2wSnfkySMUenBXlDqm7TYQrqocwGJofZQFdIpM87E03RQUtXxgTypAJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dKh7nmkaSdzB3ghyDF6RJecUyhtYIfwA0UmbLzDOakc=; b=ZDGBjQqXOJDR0oCmdUSWdKZQuH/QTHI4D+lvQLeKWVLHXhOGTyt9NaC2hNNOBRgpvhfozImz971Re3jem6RImD+OHrT/NJzJBSzsrZ/oCwlRS4ThR/6bGk2zGUfvgoTqViRZXwIqpDDKfu1ho2yelV+xYvTryMCh3xW6sJTszykYoY2ruFzY5uRuH2iTq2NAELg1nW8AKWK2LRKkqhAnlpReUPDrQejReAbgffVYxcZUOvK/ZSwzBktFVelhHZp1wkfy2AHXceKnZ7ibecXjpEFNCVLjNkpTRfp6/O3UGsD8n+FFh6mz+VD1QSFnEftBsarNc6RuV369LSCLHV0kGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:06:59 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:06:59 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 19/22] dt-bindings: PCI: Add StarFive JH7110 PCIe controller Date: Mon, 8 Jan 2024 19:06:09 +0800 Message-Id: <20240108110612.19048-20-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e1f906b-b202-44a1-1c5b-08dc1039ef79 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XzLqtqdbDCoyX1rNcIXxwXkXY7yROHBD+99QsywOcn/SX0bz9wUkVrLgcgoHoAwFeR0bmvyo74EIcj+8sNICs/ywxvj0Kr3MRUr8Kzyvf7qXvMz2kDbnD/wQYXT6g1cWXyym3hjG2Mi+cfe1CcDr7LCSeEDOcfUn/v2ANgqb6UXOeAFi7YKCx70RKtNDnbaKdgHsVr5WqU8W+sqjbocqdezV3fzFeWKXOGOoXW2vHhBl0EI7FoLEnKyzwSSztfkuYlDxDeMoqQogotk4nWEWAr990MbCvVExDjHj2W/TX6075Oes6WgLA1JIByh/piugfbTKxcNswDj1NIPAQf1wIKkuE/lkEHFjsWowPrb3dbItwEkrnlIVZ0EnpRP56IBa4NdfvLI/AuHHF1BrnvkFB2iBw356NjnO5Ck91qRH3iJP9t3cdis+K79IpM7ldO+1BbMbuKzYK+MaFc2MJKMLnbEj+KVU6HFd883yE0dUtbQ3UZkRTUcF590JKhedlybbqul9XH7a5h7lrhUa+wntu/AWh8M3kV1UjqgjgQijarRlWIZ8bnpNc2MZ7fqUO9mr7Q9vsswecSFsqCwCLhmMAA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(966005)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003)(449214003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ki1hL+J7yNZaf01k3sWXdWif66mlS7K8V7Bd+yDQ7SdCfJq2KK4i34r9Xc4PbyjpUYK4eVH10P+7iaHnUBU/5WS4E8XXUBe5ZsGjSeHqX8EEPO4i+oOPc/dCJPVMvVL7ic8yqQIqRif3Z8CdBTFu/WaAzipAQbGRUW7DOxl5rM83BN6jAk5Jm2QW13s0j8INDcCSWkBwbLntWyygpV35EsuZh8x3PA1bN1U1AtLTNRXqzQZE9vihTDUqaH7fHlK5haL4JjXcHsoIECvx5waf2ari34d0v/KnXUYVCiuEDvQoJtj/PpAwZjnY7PfucY2iZa1L/90oqsEUM5qRYvo5twQALtVUd/iC0eazUUyAzJ8o16o3w5v9Ch1fFPUtRysA0m7SeFEXUj0kr3fypj7GtitXbq2TfLqQm4n+SfTCvs50dJg/ie5IY1PaayrsrKHkH3gXf0dCyF9Wdj5GO1pnCX/8esEZpckZZqI9kc8Jbeh+TDvAu3I7sQqMtzONb8N5gl4m89eeFwiqMEncBXkn4N9cSETLMw7pnBTbJuGdSzAvjFJeamupBMkEyeeF6OInzr43N9ENhJtP6mM7HrLT0raZmcV5Wczdhi5l2UNlK3wn4ZYUNZDkWiyR6AuTEflF8U2kkcTn7xgXME8qH/PAMVHXnIpdEYe3XrOwxdT2ky8vbJI1lICch5uJim4NXMD0Q6GzrCbG8S/WGPt4FDKtITPKf6SMNK+SMtrjHf+DrLflEE8L5r2UpaR8jtAoXwkGAZC7yvnsghlhtZjs7Z/7oxQWi4xszvIFRvkcZS9JLFJM0U+Ea0QbjNwrr+umrfBbWJdoSZANxA7FcY/DBYq8NeWHrH/xl7bIPYKd54bzN01mbsbjRoW/Gmcc3XbDVzmDGmlIHiFKMqa+CFBA/Sl2nk6d7EEx8bXGCl9VKqvsAEJ4cgANvZ+rBxzGpZfrvb8wjoJZubmCpylOSwom2kZfThmSzpDm9BEJ69zo5Xmg6qhoJU7BwkfNn7TtCOlXiKFpg9LF7qzc0PyUGIXT3UxOxYV0zlyootHhk9nqWSFMAeA+/VYFj0nMAoDIx1ijvL+4hpXGmmNGTz8/ohVoLKv1AM6R4AjzvnC5X+OnwrZEm4FYQDvs7yCizDsMmpmSTWkt9ST7DkPHWq+dXQ4Z1gxeeVuQIz9giwcAev9aPSEOAbS7h9YJiLdyB2GyBJ3okKLV78kuwy/z7lu9NGn1XXal8JRcMn0w+vFSyw71JHgU0vu766z6QektlJgWXYPuXIxY35zABCbchbTLj7QyVGMn1JWmyRK3T408oYDF+xxApZdoNn1dH1j5lodrP8DlOc/VcEddSafCN8qauotwUdssuTP6r/pFgc5iVcqFgCkS78ia/pJ5jmkBtj5t5CoLEZDgNvcrQHz4ZPl2yxk2zo3qFYzTy0TqAVgRqQJtUhKpb6GchI9ygxMrF08labGR+zBf1Y5d82wia/EPYxvyqxJ85yfIW7/VOF/dgicKq1jt9ogls0CtC6/pi16q/p1wMs8Hm4yE4rqSSqfUYSY5GsaptoSXsNs2CIkdX3V9rqpc8UjArBeZTdaMWB4ICkcij8Zi86xQd14xTKd9GPY6u3g0qQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e1f906b-b202-44a1-1c5b-08dc1039ef79 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:06:59.8229 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EIE5b+2zyMPKhigZmY5k4hrWDjDnWGkjBFSm+FPr8q7U2YQgU+q2RYEEK0zp9SmVOwQ/2Jb+XImJzooqjVgPhwJprUkjfpX5en0vFnjT2AM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 Add StarFive JH7110 SoC PCIe controller dt-bindings. JH7110 using PLDA XpressRICH PCIe host controller IP. Signed-off-by: Minda Chen Reviewed-by: Hal Feng Reviewed-by: Conor Dooley Reviewed-by: Rob Herring --- .../bindings/pci/starfive,jh7110-pcie.yaml | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/starfive,jh7110-pcie.yaml diff --git a/Documentation/devicetree/bindings/pci/starfive,jh7110-pcie.yaml b/Documentation/devicetree/bindings/pci/starfive,jh7110-pcie.yaml new file mode 100644 index 000000000000..67151aaa3948 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/starfive,jh7110-pcie.yaml @@ -0,0 +1,120 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pci/starfive,jh7110-pcie.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: StarFive JH7110 PCIe host controller + +maintainers: + - Kevin Xie + +allOf: + - $ref: plda,xpressrich3-axi-common.yaml# + +properties: + compatible: + const: starfive,jh7110-pcie + + clocks: + items: + - description: NOC bus clock + - description: Transport layer clock + - description: AXI MST0 clock + - description: APB clock + + clock-names: + items: + - const: noc + - const: tl + - const: axi_mst0 + - const: apb + + resets: + items: + - description: AXI MST0 reset + - description: AXI SLAVE0 reset + - description: AXI SLAVE reset + - description: PCIE BRIDGE reset + - description: PCIE CORE reset + - description: PCIE APB reset + + reset-names: + items: + - const: mst0 + - const: slv0 + - const: slv + - const: brg + - const: core + - const: apb + + starfive,stg-syscon: + $ref: /schemas/types.yaml#/definitions/phandle-array + description: + The phandle to System Register Controller syscon node. + + perst-gpios: + description: GPIO controlled connection to PERST# signal + maxItems: 1 + + phys: + description: + Specified PHY is attached to PCIe controller. + maxItems: 1 + +required: + - clocks + - resets + - starfive,stg-syscon + +unevaluatedProperties: false + +examples: + - | + #include + soc { + #address-cells = <2>; + #size-cells = <2>; + + pcie@940000000 { + compatible = "starfive,jh7110-pcie"; + reg = <0x9 0x40000000 0x0 0x10000000>, + <0x0 0x2b000000 0x0 0x1000000>; + reg-names = "cfg", "apb"; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + device_type = "pci"; + ranges = <0x82000000 0x0 0x30000000 0x0 0x30000000 0x0 0x08000000>, + <0xc3000000 0x9 0x00000000 0x9 0x00000000 0x0 0x40000000>; + starfive,stg-syscon = <&stg_syscon>; + bus-range = <0x0 0xff>; + interrupt-parent = <&plic>; + interrupts = <56>; + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + interrupt-map = <0x0 0x0 0x0 0x1 &pcie_intc0 0x1>, + <0x0 0x0 0x0 0x2 &pcie_intc0 0x2>, + <0x0 0x0 0x0 0x3 &pcie_intc0 0x3>, + <0x0 0x0 0x0 0x4 &pcie_intc0 0x4>; + msi-controller; + clocks = <&syscrg 86>, + <&stgcrg 10>, + <&stgcrg 8>, + <&stgcrg 9>; + clock-names = "noc", "tl", "axi_mst0", "apb"; + resets = <&stgcrg 11>, + <&stgcrg 12>, + <&stgcrg 13>, + <&stgcrg 14>, + <&stgcrg 15>, + <&stgcrg 16>; + perst-gpios = <&gpios 26 GPIO_ACTIVE_LOW>; + phys = <&pciephy0>; + + pcie_intc0: interrupt-controller { + #address-cells = <0>; + #interrupt-cells = <1>; + interrupt-controller; + }; + }; + }; From patchwork Mon Jan 8 11:06:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 760885 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2050.outbound.protection.partner.outlook.cn [139.219.146.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14A9514ABA; Mon, 8 Jan 2024 11:10:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WYQBUgEQ0VRnJUy+VUYvbz/90fFMBMNyWkHRvWtcYMpAcDNeGQFLtUsKb2+A+gNCMYvw2OHzakhLwNYxIrAnZoLZHovQZEjlBGd/zqr1KIKzIOfbOAZJJfSCSk/eJh9sKe6G++TSr9MQSPeVR8VYprdL9eSpd0y2cw5xiR2tWXOnNnETX6v11Baql+QyGGJ6mtCRNR1SvAlRxSvJgyS4baRGVg8LqILcZpmlM2eQjqrhzvoV+bU3Jfn2aI973McbHbkmOZqJ7JDHIjEocmAbN/tUSuPjB53+ZN39z3vtcGblospRA5ryMSsseMGMEdOzJw8EIKo1V4ZmYIDcviG8iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rk7I7qrzmKI1l/EnFZ3e3e32keUVuOOU9pJsxnUoF98=; b=IfLLApPUaHJzEHxEhUji8xXP8icyHYIFPBvpkRo4c0bSzWvXYplczuyI5m/ElY94qcbztulVaDDwp5ySQgCkRdrELRYCfU7++9/hIT59nMPeRmOIoPPL6rkYaIOfSZQ0VhkNkERzA2L2u9f5glchWtdDLz2ryG09rMZfjWjWTAJGbmfEgoQjf9YSachdc2bnhDfZyaOQPDZ/t4fsSW8EhJBEYw7+d5Y5l8NcXmyaGXXVICM6iYNJYIkZhuTrnPd8AW1SltDoxBXKUPU1dr1Mvx3hUd87BBSmtdVXo8MzfV5MnEgyPfQE/mtRBaDhI2SMg+QvBh5MCG9qS1RMWfFWIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:07:01 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:07:01 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 20/22] PCI: Add PCIE_RESET_CONFIG_DEVICE_WAIT_MS waiting time value Date: Mon, 8 Jan 2024 19:06:10 +0800 Message-Id: <20240108110612.19048-21-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: c41f4676-138d-417d-e107-08dc1039f0a7 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yEpwQKZcTzsksPNn2w9h01LlRRzpEQd6tKMBfojLcLvrkCAYijI1gUENONjYtf5cFY1q4ptr6Lw+uAAThokUXkNCoqwxgjZsOx6e1L7Pdkp0CEODZxtUi0T6MHyxBbZcn9ZnXgYsnGxUx/M14ZANq3mXiC+Jmrkqb/6RfG4eR8ZNBRMd8/sxIaj+NcqLbU43hCLR5L/WQw4cM7MidGsuPIHKNWcFsjrl6AhMQnnBPoUcuqlDTL/y+Kj2Zr5dQWVb2KZjqsLvHSzaxqi0rBOHJLJMr8yvKIvDTurimrAUWOH7YYuSgb03Nu1Ij6W3q29SsjYk95F33SVS/yJathFBRbN0/fnFjwAB1763lo7XSX8Q4aatywxC6qTUgJxnNPbatf0WIG8HwuQoeA/PtyksRioVzAohiGltNwINKUdJ0pmlgAaPcoQq92r0jRu+HvuXFQVN8mQTjoyN8ywGt9mJXrbHQUjIrvye4tsDlnvJPH2O+RaxzmAaYVQA7CHOq7s6NZeRbY4JSBygXBvMznvBHIFvbtOe/6kAs6vM/dmxzoAstnvmFPxSrbVWs7UhiXNi X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(40180700001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: je5Z9Y5AyTlaN25nO+PfGa1ZdN51/92SBR/EWZXp+CSLzsQ+xZTKYLQQmjXbjjq/NSKQEEJMQonb707SRUwS8xabFwVwfkd0/y1Ngps50Mt6X+SdyMKzxjThYnzPuNnXmIETCvjpAjkvnpja86GjSwbwnFruSxe+UdZy5HBNpQ+IF1Ewulk4u7WAsm+FXJXk9ovKtnFkIAZae6nesuQCwi/z+GEtBP/UYeZhlqoq6Mqf6huFwMTI6j7ur0ubGzGvo31wLxmfUMls8sZjpo59/JZAEiT4NH21zSMMvZBMXOkEHaLiooW3KJC2HDazE6iemfOt0g4SOOI6mEt4aqV2Ndh4x5gngwyj1RRnf5MNxXgcaaJ3kAei1jR/qevSXYko5+BvChWCMq3T6Wu0mFOrzrwbduEY06IoLvcRgzH4ih6IMg//yZQZ8A0RgCeCkxaOZuxYYZcWUtRJhxrCrwWBybYxIM/W8C6AB1CCAIECPmqiGPNiJlTb6Nk+vd0LYUXCj2EfVUXYy38mClKPjq87JP0W8CmZvjGSat23R7RIxNv2SyVWwC3bjnTqmhKODEcerfWdbPvkpOE/QhDPB5GYdMMpJs5kNAMQKI4sYpStwbR5eHfRVg6zIB2ihZGfPBeuTpB7bnXRJ6ZhH2qGVKNoaGH7OkY2fPrq0cYCQUjcSct+aQCL3XFjGUXzO6lB/ba1MdPA8jbf9LO8fzF5hLLGNCmoDTjhWogujNoKqgjL0uRAHAiL8txUcwJTjuXT+jD9z5jWP3EiysKQ7O+sBoDr3IOTaR8kcN48Yc5ny8BUkJ3uE95Mnh5RLh3vEPmNvgPJh8oiD62wBtS3Mt481mjTK+uBTl496UfjqAvGwUFMy/kno90SgAFDf135J9u7L/nU9UjILZaYINGXQemIRY6Rh7gvvF4AohCw33+y8NYCllaCjS0R8SsyGDlHuV9wWK9q/eVJsZ89B/yD8kJvd00pArPqrKz923zH20z/96c2aKEUqBWn7c4rP5O2cNTSmNhJGaa0RGRxb2jp/rmm0e5uT1WufBKwpCzgXP85dS07P6dfbUpjtpHSnJZkL7/1uNQ2ZfwQRfNQGWzul+Q7RTgI1V9nG3mNt1LDi7tgAiLZRZqRfFMvbbwgi5nuDFoKtfugVqDMBeCh592FiF5yeJ9V+BQxdvC1hWJ9CDhDIQJwzbaoRcpXdNiv04FHmuoIzCC40Gphgtm7fHZdKY4zoLDB5jPoqSRwScMQMPdy5cHXTEM4DqfWdMnOD99w9D/YFshrfj4kckv2ztPMhc+BxeM7ojGgkMEm+BdUpfSOYt/TrIU6deRiWTC1kDz2oI1l6RvbwjSDsk/Dc25WhdCeti4/EVE+Z4MUoM82swpCm5o1tJYjAUk6OuQKtSZCSamL+RNBZi/CfWCE84xmy9ItZ+LHvNoNQvchc6Unyth9b8zI6QtU2LZxXjSAOWf/CK51a8CP2gmpkf7UfwtDVii7A4nFHcIccuA8TYIhqCh6s8uouaasr9xDCwzSB0hACAD06oPAZqq9vWa9qPMcEg+q0UsTiBgdVw0nEfwEHjVJdDb9xYTvX20WOKdVWOxzoXeNH8BquYWZgC59iihulk+BqeFSrQ== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: c41f4676-138d-417d-e107-08dc1039f0a7 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:07:01.7931 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 49OUmuFZt+eC2Q2JgObT9k4JA1LdP1QMbBs41tyIQH9bGqW9//cNJ2GvdOx9ZRW4m7JosuRVQzWgQOUxtg+59Ejce/91M7im7OiPNYhXx+s= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 From: Kevin Xie Add the PCIE_RESET_CONFIG_DEVICE_WAIT_MS macro to define the minimum waiting time between exit from a conventional reset and sending the first configuration request to the device. As described in PCI base specification r6.0, section 6.6.1 , there are two different use cases of the value: - "With a Downstream Port that does not support Link speeds greater than 5.0 GT/s, software must wait a minimum of 100 ms following exit from a Conventional Reset before sending a Configuration Request to the device immediately below that Port." - "With a Downstream Port that supports Link speeds greater than 5.0 GT/s, software must wait a minimum of 100 ms after Link training completes before sending a Configuration Request to the device immediately below that Port." Signed-off-by: Kevin Xie Reviewed-by: Mason Huo Acked-by: Bjorn Helgaas --- drivers/pci/pci.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index f43873049d52..6990146e14e3 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -22,6 +22,22 @@ */ #define PCIE_PME_TO_L2_TIMEOUT_US 10000 +/* + * As described in PCI base specification r6.0, section 6.6.1 , there are two different use cases of the value: + * + * - "With a Downstream Port that does not support Link speeds greater + * than 5.0 GT/s, software must wait a minimum of 100 ms following exit + * from a Conventional Reset before sending a Configuration Request to + * the device immediately below that Port." + * + * - "With a Downstream Port that supports Link speeds greater than + * 5.0 GT/s, software must wait a minimum of 100 ms after Link training + * completes before sending a Configuration Request to the device + * immediately below that Port." + */ +#define PCIE_RESET_CONFIG_DEVICE_WAIT_MS 100 + extern const unsigned char pcie_link_speed[]; extern bool pci_early_dump; From patchwork Mon Jan 8 11:06:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 760884 Received: from CHN02-SH0-obe.outbound.protection.partner.outlook.cn (mail-sh0chn02on2041.outbound.protection.partner.outlook.cn [139.219.146.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95BCA14A87; Mon, 8 Jan 2024 11:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=starfivetech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=starfivetech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PRAhfbcpNECD3bUEbKwaPktbW2YiCJMM9K8d/8VIZhYmDox/WOmpNk6vMtIMPGBxSPBizjQ92I3FNuI280dRWZDb+3VvWv8c+95cxrehy9dRbdV+RkCZxgJnoFJn/LoBCcJPrw/UTXH2EwQ0cVSsKNjqZTauLvhMxmf9KFcZRsidnoVbDGZBW5e45jO+ICxoZUBeix5pPswQCjfDKab9I5RTfYSb0dBqCPYgMP1B8k4DUl+SR9gd6qBCYWsfWvOqxF19itJOZQdyEwZHlVhXUIvzerOhagT3S93O510qMNICZoO8OrGxf/dWs6iBGYeGcnY/Wbpaug4K1ORQLYWBvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Au2/G4EBK5VuF6ZN6z3pGw3XNqUfkLw2F7N4CI+h8AQ=; b=eleojd4SQAm6nQrYI9fj2EOWoEQVH68riTf7caSnHDwVmlqtq6X3R4qGTcpEUZRIsvDTU7UknERDh5BPuM5BqL2sEfCcFseEtk8AJZ7fkWWZSV5Wbxp51v2+mAsJoFjz2pgdXP8KkgNMoLjjKRtkEpfq89P1uSl0xmAjJfRudBQLqy8AwmR+i+5ojzJZTNgJD/BSCdx2tTx1aAcJf0fwfkpipD/Y01Osj4PkE3+nRP/CnIGRBwB6DBG0tAOb7QxeA8ukI3zMUUsgtfz8ad3syizT9OXXOhHlDkMXy4GnQTgM3H7SuKrw16qd8Y0aiqqbLfbS22z1jxPjMm5h27Xg9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=starfivetech.com; dmarc=pass action=none header.from=starfivetech.com; dkim=pass header.d=starfivetech.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=starfivetech.com; Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) by SHXPR01MB0797.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:26::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.32; Mon, 8 Jan 2024 11:07:03 +0000 Received: from SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2]) by SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn ([fe80::e6aa:baea:fd8c:4cd2%7]) with mapi id 15.20.7135.032; Mon, 8 Jan 2024 11:07:03 +0000 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Daire McNamara , Emil Renner Berthing , Krzysztof Kozlowski Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-pci@vger.kernel.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v14 21/22] PCI: starfive: Add JH7110 PCIe controller Date: Mon, 8 Jan 2024 19:06:11 +0800 Message-Id: <20240108110612.19048-22-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240108110612.19048-1-minda.chen@starfivetech.com> References: <20240108110612.19048-1-minda.chen@starfivetech.com> X-ClientProxiedBy: ZQ0PR01CA0014.CHNPR01.prod.partner.outlook.cn (2406:e500:c550:5::19) To SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn (2406:e500:c311:25::15) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SHXPR01MB0863:EE_|SHXPR01MB0797:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f4f205f-f0db-41a6-a5d0-08dc1039f1d6 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c858YkTLYaFP8+ZpSzVtlcVfVOEWH4+v4Y4kDiaBsAq+1Q+jVojg3+9PjiIYAk+EzByU5TV/ZVwLDZx2Z3ZfCl3pU8doQCxLi4bT1QTd606ZC6q4nkHyli7yLzXRV+SVntr1XQeK8ghdZ3wZ4o8xKcGwrNNBJnIXVtu8ga1NQoghqnyw4jkUkWpqG4/hlCfn0cHKL4cZuZ5iHwX4RBov/LwSlOt4Jxf8gwLMU8y05vcq8zeMfSw3CkrCC95bu6JLnDmXmk/H08YKCT+R4IeI9Fcr9YhmedOynDsaAOJOeDjf/jLTynd3j7YT00ci2gf55xfVG8c89dnDAr8cBgoHwuRiitYGLRrXr4EnGIl+lwpeat0XyUKBL6aaPuCR4+/RSJAVbW7h0zQTZp2YpbhxIf04ZVN1ojWxVt54oBgfAhbXSciXSrCfPOdXaHQ6tn0FapOnq8tJxuWyD0Wpqe0vSgFxPZe9g5+Arn7qu1qiBzfNLh+52xoRBHi7MLaD85KC3rU3ekU7HjBS37F6KHxrJltXOmsUIVAeM62rvB731pENfqTfQ8MI09O+u5vehMA3 X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn; PTR:; CAT:NONE; SFS:(13230031)(366004)(396003)(136003)(39830400003)(346002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(8936002)(41320700001)(1076003)(107886003)(26005)(2616005)(83380400001)(44832011)(8676002)(4326008)(86362001)(52116002)(508600001)(66476007)(6666004)(66946007)(66556008)(54906003)(110136005)(40160700002)(38100700002)(38350700005)(2906002)(5660300002)(7416002)(30864003)(40180700001)(41300700001)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f9d/PqNr6u1GS5i5i9v1i1YluIhql9foIksNjLaef4ox6THGUel2NibtTWWtqJRM41f1/M/ve5brc7HAFlKjhmU/GoKpbv961T7PULCaMYXWkmFnuuMgd4nKF2i0Bv31bP6e+N+0cUDDunm27Bo6h0utY3SdS4N0eeeNKsQHw8642unk780GzTVuvRLRlBsf830++Y+EMylmx0q78BoMAThHOmYHdMhkj6NxP8Q/6MYacTI7VjELv5JZBZzDidyjILdAJENkBJkkFQEBApVBuU1txF+/kZPi2CYYidj7R1Rl1AijzYw0dSVFjcZchYqFF2hq7zCsOYdJwatgcLxF3e1aR0cJ/R+CUNK/o5b3hBM1yIc2c6rl/Xwb4IauOeRW0DUtXNxoZ0i11awrwm5ZY9ng5clvytOnbKkHsM/38jfokkPS062BzXpCHRVmqCHoLgyzc90Yvcz9UbiUjUt6aFmc4k548r8xyI3GpJ4TpSimZfmCGua0CfS/h5zDmHij0VM2k+DtIa9deVtUirInx66LJjJIysZ9rB/5wiuLX2pzpGuDRiaXqTBClJtGGkx7C1O5mSzbYr7crLi4sPgOy+pHirLrHpcWMqgVGeCgC9wrQX1BUH/FdQDf98EfD1JdWxEyBQoOqaFJmiB2V5IArWvzxOtFkI3gpjd8NHqLPDYLoNhZ0s+7scRu6t4xMJ8DoKjhoGEhW9Voeq9Yzv17vh4lOB3Ho3ahxw2XA2//J1vfDURyL/1dUejVJ2AaHDoAJ2DhEGTB8DA/fyoADHsDFNRsqnd4MP/6KTKfLOt4Zewt5iuBrd5AY8tbSa+ooGQSoh/OTZZLao2pXNoSDHck4m7hUstVgIqz8eWvD4z2npKwupNjgL5dlsGjvw+qmpVymJewIDTLnNHizgKiUP00wm2jYWI6pQJr6ImmWuvDqIK1IG297RwT3o2V14ESdSeMM9zJqIclmtiVnR7/zdo0SX7Hc5QFrbTaggff6IMHauG37HTckGDEHojGEZq+Z1IFf2QIhM6j9L5CFMGtN8sGhjqYarKKCdiyTRijDpzcXbTia4dNcP0kws0IXDFA8Pb0PulxkBpnYhMQ7Fz3oQqLdTegyfWCJ8X69Lb0jx9Dz8b1mQbJu/BCVKn31n6GR2dbOu7gKpT1Accvz312mnyW40giI7EhQrkv0J1y2ygxgfsPPksPLUh5qg62Js8SyrqmhUPC6laQrlGFaEP16SzTqs2mT8gHLlJOUfb+N9kXEIX5Ce5zjDU3m62bvStui9ulLQdaQ/2YavHbIMcFHvWFX2RO9w/6eSa1lwUCEfpo3unoe60+Vjse0OEsE2Ve0ZBa7ZwY+wrP51X65KjlHTkVl+AMlOjRitE/umy6q8qCMSxxhhWS/2CT9B+a/uz6PS6+H27NTdgQdT1SdZCPCvD1jjYnAPpyyXJNYqyU+BbWq2vIYhI+qPQtRc5PMIQr0wPjtnOjxGpVOLZza4kv/sIhFhNwE5PuhvqZkFNMXLjzAZyxlgOUb0jyQ4REBKRSdd9CIx+6ShhSH+bkWk0cLaLghMwvhSq84+jOUaQ4WcGfCxspAv6/oReTcuZPaUVi17UEG3Y7u4AfJwNJfeiUsdjuVw== X-OriginatorOrg: starfivetech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f4f205f-f0db-41a6-a5d0-08dc1039f1d6 X-MS-Exchange-CrossTenant-AuthSource: SHXPR01MB0863.CHNPR01.prod.partner.outlook.cn X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jan 2024 11:07:03.7864 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 06fe3fa3-1221-43d3-861b-5a4ee687a85c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: n3nS4MQwsH2PxpzNMKN0LmKlipVI97Y7Jhi8CQknj10K20sgqQ+xu7qf4n2jk5d26hgHS/pykXLk1xnxg6a/3aE99KYBZSS9kcM+4FJhTCE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SHXPR01MB0797 Add StarFive JH7110 SoC PCIe controller platform driver codes, JH7110 with PLDA host PCIe core. Signed-off-by: Minda Chen Co-developed-by: Kevin Xie Reviewed-by: Mason Huo --- MAINTAINERS | 7 + drivers/pci/controller/plda/Kconfig | 12 + drivers/pci/controller/plda/Makefile | 1 + drivers/pci/controller/plda/pcie-plda.h | 71 ++- drivers/pci/controller/plda/pcie-starfive.c | 473 ++++++++++++++++++++ 5 files changed, 563 insertions(+), 1 deletion(-) create mode 100644 drivers/pci/controller/plda/pcie-starfive.c diff --git a/MAINTAINERS b/MAINTAINERS index 730fe2d640a1..7fa339e6c25d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -16821,6 +16821,13 @@ S: Maintained F: Documentation/devicetree/bindings/pci/socionext,uniphier-pcie* F: drivers/pci/controller/dwc/pcie-uniphier* +PCIE DRIVER FOR STARFIVE JH71x0 +M: Kevin Xie +L: linux-pci@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/pci/starfive* +F: drivers/pci/controller/plda/pcie-starfive.c + PCIE DRIVER FOR ST SPEAR13XX M: Pratyush Anand L: linux-pci@vger.kernel.org diff --git a/drivers/pci/controller/plda/Kconfig b/drivers/pci/controller/plda/Kconfig index e54a82ee94f5..c0e14146d7e4 100644 --- a/drivers/pci/controller/plda/Kconfig +++ b/drivers/pci/controller/plda/Kconfig @@ -15,4 +15,16 @@ config PCIE_MICROCHIP_HOST Say Y here if you want kernel to support the Microchip AXI PCIe Host Bridge driver. +config PCIE_STARFIVE_HOST + tristate "StarFive PCIe host controller" + depends on PCI_MSI && OF + depends on ARCH_STARFIVE || COMPILE_TEST + select PCIE_PLDA_HOST + help + Say Y here if you want to support the StarFive PCIe controller in + host mode. StarFive PCIe controller uses PLDA PCIe core. + + If you choose to build this driver as module it will be dynamically + linked and module will be called pcie-starfive.ko. + endmenu diff --git a/drivers/pci/controller/plda/Makefile b/drivers/pci/controller/plda/Makefile index 4340ab007f44..0ac6851bed48 100644 --- a/drivers/pci/controller/plda/Makefile +++ b/drivers/pci/controller/plda/Makefile @@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_PCIE_PLDA_HOST) += pcie-plda-host.o obj-$(CONFIG_PCIE_MICROCHIP_HOST) += pcie-microchip-host.o +obj-$(CONFIG_PCIE_STARFIVE_HOST) += pcie-starfive.o diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index 7b69891700a4..04e385758a2f 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -10,10 +10,20 @@ #define PLDA_MAX_NUM_MSI_IRQS 32 /* PCIe Bridge Phy Regs */ +#define GEN_SETTINGS 0x80 +#define RP_ENABLE 1 +#define PCIE_PCI_IDS_DW1 0x9c +#define IDS_CLASS_CODE_SHIFT 16 +#define REVISION_ID_MASK GENMASK(7, 0) +#define CLASS_CODE_ID_MASK GENMASK(31, 8) #define PCIE_PCI_IRQ_DW0 0xa8 #define MSIX_CAP_MASK BIT(31) #define NUM_MSI_MSGS_MASK GENMASK(6, 4) #define NUM_MSI_MSGS_SHIFT 4 +#define PCI_MISC 0xb4 +#define PHY_FUNCTION_DIS BIT(15) +#define PCIE_WINROM 0xfc +#define PREF_MEM_WIN_64_SUPPORT BIT(3) #define IMASK_LOCAL 0x180 #define DMA_END_ENGINE_0_MASK 0x00000000u @@ -65,6 +75,8 @@ #define ISTATUS_HOST 0x18c #define IMSI_ADDR 0x190 #define ISTATUS_MSI 0x194 +#define PMSG_SUPPORT_RX 0x3f0 +#define PMSG_LTR_SUPPORT BIT(2) /* PCIe Master table init defines */ #define ATR0_PCIE_WIN0_SRCADDR_PARAM 0x600u @@ -86,6 +98,8 @@ #define PCIE_TX_RX_INTERFACE 0x00000000u #define PCIE_CONFIG_INTERFACE 0x00000001u +#define CONFIG_SPACE_ADDR_OFFSET 0x1000u + #define ATR_ENTRY_SIZE 32 enum plda_int_event { @@ -200,4 +214,59 @@ static inline void plda_set_default_msi(struct plda_msi *msi) msi->vector_phy = IMSI_ADDR; msi->num_vectors = PLDA_MAX_NUM_MSI_IRQS; } -#endif + +static inline void plda_pcie_enable_root_port(struct plda_pcie_rp *plda) +{ + u32 value; + + value = readl_relaxed(plda->bridge_addr + GEN_SETTINGS); + value |= RP_ENABLE; + writel_relaxed(value, plda->bridge_addr + GEN_SETTINGS); +} + +static inline void plda_pcie_set_standard_class(struct plda_pcie_rp *plda) +{ + u32 value; + + /* set class code and reserve revision id */ + value = readl_relaxed(plda->bridge_addr + PCIE_PCI_IDS_DW1); + value &= REVISION_ID_MASK; + value |= (PCI_CLASS_BRIDGE_PCI << IDS_CLASS_CODE_SHIFT); + writel_relaxed(value, plda->bridge_addr + PCIE_PCI_IDS_DW1); +} + +static inline void plda_pcie_set_pref_win_64bit(struct plda_pcie_rp *plda) +{ + u32 value; + + value = readl_relaxed(plda->bridge_addr + PCIE_WINROM); + value |= PREF_MEM_WIN_64_SUPPORT; + writel_relaxed(value, plda->bridge_addr + PCIE_WINROM); +} + +static inline void plda_pcie_disable_ltr(struct plda_pcie_rp *plda) +{ + u32 value; + + value = readl_relaxed(plda->bridge_addr + PMSG_SUPPORT_RX); + value &= ~PMSG_LTR_SUPPORT; + writel_relaxed(value, plda->bridge_addr + PMSG_SUPPORT_RX); +} + +static inline void plda_pcie_disable_func(struct plda_pcie_rp *plda) +{ + u32 value; + + value = readl_relaxed(plda->bridge_addr + PCI_MISC); + value |= PHY_FUNCTION_DIS; + writel_relaxed(value, plda->bridge_addr + PCI_MISC); +} + +static inline void plda_pcie_write_rc_bar(struct plda_pcie_rp *plda, u64 val) +{ + void __iomem *addr = plda->bridge_addr + CONFIG_SPACE_ADDR_OFFSET; + + writel_relaxed(lower_32_bits(val), addr + PCI_BASE_ADDRESS_0); + writel_relaxed(upper_32_bits(val), addr + PCI_BASE_ADDRESS_1); +} +#endif /* _PCIE_PLDA_H */ diff --git a/drivers/pci/controller/plda/pcie-starfive.c b/drivers/pci/controller/plda/pcie-starfive.c new file mode 100644 index 000000000000..9bb9f0e29565 --- /dev/null +++ b/drivers/pci/controller/plda/pcie-starfive.c @@ -0,0 +1,473 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * PCIe host controller driver for StarFive JH7110 Soc. + * + * Copyright (C) 2023 StarFive Technology Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../pci.h" + +#include "pcie-plda.h" + +#define PCIE_FUNC_NUM 4 + +/* system control */ +#define STG_SYSCON_PCIE0_BASE 0x48 +#define STG_SYSCON_PCIE1_BASE 0x1f8 + +#define STG_SYSCON_AR_OFFSET 0x78 +#define STG_SYSCON_AXI4_SLVL_AR_MASK GENMASK(22, 8) +#define STG_SYSCON_AXI4_SLVL_PHY_AR(x) FIELD_PREP(GENMASK(20, 17), x) +#define STG_SYSCON_AW_OFFSET 0x7c +#define STG_SYSCON_AXI4_SLVL_AW_MASK GENMASK(14, 0) +#define STG_SYSCON_AXI4_SLVL_PHY_AW(x) FIELD_PREP(GENMASK(12, 9), x) +#define STG_SYSCON_CLKREQ BIT(22) +#define STG_SYSCON_CKREF_SRC_MASK GENMASK(19, 18) +#define STG_SYSCON_RP_NEP_OFFSET 0xe8 +#define STG_SYSCON_K_RP_NEP BIT(8) +#define STG_SYSCON_LNKSTA_OFFSET 0x170 +#define DATA_LINK_ACTIVE BIT(5) + +/* Parameters for the waiting for link up routine */ +#define LINK_WAIT_MAX_RETRIES 10 +#define LINK_WAIT_USLEEP_MIN 90000 +#define LINK_WAIT_USLEEP_MAX 100000 + +struct starfive_jh7110_pcie { + struct plda_pcie_rp plda; + struct reset_control *resets; + struct clk_bulk_data *clks; + struct regmap *reg_syscon; + struct gpio_desc *power_gpio; + struct gpio_desc *reset_gpio; + struct phy *phy; + + unsigned int stg_pcie_base; + int num_clks; +}; + +/* + * The BAR0/1 of bridge should be hidden during enumeration to + * avoid the sizing and resource allocation by PCIe core. + */ +static bool starfive_pcie_hide_rc_bar(struct pci_bus *bus, unsigned int devfn, + int offset) +{ + if (pci_is_root_bus(bus) && !devfn && + (offset == PCI_BASE_ADDRESS_0 || offset == PCI_BASE_ADDRESS_1)) + return true; + + return false; +} + +static int starfive_pcie_config_write(struct pci_bus *bus, unsigned int devfn, + int where, int size, u32 value) +{ + if (starfive_pcie_hide_rc_bar(bus, devfn, where)) + return PCIBIOS_SUCCESSFUL; + + return pci_generic_config_write(bus, devfn, where, size, value); +} + +static int starfive_pcie_config_read(struct pci_bus *bus, unsigned int devfn, + int where, int size, u32 *value) +{ + if (starfive_pcie_hide_rc_bar(bus, devfn, where)) { + *value = 0; + return PCIBIOS_SUCCESSFUL; + } + + return pci_generic_config_read(bus, devfn, where, size, value); +} + +static int starfive_pcie_parse_dt(struct starfive_jh7110_pcie *pcie, + struct device *dev) +{ + int domain_nr; + + pcie->num_clks = devm_clk_bulk_get_all(dev, &pcie->clks); + if (pcie->num_clks < 0) + return dev_err_probe(dev, pcie->num_clks, + "failed to get pcie clocks\n"); + + pcie->resets = devm_reset_control_array_get_exclusive(dev); + if (IS_ERR(pcie->resets)) + return dev_err_probe(dev, PTR_ERR(pcie->resets), + "failed to get pcie resets"); + + pcie->reg_syscon = + syscon_regmap_lookup_by_phandle(dev->of_node, + "starfive,stg-syscon"); + + if (IS_ERR(pcie->reg_syscon)) + return dev_err_probe(dev, PTR_ERR(pcie->reg_syscon), + "failed to parse starfive,stg-syscon\n"); + + pcie->phy = devm_phy_optional_get(dev, NULL); + if (IS_ERR(pcie->phy)) + return dev_err_probe(dev, PTR_ERR(pcie->phy), + "failed to get pcie phy\n"); + + domain_nr = of_get_pci_domain_nr(dev->of_node); + + if (domain_nr < 0 || domain_nr > 1) + return dev_err_probe(dev, -ENODEV, + "failed to get valid pcie domain\n"); + + if (domain_nr == 0) + pcie->stg_pcie_base = STG_SYSCON_PCIE0_BASE; + else + pcie->stg_pcie_base = STG_SYSCON_PCIE1_BASE; + + pcie->reset_gpio = devm_gpiod_get_optional(dev, "perst", + GPIOD_OUT_HIGH); + if (IS_ERR(pcie->reset_gpio)) + return dev_err_probe(dev, PTR_ERR(pcie->reset_gpio), + "failed to get perst-gpio\n"); + + pcie->power_gpio = devm_gpiod_get_optional(dev, "enable", + GPIOD_OUT_LOW); + if (IS_ERR(pcie->power_gpio)) + return dev_err_probe(dev, PTR_ERR(pcie->power_gpio), + "failed to get power-gpio\n"); + + return 0; +} + +static struct pci_ops starfive_pcie_ops = { + .map_bus = plda_pcie_map_bus, + .read = starfive_pcie_config_read, + .write = starfive_pcie_config_write, +}; + +static int starfive_pcie_clk_rst_init(struct starfive_jh7110_pcie *pcie) +{ + struct device *dev = pcie->plda.dev; + int ret; + + ret = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); + if (ret) + return dev_err_probe(dev, ret, "failed to enable clocks\n"); + + ret = reset_control_deassert(pcie->resets); + if (ret) { + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); + dev_err_probe(dev, ret, "failed to deassert resets\n"); + } + + return ret; +} + +static void starfive_pcie_clk_rst_deinit(struct starfive_jh7110_pcie *pcie) +{ + reset_control_assert(pcie->resets); + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); +} + +static bool starfive_pcie_link_up(struct plda_pcie_rp *plda) +{ + struct starfive_jh7110_pcie *pcie = + container_of(plda, struct starfive_jh7110_pcie, plda); + int ret; + u32 stg_reg_val; + + ret = regmap_read(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_LNKSTA_OFFSET, + &stg_reg_val); + if (ret) { + dev_err(pcie->plda.dev, "failed to read link status\n"); + return false; + } + + return !!(stg_reg_val & DATA_LINK_ACTIVE); +} + +static int starfive_pcie_host_wait_for_link(struct starfive_jh7110_pcie *pcie) +{ + int retries; + + /* Check if the link is up or not */ + for (retries = 0; retries < LINK_WAIT_MAX_RETRIES; retries++) { + if (starfive_pcie_link_up(&pcie->plda)) { + dev_info(pcie->plda.dev, "port link up\n"); + return 0; + } + usleep_range(LINK_WAIT_USLEEP_MIN, LINK_WAIT_USLEEP_MAX); + } + + return -ETIMEDOUT; +} + +static int starfive_pcie_enable_phy(struct device *dev, + struct starfive_jh7110_pcie *pcie) +{ + int ret; + + if (!pcie->phy) + return 0; + + ret = phy_init(pcie->phy); + if (ret) + return dev_err_probe(dev, ret, + "failed to initialize pcie phy\n"); + + ret = phy_set_mode(pcie->phy, PHY_MODE_PCIE); + if (ret) { + dev_err_probe(dev, ret, "failed to set pcie mode\n"); + goto err_phy_on; + } + + ret = phy_power_on(pcie->phy); + if (ret) { + dev_err_probe(dev, ret, "failed to power on pcie phy\n"); + goto err_phy_on; + } + + return 0; + +err_phy_on: + phy_exit(pcie->phy); + return ret; +} + +static void starfive_pcie_disable_phy(struct starfive_jh7110_pcie *pcie) +{ + phy_power_off(pcie->phy); + phy_exit(pcie->phy); +} + +static void starfive_pcie_host_deinit(struct plda_pcie_rp *plda) +{ + struct starfive_jh7110_pcie *pcie = + container_of(plda, struct starfive_jh7110_pcie, plda); + + starfive_pcie_clk_rst_deinit(pcie); + if (pcie->power_gpio) + gpiod_set_value_cansleep(pcie->power_gpio, 0); + starfive_pcie_disable_phy(pcie); +} + +static int starfive_pcie_host_init(struct plda_pcie_rp *plda) +{ + struct starfive_jh7110_pcie *pcie = + container_of(plda, struct starfive_jh7110_pcie, plda); + struct device *dev = plda->dev; + int ret; + int i; + + ret = starfive_pcie_enable_phy(dev, pcie); + if (ret) + return ret; + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_RP_NEP_OFFSET, + STG_SYSCON_K_RP_NEP, STG_SYSCON_K_RP_NEP); + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AW_OFFSET, + STG_SYSCON_CKREF_SRC_MASK, + FIELD_PREP(STG_SYSCON_CKREF_SRC_MASK, 2)); + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AW_OFFSET, + STG_SYSCON_CLKREQ, STG_SYSCON_CLKREQ); + + ret = starfive_pcie_clk_rst_init(pcie); + if (ret) + return ret; + + if (pcie->power_gpio) + gpiod_set_value_cansleep(pcie->power_gpio, 1); + + if (pcie->reset_gpio) + gpiod_set_value_cansleep(pcie->reset_gpio, 1); + + /* Disable physical functions except #0 */ + for (i = 1; i < PCIE_FUNC_NUM; i++) { + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AR_OFFSET, + STG_SYSCON_AXI4_SLVL_AR_MASK, + STG_SYSCON_AXI4_SLVL_PHY_AR(i)); + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AW_OFFSET, + STG_SYSCON_AXI4_SLVL_AW_MASK, + STG_SYSCON_AXI4_SLVL_PHY_AW(i)); + + plda_pcie_disable_func(plda); + } + + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AR_OFFSET, + STG_SYSCON_AXI4_SLVL_AR_MASK, 0); + regmap_update_bits(pcie->reg_syscon, + pcie->stg_pcie_base + STG_SYSCON_AW_OFFSET, + STG_SYSCON_AXI4_SLVL_AW_MASK, 0); + + plda_pcie_enable_root_port(plda); + plda_pcie_write_rc_bar(plda, 0); + + /* PCIe PCI Standard Configuration Identification Settings. */ + plda_pcie_set_standard_class(plda); + + /* + * The LTR message forwarding of PCIe Message Reception was set by core + * as default, but the forward id & addr are also need to be reset. + * If we do not disable LTR message forwarding here, or set a legal + * forwarding address, the kernel will get stuck after the driver probe. + * To workaround, disable the LTR message forwarding support on + * PCIe Message Reception. + */ + plda_pcie_disable_ltr(plda); + + /* Prefetchable memory window 64-bit addressing support */ + plda_pcie_set_pref_win_64bit(plda); + + /* + * Ensure that PERST has been asserted for at least 100 ms, + * the sleep value is T_PVPERL from PCIe CEM spec r2.0 (Table 2-4) + */ + msleep(100); + if (pcie->reset_gpio) + gpiod_set_value_cansleep(pcie->reset_gpio, 0); + + /* + * With a Downstream Port (<=5GT/s), software must wait a minimum + * of 100ms following exit from a conventional reset before + * sending a configuration request to the device. + */ + msleep(PCIE_RESET_CONFIG_DEVICE_WAIT_MS); + + if (starfive_pcie_host_wait_for_link(pcie)) + dev_info(dev, "port link down\n"); + + return 0; +} + +static const struct plda_pcie_host_ops sf_host_ops = { + .host_init = starfive_pcie_host_init, + .host_deinit = starfive_pcie_host_deinit, +}; + +static const struct plda_event stf_pcie_event = { + .intx_event = EVENT_PM_MSI_INT_INTX, + .msi_event = EVENT_PM_MSI_INT_MSI +}; + +static int starfive_pcie_probe(struct platform_device *pdev) +{ + struct starfive_jh7110_pcie *pcie; + struct device *dev = &pdev->dev; + struct plda_pcie_rp *plda; + int ret; + + pcie = devm_kzalloc(dev, sizeof(*pcie), GFP_KERNEL); + if (!pcie) + return -ENOMEM; + + plda = &pcie->plda; + plda->dev = dev; + + ret = starfive_pcie_parse_dt(pcie, dev); + if (ret) + return ret; + + plda->host_ops = &sf_host_ops; + plda->num_events = PLDA_MAX_EVENT_NUM; + /* mask doorbell event */ + plda->events_bitmap = GENMASK(PLDA_INT_EVENT_NUM - 1, 0) + & ~BIT(PLDA_AXI_DOORBELL) + & ~BIT(PLDA_PCIE_DOORBELL); + plda->events_bitmap <<= PLDA_NUM_DMA_EVENTS; + ret = plda_pcie_host_init(&pcie->plda, &starfive_pcie_ops, + &stf_pcie_event); + if (ret) + return ret; + + pm_runtime_enable(&pdev->dev); + pm_runtime_get_sync(&pdev->dev); + platform_set_drvdata(pdev, pcie); + + return 0; +} + +static void starfive_pcie_remove(struct platform_device *pdev) +{ + struct starfive_jh7110_pcie *pcie = platform_get_drvdata(pdev); + + pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); + plda_pcie_host_deinit(&pcie->plda); + platform_set_drvdata(pdev, NULL); +} + +static int starfive_pcie_suspend_noirq(struct device *dev) +{ + struct starfive_jh7110_pcie *pcie = dev_get_drvdata(dev); + + clk_bulk_disable_unprepare(pcie->num_clks, pcie->clks); + starfive_pcie_disable_phy(pcie); + + return 0; +} + +static int starfive_pcie_resume_noirq(struct device *dev) +{ + struct starfive_jh7110_pcie *pcie = dev_get_drvdata(dev); + int ret; + + ret = starfive_pcie_enable_phy(dev, pcie); + if (ret) + return ret; + + ret = clk_bulk_prepare_enable(pcie->num_clks, pcie->clks); + if (ret) { + dev_err(dev, "failed to enable clocks\n"); + starfive_pcie_disable_phy(pcie); + return ret; + } + + return 0; +} + +static const struct dev_pm_ops starfive_pcie_pm_ops = { + NOIRQ_SYSTEM_SLEEP_PM_OPS(starfive_pcie_suspend_noirq, + starfive_pcie_resume_noirq) +}; + +static const struct of_device_id starfive_pcie_of_match[] = { + { .compatible = "starfive,jh7110-pcie", }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, starfive_pcie_of_match); + +static struct platform_driver starfive_pcie_driver = { + .driver = { + .name = "pcie-starfive", + .of_match_table = of_match_ptr(starfive_pcie_of_match), + .pm = pm_sleep_ptr(&starfive_pcie_pm_ops), + }, + .probe = starfive_pcie_probe, + .remove_new = starfive_pcie_remove, +}; +module_platform_driver(starfive_pcie_driver); + +MODULE_DESCRIPTION("StarFive JH7110 PCIe host driver"); +MODULE_LICENSE("GPL v2");