linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: laurentiu.tudor@nxp.com
To: devicetree@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Cc: roy.pledge@nxp.com, madalin.bucur@nxp.com, davem@davemloft.net,
	shawnguo@kernel.org, leoyang.li@nxp.com, robin.murphy@arm.com,
	bharat.bhushan@nxp.com, Laurentiu Tudor <laurentiu.tudor@nxp.com>
Subject: [PATCH v2 09/22] fsl/fman: backup and restore ICID registers
Date: Wed, 26 Sep 2018 16:22:34 +0300	[thread overview]
Message-ID: <20180926132247.10971-10-laurentiu.tudor@nxp.com> (raw)
In-Reply-To: <20180926132247.10971-1-laurentiu.tudor@nxp.com>

From: Laurentiu Tudor <laurentiu.tudor@nxp.com>

During probing, FMAN is reset thus losing all its register
settings. Backup port ICID registers before reset and restore
them after, similarly to how it's done on powerpc / PAMU based
platforms.
This also has the side effect of disabling the old code path
(liodn backup/restore handling) that obviously make no sense
in the context of SMMU on ARMs.

Signed-off-by: Laurentiu Tudor <laurentiu.tudor@nxp.com>
---
 drivers/net/ethernet/freescale/fman/fman.c | 35 +++++++++++++++++++++-
 drivers/net/ethernet/freescale/fman/fman.h |  4 +++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman.c b/drivers/net/ethernet/freescale/fman/fman.c
index c415ac67cb7b..8f9136892d98 100644
--- a/drivers/net/ethernet/freescale/fman/fman.c
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -629,6 +629,7 @@ static void set_port_order_restoration(struct fman_fpm_regs __iomem *fpm_rg,
 	iowrite32be(tmp, &fpm_rg->fmfp_prc);
 }
 
+#ifdef CONFIG_PPC
 static void set_port_liodn(struct fman *fman, u8 port_id,
 			   u32 liodn_base, u32 liodn_ofst)
 {
@@ -646,6 +647,27 @@ static void set_port_liodn(struct fman *fman, u8 port_id,
 	iowrite32be(tmp, &fman->dma_regs->fmdmplr[port_id / 2]);
 	iowrite32be(liodn_ofst, &fman->bmi_regs->fmbm_spliodn[port_id - 1]);
 }
+#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
+static void save_restore_port_icids(struct fman *fman, bool save)
+{
+	int port_idxes[] = {
+		0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc,
+		0xd, 0xe, 0xf, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+		0x10, 0x11, 0x30, 0x31
+	};
+	int idx, i;
+
+	for (i = 0; i < ARRAY_SIZE(port_idxes); i++) {
+		idx = port_idxes[i];
+		if (save)
+			fman->sp_icids[idx] =
+				ioread32be(&fman->bmi_regs->fmbm_spliodn[idx]);
+		else
+			iowrite32be(fman->sp_icids[idx],
+				    &fman->bmi_regs->fmbm_spliodn[idx]);
+	}
+}
+#endif
 
 static void enable_rams_ecc(struct fman_fpm_regs __iomem *fpm_rg)
 {
@@ -1914,7 +1936,10 @@ static int fman_reset(struct fman *fman)
 static int fman_init(struct fman *fman)
 {
 	struct fman_cfg *cfg = NULL;
-	int err = 0, i, count;
+	int err = 0, count;
+#ifdef CONFIG_PPC
+	int i;
+#endif
 
 	if (is_init_done(fman->cfg))
 		return -EINVAL;
@@ -1934,6 +1959,7 @@ static int fman_init(struct fman *fman)
 	memset_io((void __iomem *)(fman->base_addr + CGP_OFFSET), 0,
 		  fman->state->fm_port_num_of_cg);
 
+#ifdef CONFIG_PPC
 	/* Save LIODN info before FMan reset
 	 * Skipping non-existent port 0 (i = 1)
 	 */
@@ -1953,6 +1979,9 @@ static int fman_init(struct fman *fman)
 		}
 		fman->liodn_base[i] = liodn_base;
 	}
+#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
+	save_restore_port_icids(fman, true);
+#endif
 
 	err = fman_reset(fman);
 	if (err)
@@ -2181,8 +2210,12 @@ int fman_set_port_params(struct fman *fman,
 	if (err)
 		goto return_err;
 
+#ifdef CONFIG_PPC
 	set_port_liodn(fman, port_id, fman->liodn_base[port_id],
 		       fman->liodn_offset[port_id]);
+#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
+	save_restore_port_icids(fman, false);
+#endif
 
 	if (fman->state->rev_info.major < 6)
 		set_port_order_restoration(fman->fpm_regs, port_id);
diff --git a/drivers/net/ethernet/freescale/fman/fman.h b/drivers/net/ethernet/freescale/fman/fman.h
index 935c317fa696..19f20fa58053 100644
--- a/drivers/net/ethernet/freescale/fman/fman.h
+++ b/drivers/net/ethernet/freescale/fman/fman.h
@@ -346,8 +346,12 @@ struct fman {
 	unsigned long fifo_offset;
 	size_t fifo_size;
 
+#ifdef CONFIG_PPC
 	u32 liodn_base[64];
 	u32 liodn_offset[64];
+#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64)
+	u32 sp_icids[64];
+#endif
 
 	struct fman_dts_params dts_params;
 };
-- 
2.17.1


  parent reply	other threads:[~2018-09-26 13:25 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 13:22 [PATCH v2 00/22] SMMU enablement for NXP LS1043A and LS1046A laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 01/22] soc/fsl/qman: fixup liodns only on ppc targets laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 02/22] soc/fsl/bman: map FBPR area in the iommu laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 03/22] soc/fsl/qman: map FQD and PFDR areas " laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 04/22] soc/fsl/qman-portal: map CENA area " laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 05/22] soc/fsl/qbman: add APIs to retrieve the probing status laurentiu.tudor
2018-09-27 20:37   ` Li Yang
2018-09-26 13:22 ` [PATCH v2 06/22] soc/fsl/qman_portals: defer probe after qman's probe laurentiu.tudor
2018-09-27 20:37   ` Li Yang
2018-09-26 13:22 ` [PATCH v2 07/22] soc/fsl/bman_portals: defer probe after bman's probe laurentiu.tudor
2018-09-27 20:40   ` Li Yang
2018-09-26 13:22 ` [PATCH v2 08/22] soc/fsl/qbman_portals: add APIs to retrieve the probing status laurentiu.tudor
2018-09-27 20:03   ` Li Yang
2018-10-03 10:50     ` Laurentiu Tudor
2018-10-03 12:27       ` Robin Murphy
2018-09-26 13:22 ` laurentiu.tudor [this message]
2018-09-26 13:22 ` [PATCH v2 10/22] fsl/fman: add API to get the device behind a fman port laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 11/22] dpaa_eth: defer probing after qbman laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 12/22] dpaa_eth: base dma mappings on the fman rx port laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 13/22] dpaa_eth: fix iova handling for contiguous frames laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 14/22] dpaa_eth: fix iova handling for sg frames laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 15/22] dpaa_eth: fix SG frame cleanup laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 16/22] arm64: dts: ls1046a: add smmu node laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 17/22] arm64: dts: ls1043a: " laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 18/22] arm64: dts: ls104xa: set mask to drop TBU ID from StreamID laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 19/22] arm64: dts: ls104x: add missing dma ranges property laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 20/22] arm64: dts: ls104x: add iommu-map to pci controllers laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 21/22] arm64: dts: ls104x: make dma-coherent global to the SoC laurentiu.tudor
2018-09-26 13:22 ` [PATCH v2 22/22] arm64: dts: ls104x: use a pseudo-bus to constrain usb dma size laurentiu.tudor
2018-09-27 13:39 ` [PATCH v2 00/22] SMMU enablement for NXP LS1043A and LS1046A Madalin-cristian Bucur

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=20180926132247.10971-10-laurentiu.tudor@nxp.com \
    --to=laurentiu.tudor@nxp.com \
    --cc=bharat.bhushan@nxp.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=leoyang.li@nxp.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=madalin.bucur@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=roy.pledge@nxp.com \
    --cc=shawnguo@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).