U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Tom Rini <trini@konsulko.com>, Peng Fan <peng.fan@nxp.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Michael Trimarchi <michael@amarulasolutions.com>,
	Frieder Schrempf <frieder.schrempf@kontron.de>,
	Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Christian Marangi <ansuelsmth@gmail.com>,
	Bruce Suen <bruce_suen@163.com>,
	u-boot@lists.denx.de
Subject: [PATCH v2 11/14] spinand: call SPI setup_for_spinand if supported
Date: Mon,  7 Apr 2025 22:01:55 +0200	[thread overview]
Message-ID: <20250407200208.25594-12-ansuelsmth@gmail.com> (raw)
In-Reply-To: <20250407200208.25594-1-ansuelsmth@gmail.com>

Call SPI setup_for_spinand() if supported and defined to configure the
SPI slave for the attached NAND. This is needed to configure the SPI
with the NAND page size and spare size for correct configuration of the
device.

Call it as soon as the NAND is detected to correctly handle SPI
controller with select_op_variant detection.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/mtd/nand/spi/core.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
index f5ddfbf4b83..3a1e7e18736 100644
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -941,6 +941,19 @@ spinand_select_op_variant(struct spinand_device *spinand,
 	return NULL;
 }
 
+static int spinand_setup_slave(struct spinand_device *spinand,
+			       const struct spinand_info *spinand_info)
+{
+	struct spi_slave *slave = spinand->slave;
+	struct udevice *bus = slave->dev->parent;
+	struct dm_spi_ops *ops = spi_get_ops(bus);
+
+	if (!ops->setup_for_spinand)
+		return 0;
+
+	return ops->setup_for_spinand(slave, spinand_info);
+}
+
 /**
  * spinand_match_and_init() - Try to find a match between a device ID and an
  *			      entry in a spinand_info table
@@ -964,6 +977,7 @@ int spinand_match_and_init(struct spinand_device *spinand,
 	u8 *id = spinand->id.data;
 	struct nand_device *nand = spinand_to_nand(spinand);
 	unsigned int i;
+	int ret;
 
 	for (i = 0; i < table_size; i++) {
 		const struct spinand_info *info = &table[i];
@@ -975,6 +989,10 @@ int spinand_match_and_init(struct spinand_device *spinand,
 		if (memcmp(id + 1, info->devid.id, info->devid.len))
 			continue;
 
+		ret = spinand_setup_slave(spinand, info);
+		if (ret)
+			return ret;
+
 		nand->memorg = table[i].memorg;
 		nand->eccreq = table[i].eccreq;
 		spinand->eccinfo = table[i].eccinfo;
-- 
2.48.1


  parent reply	other threads:[~2025-04-07 20:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07 20:01 [PATCH v2 00/14] airoha: add support spi/mmc/ethernet Christian Marangi
2025-04-07 20:01 ` [PATCH v2 01/14] arch: arm: dts: an7581: add Chip SCU node Christian Marangi
2025-04-07 20:01 ` [PATCH v2 02/14] net: airoha: Add Airoha Ethernet driver Christian Marangi
2025-04-07 20:01 ` [PATCH v2 03/14] airoha: Add Ethernet config to defconfig Christian Marangi
2025-04-07 20:01 ` [PATCH v2 04/14] arch: arm: dts: an7581: Add Ethernet nodes Christian Marangi
2025-04-07 20:01 ` [PATCH v2 05/14] mmc: mediatek: permit to also build for Airoha arch Christian Marangi
2025-04-07 20:01 ` [PATCH v2 06/14] arch: arm: dts: an7581: Add eMMC nodes Christian Marangi
2025-04-07 20:01 ` [PATCH v2 07/14] airoha: Add eMMC config to defconfig Christian Marangi
2025-04-07 20:01 ` [PATCH v2 08/14] regmap: Add regmap_set/clear_bits shorthands Christian Marangi
2025-04-07 20:01 ` [PATCH v2 09/14] spi: drop unneeded spi.h header include from spinand.h Christian Marangi
2025-04-07 20:01 ` [PATCH v2 10/14] spi: Introduce setup_for_spinand() Christian Marangi
2025-04-07 20:01 ` Christian Marangi [this message]
2025-04-07 20:01 ` [PATCH v2 12/14] spi: airoha: Add Airoha SPI NAND driver Christian Marangi
2025-04-07 20:01 ` [PATCH v2 13/14] arm: dts: an7581: Add SNAND node Christian Marangi
2025-04-07 20:01 ` [PATCH v2 14/14] configs: airoha: an7581_evb: Enable Airoha SNFI SPI config Christian Marangi
2025-04-17 17:06 ` [PATCH v2 00/14] airoha: add support spi/mmc/ethernet Tom Rini

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=20250407200208.25594-12-ansuelsmth@gmail.com \
    --to=ansuelsmth@gmail.com \
    --cc=bruce_suen@163.com \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=frieder.schrempf@kontron.de \
    --cc=jagan@amarulasolutions.com \
    --cc=jh80.chung@samsung.com \
    --cc=joe.hershberger@ni.com \
    --cc=michael@amarulasolutions.com \
    --cc=peng.fan@nxp.com \
    --cc=rfried.dev@gmail.com \
    --cc=trini@konsulko.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox