summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Marangi <[email protected]>2025-04-07 22:01:55 +0200
committerTom Rini <[email protected]>2025-04-16 19:57:35 -0600
commit5ff602a3519b2efd9aa84b3bb364f782349e7fa2 (patch)
tree83232859c9b853c82fa348c073e85a0e23906cbb
parentef45b9c395f92d9239d6c363b1f5a89f6a53f2e6 (diff)
spinand: call SPI setup_for_spinand if supported
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 <[email protected]>
-rw-r--r--drivers/mtd/nand/spi/core.c18
1 files changed, 18 insertions, 0 deletions
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;