2022-04-07 20:05:08

by Chuanhong Guo

[permalink] [raw]
Subject: [PATCH v4 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.

Signed-off-by: Chuanhong Guo <[email protected]>
---

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

Change since v2: None
Change since v3: None
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%)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index 9b249826ef93..2f3e02ab72ed 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -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
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index a4e6b7ae0614..19e1291ac4d5 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -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/
diff --git a/drivers/mtd/nand/raw/mtk_ecc.c b/drivers/mtd/nand/ecc-mtk.c
similarity index 99%
rename from drivers/mtd/nand/raw/mtk_ecc.c
rename to drivers/mtd/nand/ecc-mtk.c
index 49ab3448b9b1..74ddaa46ba7c 100644
--- a/drivers/mtd/nand/raw/mtk_ecc.c
+++ b/drivers/mtd/nand/ecc-mtk.c
@@ -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)
diff --git a/drivers/mtd/nand/raw/Kconfig b/drivers/mtd/nand/raw/Kconfig
index 9b078e78f3fa..8b6d7a515445 100644
--- a/drivers/mtd/nand/raw/Kconfig
+++ b/drivers/mtd/nand/raw/Kconfig
@@ -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
diff --git a/drivers/mtd/nand/raw/Makefile b/drivers/mtd/nand/raw/Makefile
index 88a566513c56..fa1d00120310 100644
--- a/drivers/mtd/nand/raw/Makefile
+++ b/drivers/mtd/nand/raw/Makefile
@@ -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
diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c
index 66f04c693c87..d540454cbbdf 100644
--- a/drivers/mtd/nand/raw/mtk_nand.c
+++ b/drivers/mtd/nand/raw/mtk_nand.c
@@ -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)
diff --git a/drivers/mtd/nand/raw/mtk_ecc.h b/include/linux/mtd/nand-ecc-mtk.h
similarity index 100%
rename from drivers/mtd/nand/raw/mtk_ecc.h
rename to include/linux/mtd/nand-ecc-mtk.h
--
2.35.1


2022-04-08 07:02:51

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH v4 1/5] mtd: nand: make mtk_ecc.c a separated module

Hi Chuanhong,

[email protected] wrote on Thu, 7 Apr 2022 23:06:48 +0800:

> this code will be used in mediatek snfi spi-mem controller with
> pipelined ECC engine.
>
> Signed-off-by: Chuanhong Guo <[email protected]>
> ---
>
> Change since v1:
> actually make it a module instead of a part of nandcore.o
> (ECC_MXIC probablly needs a similar fix.)

Please do not hesitate to propose something about it.

Otherwise on the MTD side the series looks good (besides the two
comments you already received).

I don't know if something changed regarding the comments style in the
spi subsystem, but using // everywhere looks strange, it's usually
reserved for the SPDX tag, but I'll let Mark comment on it.

Otherwise, MTD patches 1 and 3 look fine.

Thanks,
Miquèl

2022-04-09 13:28:32

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH v4 1/5] mtd: nand: make mtk_ecc.c a separated module

On Fri, Apr 08, 2022 at 08:32:14AM +0200, Miquel Raynal wrote:

> Otherwise on the MTD side the series looks good (besides the two
> comments you already received).

What's the plan for merging then?

> I don't know if something changed regarding the comments style in the
> spi subsystem, but using // everywhere looks strange, it's usually
> reserved for the SPDX tag, but I'll let Mark comment on it.

I generally request that, it looks messy if the comment block at the top
mixes styles.


Attachments:
(No filename) (505.00 B)
signature.asc (499.00 B)
Download all attachments

2022-04-12 08:42:12

by Miquel Raynal

[permalink] [raw]
Subject: Re: [PATCH v4 1/5] mtd: nand: make mtk_ecc.c a separated module

Hi Mark,

[email protected] wrote on Sat, 9 Apr 2022 19:08:57 +0800:

> Hi Mark!
>
> On Fri, Apr 8, 2022 at 8:28 PM Mark Brown <[email protected]> wrote:
> >
> > On Fri, Apr 08, 2022 at 08:32:14AM +0200, Miquel Raynal wrote:
> >
> > > Otherwise on the MTD side the series looks good (besides the two
> > > comments you already received).
> >
> > What's the plan for merging then?
>
> I just tested this driver on a different chip and found out it's buggy
> there. I'm still debugging.
> Please wait for v5 of this series. Sorry.

We need to merge this series in an immutable branch. Perhaps as the big
"part" is the SPI controller driver, it should preferably go through
spi, but I'm fine either ways, let me know what you prefer.

Thanks,
Miquèl

2022-04-12 11:07:36

by Chuanhong Guo

[permalink] [raw]
Subject: Re: [PATCH v4 1/5] mtd: nand: make mtk_ecc.c a separated module

Hi Mark!

On Fri, Apr 8, 2022 at 8:28 PM Mark Brown <[email protected]> wrote:
>
> On Fri, Apr 08, 2022 at 08:32:14AM +0200, Miquel Raynal wrote:
>
> > Otherwise on the MTD side the series looks good (besides the two
> > comments you already received).
>
> What's the plan for merging then?

I just tested this driver on a different chip and found out it's buggy
there. I'm still debugging.
Please wait for v5 of this series. Sorry.

--
Regards,
Chuanhong Guo