From patchwork Sun Aug 11 02:23:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thippeswamy Havalige X-Patchwork-Id: 13759667 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2AA96C3DA7F for ; Sun, 11 Aug 2024 02:26:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=e2rc8i2Mj2nzPHOkyHFlQiZPHFWOIXenaKXby9DdNoQ=; b=RCvBRSZR2Vh5+nGsDD7+mWFxdJ /GHb79umr7/Hi/nRZzYmCaue4ddNCMdw9aHnPG3GLVmOELsn+oFa/f+G3KXEJv5UUzEI40cZIbHPA TMcs8Zphj/0jWVVP1j03+zSV6lg9nZvAooGknv+cY4zm59KFKWLnOPYcDwS9VkrwJt2EnxP0YTXXW 7LF3ZQC2g985g0yD/Ch3ixwIWRx8AyLL3k0WxBXVXi1kpSZ8SUk9AkpEOl0H9K24h0NWXssow77WZ SoEtIJox6XYMat1vyvCZz9bn1litC42DyXw8Csxhl/Zujkn6UoP38H/RwzO3HWaY8b6vB2Xmjf1UH heRXE+XA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1scyHL-0000000Esqo-2XLE; Sun, 11 Aug 2024 02:25:55 +0000 Received: from mail-dm6nam10on2060b.outbound.protection.outlook.com ([2a01:111:f400:7e88::60b] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1scyFl-0000000EsSC-42Hk for linux-arm-kernel@lists.infradead.org; Sun, 11 Aug 2024 02:24:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mWoe+nDjDv//1uyIPnKzEDG6O5830elLCwgZasLNlBZpi7JmTOxaQfimBAHKT2gwlQWmKEL5CmQCWNfwvdUWCV56aL1VA/U5HeGrQF/79gPQn/05si/Ttx3x4J6/QBrQ4gPQ+8QKsXlYCbkrcUILfGGVdfNe+vjRCLCnEAWhaFeJ957oYtPgCKm34djVOtAL5V4ApLL/jwZLzbGbe3VBB14LZtSyq9YW28iHJhizb6oVptXdg9t85cCFAOEQs2jRwstZNa+Md8VAzD7FZOcK+/OlbVDnxF8ft7ODElJViXzdf8fjyPAMovTC+enxbpp+D3IryMEaLr/sSHij/T8cSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=e2rc8i2Mj2nzPHOkyHFlQiZPHFWOIXenaKXby9DdNoQ=; b=kEEs05TCZQHwGn5wAyb3kMcf2WgMgrkAl/QKet+GvUk+nM8qZU+gshKPeBO3gF7E5WTQs2WIO1NemMn+gX2KjWCtX3iwrEBCaBSvSFmGVVuB/F/mGNKWdDo7JYS6EwheFj1qm/G13Z4/G2Lphy0KTpSYHR4FKNndlqgP4Dtv7FJBJR2/MoS4OpsOFRtoYdUTumEKXKRVhblTQZ7ro3KnfYK4I9g1XYgjAhTVWM8i8BV2CEwb9mZPjcBx9cdeR5jft4JoxllRdt0HdMXvbUr92g+DeM7xx2RB62w1BSji5h7to0cOTRcTX9VzChOot5Kiub9ObuU7QuCYucbPRdIW+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=google.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e2rc8i2Mj2nzPHOkyHFlQiZPHFWOIXenaKXby9DdNoQ=; b=Z+bub5rzmklwYV6BHYft+0jezFEzaPryL6C/q3gQQUyWADDqeyKfFgU8hd1EXZGphglggcPTzuVSTksbuXgrKU7wpm0U3g4UmjgO2OnPRV8XGM2zP7kFDyDn4TT58Rj6/y1YIlysUpuVbUfohlzzwRz/ptJrDVq6ZCXIRIQyC2g= Received: from BN9PR03CA0410.namprd03.prod.outlook.com (2603:10b6:408:111::25) by DM6PR12MB4218.namprd12.prod.outlook.com (2603:10b6:5:21b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.19; Sun, 11 Aug 2024 02:24:07 +0000 Received: from BL6PEPF00020E66.namprd04.prod.outlook.com (2603:10b6:408:111:cafe::ef) by BN9PR03CA0410.outlook.office365.com (2603:10b6:408:111::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.33 via Frontend Transport; Sun, 11 Aug 2024 02:24:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF00020E66.mail.protection.outlook.com (10.167.249.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7849.8 via Frontend Transport; Sun, 11 Aug 2024 02:24:07 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 10 Aug 2024 21:24:06 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 10 Aug 2024 21:24:06 -0500 Received: from xhdbharatku40.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Sat, 10 Aug 2024 21:24:03 -0500 From: Thippeswamy Havalige To: , , , , , , , , CC: , , Thippeswamy Havalige Subject: [PATCH v4 2/2] PCI: xilinx-xdma: Add Xilinx QDMA Root Port driver Date: Sun, 11 Aug 2024 07:53:45 +0530 Message-ID: <20240811022345.1178203-3-thippesw@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240811022345.1178203-1-thippesw@amd.com> References: <20240811022345.1178203-1-thippesw@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: thippesw@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF00020E66:EE_|DM6PR12MB4218:EE_ X-MS-Office365-Filtering-Correlation-Id: a6ad6829-c137-427d-03a5-08dcb9acad42 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|82310400026|36860700013|1800799024; X-Microsoft-Antispam-Message-Info: YTZrOodY04CF9R/b2STY8GsUf+oFpMH5rkMyd59wq2gA7trv0dGLEr5nVO4I2LnNhes5vU+AMer18a1QWi9FL/TxtSEPp/KrSBgWWDsg0VAuCBExg5nAVmji0A/wUS6Hc44hFheZ8nmW4hX2G0xJKzcFdy32mUSJSHD5RIJnj2qaT5ZOxrJ/Lp721zDG2MAjNZe3Jw0EgGoxHuhT6GhMk9DgHpeZj744ahPUOe7N6+qQ0FGmOc1iwvyTgY0F6RkI701e8T0sax0fR6RHm4JmIrcu/LhsYyrVFMt32oMTGZBkoD/mPRBR9sBxR1H49EgNEr9XDUymrvGAXSvMF5Q2andL9qjiib7rNuCXZW0BkuqDKhmW7UyxCGir90kWhk7EaW7nN1L8DiNipN9EfkEM20H7sYbuAOeLrfdsBhSfUIgtKWqYfeYe5P0aO1p0wNnK+a6PViGwFogmpFHkug0G/ttnDroVeVvIAksLoFbCr2jTKnJlwlblUJ4+2ZVM/abLHCJFwZh8EprsHWJtf/mLshqWhhhYXjW16QR72qpK536BOtYPmk/DNk4hcw6+It1ZkR6FjqchehycuCzPtRr22kQkGKylrT0FGF1v1srh+oRpsCLhw1ZBeKSw0rMWtgIYYwsXhgG43aw+CaMEdQ+uZJNXUos1Rp5ALY478YfHu9ApJijKlv5fi3lLSlL/rMEJ6ZEgwi3u6H81NlnCKHHYI2bt4hm18LaZt3kPWURybGpFY1HQ7qhETEnL/QY9ODZXqui1olCXuHsZsFeZ7NkmaSEWbqKCiwxjvIOi456YKWlQAWaPe+yQ5CsTNCCPRPjVV5wjeiZCHJbiDrkfH6ly00fqqMsW55CT2h4mF+b4GkH1ul7Pqo6/PprFWFJjCjTgf8BvVBHoH0oiwhxhPDzqwXAhxtE/eHU4etffMtYnLztaKLRjjLpbceNHUtL1ZQF9qaww/RybTYIOKwJJK0VqgpR5be4A3ANVl7Ev75XqkvAwAmHRXN5UTS27EOPHZJPB6YItcQx0CLssCcKZO0cBbf6JyAiV+PIVfOxE4hcEjR+kGPMThFa/rHW8nJH07wrA6ViTtx3v84KsD3CDfLwe4kJAmMGoly2tuRWkXHuA0ioK1OfiVgNp1i35GLIn9BJirBvXlAbQR28+iVRCguGtYQk8/lnp2iWhu38DaKeuahhtC/eUFWrCeSBu2kb+F1FxiWq+U2bomrZUCueDySI1EI3WUhaU7e8Ydv7QpL9Xlgm8IiF+NU/bM4UBs5TswZxqTh6sdwZn0OFV46opcLXxbVKzrav4GvkReWLU0wmQYqsVLxRjgrCinMPzrVpsmJclrUKI2QCLTo8ZKRo/mL0S9hgkqpQu4BBkuaB/aDw6674JsmFeTkO9KtYpbCxSlbF5MMXNb7rLNJ+YPyN+QUsKng== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(376014)(7416014)(82310400026)(36860700013)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2024 02:24:07.1440 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a6ad6829-c137-427d-03a5-08dcb9acad42 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF00020E66.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4218 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240810_192418_028450_119A8A9A X-CRM114-Status: GOOD ( 19.04 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for Xilinx QDMA Soft IP core as Root Port. The Versal Prime devices support QDMA soft IP module in programmable logic. The integrated QDMA Soft IP block has integrated bridge function that can act as PCIe Root Port. Signed-off-by: Thippeswamy Havalige Reviewed-by: Manivannan Sadhasivam --- drivers/pci/controller/pcie-xilinx-dma-pl.c | 54 ++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) --- changes in v4: - none changes in v3: - Modify macro value to lower case. - Change return type based QDMA compatible. changes in v2: - Add description for struct pl_dma_pcie --- diff --git a/drivers/pci/controller/pcie-xilinx-dma-pl.c b/drivers/pci/controller/pcie-xilinx-dma-pl.c index 5be5dfd8398f..1ea6a1d265bb 100644 --- a/drivers/pci/controller/pcie-xilinx-dma-pl.c +++ b/drivers/pci/controller/pcie-xilinx-dma-pl.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../pci.h" #include "pcie-xilinx-common.h" @@ -71,10 +72,24 @@ /* Phy Status/Control Register definitions */ #define XILINX_PCIE_DMA_REG_PSCR_LNKUP BIT(11) +#define QDMA_BRIDGE_BASE_OFF 0xcd8 /* Number of MSI IRQs */ #define XILINX_NUM_MSI_IRQS 64 +enum xilinx_pl_dma_version { + XDMA, + QDMA, +}; + +/** + * struct xilinx_pl_dma_variant - PL DMA PCIe variant information + * @version: DMA version + */ +struct xilinx_pl_dma_variant { + enum xilinx_pl_dma_version version; +}; + struct xilinx_msi { struct irq_domain *msi_domain; unsigned long *bitmap; @@ -88,6 +103,7 @@ struct xilinx_msi { * struct pl_dma_pcie - PCIe port information * @dev: Device pointer * @reg_base: IO Mapped Register Base + * @cfg_base: IO Mapped Configuration Base * @irq: Interrupt number * @cfg: Holds mappings of config space window * @phys_reg_base: Physical address of reg base @@ -97,10 +113,12 @@ struct xilinx_msi { * @msi: MSI information * @intx_irq: INTx error interrupt number * @lock: Lock protecting shared register access + * @variant: PL DMA PCIe version check pointer */ struct pl_dma_pcie { struct device *dev; void __iomem *reg_base; + void __iomem *cfg_base; int irq; struct pci_config_window *cfg; phys_addr_t phys_reg_base; @@ -110,16 +128,23 @@ struct pl_dma_pcie { struct xilinx_msi msi; int intx_irq; raw_spinlock_t lock; + const struct xilinx_pl_dma_variant *variant; }; static inline u32 pcie_read(struct pl_dma_pcie *port, u32 reg) { + if (port->variant->version == QDMA) + return readl(port->reg_base + reg + QDMA_BRIDGE_BASE_OFF); + return readl(port->reg_base + reg); } static inline void pcie_write(struct pl_dma_pcie *port, u32 val, u32 reg) { - writel(val, port->reg_base + reg); + if (port->variant->version == QDMA) + writel(val, port->reg_base + reg + QDMA_BRIDGE_BASE_OFF); + else + writel(val, port->reg_base + reg); } static inline bool xilinx_pl_dma_pcie_link_up(struct pl_dma_pcie *port) @@ -173,6 +198,9 @@ static void __iomem *xilinx_pl_dma_pcie_map_bus(struct pci_bus *bus, if (!xilinx_pl_dma_pcie_valid_device(bus, devfn)) return NULL; + if (port->variant->version == QDMA) + return port->cfg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where); + return port->reg_base + PCIE_ECAM_OFFSET(bus->number, devfn, where); } @@ -731,6 +759,15 @@ static int xilinx_pl_dma_pcie_parse_dt(struct pl_dma_pcie *port, port->reg_base = port->cfg->win; + if (port->variant->version == QDMA) { + port->cfg_base = port->cfg->win; + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "breg"); + port->reg_base = devm_ioremap_resource(dev, res); + if (IS_ERR(port->reg_base)) + return PTR_ERR(port->reg_base); + port->phys_reg_base = res->start; + } + err = xilinx_request_msi_irq(port); if (err) { pci_ecam_free(port->cfg); @@ -760,6 +797,8 @@ static int xilinx_pl_dma_pcie_probe(struct platform_device *pdev) if (!bus) return -ENODEV; + port->variant = of_device_get_match_data(dev); + err = xilinx_pl_dma_pcie_parse_dt(port, bus->res); if (err) { dev_err(dev, "Parsing DT failed\n"); @@ -791,9 +830,22 @@ static int xilinx_pl_dma_pcie_probe(struct platform_device *pdev) return err; } +static const struct xilinx_pl_dma_variant xdma_host = { + .version = XDMA, +}; + +static const struct xilinx_pl_dma_variant qdma_host = { + .version = QDMA, +}; + static const struct of_device_id xilinx_pl_dma_pcie_of_match[] = { { .compatible = "xlnx,xdma-host-3.00", + .data = &xdma_host, + }, + { + .compatible = "xlnx,qdma-host-3.00", + .data = &qdma_host, }, {} };