mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Elad Nachman <enachman@marvell.com>
To: <thomas.petazzoni@bootlin.com>, <bhelgaas@google.com>,
	<lpieralisi@kernel.org>, <robh@kernel.org>, <kw@linux.com>,
	<krzysztof.kozlowski+dt@linaro.org>, <linux-pci@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: Elad Nachman <enachman@marvell.com>
Subject: [PATCH v3 7/7] PCI: dwc: Introduce region limit from DT
Date: Thu, 23 Feb 2023 20:05:31 +0200	[thread overview]
Message-ID: <20230223180531.15148-8-enachman@marvell.com> (raw)
In-Reply-To: <20230223180531.15148-1-enachman@marvell.com>

From: Elad Nachman <enachman@marvell.com>

Allow dts override of region limit for SOCs with older Synopsis
Designware PCIe IP but with greater than 32-bit address range support,
such as the Armada 7020/7040/8040 family of SOCs by Marvell,
when the DT file places the PCIe window above the 4GB region.
The Synopsis Designware PCIe IP in these SOCs is too old to specify the
highest memory location supported by the PCIe, but practically supports
such locations. Allow these locations to be specified in the DT file.
DT property is called num-regionmask , and can range between 33 and 64.

Signed-off-by: Elad Nachman <enachman@marvell.com>
---
 drivers/pci/controller/dwc/pcie-designware.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c
index 53a16b8b6ac2..429594e853ae 100644
--- a/drivers/pci/controller/dwc/pcie-designware.c
+++ b/drivers/pci/controller/dwc/pcie-designware.c
@@ -401,7 +401,6 @@ static void dw_pcie_writel_atu(struct dw_pcie *pci, u32 dir, u32 index,
 	int ret;
 
 	base = dw_pcie_select_atu(pci, dir, index);
-
 	if (pci->ops && pci->ops->write_dbi) {
 		pci->ops->write_dbi(pci, base, reg, 4, val);
 		return;
@@ -735,10 +734,13 @@ static void dw_pcie_link_set_max_speed(struct dw_pcie *pci, u32 link_gen)
 void dw_pcie_iatu_detect(struct dw_pcie *pci)
 {
 	int max_region, ob, ib;
-	u32 val, min, dir;
+	u32 val, min, dir, ret, num_region_maskbits;
 	u64 max;
+	struct device *dev = pci->dev;
+	struct device_node *np = dev->of_node;
 
 	val = dw_pcie_readl_dbi(pci, PCIE_ATU_VIEWPORT);
+
 	if (val == 0xFFFFFFFF) {
 		dw_pcie_cap_set(pci, IATU_UNROLL);
 
@@ -781,7 +783,12 @@ void dw_pcie_iatu_detect(struct dw_pcie *pci)
 		dw_pcie_writel_atu(pci, dir, 0, PCIE_ATU_UPPER_LIMIT, 0xFFFFFFFF);
 		max = dw_pcie_readl_atu(pci, dir, 0, PCIE_ATU_UPPER_LIMIT);
 	} else {
-		max = 0;
+		/* Allow dts override of region limit for older IP with above 32-bit support: */
+		ret = of_property_read_u32(np, "num-regionmask", &num_region_maskbits);
+		if (!ret && num_region_maskbits > 32)
+			max = GENMASK(num_region_maskbits - 33, 0);
+		else
+			max = 0;
 	}
 
 	pci->num_ob_windows = ob;
-- 
2.17.1


  parent reply	other threads:[~2023-02-23 18:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-23 18:05 [PATCH v3 0/7] PCI: dwc: Add support for Marvell AC5 SoC Elad Nachman
2023-02-23 18:05 ` [PATCH v3 1/7] dt-bindings: PCI: armada8k: Add compatible string for " Elad Nachman
2023-02-23 18:05 ` [PATCH v3 2/7] PCI: armada8k: Add AC5 SoC support Elad Nachman
2023-02-23 18:05 ` [PATCH v3 3/7] PCI: armada8k: Add MSI support for AC5 SoC Elad Nachman
2023-02-23 18:05 ` [PATCH v3 4/7] dt-bindings: PCI: dwc: add DMA, region mask bits Elad Nachman
2023-02-23 18:12   ` Krzysztof Kozlowski
2023-02-27 18:55   ` Rob Herring
2023-02-23 18:05 ` [PATCH v3 5/7] PCI: dwc: support AC5 Legacy PCIe interrupts Elad Nachman
2023-02-23 19:48   ` Bjorn Helgaas
2023-02-23 18:05 ` [PATCH v3 6/7] PCI: dwc: Introduce Configurable DMA mask Elad Nachman
2023-02-23 18:14   ` Krzysztof Kozlowski
2023-02-23 18:05 ` Elad Nachman [this message]
2023-02-23 18:16   ` [PATCH v3 7/7] PCI: dwc: Introduce region limit from DT Krzysztof Kozlowski
2023-02-23 19:42 ` [PATCH v3 0/7] PCI: dwc: Add support for Marvell AC5 SoC Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230223180531.15148-8-enachman@marvell.com \
    --to=enachman@marvell.com \
    --cc=bhelgaas@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kw@linux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=robh@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®