Skip to contentSkip to conversation

spi: add support for Mediatek SPI-NAND controller

PATCH Superseded Chuanhong Guo 3 participants 12 messages Apr 4, 2022

Subsystems (6)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover spi: add support for Mediatek SPI-NAND controller

Mediatek has an extended version of their NAND Flash Interface which has a SPI-NAND mode. In this mode, the controller can perform 1-bit spi-mem ops for up-to 0xa0 bytes and typical SPI-NAND single, dual and quad IO page cache ops with 2-byte address. Additionally, the page cache ops can be performed with ECC and auto data formatting using the ECC engine of the controller.

This patchset implements support of this mode as a separated SPI-MEM driver with piplined ECC engine.

Changes since v1:
add a blank line between properties in dt binding doc

 rename ecc-engine to nand-ecc-engine for the generic properties

fix warnings/errors from the CI

Chuanhong Guo (5):
mtd: nand: make mtk_ecc.c a separated module
spi: add driver for MTK SPI NAND Flash Interface
mtd: nand: mtk-ecc: also parse nand-ecc-engine if available
dt-bindings: spi: add binding doc for spi-mtk-snfi
arm64: dts: mediatek: add mtk-snfi for mt7622

 .../bindings/spi/mediatek,spi-mtk-snfi.yaml   |   88 ++
 arch/arm64/boot/dts/mediatek/mt7622.dtsi      |   12 +
 drivers/mtd/nand/Kconfig                      |    7 +
 drivers/mtd/nand/Makefile                     |    1 +
 drivers/mtd/nand/{raw/mtk_ecc.c => ecc-mtk.c} |    8 +-
 drivers/mtd/nand/raw/Kconfig                  |    1 +
 drivers/mtd/nand/raw/Makefile                 |    2 +-
 drivers/mtd/nand/raw/mtk_nand.c               |    2 +-
 drivers/spi/Kconfig                           |   10 +
 drivers/spi/Makefile                          |    1 +
 drivers/spi/spi-mtk-snfi.c                    | 1351 +++++++++++++++++
 .../linux/mtd/nand-ecc-mtk.h                  |    0
 12 files changed, 1478 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
 rename drivers/mtd/nand/{raw/mtk_ecc.c => ecc-mtk.c} (98%)
 create mode 100644 drivers/spi/spi-mtk-snfi.c
 rename drivers/mtd/nand/raw/mtk_ecc.h => include/linux/mtd/nand-ecc-mtk.h (100%)
Signature · 1 line
2.35.1
#1 lore raw

PATCH v2 1/5 mtd: nand: make mtk_ecc.c a separated module

this code will be used in mediatek snfi spi-mem controller with pipelined ECC engine.

---

Change since v1:
actually make it a module instead of a part of nandcore.o
(ECC_MXIC probablly needs a similar fix.)

 drivers/mtd/nand/Kconfig                                   | 7 +++++++
 drivers/mtd/nand/Makefile                                  | 1 +
 drivers/mtd/nand/{raw/mtk_ecc.c => ecc-mtk.c}              | 3 +--
 drivers/mtd/nand/raw/Kconfig                               | 1 +
 drivers/mtd/nand/raw/Makefile                              | 2 +-
 drivers/mtd/nand/raw/mtk_nand.c                            | 2 +-
 .../nand/raw/mtk_ecc.h => include/linux/mtd/nand-ecc-mtk.h | 0
 7 files changed, 12 insertions(+), 4 deletions(-)
 rename drivers/mtd/nand/{raw/mtk_ecc.c => ecc-mtk.c} (99%)
 rename drivers/mtd/nand/raw/mtk_ecc.h => include/linux/mtd/nand-ecc-mtk.h (100%)
drivers/mtd/nand/Kconfig +7 -0
index 9b249826ef93..2f3e02ab72ed 100644
@@ -53,6 +53,13 @@ config MTD_NAND_ECC_MXIC
 	help
 	  This enables support for the hardware ECC engine from Macronix.
 
+config MTD_NAND_ECC_MEDIATEK
+	tristate "Mediatek hardware ECC engine"
+	depends on HAS_IOMEM
+	select MTD_NAND_ECC
+	help
+	  This enables support for the hardware ECC engine from Mediatek.
+
 endmenu
 
 endmenu
drivers/mtd/nand/Makefile +1 -0
index a4e6b7ae0614..19e1291ac4d5 100644
@@ -2,6 +2,7 @@
 
 nandcore-objs := core.o bbt.o
 obj-$(CONFIG_MTD_NAND_CORE) += nandcore.o
+obj-$(CONFIG_MTD_NAND_ECC_MEDIATEK) += ecc-mtk.o
 
 obj-y	+= onenand/
 obj-y	+= raw/
drivers/mtd/nand/ecc-mtk.c renamed from drivers/mtd/nand/raw/mtk_ecc.c +1 -2
similarity index 99%
rename from drivers/mtd/nand/raw/mtk_ecc.c
rename to drivers/mtd/nand/ecc-mtk.c
index 49ab3448b9b1..74ddaa46ba7c 100644
@@ -15,8 +15,7 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/mutex.h>
-
-#include "mtk_ecc.h"
+#include <linux/mtd/nand-ecc-mtk.h>
 
 #define ECC_IDLE_MASK		BIT(0)
 #define ECC_IRQ_EN		BIT(0)
drivers/mtd/nand/raw/Kconfig +1 -0
index 9b078e78f3fa..8b6d7a515445 100644
@@ -374,6 +374,7 @@ config MTD_NAND_QCOM
 
 config MTD_NAND_MTK
 	tristate "MTK NAND controller"
+	depends on MTD_NAND_ECC_MEDIATEK
 	depends on ARCH_MEDIATEK || COMPILE_TEST
 	depends on HAS_IOMEM
 	help
drivers/mtd/nand/raw/Makefile +1 -1
index 88a566513c56..fa1d00120310 100644
@@ -48,7 +48,7 @@ obj-$(CONFIG_MTD_NAND_SUNXI)		+= sunxi_nand.o
 obj-$(CONFIG_MTD_NAND_HISI504)	        += hisi504_nand.o
 obj-$(CONFIG_MTD_NAND_BRCMNAND)		+= brcmnand/
 obj-$(CONFIG_MTD_NAND_QCOM)		+= qcom_nandc.o
-obj-$(CONFIG_MTD_NAND_MTK)		+= mtk_ecc.o mtk_nand.o
+obj-$(CONFIG_MTD_NAND_MTK)		+= mtk_nand.o
 obj-$(CONFIG_MTD_NAND_MXIC)		+= mxic_nand.o
 obj-$(CONFIG_MTD_NAND_TEGRA)		+= tegra_nand.o
 obj-$(CONFIG_MTD_NAND_STM32_FMC2)	+= stm32_fmc2_nand.o
drivers/mtd/nand/raw/mtk_nand.c +1 -1
index 66f04c693c87..d540454cbbdf 100644
@@ -17,7 +17,7 @@
 #include <linux/iopoll.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include "mtk_ecc.h"
+#include <linux/mtd/nand-ecc-mtk.h>
 
 /* NAND controller register definition */
 #define NFI_CNFG		(0x00)
include/linux/mtd/nand-ecc-mtk.h renamed from drivers/mtd/nand/raw/mtk_ecc.h +0 -0
similarity index 100%
rename from drivers/mtd/nand/raw/mtk_ecc.h
rename to include/linux/mtd/nand-ecc-mtk.h
Signature · 1 line
2.35.1
#2 lore raw

PATCH v2 2/5 spi: add driver for MTK SPI NAND Flash Interface

In reply to Chuanhong Guo

This driver implements support for the SPI-NAND mode of MTK NAND Flash Interface as a SPI-MEM controller with piplined ECC capability.

---

Change since v1:
fix CI warnings

 drivers/spi/Kconfig        |   10 +
 drivers/spi/Makefile       |    1 +
 drivers/spi/spi-mtk-snfi.c | 1351 ++++++++++++++++++++++++++++++++++++
 3 files changed, 1362 insertions(+)
 create mode 100644 drivers/spi/spi-mtk-snfi.c
drivers/spi/Kconfig +10 -0
index d2815eb361c0..739eec7d0c15 100644
@@ -590,6 +590,16 @@ config SPI_MTK_NOR
 	  SPI interface as well as several SPI NOR specific instructions
 	  via SPI MEM interface.
 
+config SPI_MTK_SNFI
+	tristate "MediaTek SPI NAND Flash Interface"
+	depends on ARCH_MEDIATEK || COMPILE_TEST
+	depends on MTD_NAND_ECC_MEDIATEK
+	help
+	  This enables support for SPI-NAND mode on the MediaTek NAND
+	  Flash Interface found on MediaTek ARM SoCs. This controller
+	  is implemented as a SPI-MEM controller with pipelined ECC
+	  capcability.
+
 config SPI_NPCM_FIU
 	tristate "Nuvoton NPCM FLASH Interface Unit"
 	depends on ARCH_NPCM || COMPILE_TEST
drivers/spi/Makefile +1 -0
index 3aa28ed3f761..51541ff17e67 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_SPI_MPC52xx)		+= spi-mpc52xx.o
 obj-$(CONFIG_SPI_MT65XX)                += spi-mt65xx.o
 obj-$(CONFIG_SPI_MT7621)		+= spi-mt7621.o
 obj-$(CONFIG_SPI_MTK_NOR)		+= spi-mtk-nor.o
+obj-$(CONFIG_SPI_MTK_SNFI)		+= spi-mtk-snfi.o
 obj-$(CONFIG_SPI_MXIC)			+= spi-mxic.o
 obj-$(CONFIG_SPI_MXS)			+= spi-mxs.o
 obj-$(CONFIG_SPI_NPCM_FIU)		+= spi-npcm-fiu.o
drivers/spi/spi-mtk-snfi.c new file +1351 -0

1,351 lines not on this page · raw message

Signature · 1 line
2.35.1
maintainer
#3 lore raw

Re: [PATCH v2 2/5] spi: add driver for MTK SPI NAND Flash Interface

Hi Chuanhong,

[email protected] wrote on Mon, 4 Apr 2022 12:01:50 +0800:

Quoted 53 lines

This driver implements support for the SPI-NAND mode of MTK NAND Flash Interface as a SPI-MEM controller with piplined ECC capability.

---

Change since v1:
fix CI warnings

 drivers/spi/Kconfig        |   10 +
 drivers/spi/Makefile       |    1 +
 drivers/spi/spi-mtk-snfi.c | 1351 ++++++++++++++++++++++++++++++++++++
 3 files changed, 1362 insertions(+)
 create mode 100644 drivers/spi/spi-mtk-snfi.c
drivers/spi/Kconfig +10 -0
index d2815eb361c0..739eec7d0c15 100644
@@ -590,6 +590,16 @@ config SPI_MTK_NOR
 	  SPI interface as well as several SPI NOR specific instructions
 	  via SPI MEM interface.
 
+config SPI_MTK_SNFI
+	tristate "MediaTek SPI NAND Flash Interface"
+	depends on ARCH_MEDIATEK || COMPILE_TEST
+	depends on MTD_NAND_ECC_MEDIATEK
+	help
+	  This enables support for SPI-NAND mode on the MediaTek NAND
+	  Flash Interface found on MediaTek ARM SoCs. This controller
+	  is implemented as a SPI-MEM controller with pipelined ECC
+	  capcability.
+
 config SPI_NPCM_FIU
 	tristate "Nuvoton NPCM FLASH Interface Unit"
 	depends on ARCH_NPCM || COMPILE_TEST
drivers/spi/Makefile +1 -0
index 3aa28ed3f761..51541ff17e67 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_SPI_MPC52xx)		+= spi-mpc52xx.o
 obj-$(CONFIG_SPI_MT65XX)                += spi-mt65xx.o
 obj-$(CONFIG_SPI_MT7621)		+= spi-mt7621.o
 obj-$(CONFIG_SPI_MTK_NOR)		+= spi-mtk-nor.o
+obj-$(CONFIG_SPI_MTK_SNFI)		+= spi-mtk-snfi.o
 obj-$(CONFIG_SPI_MXIC)			+= spi-mxic.o
 obj-$(CONFIG_SPI_MXS)			+= spi-mxs.o
 obj-$(CONFIG_SPI_NPCM_FIU)		+= spi-npcm-fiu.o
drivers/spi/spi-mtk-snfi.c new file +0 -0
new file mode 100644
index 000000000000..e8f8f30bd7ee

[...]

Quoted 4 lines
drivers/spi/spi-mtk-snfi.c new file +4 -0
+static struct mtk_snand *nand_to_mtk_snand(struct nand_device *nand)
+{
+	struct nand_ecc_engine *eng = nand->ecc.engine;
+

drivers/spi/spi-mtk-snfi.c line 304

Quoted 10 lines
drivers/spi/spi-mtk-snfi.c new file +10 -0
+	return container_of(eng, struct mtk_snand, ecc_eng);
+}
+
+static inline int snand_prepare_bouncebuf(struct mtk_snand *snf, size_t size)
+{
+	if (snf->buf_len >= size)
+		return 0;
+	if (snf->buf)
+		dmam_free_coherent(snf->dev, snf->buf_len, snf->buf,
+				   snf->buf_dma);

Can't we use a single coherent buffer once for all?

Quoted 9 lines
drivers/spi/spi-mtk-snfi.c new file +9 -0
+	snf->buf =
+		dmam_alloc_coherent(snf->dev, size, &snf->buf_dma, GFP_KERNEL);
+	if (!snf->buf)
+		return -ENOMEM;
+	snf->buf_len = size;
+	memset(snf->buf, 0xff, snf->buf_len);
+	return 0;
+}
+

[...]

Quoted 8 lines
drivers/spi/spi-mtk-snfi.c new file +8 -0
+static int mtk_snand_ecc_init_ctx(struct nand_device *nand)
+{
+	struct mtk_snand *snf = nand_to_mtk_snand(nand);
+	struct nand_ecc_props *conf = &nand->ecc.ctx.conf;
+	struct mtd_info *mtd = nanddev_to_mtd(nand);
+	int ret;
+
+	ret = mtk_snand_setup_pagefmt(snf, nand->memorg.pagesize,

drivers/spi/spi-mtk-snfi.c line 667

Quoted 10 lines
drivers/spi/spi-mtk-snfi.c new file +10 -0
+				      nand->memorg.oobsize);
+	if (ret)
+		return ret;
+
+	mtd_set_ooblayout(mtd, &mtk_snand_ooblayout);
+
+	// This driver ignores any ECC capability configured by user or
+	// requested by the nand chip because the BootROM and MTK bootloader
+	// expects the page format to be the exact one as calculated in
+	// setup_pagefmt.

I don't like this :)

I understand that the boot partition might have specific constraints, but other partitions (or if we don't use the NAND to boot?) should probably be usable with other ECC schemes.

Quoted 24 lines
drivers/spi/spi-mtk-snfi.c new file +24 -0
+	conf->step_size = snf->caps->sector_size;
+	conf->strength = snf->ecc_cfg.strength;
+
+	return 0;
+}
+
+static int mtk_snand_ecc_prepare_io_req(struct nand_device *nand,
+					struct nand_page_io_req *req)
+{
+	struct mtk_snand *snf = nand_to_mtk_snand(nand);
+	int ret;
+
+	ret = mtk_snand_setup_pagefmt(snf, nand->memorg.pagesize,
+				      nand->memorg.oobsize);
+	if (ret)
+		return ret;
+	snf->autofmt = true;
+	return 0;
+}
+
+static int mtk_snand_ecc_finish_io_req(struct nand_device *nand,
+				       struct nand_page_io_req *req)
+{
+	struct mtk_snand *snf = nand_to_mtk_snand(nand);

drivers/spi/spi-mtk-snfi.c line 701

Quoted 10 lines
drivers/spi/spi-mtk-snfi.c new file +10 -0
+	struct mtd_info *mtd = nanddev_to_mtd(nand);
+
+	snf->autofmt = false;
+	if ((req->mode == MTD_OPS_RAW) || (req->type != NAND_PAGE_READ))
+		return 0;
+
+	if (snf->ecc_stats.failed)
+		mtd->ecc_stats.failed += snf->ecc_stats.failed;
+	mtd->ecc_stats.corrected += snf->ecc_stats.corrected;
+	return snf->ecc_stats.failed ? -EBADMSG : snf->ecc_stats.bitflips;

Did you verify that nandbiterrs -i succeeds?

drivers/spi/spi-mtk-snfi.c line 707

Quoted 6 lines
drivers/spi/spi-mtk-snfi.c new file +6 -0
+}
+
+static struct nand_ecc_engine_ops mtk_snfi_ecc_engine_ops = {
+	.init_ctx = mtk_snand_ecc_init_ctx,
+	.prepare_io_req = mtk_snand_ecc_prepare_io_req,
+	.finish_io_req = mtk_snand_ecc_finish_io_req,

I believe you need to take care of the bounce buffer in the exit path?

Quoted 8 lines
drivers/spi/spi-mtk-snfi.c new file +8 -0
+};
+
+static void mtk_snand_read_fdm(struct mtk_snand *snf, uint8_t *buf)
+{
+	uint32_t vall, valm;
+	uint8_t *oobptr = buf;
+	int i, j;
+

drivers/spi/spi-mtk-snfi.c line 725

Quoted 10 lines
drivers/spi/spi-mtk-snfi.c new file +10 -0
+	for (i = 0; i < snf->nfi_cfg.nsectors; i++) {
+		vall = nfi_read32(snf, NFI_FDML(i));
+		valm = nfi_read32(snf, NFI_FDMM(i));
+
+		for (j = 0; j < snf->caps->fdm_size; j++)
+			oobptr[j] = (j >= 4 ? valm : vall) >> ((j % 4) * 8);
+
+		oobptr += snf->caps->fdm_size;
+	}
+}

Thanks,
Miquèl

#4 lore raw

Re: [PATCH v2 2/5] spi: add driver for MTK SPI NAND Flash Interface

Hi!

Quoted 61 lines · Miquel Raynal

Hi Chuanhong,

[email protected] wrote on Mon, 4 Apr 2022 12:01:50 +0800:

Quoted 53 lines

This driver implements support for the SPI-NAND mode of MTK NAND Flash Interface as a SPI-MEM controller with piplined ECC capability.

---

Change since v1:
fix CI warnings

 drivers/spi/Kconfig        |   10 +
 drivers/spi/Makefile       |    1 +
 drivers/spi/spi-mtk-snfi.c | 1351 ++++++++++++++++++++++++++++++++++++
 3 files changed, 1362 insertions(+)
 create mode 100644 drivers/spi/spi-mtk-snfi.c
drivers/spi/Kconfig +10 -0
index d2815eb361c0..739eec7d0c15 100644
@@ -590,6 +590,16 @@ config SPI_MTK_NOR
        SPI interface as well as several SPI NOR specific instructions
        via SPI MEM interface.
 
+config SPI_MTK_SNFI
+     tristate "MediaTek SPI NAND Flash Interface"
+     depends on ARCH_MEDIATEK || COMPILE_TEST
+     depends on MTD_NAND_ECC_MEDIATEK
+     help
+       This enables support for SPI-NAND mode on the MediaTek NAND
+       Flash Interface found on MediaTek ARM SoCs. This controller
+       is implemented as a SPI-MEM controller with pipelined ECC
+       capcability.
+
 config SPI_NPCM_FIU
      tristate "Nuvoton NPCM FLASH Interface Unit"
      depends on ARCH_NPCM || COMPILE_TEST
drivers/spi/Makefile +1 -0
index 3aa28ed3f761..51541ff17e67 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_SPI_MPC52xx)           += spi-mpc52xx.o
 obj-$(CONFIG_SPI_MT65XX)                += spi-mt65xx.o
 obj-$(CONFIG_SPI_MT7621)             += spi-mt7621.o
 obj-$(CONFIG_SPI_MTK_NOR)            += spi-mtk-nor.o
+obj-$(CONFIG_SPI_MTK_SNFI)           += spi-mtk-snfi.o
 obj-$(CONFIG_SPI_MXIC)                       += spi-mxic.o
 obj-$(CONFIG_SPI_MXS)                        += spi-mxs.o
 obj-$(CONFIG_SPI_NPCM_FIU)           += spi-npcm-fiu.o
drivers/spi/spi-mtk-snfi.c new file +0 -0
new file mode 100644
index 000000000000..e8f8f30bd7ee

[...]

Quoted 16 lines
Quoted 4 lines
drivers/spi/spi-mtk-snfi.c new file +4 -0
+static struct mtk_snand *nand_to_mtk_snand(struct nand_device *nand)
+{
+     struct nand_ecc_engine *eng = nand->ecc.engine;
+

drivers/spi/spi-mtk-snfi.c line 304

Quoted 10 lines
drivers/spi/spi-mtk-snfi.c new file +10 -0
+     return container_of(eng, struct mtk_snand, ecc_eng);
+}
+
+static inline int snand_prepare_bouncebuf(struct mtk_snand *snf, size_t size)
+{
+     if (snf->buf_len >= size)
+             return 0;
+     if (snf->buf)
+             dmam_free_coherent(snf->dev, snf->buf_len, snf->buf,
+                                snf->buf_dma);

Can't we use a single coherent buffer once for all?

This only reallocates when the page size changes to a larger one, so there's at most two allocations: one during probe and the other one in the first call to init_ctx. The other solution is to allocate a buffer for the maximum supported page size but I think that's a waste of memory.

Quoted 34 lines
Quoted 10 lines
drivers/spi/spi-mtk-snfi.c new file +9 -0
+     snf->buf =
+             dmam_alloc_coherent(snf->dev, size, &snf->buf_dma, GFP_KERNEL);
+     if (!snf->buf)
+             return -ENOMEM;
+     snf->buf_len = size;
+     memset(snf->buf, 0xff, snf->buf_len);
+     return 0;
+}
+

[...]

Quoted 8 lines
drivers/spi/spi-mtk-snfi.c new file +8 -0
+static int mtk_snand_ecc_init_ctx(struct nand_device *nand)
+{
+     struct mtk_snand *snf = nand_to_mtk_snand(nand);
+     struct nand_ecc_props *conf = &nand->ecc.ctx.conf;
+     struct mtd_info *mtd = nanddev_to_mtd(nand);
+     int ret;
+
+     ret = mtk_snand_setup_pagefmt(snf, nand->memorg.pagesize,

drivers/spi/spi-mtk-snfi.c line 667

Quoted 10 lines
drivers/spi/spi-mtk-snfi.c new file +10 -0
+                                   nand->memorg.oobsize);
+     if (ret)
+             return ret;
+
+     mtd_set_ooblayout(mtd, &mtk_snand_ooblayout);
+
+     // This driver ignores any ECC capability configured by user or
+     // requested by the nand chip because the BootROM and MTK bootloader
+     // expects the page format to be the exact one as calculated in
+     // setup_pagefmt.

I don't like this :)

Quoted 3 lines

I understand that the boot partition might have specific constraints, but other partitions (or if we don't use the NAND to boot?) should probably be usable with other ECC schemes.

In this controller, the ECC step size is fixed and it can only change ECC strength. The calculated ECC correction capability is the max possible one supported by the controller.
I still want the default behavior to match the boot partition requirement, because we can't just tell end-users to customize their dts by taking apart their device and figure out which flash is used.

I can implement the following:
1. select the minimum capability exceeding ecc.user_conf
2. If that doesn't exist, use the calculated one and warn if it doesn't meet ecc.requirements
Is this OK?

Quoted 29 lines
Quoted 29 lines
drivers/spi/spi-mtk-snfi.c new file +28 -0
+     conf->step_size = snf->caps->sector_size;
+     conf->strength = snf->ecc_cfg.strength;
+
+     return 0;
+}
+
+static int mtk_snand_ecc_prepare_io_req(struct nand_device *nand,
+                                     struct nand_page_io_req *req)
+{
+     struct mtk_snand *snf = nand_to_mtk_snand(nand);
+     int ret;
+
+     ret = mtk_snand_setup_pagefmt(snf, nand->memorg.pagesize,
+                                   nand->memorg.oobsize);
+     if (ret)
+             return ret;
+     snf->autofmt = true;
+     return 0;
+}
+
+static int mtk_snand_ecc_finish_io_req(struct nand_device *nand,
+                                    struct nand_page_io_req *req)
+{
+     struct mtk_snand *snf = nand_to_mtk_snand(nand);
+     struct mtd_info *mtd = nanddev_to_mtd(nand);
+
+     snf->autofmt = false;
+     if ((req->mode == MTD_OPS_RAW) || (req->type != NAND_PAGE_READ))
Quoted 8 lines

drivers/spi/spi-mtk-snfi.c line 701

Quoted 6 lines
drivers/spi/spi-mtk-snfi.c new file +6 -0
+             return 0;
+
+     if (snf->ecc_stats.failed)
+             mtd->ecc_stats.failed += snf->ecc_stats.failed;
+     mtd->ecc_stats.corrected += snf->ecc_stats.corrected;
+     return snf->ecc_stats.failed ? -EBADMSG : snf->ecc_stats.bitflips;

Did you verify that nandbiterrs -i succeeds?

I did a insmod mtd_nandbiterrs.ko dev=x and the reported bitflips in kernel log is correct.

Is there a userspace tool for this? I'd like to use that instead of a kernel module in the future.

Quoted 9 lines

drivers/spi/spi-mtk-snfi.c line 707

Quoted 7 lines
drivers/spi/spi-mtk-snfi.c new file +6 -0
+}
+
+static struct nand_ecc_engine_ops mtk_snfi_ecc_engine_ops = {
+     .init_ctx = mtk_snand_ecc_init_ctx,
+     .prepare_io_req = mtk_snand_ecc_prepare_io_req,
+     .finish_io_req = mtk_snand_ecc_finish_io_req,

I believe you need to take care of the bounce buffer in the exit path?

No. The buffer should be left there for non-ecc spi-mem operations.

Quoted 14 lines
Quoted 14 lines
drivers/spi/spi-mtk-snfi.c new file +13 -0
+};
+
+static void mtk_snand_read_fdm(struct mtk_snand *snf, uint8_t *buf)
+{
+     uint32_t vall, valm;
+     uint8_t *oobptr = buf;
+     int i, j;
+
+     for (i = 0; i < snf->nfi_cfg.nsectors; i++) {
+             vall = nfi_read32(snf, NFI_FDML(i));
+             valm = nfi_read32(snf, NFI_FDMM(i));
+
+             for (j = 0; j < snf->caps->fdm_size; j++)
Quoted 8 lines

drivers/spi/spi-mtk-snfi.c line 725

Quoted 5 lines
drivers/spi/spi-mtk-snfi.c new file +5 -0
+                     oobptr[j] = (j >= 4 ? valm : vall) >> ((j % 4) * 8);
+
+             oobptr += snf->caps->fdm_size;
+     }
+}

Thanks,
Miquèl

--
Regards,
Chuanhong Guo

#5 lore raw

Re: [PATCH v2 2/5] spi: add driver for MTK SPI NAND Flash Interface

Hi!

Quoted 5 lines · Chuanhong Guo

[...]
I can implement the following:
1. select the minimum capability exceeding ecc.user_conf
2. If that doesn't exist, use the calculated one and warn if it doesn't meet ecc.requirements

I mean If there is no ecc.user_conf in the 2nd case :)

Quoted 1 line

Is this OK?

Signature · 2 lines
Regards,
Chuanhong Guo
maintainer
#6 lore raw

Re: [PATCH v2 2/5] spi: add driver for MTK SPI NAND Flash Interface

In reply to Chuanhong Guo

Hi Chuanhong,

[email protected] wrote on Mon, 4 Apr 2022 17:13:55 +0800:

Quoted 81 lines

Hi!

Quoted 61 lines · Miquel Raynal

Hi Chuanhong,

[email protected] wrote on Mon, 4 Apr 2022 12:01:50 +0800:

Quoted 53 lines

This driver implements support for the SPI-NAND mode of MTK NAND Flash Interface as a SPI-MEM controller with piplined ECC capability.

---

Change since v1:
fix CI warnings

 drivers/spi/Kconfig        |   10 +
 drivers/spi/Makefile       |    1 +
 drivers/spi/spi-mtk-snfi.c | 1351 ++++++++++++++++++++++++++++++++++++
 3 files changed, 1362 insertions(+)
 create mode 100644 drivers/spi/spi-mtk-snfi.c
drivers/spi/Kconfig +10 -0
index d2815eb361c0..739eec7d0c15 100644
@@ -590,6 +590,16 @@ config SPI_MTK_NOR
        SPI interface as well as several SPI NOR specific instructions
        via SPI MEM interface.
 
+config SPI_MTK_SNFI
+     tristate "MediaTek SPI NAND Flash Interface"
+     depends on ARCH_MEDIATEK || COMPILE_TEST
+     depends on MTD_NAND_ECC_MEDIATEK
+     help
+       This enables support for SPI-NAND mode on the MediaTek NAND
+       Flash Interface found on MediaTek ARM SoCs. This controller
+       is implemented as a SPI-MEM controller with pipelined ECC
+       capcability.
+
 config SPI_NPCM_FIU
      tristate "Nuvoton NPCM FLASH Interface Unit"
      depends on ARCH_NPCM || COMPILE_TEST
drivers/spi/Makefile +1 -0
index 3aa28ed3f761..51541ff17e67 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_SPI_MPC52xx)           += spi-mpc52xx.o
 obj-$(CONFIG_SPI_MT65XX)                += spi-mt65xx.o
 obj-$(CONFIG_SPI_MT7621)             += spi-mt7621.o
 obj-$(CONFIG_SPI_MTK_NOR)            += spi-mtk-nor.o
+obj-$(CONFIG_SPI_MTK_SNFI)           += spi-mtk-snfi.o
 obj-$(CONFIG_SPI_MXIC)                       += spi-mxic.o
 obj-$(CONFIG_SPI_MXS)                        += spi-mxs.o
 obj-$(CONFIG_SPI_NPCM_FIU)           += spi-npcm-fiu.o
drivers/spi/spi-mtk-snfi.c new file +0 -0
new file mode 100644
index 000000000000..e8f8f30bd7ee

[...]

Quoted 16 lines
Quoted 4 lines
drivers/spi/spi-mtk-snfi.c new file +4 -0
+static struct mtk_snand *nand_to_mtk_snand(struct nand_device *nand)
+{
+     struct nand_ecc_engine *eng = nand->ecc.engine;
+

drivers/spi/spi-mtk-snfi.c line 304

Quoted 10 lines
drivers/spi/spi-mtk-snfi.c new file +10 -0
+     return container_of(eng, struct mtk_snand, ecc_eng);
+}
+
+static inline int snand_prepare_bouncebuf(struct mtk_snand *snf, size_t size)
+{
+     if (snf->buf_len >= size)
+             return 0;
+     if (snf->buf)
+             dmam_free_coherent(snf->dev, snf->buf_len, snf->buf,
+                                snf->buf_dma);  

Can't we use a single coherent buffer once for all?

Quoted 5 lines

This only reallocates when the page size changes to a larger one, so there's at most two allocations: one during probe and the other one in the first call to init_ctx. The other solution is to allocate a buffer for the maximum supported page size but I think that's a waste of memory.

Ok, fine.

Quoted 35 lines
Quoted 35 lines
Quoted 11 lines
drivers/spi/spi-mtk-snfi.c new file +9 -0
+     snf->buf =
+             dmam_alloc_coherent(snf->dev, size, &snf->buf_dma, GFP_KERNEL);
+     if (!snf->buf)
+             return -ENOMEM;
+     snf->buf_len = size;
+     memset(snf->buf, 0xff, snf->buf_len);
+     return 0;
+}
+  

[...]

Quoted 8 lines
drivers/spi/spi-mtk-snfi.c new file +8 -0
+static int mtk_snand_ecc_init_ctx(struct nand_device *nand)
+{
+     struct mtk_snand *snf = nand_to_mtk_snand(nand);
+     struct nand_ecc_props *conf = &nand->ecc.ctx.conf;
+     struct mtd_info *mtd = nanddev_to_mtd(nand);
+     int ret;
+
+     ret = mtk_snand_setup_pagefmt(snf, nand->memorg.pagesize,

drivers/spi/spi-mtk-snfi.c line 667

Quoted 10 lines
drivers/spi/spi-mtk-snfi.c new file +10 -0
+                                   nand->memorg.oobsize);
+     if (ret)
+             return ret;
+
+     mtd_set_ooblayout(mtd, &mtk_snand_ooblayout);
+
+     // This driver ignores any ECC capability configured by user or
+     // requested by the nand chip because the BootROM and MTK bootloader
+     // expects the page format to be the exact one as calculated in
+     // setup_pagefmt.  

I don't like this :)

Quoted 6 lines
Quoted 3 lines

I understand that the boot partition might have specific constraints, but other partitions (or if we don't use the NAND to boot?) should probably be usable with other ECC schemes.

In this controller, the ECC step size is fixed and it can only change ECC strength.

That's fine.

Quoted 4 lines

The calculated ECC correction capability is the max possible one supported by the controller.
I still want the default behavior to match the boot partition requirement,

That is okay, but that does not mean you can only support this one.

Quoted 3 lines

because we can't just tell end-users to customize
their dts by taking apart their device and figure out which flash is used.

They don't have to do so. In theory they should not request anything, the core would take care of all of that. But they can request specific values by using the DT and you must follow them in the driver.

On his side the core is responsible of telling you which strength should be used otherwise and the driver is expected to use it.

Quoted 1 line

I can implement the following:

You should take the user requirements first. If there are no user inputs, you should in theory look at the device's requirements.

Quoted 43 lines

1. select the minimum capability exceeding ecc.user_conf
2. If that doesn't exist, use the calculated one and warn if it doesn't meet ecc.requirements
Is this OK?

Quoted 29 lines
Quoted 29 lines
drivers/spi/spi-mtk-snfi.c new file +28 -0
+     conf->step_size = snf->caps->sector_size;
+     conf->strength = snf->ecc_cfg.strength;
+
+     return 0;
+}
+
+static int mtk_snand_ecc_prepare_io_req(struct nand_device *nand,
+                                     struct nand_page_io_req *req)
+{
+     struct mtk_snand *snf = nand_to_mtk_snand(nand);
+     int ret;
+
+     ret = mtk_snand_setup_pagefmt(snf, nand->memorg.pagesize,
+                                   nand->memorg.oobsize);
+     if (ret)
+             return ret;
+     snf->autofmt = true;
+     return 0;
+}
+
+static int mtk_snand_ecc_finish_io_req(struct nand_device *nand,
+                                    struct nand_page_io_req *req)
+{
+     struct mtk_snand *snf = nand_to_mtk_snand(nand);
+     struct mtd_info *mtd = nanddev_to_mtd(nand);
+
+     snf->autofmt = false;
+     if ((req->mode == MTD_OPS_RAW) || (req->type != NAND_PAGE_READ))
Quoted 8 lines

drivers/spi/spi-mtk-snfi.c line 701

Quoted 6 lines
drivers/spi/spi-mtk-snfi.c new file +6 -0
+             return 0;
+
+     if (snf->ecc_stats.failed)
+             mtd->ecc_stats.failed += snf->ecc_stats.failed;
+     mtd->ecc_stats.corrected += snf->ecc_stats.corrected;
+     return snf->ecc_stats.failed ? -EBADMSG : snf->ecc_stats.bitflips;  

Did you verify that nandbiterrs -i succeeds?

Quoted 5 lines

I did a insmod mtd_nandbiterrs.ko dev=x and the reported bitflips in kernel log is correct.

Is there a userspace tool for this? I'd like to use that instead of a kernel module in the future.

Yes, you can give the mtd-utils test suite a try. Almost all the tools have been migrated there. There even is a Buildroot package.

Quoted 10 lines
Quoted 8 lines

drivers/spi/spi-mtk-snfi.c line 707

Quoted 6 lines
drivers/spi/spi-mtk-snfi.c new file +6 -0
+}
+
+static struct nand_ecc_engine_ops mtk_snfi_ecc_engine_ops = {
+     .init_ctx = mtk_snand_ecc_init_ctx,
+     .prepare_io_req = mtk_snand_ecc_prepare_io_req,
+     .finish_io_req = mtk_snand_ecc_finish_io_req,  

I believe you need to take care of the bounce buffer in the exit path?

No. The buffer should be left there for non-ecc spi-mem operations.

AFAIR you initialize the buffer in the ECC part, so if it must be used without ECC you should probably allocate it for the SPI controller. In any way, you need to free that memory at some point (when removing the driver).

Quoted 26 lines
Quoted 15 lines
Quoted 15 lines
drivers/spi/spi-mtk-snfi.c new file +13 -0
+};
+
+static void mtk_snand_read_fdm(struct mtk_snand *snf, uint8_t *buf)
+{
+     uint32_t vall, valm;
+     uint8_t *oobptr = buf;
+     int i, j;
+
+     for (i = 0; i < snf->nfi_cfg.nsectors; i++) {
+             vall = nfi_read32(snf, NFI_FDML(i));
+             valm = nfi_read32(snf, NFI_FDMM(i));
+
+             for (j = 0; j < snf->caps->fdm_size; j++)
Quoted 8 lines

drivers/spi/spi-mtk-snfi.c line 725

Quoted 5 lines
drivers/spi/spi-mtk-snfi.c new file +5 -0
+                     oobptr[j] = (j >= 4 ? valm : vall) >> ((j % 4) * 8);
+
+             oobptr += snf->caps->fdm_size;
+     }
+}  

Thanks,
Miquèl

Quoted 3 lines

--
Regards,
Chuanhong Guo

Thanks,
Miquèl

#7 lore raw

Re: [PATCH v2 2/5] spi: add driver for MTK SPI NAND Flash Interface

Hi!

Quoted 29 lines · Miquel Raynal

[...]

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
drivers/spi/spi-mtk-snfi.c new file +5 -0
+
+     // This driver ignores any ECC capability configured by user or
+     // requested by the nand chip because the BootROM and MTK bootloader
+     // expects the page format to be the exact one as calculated in
+     // setup_pagefmt.
Quoted 8 lines
Quoted 5 lines

I don't like this :)

I understand that the boot partition might have specific constraints, but other partitions (or if we don't use the NAND to boot?) should probably be usable with other ECC schemes.

In this controller, the ECC step size is fixed and it can only change ECC strength.

That's fine.

Quoted 4 lines

The calculated ECC correction capability is the max possible one supported by the controller.
I still want the default behavior to match the boot partition requirement,

That is okay, but that does not mean you can only support this one.

Quoted 3 lines

because we can't just tell end-users to customize
their dts by taking apart their device and figure out which flash is used.

Quoted 6 lines

They don't have to do so. In theory they should not request anything, the core would take care of all of that. But they can request specific values by using the DT and you must follow them in the driver.

On his side the core is responsible of telling you which strength should be used otherwise and the driver is expected to use it.

The core provided ecc strength may be smaller than the calculated one. e.g. A nand chip may only have a requirement of 8/512bits ECC. But if it has a 2k+128 pagesize, this controller can do 12/512bits ECC and the bootrom expects the latter.

Quoted 2 lines

You should take the user requirements first. If there are no user inputs, you should in theory look at the device's requirements.

I'll take the user requirements if there is one. If there isn't, I'll follow the calculated strength instead of the device requirement so that user doesn't have to specify a custom strength in dt.

Quoted 6 lines

[...]

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
drivers/spi/spi-mtk-snfi.c new file +4 -0
+static struct nand_ecc_engine_ops mtk_snfi_ecc_engine_ops = {
+     .init_ctx = mtk_snand_ecc_init_ctx,
+     .prepare_io_req = mtk_snand_ecc_prepare_io_req,
+     .finish_io_req = mtk_snand_ecc_finish_io_req,
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I believe you need to take care of the bounce buffer in the exit path?

No. The buffer should be left there for non-ecc spi-mem operations.

AFAIR you initialize the buffer in the ECC part, so if it must be used without ECC you should probably allocate it for the SPI controller.

I did. the setup_pagefmt is called once with the minimal page+oob size in probe.

Quoted 3 lines

In
any way, you need to free that memory at some point (when removing the driver).

I was using the devm api for this allocation so kernel should take care of that.

I'll change the DMA to use streamed API in the next version to avoid an extra memory copy in reading, and the allocated buffer will be freed in remove().

Signature · 2 lines
Regards,
Chuanhong Guo
#8 lore raw

PATCH v2 3/5 mtd: nand: mtk-ecc: also parse nand-ecc-engine if available

In reply to Chuanhong Guo

The recently added ECC engine support introduced a generic property named nand-ecc-engine for ecc engine phandle. This patch adds support for this new property.

---
Change since v1:
new patch

 drivers/mtd/nand/ecc-mtk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/mtd/nand/ecc-mtk.c +4 -1
index 74ddaa46ba7c..9f9b201fe706 100644
@@ -279,7 +279,10 @@ struct mtk_ecc *of_mtk_ecc_get(struct device_node *of_node)
 	struct mtk_ecc *ecc = NULL;
 	struct device_node *np;
 
-	np = of_parse_phandle(of_node, "ecc-engine", 0);
+	np = of_parse_phandle(of_node, "nand-ecc-engine", 0);
+	/* for backward compatibility */
+	if (!np)
+		np = of_parse_phandle(of_node, "ecc-engine", 0);
 	if (np) {
 		ecc = mtk_ecc_get(np);
 		of_node_put(np);
Signature · 1 line
2.35.1
#9 lore raw

PATCH v2 4/5 dt-bindings: spi: add binding doc for spi-mtk-snfi

In reply to Chuanhong Guo

Add device-tree binding documentation for Mediatek SPI-NAND Flash Interface.

---

Changes since v1:
1. add a blank line between properties in dt binding doc
2. rename ecc-engine to nand-ecc-engine for the generic properties

 .../bindings/spi/mediatek,spi-mtk-snfi.yaml   | 88 +++++++++++++++++++
 1 file changed, 88 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml new file +88 -0
new file mode 100644
index 000000000000..7d57570ad617
@@ -0,0 +1,88 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spi/mediatek,spi-mtk-snfi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SPI-NAND flash controller for MediaTek ARM SoCs
+
+maintainers:
+  - Chuanhong Guo <[email protected]>
+
+description: |
+  The Mediatek SPI-NAND flash controller is an extended version of
+  the Mediatek NAND flash controller. It can perform standard SPI
+  instructions with one continuous write and one read for up-to 0xa0
+  bytes. It also supports typical SPI-NAND page cache operations
+  in single, dual or quad IO mode with piplined ECC encoding/decoding
+  using the accompanying ECC engine. There should be only one spi
+  slave device following generic spi bindings.
+
+allOf:
+  - $ref: /schemas/spi/spi-controller.yaml#
+
+properties:
+  compatible:
+    enum:
+      - mediatek,mt7622-snand
+      - mediatek,mt7629-snand
+
+  reg:
+    items:
+      - description: core registers
+
+  interrupts:
+    items:
+      - description: NFI interrupt
+
+  clocks:
+    items:
+      - description: clock used for the controller
+      - description: clock used for the SPI bus
+
+  clock-names:
+    items:
+      - const: nfi_clk
+      - const: pad_clk
+
+  nand-ecc-engine:
+    description: device-tree node of the accompanying ECC engine.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - ecc-engine
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/interrupt-controller/arm-gic.h>
+    #include <dt-bindings/clock/mt7622-clk.h>
+    soc {
+      #address-cells = <2>;
+      #size-cells = <2>;
+      snfi: spi@1100d000 {
+        compatible = "mediatek,mt7622-snand";
+        reg = <0 0x1100d000 0 0x1000>;
+        interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>;
+        clocks = <&pericfg CLK_PERI_NFI_PD>, <&pericfg CLK_PERI_SNFI_PD>;
+        clock-names = "nfi_clk", "pad_clk";
+        nand-ecc-engine = <&bch>;
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        flash@0 {
+          compatible = "spi-nand";
+          reg = <0>;
+          spi-tx-bus-width = <4>;
+          spi-rx-bus-width = <4>;
+          nand-ecc-engine = <&snfi>;
+        };
+      };
+    };
Signature · 1 line
2.35.1
#10 lore raw

Re: [PATCH v2 4/5] dt-bindings: spi: add binding doc for spi-mtk-snfi

Quoted 68 lines · Chuanhong Guo

Add device-tree binding documentation for Mediatek SPI-NAND Flash Interface.

---

Changes since v1:
1. add a blank line between properties in dt binding doc
2. rename ecc-engine to nand-ecc-engine for the generic properties

 .../bindings/spi/mediatek,spi-mtk-snfi.yaml   | 88 +++++++++++++++++++
 1 file changed, 88 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml
Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml new file +48 -0
new file mode 100644
index 000000000000..7d57570ad617
@@ -0,0 +1,88 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/spi/mediatek,spi-mtk-snfi.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: SPI-NAND flash controller for MediaTek ARM SoCs
+
+maintainers:
+  - Chuanhong Guo <[email protected]>
+
+description: |
+  The Mediatek SPI-NAND flash controller is an extended version of
+  the Mediatek NAND flash controller. It can perform standard SPI
+  instructions with one continuous write and one read for up-to 0xa0
+  bytes. It also supports typical SPI-NAND page cache operations
+  in single, dual or quad IO mode with piplined ECC encoding/decoding
+  using the accompanying ECC engine. There should be only one spi
+  slave device following generic spi bindings.
+
+allOf:
+  - $ref: /schemas/spi/spi-controller.yaml#
+
+properties:
+  compatible:
+    enum:
+      - mediatek,mt7622-snand
+      - mediatek,mt7629-snand
+
+  reg:
+    items:
+      - description: core registers
+
+  interrupts:
+    items:
+      - description: NFI interrupt
+
+  clocks:
+    items:
+      - description: clock used for the controller
+      - description: clock used for the SPI bus
+
+  clock-names:
+    items:
+      - const: nfi_clk
+      - const: pad_clk
+
+  nand-ecc-engine:

Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml line 58

Quoted 10 lines
Documentation/devicetree/bindings/spi/mediatek,spi-mtk-snfi.yaml new file +10 -0
+    description: device-tree node of the accompanying ECC engine.
+    $ref: /schemas/types.yaml#/definitions/phandle
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - ecc-engine

Wrong name.

Best regards,
Krzysztof

#11 lore raw

PATCH v2 5/5 arm64: dts: mediatek: add mtk-snfi for mt7622

In reply to Chuanhong Guo

This patch adds a device-tree node for the MTK SPI-NAND Flash Interface for MT7622 device tree.

---
Changes since v1:
1. use the newly introduced nand-ecc-engine instead
2. reword commit message

 arch/arm64/boot/dts/mediatek/mt7622.dtsi | 12 ++++++++++++
 1 file changed, 12 insertions(+)
arch/arm64/boot/dts/mediatek/mt7622.dtsi +12 -0
index 6f8cb3ad1e84..4b8f7dc1ec23 100644
@@ -545,6 +545,18 @@ nandc: nfi@1100d000 {
 		status = "disabled";
 	};
 
+	snfi: spi@1100d000 {
+		compatible = "mediatek,mt7622-snand";
+		reg = <0 0x1100d000 0 0x1000>;
+		interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>;
+		clocks = <&pericfg CLK_PERI_NFI_PD>, <&pericfg CLK_PERI_SNFI_PD>;
+		clock-names = "nfi_clk", "pad_clk";
+		nand-ecc-engine = <&bch>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		status = "disabled";
+	};
+
 	bch: ecc@1100e000 {
 		compatible = "mediatek,mt7622-ecc";
 		reg = <0 0x1100e000 0 0x1000>;
Signature · 1 line
2.35.1