]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
mtd: spinand: Add support for setting plane select bits
authorCheng Ming Lin <chengminglin@mxic.com.tw>
Tue, 30 Sep 2025 00:20:57 +0000 (03:20 +0300)
committerMichael Trimarchi <michael@amarulasolutions.com>
Sun, 5 Oct 2025 18:26:08 +0000 (20:26 +0200)
Add two flags for inserting the Plane Select bit into the column
address during the write_to_cache and the read_from_cache operation.

Add the SPINAND_HAS_PROG_PLANE_SELECT_BIT flag for serial NAND flash
that require inserting the Plane Select bit into the column address
during the write_to_cache operation.

Add the SPINAND_HAS_READ_PLANE_SELECT_BIT flag for serial NAND flash
that require inserting the Plane Select bit into the column address
during the read_from_cache operation.

This is a port of linux commit
ca229bdbef29 (mtd: spinand: Add support for setting plane select bits)

Signed-off-by: Cheng Ming Lin <chengminglin@mxic.com.tw>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20240909092643.2434479-2-linchengming884@gmail.com
Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu> # U-Boot port
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
drivers/mtd/nand/spi/core.c
include/linux/mtd/spinand.h

index 2a2ab664c2c65da1478699d0f044f2248e6e9abc..2083e3673cce697953c48cfa56560e5a6a8dcfe0 100644 (file)
@@ -382,6 +382,9 @@ static int spinand_read_from_cache_op(struct spinand_device *spinand,
        else
                rdesc = spinand->dirmaps[req->pos.plane].rdesc_ecc;
 
+       if (spinand->flags & SPINAND_HAS_READ_PLANE_SELECT_BIT)
+               column |= req->pos.plane << fls(nanddev_page_size(nand));
+
        while (nbytes) {
                ret = spi_mem_dirmap_read(rdesc, column, nbytes, buf);
                if (ret < 0)
@@ -456,6 +459,9 @@ static int spinand_write_to_cache_op(struct spinand_device *spinand,
        else
                wdesc = spinand->dirmaps[req->pos.plane].wdesc_ecc;
 
+       if (spinand->flags & SPINAND_HAS_PROG_PLANE_SELECT_BIT)
+               column |= req->pos.plane << fls(nanddev_page_size(nand));
+
        while (nbytes) {
                ret = spi_mem_dirmap_write(wdesc, column, nbytes, buf);
                if (ret < 0)
index 011861dd05992757e167bd914c83308cc7a020c7..fb3a2e5d909059c6139b27d6ba02e197c71484ae 100644 (file)
@@ -316,8 +316,10 @@ struct spinand_ecc_info {
        const struct mtd_ooblayout_ops *ooblayout;
 };
 
-#define SPINAND_HAS_QE_BIT             BIT(0)
-#define SPINAND_HAS_CR_FEAT_BIT                BIT(1)
+#define SPINAND_HAS_QE_BIT                     BIT(0)
+#define SPINAND_HAS_CR_FEAT_BIT                        BIT(1)
+#define SPINAND_HAS_PROG_PLANE_SELECT_BIT      BIT(2)
+#define SPINAND_HAS_READ_PLANE_SELECT_BIT      BIT(3)
 
 /**
  * struct spinand_info - Structure used to describe SPI NAND chips