From patchwork Mon Sep 5 19:23:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12966485 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 DBC58ECAAD3 for ; Mon, 5 Sep 2022 19:46:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id: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=gsALJJgs+AbO0P+5Dyf+GLz5Cyho7l6YKE99yu+Skgc=; b=4fZgADaJF+8rmn MS2iULoCdHcU//I8CMruXwBc/Y/XSGfEtDWXPZ5XqTasxAze1tHLID3alr2HdxIrRkDwqX83iKMMA FoepIdHmUJ3aXYpZC2T0QVi4i6ee1odymkvi3SrhAVAtgwkmQlVNbGYAbzx8oED/uGyUBj20B8Fx9 KKNEEmBVrxJQyetsLFwLV2UerBgWBXAtYHGpEeUb9SmS11Qi9uhnAd7awcy1X4q5XbcmBP3scBYzc 2pnb2ht2khbZOwDYzkfWr/1RdPs6niS/imvx5CVS5xMogVz3mpfgjL1EWe0FZmshddACkYkxvsA4V WZ+Q8B4QL6SLUjbtvxBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVI1o-009a2a-Q6; Mon, 05 Sep 2022 19:45:05 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVHie-009Fag-Eq for linux-arm-kernel@lists.infradead.org; Mon, 05 Sep 2022 19:25:18 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E2E226146E; Mon, 5 Sep 2022 19:25:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C43CC4347C; Mon, 5 Sep 2022 19:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662405915; bh=QcA9P29C0sz6J16OH80UZGgfyJ/0RAYN/Ol8iwII854=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sjsNdaOV3UxRhrTFbFDnG29YL3sykxiwO5qs3BoCGx10zUv1TMRkllWW3N5nRGByK 6zVBAABQKIYsjuv+J/VRXmrq7OT74BubwtWywIky66KS6Mri3d1HW6WpkjuViIkCTz 0oOvEzcxNLXsvKeWTpQkS3p95jWQKAgvLG+C2lrSglZ30AtOZ418cWj4pMQBAEqLQQ Ci1fc/+26Y8zBhtTLqTPZn00xvTT7l5vmnvzhcO/Q/dz77Q2nPGQQgyr4x+gaZWv5h /R5C7zW4JYwecJ3xSCYGYHoKsfa3LQ7ikgo47X1sVUcxurJN0i97vVqmeNVBFfr/0E BxN3eewDuVkQA== Received: by pali.im (Postfix) id 1204F2145; Mon, 5 Sep 2022 21:25:13 +0200 (CEST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Bjorn Helgaas , Lorenzo Pieralisi , Rob Herring , Krzysztof Kozlowski , Andrew Lunn , Sebastian Hesselbarth , Gregory Clement , Russell King , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Thomas Petazzoni , Mauri Sandberg Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 2/7] bus: mvebu-mbus: add configuration space aperture Date: Mon, 5 Sep 2022 21:23:05 +0200 Message-Id: <20220905192310.22786-3-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220905192310.22786-1-pali@kernel.org> References: <20220718202843.6766-1-maukka@ext.kapsi.fi> <20220905192310.22786-1-pali@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220905_122516_663485_8EC19471 X-CRM114-Status: GOOD ( 18.15 ) 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 From: Mauri Sandberg Adds a new resource for describing PCI configuration space and accessor for it. Signed-off-by: Mauri Sandberg Signed-off-by: Pali Rohár --- drivers/bus/mvebu-mbus.c | 26 +++++++++++++++++++++++--- include/linux/mbus.h | 1 + 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c index 5dc2669432ba..9702c6ddbbe6 100644 --- a/drivers/bus/mvebu-mbus.c +++ b/drivers/bus/mvebu-mbus.c @@ -139,6 +139,7 @@ struct mvebu_mbus_state { struct dentry *debugfs_devs; struct resource pcie_mem_aperture; struct resource pcie_io_aperture; + struct resource pcie_cfg_aperture; const struct mvebu_mbus_soc_data *soc; int hw_io_coherency; @@ -950,6 +951,14 @@ void mvebu_mbus_get_pcie_io_aperture(struct resource *res) } EXPORT_SYMBOL_GPL(mvebu_mbus_get_pcie_io_aperture); +void mvebu_mbus_get_pcie_cfg_aperture(struct resource *res) +{ + if (!res) + return; + *res = mbus_state.pcie_cfg_aperture; +} +EXPORT_SYMBOL_GPL(mvebu_mbus_get_pcie_cfg_aperture); + int mvebu_mbus_get_dram_win_info(phys_addr_t phyaddr, u8 *target, u8 *attr) { const struct mbus_dram_target_info *dram; @@ -1277,7 +1286,8 @@ static int __init mbus_dt_setup(struct mvebu_mbus_state *mbus, static void __init mvebu_mbus_get_pcie_resources(struct device_node *np, struct resource *mem, - struct resource *io) + struct resource *io, + struct resource *cfg) { u32 reg[2]; int ret; @@ -1290,6 +1300,8 @@ static void __init mvebu_mbus_get_pcie_resources(struct device_node *np, mem->end = -1; memset(io, 0, sizeof(struct resource)); io->end = -1; + memset(cfg, 0, sizeof(struct resource)); + cfg->end = -1; ret = of_property_read_u32_array(np, "pcie-mem-aperture", reg, ARRAY_SIZE(reg)); if (!ret) { @@ -1304,6 +1316,13 @@ static void __init mvebu_mbus_get_pcie_resources(struct device_node *np, io->end = io->start + reg[1] - 1; io->flags = IORESOURCE_IO; } + + ret = of_property_read_u32_array(np, "pcie-cfg-aperture", reg, ARRAY_SIZE(reg)); + if (!ret) { + cfg->start = reg[0]; + cfg->end = cfg->start + reg[1] - 1; + cfg->flags = IORESOURCE_MEM; + } } int __init mvebu_mbus_dt_init(bool is_coherent) @@ -1359,9 +1378,10 @@ int __init mvebu_mbus_dt_init(bool is_coherent) mbus_state.hw_io_coherency = is_coherent; - /* Get optional pcie-{mem,io}-aperture properties */ + /* Get optional pcie-{mem,io,cfg}-aperture properties */ mvebu_mbus_get_pcie_resources(np, &mbus_state.pcie_mem_aperture, - &mbus_state.pcie_io_aperture); + &mbus_state.pcie_io_aperture, + &mbus_state.pcie_cfg_aperture); ret = mvebu_mbus_common_init(&mbus_state, mbuswins_res.start, diff --git a/include/linux/mbus.h b/include/linux/mbus.h index 4773145246ed..525b56ddd0c2 100644 --- a/include/linux/mbus.h +++ b/include/linux/mbus.h @@ -86,6 +86,7 @@ static inline int mvebu_mbus_get_io_win_info(phys_addr_t phyaddr, u32 *size, int mvebu_mbus_save_cpu_target(u32 __iomem *store_addr); void mvebu_mbus_get_pcie_mem_aperture(struct resource *res); void mvebu_mbus_get_pcie_io_aperture(struct resource *res); +void mvebu_mbus_get_pcie_cfg_aperture(struct resource *res); int mvebu_mbus_get_dram_win_info(phys_addr_t phyaddr, u8 *target, u8 *attr); int mvebu_mbus_add_window_remap_by_id(unsigned int target, unsigned int attribute,