All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wasim Khan <wasim.khan@nxp.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 7/9] pci: layerscape: Move streamId allocation to common device tree fixup
Date: Fri, 15 Nov 2019 09:23:42 +0000	[thread overview]
Message-ID: <1573809796-1196-8-git-send-email-wasim.khan@nxp.com> (raw)
In-Reply-To: <1573809796-1196-1-git-send-email-wasim.khan@nxp.com>

Move streamId allocation to layerscape common device tree fixup.
Calculate streamId based on SoC variant.

Signed-off-by: Wasim Khan <wasim.khan@nxp.com>
---
Changes in v3:None

Changes in v2:None

 drivers/pci/pcie_layerscape_fixup.c        | 16 ++++------------
 drivers/pci/pcie_layerscape_fixup_common.c | 24 ++++++++++++++++++++++++
 drivers/pci/pcie_layerscape_fixup_common.h |  1 +
 drivers/pci/pcie_layerscape_gen4_fixup.c   | 18 ++++--------------
 4 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/drivers/pci/pcie_layerscape_fixup.c b/drivers/pci/pcie_layerscape_fixup.c
index 7635df7..b1d2470 100644
--- a/drivers/pci/pcie_layerscape_fixup.c
+++ b/drivers/pci/pcie_layerscape_fixup.c
@@ -31,17 +31,6 @@ static int ls_pcie_next_lut_index(struct ls_pcie *pcie)
 		return -ENOSPC;  /* LUT is full */
 }
 
-/* returns the next available streamid for pcie, -errno if failed */
-static int ls_pcie_next_streamid(void)
-{
-	static int next_stream_id = FSL_PEX_STREAM_ID_START;
-
-	if (next_stream_id > FSL_PEX_STREAM_ID_END)
-		return -EINVAL;
-
-	return next_stream_id++;
-}
-
 static void lut_writel(struct ls_pcie *pcie, unsigned int value,
 		       unsigned int offset)
 {
@@ -192,10 +181,13 @@ static void fdt_fixup_pcie_ls(void *blob)
 			bus = bus->parent;
 		pcie = dev_get_priv(bus);
 
-		streamid = ls_pcie_next_streamid();
+		streamid = pcie_next_streamid(pcie->stream_id_cur, pcie->idx);
+
 		if (streamid < 0) {
 			debug("ERROR: no stream ids free\n");
 			continue;
+		} else {
+			pcie->stream_id_cur++;
 		}
 
 		index = ls_pcie_next_lut_index(pcie);
diff --git a/drivers/pci/pcie_layerscape_fixup_common.c b/drivers/pci/pcie_layerscape_fixup_common.c
index b953952..3458ae8 100644
--- a/drivers/pci/pcie_layerscape_fixup_common.c
+++ b/drivers/pci/pcie_layerscape_fixup_common.c
@@ -27,3 +27,27 @@ void ft_pci_setup(void *blob, bd_t *bd)
 	ft_pci_setup_ls(blob, bd);
 #endif /* CONFIG_FSL_LAYERSCAPE */
 }
+
+#if defined(CONFIG_FSL_LAYERSCAPE)
+#ifdef CONFIG_ARCH_LX2160A
+/* returns the next available streamid for pcie, -errno if failed */
+int pcie_next_streamid(int currentid, int idx)
+{
+	if (currentid > FSL_PEX_STREAM_ID_END)
+		return -EINVAL;
+
+	return currentid | ((idx + 1) << 11);
+}
+#else
+/* returns the next available streamid for pcie, -errno if failed */
+int pcie_next_streamid(int currentid, int idx)
+{
+	static int next_stream_id = FSL_PEX_STREAM_ID_START;
+
+	if (next_stream_id > FSL_PEX_STREAM_ID_END)
+		return -EINVAL;
+
+	return next_stream_id++;
+}
+#endif
+#endif /* CONFIG_FSL_LAYERSCAPE */
diff --git a/drivers/pci/pcie_layerscape_fixup_common.h b/drivers/pci/pcie_layerscape_fixup_common.h
index 5640406..e747396 100644
--- a/drivers/pci/pcie_layerscape_fixup_common.h
+++ b/drivers/pci/pcie_layerscape_fixup_common.h
@@ -22,5 +22,6 @@ static void ft_pci_setup_ls_gen4(void *blob, bd_t *bd)
 }
 #endif
 #endif /* CONFIG_FSL_LAYERSCAPE */
+int pcie_next_streamid(int currentid, int id);
 
 #endif //_PCIE_LAYERSCAPE_FIXUP_COMMON_H_
diff --git a/drivers/pci/pcie_layerscape_gen4_fixup.c b/drivers/pci/pcie_layerscape_gen4_fixup.c
index 480d242..28cfc9a 100644
--- a/drivers/pci/pcie_layerscape_gen4_fixup.c
+++ b/drivers/pci/pcie_layerscape_gen4_fixup.c
@@ -33,19 +33,6 @@ static int ls_pcie_g4_next_lut_index(struct ls_pcie_g4 *pcie)
 	return -ENOSPC;  /* LUT is full */
 }
 
-/* returns the next available streamid for pcie, -errno if failed */
-static int ls_pcie_g4_next_streamid(struct ls_pcie_g4 *pcie)
-{
-	int stream_id = pcie->stream_id_cur;
-
-	if (stream_id > FSL_PEX_STREAM_ID_END)
-		return -EINVAL;
-
-	pcie->stream_id_cur++;
-
-	return stream_id | ((pcie->idx + 1) << 11);
-}
-
 /*
  * Program a single LUT entry
  */
@@ -162,10 +149,13 @@ static void fdt_fixup_pcie_ls_gen4(void *blob)
 			bus = bus->parent;
 		pcie = dev_get_priv(bus);
 
-		streamid = ls_pcie_g4_next_streamid(pcie);
+		streamid = pcie_next_streamid(pcie->stream_id_cur, pcie->idx);
+
 		if (streamid < 0) {
 			debug("ERROR: no stream ids free\n");
 			continue;
+		} else {
+			pcie->stream_id_cur++;
 		}
 
 		index = ls_pcie_g4_next_lut_index(pcie);
-- 
2.7.4

  parent reply	other threads:[~2019-11-15  9:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15  9:23 [U-Boot] [PATCH v3 0/9] Enablement of PCIe controller for lx2160a rev2 Wasim Khan
2019-11-15  9:23 ` [U-Boot] [PATCH v3 1/9] drivers/pci : enable pcie_layerscape code " Wasim Khan
2019-11-15  9:23 ` [U-Boot] [PATCH v3 2/9] pci: layerscape: Add stream_id_cur field to ls_pcie structure Wasim Khan
2019-11-15  9:23 ` [U-Boot] [PATCH v3 3/9] pci: layerscape: Suffix API names with _ls Wasim Khan
2019-11-15  9:23 ` [U-Boot] [PATCH v3 4/9] pci: layerscape_gen4: Suffix API names with _ls_gen4 Wasim Khan
2019-11-15  9:23 ` [U-Boot] [PATCH v3 5/9] armv8: lx2160a: Add FSL_PEX_STREAM_ID_END for LX2160A Wasim Khan
2019-11-15  9:23 ` [U-Boot] [PATCH v3 6/9] pci: layerscape: Common device tree fixup for NXP SoCs Wasim Khan
2019-12-26 10:54   ` Priyanka Jain
2019-11-15  9:23 ` Wasim Khan [this message]
2019-11-15  9:23 ` [U-Boot] [PATCH v3 8/9] pci: layerscape: device tree fixup based on SoC and Version Wasim Khan
2019-11-15  9:23 ` [U-Boot] [PATCH v3 9/9] configs: lx2160a: enable CONFIG_OF_BOARD_FIXUP for SECURE_BOOT defconfig Wasim Khan

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=1573809796-1196-8-git-send-email-wasim.khan@nxp.com \
    --to=wasim.khan@nxp.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.