SPI Nand patch code of SkyHigh Memory
Subsystems (2)
PATCH 1/1 SPI Nand patch code of SkyHigh Memory
The following list shows the additional features that are required to support Skyhighmemory S35ML0xG3 SPI Nand:
[Always ECC On]
Always keep the ECC On during Bad Block Marking and Bad Block Checking
1. The on-die ECC feature is totally transparent to the host. The ECC parity bits used for this feature do not occupy the NAND spare areas.
2. The host is free to have its own ECC engine by using the spare areas that have standard size.
3. We provide this patch to enable users who have limited ECC capabilities on the host side to use the NAND flash. This patch has been tested thoroughly on Linux.
[Change ECC Status information]
This patch changes the ECC status information as follows to maintain compatibility.
00 (normal)
01(1-2 errors corrected)
10(3-6 errors corrected)
11(uncorrectable)
--- drivers/mtd/nand/spi/Makefile | 2 +- drivers/mtd/nand/spi/core.c | 14 +++- drivers/mtd/nand/spi/skyhigh.c | 145 +++++++++++++++++++++++++++++++++ include/linux/mtd/spinand.h | 3 + 4 files changed, 162 insertions(+), 2 deletions(-) mode change 100644 => 100755 drivers/mtd/nand/spi/Makefile mode change 100644 => 100755 drivers/mtd/nand/spi/core.c create mode 100644 drivers/mtd/nand/spi/skyhigh.c mode change 100644 => 100755 include/linux/mtd/spinand.h
drivers/mtd/nand/spi/Makefile +1 -1
@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 spinand-objs := core.o alliancememory.o ato.o esmt.o foresee.o gigadevice.o macronix.o -spinand-objs += micron.o paragon.o toshiba.o winbond.o xtx.o +spinand-objs += micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
drivers/mtd/nand/spi/core.c +13 -1
@@ -196,6 +196,17 @@ static int spinand_init_quad_enable(struct spinand_device *spinand)static int spinand_ecc_enable (struct spinand_device *spinand,bool enable) { +/* +* SkyHigh Memory : always ECC on +* The on-die ECC feature is totally transparent to the host. +* The ECC parity bits used for this feature do not occupy the NAND spare areas. +* The host is free to have its own ECC engine by using the spare areas that have standard size. +* We provide this patch to enable users who have limited ECC capabilities on the host side to use the NAND flash. +* This patch has been tested thoroughly on Linux. +*/ +if (spinand->flags &SPINAND_ON_DIE_ECC_MANDATORY ) +return 0 ; +return spinand_upd_cfg (spinand,CFG_ECC_ENABLE , enable ?CFG_ECC_ENABLE :0 ); }
@@ -561,7 +572,7 @@ static int spinand_reset_op(struct spinand_device *spinand) NULL); } -static int spinand_lock_block (struct spinand_device *spinand,u8 lock) +int spinand_lock_block (struct spinand_device *spinand,u8 lock) {return spinand_write_reg_op (spinand,REG_BLOCK_LOCK , lock); }
@@ -945,6 +956,7 @@ static const struct spinand_manufacturer *spinand_manufacturers[] = { ¯onix_spinand_manufacturer, µn_spinand_manufacturer, ¶gon_spinand_manufacturer, + &skyhigh_spinand_manufacturer, &toshiba_spinand_manufacturer, &winbond_spinand_manufacturer, &xtx_spinand_manufacturer,
drivers/mtd/nand/spi/skyhigh.c new file +145 -0
145 lines not on this page · raw message
include/linux/mtd/spinand.h +3 -0
@@ -268,6 +268,7 @@ extern const struct spinand_manufacturer gigadevice_spinand_manufacturer;extern const struct spinand_manufacturer macronix_spinand_manufacturer;extern const struct spinand_manufacturer micron_spinand_manufacturer;extern const struct spinand_manufacturer paragon_spinand_manufacturer; +extern const struct spinand_manufacturer skyhigh_spinand_manufacturer;extern const struct spinand_manufacturer toshiba_spinand_manufacturer;extern const struct spinand_manufacturer winbond_spinand_manufacturer;extern const struct spinand_manufacturer xtx_spinand_manufacturer;
@@ -312,6 +313,7 @@ struct spinand_ecc_info {#define SPINAND_HAS_QE_BIT BIT(0)#define SPINAND_HAS_CR_FEAT_BIT BIT(1) +#define SPINAND_ON_DIE_ECC_MANDATORY BIT(2)/* SHM */ /** * struct spinand_ondie_ecc_conf - private SPI-NAND on-die ECC engine structure
@@ -518,5 +520,6 @@ int spinand_match_and_init(struct spinand_device *spinand,int spinand_upd_cfg (struct spinand_device *spinand,u8 mask,u8 val);int spinand_select_target (struct spinand_device *spinand,unsigned int target); +int spinand_lock_block (struct spinand_device *spinand,u8 lock);/* SHM */ #endif /* __LINUX_MTD_SPINAND_H */
Signature · 1 line
2.34.1
+Takahiro, I saw he was quoted as author
Hi, KR,
Thank you for the patch.
Plese run "./scripts/checkpatch.pl --strict" on your patch and fix the errors and warning that are shown.
Subject is wrong, it should follow how other drivers were introduced. You may use the following in the next version:
"mtd: spinand: add support for SkyHigh S35ML flashes"
Other comments below.
Quoted 8 lines · KR Kim
The following list shows the additional features that are required to support Skyhighmemory S35ML0xG3 SPI Nand:
[Always ECC On]
Always keep the ECC On during Bad Block Marking and Bad Block Checking
1. The on-die ECC feature is totally transparent to the host. The ECC parity bits used for this feature do not occupy the NAND spare areas.
2. The host is free to have its own ECC engine by using the spare areas that have standard size.
3. We provide this patch to enable users who have limited ECC capabilities on the host side to use the NAND flash. This patch has been tested thoroughly on Linux.
Quoted 6 lines
[Change ECC Status information]
This patch changes the ECC status information as follows to maintain compatibility.
00 (normal)
01(1-2 errors corrected)
10(3-6 errors corrected)
11(uncorrectable)
Please read the guide on submitting patches before sending v2:
https://www.kernel.org/doc/html/latest/process/submitting-patches.html
It describes how one shall describe the changes. You missed to add your Signed-of-by tag.
Quoted 10 lines
--- drivers/mtd/nand/spi/Makefile | 2 +- drivers/mtd/nand/spi/core.c | 14 +++- drivers/mtd/nand/spi/skyhigh.c | 145 +++++++++++++++++++++++++++++++++ include/linux/mtd/spinand.h | 3 + 4 files changed, 162 insertions(+), 2 deletions(-) mode change 100644 => 100755 drivers/mtd/nand/spi/Makefile mode change 100644 => 100755 drivers/mtd/nand/spi/core.c create mode 100644 drivers/mtd/nand/spi/skyhigh.c mode change 100644 => 100755 include/linux/mtd/spinand.h
all these file mode changes are wrong, keep the files as they were.
Quoted 20 lines
drivers/mtd/nand/spi/Makefile +1
-1@@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 spinand-objs := core.o alliancememory.o ato.o esmt.o foresee.o gigadevice.o macronix.o -spinand-objs += micron.o paragon.o toshiba.o winbond.o xtx.o +spinand-objs += micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o obj-$(CONFIG_MTD_SPI_NAND) += spinand.odrivers/mtd/nand/spi/core.c +0
-0
drivers/mtd/nand/spi/core.c static int spinand_init_quad_enable(struct spinand_device *spinand) · line 200
Quoted 5 lines
drivers/mtd/nand/spi/core.c +2
-0@@ -196,6 +196,17 @@ static int spinand_init_quad_enable(struct spinand_device *spinand)static int spinand_ecc_enable (struct spinand_device *spinand,bool enable) { +/* +* SkyHigh Memory : always ECC on
how does the configuration register look like, would you please tell us its fields?
drivers/mtd/nand/spi/core.c static int spinand_init_quad_enable(struct spinand_device *spinand) · line 201
Quoted 1 line
drivers/mtd/nand/spi/core.c +1
-0+* The on-die ECC feature is totally transparent to the host.
this line brings no benefit, remove it
drivers/mtd/nand/spi/core.c static int spinand_init_quad_enable(struct spinand_device *spinand) · line 202
Quoted 1 line
drivers/mtd/nand/spi/core.c +1
-0+* The ECC parity bits used for this feature do not occupy the NAND spare areas.
its already implied, remove the line
drivers/mtd/nand/spi/core.c static int spinand_init_quad_enable(struct spinand_device *spinand) · line 203
Quoted 1 line
drivers/mtd/nand/spi/core.c +1
-0+* The host is free to have its own ECC engine by using the spare areas that have standard size.
Why would one want to have both the on-die and on-host ecc engine work in parallel?
drivers/mtd/nand/spi/core.c static int spinand_init_quad_enable(struct spinand_device *spinand) · line 204
Quoted 1 line
drivers/mtd/nand/spi/core.c +1
-0+* We provide this patch to enable users who have limited ECC capabilities on the host side to use the NAND flash.
remove this line, it brings no value
drivers/mtd/nand/spi/core.c static int spinand_init_quad_enable(struct spinand_device *spinand) · line 205
Quoted 1 line
drivers/mtd/nand/spi/core.c +1
-0+* This patch has been tested thoroughly on Linux.
all code is considered tested, remove this line
drivers/mtd/nand/spi/core.c static int spinand_init_quad_enable(struct spinand_device *spinand) · line 208
Quoted 3 lines
drivers/mtd/nand/spi/core.c +3
-0+*/ +if (spinand->flags &SPINAND_ON_DIE_ECC_MANDATORY ) +return 0 ;
the always on on-die ecc shall be discussed in a dedicated patch, as it touches the core.
Quoted 27 lines
drivers/mtd/nand/spi/core.c +3
-1+return spinand_upd_cfg (spinand,CFG_ECC_ENABLE , enable ?CFG_ECC_ENABLE :0 ); }@@ -561,7 +572,7 @@ static int spinand_reset_op(struct spinand_device *spinand) NULL); } -static int spinand_lock_block (struct spinand_device *spinand,u8 lock) +int spinand_lock_block (struct spinand_device *spinand,u8 lock) {return spinand_write_reg_op (spinand,REG_BLOCK_LOCK , lock); }@@ -945,6 +956,7 @@ static const struct spinand_manufacturer *spinand_manufacturers[] = { ¯onix_spinand_manufacturer, µn_spinand_manufacturer, ¶gon_spinand_manufacturer, + &skyhigh_spinand_manufacturer, &toshiba_spinand_manufacturer, &winbond_spinand_manufacturer, &xtx_spinand_manufacturer,drivers/mtd/nand/spi/skyhigh.c new file +0
-0
drivers/mtd/nand/spi/skyhigh.c line 3
Quoted 3 lines
drivers/mtd/nand/spi/skyhigh.c new file +3
-0@@ -0,0 +1,145 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2022 SkyHigh Memory Limited
Copyright followed by (c) is redundant. Update years.
drivers/mtd/nand/spi/skyhigh.c line 5
Quoted 2 lines
drivers/mtd/nand/spi/skyhigh.c new file +2
-0+* +* Author: Takahiro Kuwano <[email protected]>
You shall consider adding Takahiro as author, or co-author, or at least specify that the patch is derived from Takahiro's work.
Quoted 2 lines
drivers/mtd/nand/spi/skyhigh.c new file +2
-0+*/ +
cut
drivers/mtd/nand/spi/skyhigh.c line 43
Quoted 8 lines
drivers/mtd/nand/spi/skyhigh.c new file +8
-0+static int skyhigh_spinand_ooblayout_ecc (struct mtd_info *mtd,int section, +struct mtd_oob_region *region) +{ +if (section) +return -ERANGE ; + +/* SkyHigh's ecc parity is stored in the internal hidden area */ + region->length =0 ;
what happens when length is zero?
Quoted 4 lines
drivers/mtd/nand/spi/skyhigh.c new file +4
-0+ region->offset = mtd->oobsize; + +return 0 ; +}
cut
drivers/mtd/nand/spi/skyhigh.c line 132
Quoted 5 lines
drivers/mtd/nand/spi/skyhigh.c new file +5
-0+}; + +static int skyhigh_spinand_init (struct spinand_device *spinand) +{ +return spinand_lock_block (spinand,SKYHIGH_CONFIG_PROTECT_EN );
I see the core unlocks all blocks. Thus I assume you can as well remove the init method altogether, it brings no functional change.
Cheers,
ta