U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: david regan <dregan@broadcom.com>
To: u-boot <u-boot@lists.denx.de>,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Michael Trimarchi <michael@amarulasolutions.com>,
	Anand Gore <anand.gore@broadcom.com>,
	William Zhang <william.zhang@broadcom.com>,
	Kursad Oney <kursad.oney@broadcom.com>,
	Philippe Reynes <philippe.reynes@softathome.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Florian Fainelli <florian.fainelli@broadcom.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Kamal Dasu <kamal.dasu@broadcom.com>,
	David Regan <dregan@broadcom.com>, David Regan <dregan@mail.com>,
	Tom Rini <trini@konsulko.com>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: [PATCH 3/4] mtd: rawnand: brcmnand: Add BCMBCA read data bus interface
Date: Wed,  6 Nov 2024 13:03:47 -0800	[thread overview]
Message-ID: <20241106210348.218507-4-dregan@broadcom.com> (raw)
In-Reply-To: <20241106210348.218507-1-dregan@broadcom.com>

The BCMBCA broadband SoC integrates the NAND controller differently than
STB, iProc and other SoCs.  It has different endianness for NAND cache
data.

Add a SoC read data bus shim for BCMBCA to meet the specific SoC need
and performance improvement using the optimized memcpy function on NAND
cache memory.

This is a port of the upstream Linux patch to U-Boot.

https://lore.kernel.org/linux-mtd/20240223034758.13753-12-william.zhang@broadcom.com/

Signed-off-by: david regan <dregan@broadcom.com>
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 17 ++---------------
 drivers/mtd/nand/raw/brcmnand/brcmnand.h | 18 ++++++++++++++++++
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 749553c9df90..6eb2fa65cc1e 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -1640,7 +1640,6 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command,
 			native_cmd == CMD_PARAMETER_CHANGE_COL) {
 		/* Copy flash cache word-wise */
 		u32 *flash_cache = (u32 *)ctrl->flash_cache;
-		int i;
 
 		brcmnand_soc_data_bus_prepare(ctrl->soc, true);
 
@@ -1648,20 +1647,8 @@ static void brcmnand_cmdfunc(struct mtd_info *mtd, unsigned command,
 		 * Must cache the FLASH_CACHE now, since changes in
 		 * SECTOR_SIZE_1K may invalidate it
 		 */
-		for (i = 0; i < FC_WORDS; i++) {
-			u32 fc;
-
-			fc = brcmnand_read_fc(ctrl, i);
-
-			/*
-			 * Flash cache is big endian for parameter pages, at
-			 * least on STB SoCs
-			 */
-			if (ctrl->parameter_page_big_endian)
-				flash_cache[i] = be32_to_cpu(fc);
-			else
-				flash_cache[i] = le32_to_cpu(fc);
-		}
+		brcmnand_soc_data_bus_read(ctrl->soc, ctrl->nand_fc, flash_cache,
+					   FC_WORDS);
 
 		brcmnand_soc_data_bus_unprepare(ctrl->soc, true);
 
diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.h b/drivers/mtd/nand/raw/brcmnand/brcmnand.h
index 3a1d60471361..72f18c3a86f7 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.h
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.h
@@ -30,6 +30,24 @@ static inline void brcmnand_soc_data_bus_unprepare(struct brcmnand_soc *soc,
 		soc->prepare_data_bus(soc, false, is_param);
 }
 
+static inline void brcmnand_soc_data_bus_read(struct brcmnand_soc *soc,
+					      void __iomem *flash_cache, u32 *buffer,
+					      int fc_words)
+{
+	int i;
+
+	if (soc->read_data_bus)
+		soc->read_data_bus(soc, flash_cache, buffer, fc_words);
+	else {
+		/*
+		 * Flash cache is big endian for parameter pages, at
+		 * least on STB SoCs
+		 */
+		for (i = 0; i < fc_words; i++, buffer++)
+			*buffer = be32_to_cpu(__raw_readl(flash_cache + i * 4));
+	}
+}
+
 static inline u32 brcmnand_readl(void __iomem *addr)
 {
 	/*
-- 
2.37.3


  parent reply	other threads:[~2024-11-07  0:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-06 21:03 [PATCH 0/4] Broadcom BCMBCA nand updates david regan
2024-11-06 21:03 ` [PATCH 1/4] mtd: nand: brcmnand: remove device specific nand driver files david regan
2024-11-07 14:09   ` Linus Walleij
2024-11-06 21:03 ` [PATCH 2/4] arm: dts: Use upstream dts david regan
2024-11-07 14:10   ` Linus Walleij
2024-11-07 14:58   ` Sumit Garg
2024-11-06 21:03 ` david regan [this message]
2024-11-07 14:16   ` [PATCH 3/4] mtd: rawnand: brcmnand: Add BCMBCA read data bus interface Linus Walleij
2024-11-08  2:22     ` William Zhang
2024-11-08  8:19       ` Michael Nazzareno Trimarchi
2024-11-06 21:03 ` [PATCH 4/4] mtd: rawnand: brcmnand: update log level messages david regan
2024-11-07 14:17   ` Linus Walleij

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=20241106210348.218507-4-dregan@broadcom.com \
    --to=dregan@broadcom.com \
    --cc=anand.gore@broadcom.com \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=dregan@mail.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=kamal.dasu@broadcom.com \
    --cc=kursad.oney@broadcom.com \
    --cc=linus.walleij@linaro.org \
    --cc=michael@amarulasolutions.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=philippe.reynes@softathome.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=william.zhang@broadcom.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