* (no subject)
@ 2010-02-03 2:56 Stanley.Miao
2010-02-03 2:56 ` [PATCH 1/5] clean up the legacy interfaces in nandwrite.c Stanley.Miao
2010-02-03 3:16 ` Mike Frysinger
0 siblings, 2 replies; 22+ messages in thread
From: Stanley.Miao @ 2010-02-03 2:56 UTC (permalink / raw)
To: linux-mtd
During some BSP development process, I found some tools in mtd-utils
contain legacy interfaces and it is not suitable with the current linux
kernel. I post my patches here in case somebody else need them.
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH 1/5] clean up the legacy interfaces in nandwrite.c
2010-02-03 2:56 Stanley.Miao
@ 2010-02-03 2:56 ` Stanley.Miao
2010-02-03 2:56 ` [PATCH 2/5] check if the start address is page-aligned Stanley.Miao
2010-02-03 3:16 ` Mike Frysinger
1 sibling, 1 reply; 22+ messages in thread
From: Stanley.Miao @ 2010-02-03 2:56 UTC (permalink / raw)
To: linux-mtd
The ioctl command "MEMSETOOBSEL" doesn't exist in the current linux kernel
anymore, and the arguments "forcelegacy", "jffs2", "yaffs", "noecc" are not
suitable with the current linux kernel, so clean them up.
Although the ioctl comand "MEMGETOOBSEL" still exist in the current linux
kernel, it is not suitable with some platforms with the NAND ECC data longer
than 32 bytes, so replace it with the new command "ECCGETLAYOUT"
Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
---
nandwrite.c | 181 +++++-----------------------------------------------------
1 files changed, 16 insertions(+), 165 deletions(-)
diff --git a/nandwrite.c b/nandwrite.c
index b77edd6..c66eda0 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -45,26 +45,6 @@
#define MAX_PAGE_SIZE 4096
#define MAX_OOB_SIZE 128
-// oob layouts to pass into the kernel as default
-static struct nand_oobinfo none_oobinfo = {
- .useecc = MTD_NANDECC_OFF,
-};
-
-static struct nand_oobinfo jffs2_oobinfo = {
- .useecc = MTD_NANDECC_PLACE,
- .eccbytes = 6,
- .eccpos = { 0, 1, 2, 3, 6, 7 }
-};
-
-static struct nand_oobinfo yaffs_oobinfo = {
- .useecc = MTD_NANDECC_PLACE,
- .eccbytes = 6,
- .eccpos = { 8, 9, 10, 13, 14, 15}
-};
-
-static struct nand_oobinfo autoplace_oobinfo = {
- .useecc = MTD_NANDECC_AUTOPLACE
-};
static void display_help (void)
{
@@ -72,13 +52,7 @@ static void display_help (void)
"Usage: nandwrite [OPTION] MTD_DEVICE [INPUTFILE|-]\n"
"Writes to the specified MTD device.\n"
"\n"
-" -a, --autoplace Use auto oob layout\n"
-" -j, --jffs2 Force jffs2 oob layout (legacy support)\n"
-" -y, --yaffs Force yaffs oob layout (legacy support)\n"
-" -f, --forcelegacy Force legacy support on autoplacement-enabled mtd\n"
-" device\n"
" -m, --markbad Mark blocks bad if write fails\n"
-" -n, --noecc Write without ecc\n"
" -o, --oob Image contains oob data\n"
" -s addr, --start=addr Set start address (default is 0)\n"
" -p, --pad Pad to page size\n"
@@ -110,12 +84,7 @@ static const char *mtd_device, *img;
static int mtdoffset = 0;
static bool quiet = false;
static bool writeoob = false;
-static bool autoplace = false;
static bool markbad = false;
-static bool forcejffs2 = false;
-static bool forceyaffs = false;
-static bool forcelegacy = false;
-static bool noecc = false;
static bool pad = false;
static int blockalign = 1; /*default to using 16K block size */
@@ -125,21 +94,16 @@ static void process_options (int argc, char * const argv[])
for (;;) {
int option_index = 0;
- static const char *short_options = "ab:fjmnopqs:y";
+ static const char *short_options = "b:mopqs:";
static const struct option long_options[] = {
{"help", no_argument, 0, 0},
{"version", no_argument, 0, 0},
- {"autoplace", no_argument, 0, 'a'},
{"blockalign", required_argument, 0, 'b'},
- {"forcelegacy", no_argument, 0, 'f'},
- {"jffs2", no_argument, 0, 'j'},
{"markbad", no_argument, 0, 'm'},
- {"noecc", no_argument, 0, 'n'},
{"oob", no_argument, 0, 'o'},
{"pad", no_argument, 0, 'p'},
{"quiet", no_argument, 0, 'q'},
{"start", required_argument, 0, 's'},
- {"yaffs", no_argument, 0, 'y'},
{0, 0, 0, 0},
};
@@ -163,21 +127,6 @@ static void process_options (int argc, char * const argv[])
case 'q':
quiet = true;
break;
- case 'a':
- autoplace = true;
- break;
- case 'j':
- forcejffs2 = true;
- break;
- case 'y':
- forceyaffs = true;
- break;
- case 'f':
- forcelegacy = true;
- break;
- case 'n':
- noecc = true;
- break;
case 'm':
markbad = true;
break;
@@ -251,8 +200,7 @@ int main(int argc, char * const argv[])
struct mtd_oob_buf oob;
loff_t offs;
int ret;
- int oobinfochanged = 0;
- struct nand_oobinfo old_oobinfo;
+ struct nand_ecclayout ecclayout;
bool failed = true;
// contains all the data read from the file so far for the current eraseblock
unsigned char *filebuf = NULL;
@@ -300,86 +248,16 @@ int main(int argc, char * const argv[])
exit (EXIT_FAILURE);
}
- if (autoplace) {
- /* Read the current oob info */
- if (ioctl (fd, MEMGETOOBSEL, &old_oobinfo) != 0) {
- perror ("MEMGETOOBSEL");
- close (fd);
- exit (EXIT_FAILURE);
- }
-
- // autoplace ECC ?
- if (autoplace && (old_oobinfo.useecc != MTD_NANDECC_AUTOPLACE)) {
-
- if (ioctl (fd, MEMSETOOBSEL, &autoplace_oobinfo) != 0) {
- perror ("MEMSETOOBSEL");
- close (fd);
- exit (EXIT_FAILURE);
- }
- oobinfochanged = 1;
- }
- }
-
- if (noecc) {
- ret = ioctl(fd, MTDFILEMODE, (void *) MTD_MODE_RAW);
- if (ret == 0) {
- oobinfochanged = 2;
- } else {
- switch (errno) {
- case ENOTTY:
- if (ioctl (fd, MEMGETOOBSEL, &old_oobinfo) != 0) {
- perror ("MEMGETOOBSEL");
- close (fd);
- exit (EXIT_FAILURE);
- }
- if (ioctl (fd, MEMSETOOBSEL, &none_oobinfo) != 0) {
- perror ("MEMSETOOBSEL");
- close (fd);
- exit (EXIT_FAILURE);
- }
- oobinfochanged = 1;
- break;
- default:
- perror ("MTDFILEMODE");
- close (fd);
- exit (EXIT_FAILURE);
- }
- }
- }
-
- /*
- * force oob layout for jffs2 or yaffs ?
- * Legacy support
- */
- if (forcejffs2 || forceyaffs) {
- struct nand_oobinfo *oobsel = forcejffs2 ? &jffs2_oobinfo : &yaffs_oobinfo;
- if (autoplace) {
- fprintf(stderr, "Autoplacement is not possible for legacy -j/-y options\n");
- goto restoreoob;
- }
- if ((old_oobinfo.useecc == MTD_NANDECC_AUTOPLACE) && !forcelegacy) {
- fprintf(stderr, "Use -f option to enforce legacy placement on autoplacement enabled mtd device\n");
- goto restoreoob;
- }
- if (meminfo.oobsize == 8) {
- if (forceyaffs) {
- fprintf (stderr, "YAFSS cannot operate on 256 Byte page size");
- goto restoreoob;
- }
- /* Adjust number of ecc bytes */
- jffs2_oobinfo.eccbytes = 3;
- }
+ oob.length = meminfo.oobsize;
+ oob.ptr = oobbuf;
- if (ioctl (fd, MEMSETOOBSEL, oobsel) != 0) {
- perror ("MEMSETOOBSEL");
- goto restoreoob;
- }
+ if (ioctl(fd, ECCGETLAYOUT, &ecclayout) != 0) {
+ perror("ECCGETLAYOUT");
+ close(fd);
+ exit(EXIT_FAILURE);
}
- oob.length = meminfo.oobsize;
- oob.ptr = noecc ? oobreadbuf : oobbuf;
-
/* Determine if we are reading from standard input or from a file. */
if (strcmp(img, standard_input) == 0) {
ifd = STDIN_FILENO;
@@ -543,6 +421,7 @@ int main(int argc, char * const argv[])
}
if (writeoob) {
+ int i, start, len;
oobreadbuf = writebuf + meminfo.writesize;
// Read more data for the OOB from the input if there isn't enough in the buffer
@@ -579,34 +458,13 @@ int main(int argc, char * const argv[])
}
}
- if (noecc) {
- oob.ptr = oobreadbuf;
- } else {
- int i, start, len;
- /*
- * We use autoplacement and have the oobinfo with the autoplacement
- * information from the kernel available
- *
- * Modified to support out of order oobfree segments,
- * such as the layout used by diskonchip.c
- */
- if (!oobinfochanged && (old_oobinfo.useecc == MTD_NANDECC_AUTOPLACE)) {
- for (i = 0;old_oobinfo.oobfree[i][1]; i++) {
- /* Set the reserved bytes to 0xff */
- start = old_oobinfo.oobfree[i][0];
- len = old_oobinfo.oobfree[i][1];
- memcpy(oobbuf + start,
- oobreadbuf + start,
- len);
- }
- } else {
- /* Set at least the ecc byte positions to 0xff */
- start = old_oobinfo.eccbytes;
- len = meminfo.oobsize - start;
- memcpy(oobbuf + start,
- oobreadbuf + start,
- len);
- }
+ for (i = 0; ecclayout.oobfree[i].length; i++) {
+ /* Set the reserved bytes to 0xff */
+ start = ecclayout.oobfree[i].offset;
+ len = ecclayout.oobfree[i].length;
+ memcpy(oobbuf + start,
+ oobreadbuf + start,
+ len);
}
/* Write OOB data first, as ecc will be placed in there*/
oob.start = mtdoffset;
@@ -666,13 +524,6 @@ closeall:
close(ifd);
restoreoob:
- if (oobinfochanged == 1) {
- if (ioctl (fd, MEMSETOOBSEL, &old_oobinfo) != 0) {
- perror ("MEMSETOOBSEL");
- close (fd);
- exit (EXIT_FAILURE);
- }
- }
close(fd);
--
1.5.4.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 2/5] check if the start address is page-aligned.
2010-02-03 2:56 ` [PATCH 1/5] clean up the legacy interfaces in nandwrite.c Stanley.Miao
@ 2010-02-03 2:56 ` Stanley.Miao
2010-02-03 2:56 ` [PATCH 3/5] Fix the bug of writing a yaffs2 image to NAND Stanley.Miao
0 siblings, 1 reply; 22+ messages in thread
From: Stanley.Miao @ 2010-02-03 2:56 UTC (permalink / raw)
To: linux-mtd
Only page-aligned address is permitted in NAND subsystem.
Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
---
nandwrite.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/nandwrite.c b/nandwrite.c
index c66eda0..c66ab54 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -248,6 +248,13 @@ int main(int argc, char * const argv[])
exit (EXIT_FAILURE);
}
+ if (mtdoffset & (meminfo.writesize - 1)) {
+ fprintf(stderr, "The start address is not page-aligned !\n"
+ "The pagesize of this NAND Flash is 0x%x.\n",
+ meminfo.writesize);
+ close(fd);
+ exit(EXIT_FAILURE);
+ }
oob.length = meminfo.oobsize;
oob.ptr = oobbuf;
--
1.5.4.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 3/5] Fix the bug of writing a yaffs2 image to NAND
2010-02-03 2:56 ` [PATCH 2/5] check if the start address is page-aligned Stanley.Miao
@ 2010-02-03 2:56 ` Stanley.Miao
2010-02-03 2:56 ` [PATCH 4/5] Discard the legacy interface MEMGETOOBSEL in flash_eraseall Stanley.Miao
0 siblings, 1 reply; 22+ messages in thread
From: Stanley.Miao @ 2010-02-03 2:56 UTC (permalink / raw)
To: linux-mtd
The tool mkyaffs2image doesn't know the oob layout of a NAND flash, so it
puts the yaffs2 tags at the offset 0 of oob area. When nandwrite writes the
image into NAND flash, it should put the yaffs2 tags at the right position
according to the NAND oob layout.
Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
---
nandwrite.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/nandwrite.c b/nandwrite.c
index c66ab54..35f1e4d 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -429,6 +429,8 @@ int main(int argc, char * const argv[])
if (writeoob) {
int i, start, len;
+ int tags_pos = 0;
+
oobreadbuf = writebuf + meminfo.writesize;
// Read more data for the OOB from the input if there isn't enough in the buffer
@@ -470,8 +472,8 @@ int main(int argc, char * const argv[])
start = ecclayout.oobfree[i].offset;
len = ecclayout.oobfree[i].length;
memcpy(oobbuf + start,
- oobreadbuf + start,
- len);
+ oobreadbuf + tags_pos, len);
+ tags_pos += len;
}
/* Write OOB data first, as ecc will be placed in there*/
oob.start = mtdoffset;
--
1.5.4.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 4/5] Discard the legacy interface MEMGETOOBSEL in flash_eraseall
2010-02-03 2:56 ` [PATCH 3/5] Fix the bug of writing a yaffs2 image to NAND Stanley.Miao
@ 2010-02-03 2:56 ` Stanley.Miao
2010-02-03 2:56 ` [PATCH 5/5] Place the cleanmarker in OOB area according to the mode MTD_OOB_AUTO Stanley.Miao
0 siblings, 1 reply; 22+ messages in thread
From: Stanley.Miao @ 2010-02-03 2:56 UTC (permalink / raw)
To: linux-mtd
The ioctl command "MEMGETOOBSEL" is not suitable with some platforms with
the NAND ECC data longer than 32 bytes, so replace it with the new command
"ECCGETLAYOUT".
Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
---
flash_eraseall.c | 42 ++++++++++++------------------------------
1 files changed, 12 insertions(+), 30 deletions(-)
diff --git a/flash_eraseall.c b/flash_eraseall.c
index a22fc49..1842906 100644
--- a/flash_eraseall.c
+++ b/flash_eraseall.c
@@ -84,41 +84,23 @@ int main (int argc, char *argv[])
if (!isNAND)
cleanmarker.totlen = cpu_to_je32 (sizeof (struct jffs2_unknown_node));
else {
- struct nand_oobinfo oobinfo;
+ struct nand_ecclayout ecclayout;
- if (ioctl(fd, MEMGETOOBSEL, &oobinfo) != 0) {
- fprintf(stderr, "%s: %s: unable to get NAND oobinfo\n", exe_name, mtd_device);
+ if (ioctl(fd, ECCGETLAYOUT, &ecclayout) != 0) {
+ fprintf(stderr, "%s: %s: unable to get NAND oob layout\n",
+ exe_name, mtd_device);
return 1;
}
- /* Check for autoplacement */
- if (oobinfo.useecc == MTD_NANDECC_AUTOPLACE) {
- /* Get the position of the free bytes */
- if (!oobinfo.oobfree[0][1]) {
- fprintf (stderr, " Eeep. Autoplacement selected and no empty space in oob\n");
- return 1;
- }
- clmpos = oobinfo.oobfree[0][0];
- clmlen = oobinfo.oobfree[0][1];
- if (clmlen > 8)
- clmlen = 8;
- } else {
- /* Legacy mode */
- switch (meminfo.oobsize) {
- case 8:
- clmpos = 6;
- clmlen = 2;
- break;
- case 16:
- clmpos = 8;
- clmlen = 8;
- break;
- case 64:
- clmpos = 16;
- clmlen = 8;
- break;
- }
+ /* Get the position of the free bytes */
+ if (!ecclayout.oobfree[0].length) {
+ fprintf(stderr, " Eeep. Autoplacement selected and no empty space in oob\n");
+ return 1;
}
+ clmpos = ecclayout.oobfree[0].offset;
+ clmlen = ecclayout.oobfree[0].length;
+ if (clmlen > 8)
+ clmlen = 8;
cleanmarker.totlen = cpu_to_je32(8);
}
cleanmarker.hdr_crc = cpu_to_je32 (crc32 (0, &cleanmarker, sizeof (struct jffs2_unknown_node) - 4));
--
1.5.4.3
^ permalink raw reply related [flat|nested] 22+ messages in thread* [PATCH 5/5] Place the cleanmarker in OOB area according to the mode MTD_OOB_AUTO
2010-02-03 2:56 ` [PATCH 4/5] Discard the legacy interface MEMGETOOBSEL in flash_eraseall Stanley.Miao
@ 2010-02-03 2:56 ` Stanley.Miao
0 siblings, 0 replies; 22+ messages in thread
From: Stanley.Miao @ 2010-02-03 2:56 UTC (permalink / raw)
To: linux-mtd
In the current linux kernel, Jffs2 writes the cleanmarker according to the
mode MTD_OOB_AUTO, so modify the layout of the cleanmarker from
MTD_OOB_PLACE to MTD_OOB_AUTO in flash_eraseall.
Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
---
flash_eraseall.c | 38 ++++++++++++++++++++------------------
1 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/flash_eraseall.c b/flash_eraseall.c
index 1842906..d2d0bcb 100644
--- a/flash_eraseall.c
+++ b/flash_eraseall.c
@@ -34,7 +34,7 @@
#include <time.h>
#include <getopt.h>
#include <sys/ioctl.h>
-#include <sys/mount.h>
+#include <sys/param.h>
#include "crc32.h"
#include <mtd/mtd-user.h>
@@ -58,9 +58,11 @@ int target_endian = __BYTE_ORDER;
int main (int argc, char *argv[])
{
mtd_info_t meminfo;
- int fd, clmpos = 0, clmlen = 8;
+ int fd;
erase_info_t erase;
int isNAND, bbtest = 1;
+ unsigned char oobbuf[128];
+ memset(oobbuf, 0xFF, 128);
process_options(argc, argv);
@@ -81,29 +83,29 @@ int main (int argc, char *argv[])
if (jffs2) {
cleanmarker.magic = cpu_to_je16 (JFFS2_MAGIC_BITMASK);
cleanmarker.nodetype = cpu_to_je16 (JFFS2_NODETYPE_CLEANMARKER);
- if (!isNAND)
+ if (!isNAND) {
cleanmarker.totlen = cpu_to_je32 (sizeof (struct jffs2_unknown_node));
- else {
+ cleanmarker.hdr_crc = cpu_to_je32(crc32(0, &cleanmarker, sizeof(struct jffs2_unknown_node) - 4));
+ } else {
+ int already_read, num, i, start;
struct nand_ecclayout ecclayout;
+ cleanmarker.totlen = cpu_to_je32(8);
+ cleanmarker.hdr_crc = cpu_to_je32(crc32(0, &cleanmarker, sizeof(struct jffs2_unknown_node) - 4));
+
if (ioctl(fd, ECCGETLAYOUT, &ecclayout) != 0) {
fprintf(stderr, "%s: %s: unable to get NAND oob layout\n",
exe_name, mtd_device);
return 1;
}
-
- /* Get the position of the free bytes */
- if (!ecclayout.oobfree[0].length) {
- fprintf(stderr, " Eeep. Autoplacement selected and no empty space in oob\n");
- return 1;
+ already_read = 0;
+ for (i = 0; (already_read < 8) && ecclayout.oobfree[i].length; i++) {
+ num = MIN(8 - already_read, ecclayout.oobfree[i].length);
+ start = ecclayout.oobfree[i].offset;
+ memcpy(oobbuf + start, (unsigned char *)&cleanmarker + already_read, num);
+ already_read += num;
}
- clmpos = ecclayout.oobfree[0].offset;
- clmlen = ecclayout.oobfree[0].length;
- if (clmlen > 8)
- clmlen = 8;
- cleanmarker.totlen = cpu_to_je32(8);
}
- cleanmarker.hdr_crc = cpu_to_je32 (crc32 (0, &cleanmarker, sizeof (struct jffs2_unknown_node) - 4));
}
for (erase.start = 0; erase.start < meminfo.size; erase.start += meminfo.erasesize) {
@@ -143,9 +145,9 @@ int main (int argc, char *argv[])
/* write cleanmarker */
if (isNAND) {
struct mtd_oob_buf oob;
- oob.ptr = (unsigned char *) &cleanmarker;
- oob.start = erase.start + clmpos;
- oob.length = clmlen;
+ oob.ptr = oobbuf;
+ oob.start = erase.start;
+ oob.length = meminfo.oobsize;
if (ioctl (fd, MEMWRITEOOB, &oob) != 0) {
fprintf(stderr, "\n%s: %s: MTD writeoob failure: %s\n", exe_name, mtd_device, strerror(errno));
continue;
--
1.5.4.3
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re:
2010-02-03 2:56 Stanley.Miao
2010-02-03 2:56 ` [PATCH 1/5] clean up the legacy interfaces in nandwrite.c Stanley.Miao
@ 2010-02-03 3:16 ` Mike Frysinger
2010-02-03 4:31 ` Re: stanley.miao
1 sibling, 1 reply; 22+ messages in thread
From: Mike Frysinger @ 2010-02-03 3:16 UTC (permalink / raw)
To: Stanley.Miao; +Cc: linux-mtd
On Tue, Feb 2, 2010 at 21:56, Stanley.Miao wrote:
> During some BSP development process, I found some tools in mtd-utils
> contain legacy interfaces and it is not suitable with the current linux
> kernel. I post my patches here in case somebody else need them.
these are good, but i think people might want to keep support for
older kernels around. so you'd have the code try the newer ioctls
first and if those fail, fall back to the old ones.
-mike
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re:
2010-02-03 3:16 ` Mike Frysinger
@ 2010-02-03 4:31 ` stanley.miao
0 siblings, 0 replies; 22+ messages in thread
From: stanley.miao @ 2010-02-03 4:31 UTC (permalink / raw)
To: Mike Frysinger; +Cc: linux-mtd
Mike Frysinger wrote:
> On Tue, Feb 2, 2010 at 21:56, Stanley.Miao wrote:
>
>> During some BSP development process, I found some tools in mtd-utils
>> contain legacy interfaces and it is not suitable with the current linux
>> kernel. I post my patches here in case somebody else need them.
>>
>
> these are good, but i think people might want to keep support for
> older kernels around. so you'd have the code try the newer ioctls
> first and if those fail, fall back to the old ones.
> -mike
>
>
Yeah, we should keep it compatible ASAP. But in the conflict occasion, I
think, the
new kernel should get the higher priorities than the older kernel. The
people who
use the old kernels can use the old version mtd-utils(not very old,
1.3.1 or earlier).
Stanley.
^ permalink raw reply [flat|nested] 22+ messages in thread
* (no subject)
@ 2024-03-07 6:07 KR Kim
2024-03-07 8:01 ` Miquel Raynal
0 siblings, 1 reply; 22+ messages in thread
From: KR Kim @ 2024-03-07 6:07 UTC (permalink / raw)
To: miquel.raynal, richard, vigneshr, mmkurbanov, ddrokosov,
gch981213
Cc: kr.kim, michael, broonie, mika.westerberg, acelan.kao,
linux-kernel, linux-mtd, moh.sardi, changsub.shim
Feat: Add SkyHigh Memory Patch code
Add SPI Nand Patch code of SkyHigh Memory
- Add company dependent code with 'skyhigh.c'
- Insert into 'core.c' so that 'always ECC on'
commit 6061b97a830af8cb5fd0917e833e779451f9046a (HEAD -> master)
Author: KR Kim <kr.kim@skyhighmemory.com>
Date: Thu Mar 7 13:24:11 2024 +0900
SPI Nand Patch code of SkyHigh Momory
Signed-off-by: KR Kim <kr.kim@skyhighmemory.com>
From 6061b97a830af8cb5fd0917e833e779451f9046a Mon Sep 17 00:00:00 2001
From: KR Kim <kr.kim@skyhighmemory.com>
Date: Thu, 7 Mar 2024 13:24:11 +0900
Subject: [PATCH] SPI Nand Patch code of SkyHigh Memory
---
drivers/mtd/nand/spi/Makefile | 2 +-
drivers/mtd/nand/spi/core.c | 7 +-
drivers/mtd/nand/spi/skyhigh.c | 155 +++++++++++++++++++++++++++++++++
include/linux/mtd/spinand.h | 3 +
4 files changed, 165 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
diff --git a/drivers/mtd/nand/spi/Makefile b/drivers/mtd/nand/spi/Makefile
old mode 100644
new mode 100755
index 19cc77288ebb..1e61ab21893a
--- a/drivers/mtd/nand/spi/Makefile
+++ b/drivers/mtd/nand/spi/Makefile
@@ -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
diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
old mode 100644
new mode 100755
index e0b6715e5dfe..e3f0a7544ba4
--- a/drivers/mtd/nand/spi/core.c
+++ b/drivers/mtd/nand/spi/core.c
@@ -34,7 +34,7 @@ static int spinand_read_reg_op(struct spinand_device *spinand, u8 reg, u8 *val)
return 0;
}
-static int spinand_write_reg_op(struct spinand_device *spinand, u8 reg, u8 val)
+int spinand_write_reg_op(struct spinand_device *spinand, u8 reg, u8 val)
{
struct spi_mem_op op = SPINAND_SET_FEATURE_OP(reg,
spinand->scratchbuf);
@@ -196,6 +196,10 @@ static int spinand_init_quad_enable(struct spinand_device *spinand)
static int spinand_ecc_enable(struct spinand_device *spinand,
bool enable)
{
+ /* SHM : always ECC enable */
+ if (spinand->flags & SPINAND_ON_DIE_ECC_MANDATORY)
+ return 0;
+
return spinand_upd_cfg(spinand, CFG_ECC_ENABLE,
enable ? CFG_ECC_ENABLE : 0);
}
@@ -945,6 +949,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,
diff --git a/drivers/mtd/nand/spi/skyhigh.c b/drivers/mtd/nand/spi/skyhigh.c
new file mode 100644
index 000000000000..92e7572094ff
--- /dev/null
+++ b/drivers/mtd/nand/spi/skyhigh.c
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2022 SkyHigh Memory Limited
+ *
+ * Author: Takahiro Kuwano <takahiro.kuwano@infineon.com>
+ */
+
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/mtd/spinand.h>
+
+#define SPINAND_MFR_SKYHIGH 0x01
+
+#define SKYHIGH_STATUS_ECC_1TO2_BITFLIPS (1 << 4)
+#define SKYHIGH_STATUS_ECC_3TO6_BITFLIPS (2 << 4)
+#define SKYHIGH_STATUS_ECC_UNCOR_ERROR (3 << 4)
+
+#define SKYHIGH_CONFIG_PROTECT_EN BIT(1)
+
+static SPINAND_OP_VARIANTS(read_cache_variants,
+ SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 4, NULL, 0),
+ SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
+ SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 2, NULL, 0),
+ SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
+ SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
+ SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
+
+static SPINAND_OP_VARIANTS(write_cache_variants,
+ SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
+ SPINAND_PROG_LOAD(true, 0, NULL, 0));
+
+static SPINAND_OP_VARIANTS(update_cache_variants,
+ SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
+ SPINAND_PROG_LOAD(false, 0, NULL, 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 and is not needed for them. */
+ region->length = 0;
+ region->offset = mtd->oobsize;
+
+ return 0;
+}
+
+static int skyhigh_spinand_ooblayout_free(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *region)
+{
+ if (section)
+ return -ERANGE;
+
+ region->length = mtd->oobsize - 2;
+ region->offset = 2;
+
+ return 0;
+}
+
+static const struct mtd_ooblayout_ops skyhigh_spinand_ooblayout = {
+ .ecc = skyhigh_spinand_ooblayout_ecc,
+ .free = skyhigh_spinand_ooblayout_free,
+};
+
+static int skyhigh_spinand_ecc_get_status(struct spinand_device *spinand,
+ u8 status)
+{
+ /* SHM
+ * 00 : No bit-flip
+ * 01 : 1-2 errors corrected
+ * 10 : 3-6 errors corrected
+ * 11 : uncorrectable
+ */
+
+ switch (status & STATUS_ECC_MASK) {
+ case STATUS_ECC_NO_BITFLIPS:
+ return 0;
+
+ case SKYHIGH_STATUS_ECC_1TO2_BITFLIPS:
+ return 2;
+
+ case SKYHIGH_STATUS_ECC_3TO6_BITFLIPS:
+ return 6;
+
+ case SKYHIGH_STATUS_ECC_UNCOR_ERROR:
+ return -EBADMSG;;
+
+ default:
+ break;
+ }
+
+ return -EINVAL;
+}
+
+static const struct spinand_info skyhigh_spinand_table[] = {
+ SPINAND_INFO("S35ML01G301",
+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x15),
+ NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
+ NAND_ECCREQ(6, 32),
+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+ &write_cache_variants,
+ &update_cache_variants),
+ SPINAND_ON_DIE_ECC_MANDATORY,
+ SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
+ skyhigh_spinand_ecc_get_status)),
+ SPINAND_INFO("S35ML01G300",
+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14),
+ NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
+ NAND_ECCREQ(6, 32),
+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+ &write_cache_variants,
+ &update_cache_variants),
+ SPINAND_ON_DIE_ECC_MANDATORY,
+ SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
+ skyhigh_spinand_ecc_get_status)),
+ SPINAND_INFO("S35ML02G300",
+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x25),
+ NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1),
+ NAND_ECCREQ(6, 32),
+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+ &write_cache_variants,
+ &update_cache_variants),
+ SPINAND_ON_DIE_ECC_MANDATORY,
+ SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
+ skyhigh_spinand_ecc_get_status)),
+ SPINAND_INFO("S35ML04G300",
+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35),
+ NAND_MEMORG(1, 2048, 128, 64, 4096, 80, 2, 1, 1),
+ NAND_ECCREQ(6, 32),
+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+ &write_cache_variants,
+ &update_cache_variants),
+ SPINAND_ON_DIE_ECC_MANDATORY,
+ SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
+ skyhigh_spinand_ecc_get_status)),
+};
+
+static int skyhigh_spinand_init(struct spinand_device *spinand)
+{
+ return spinand_write_reg_op(spinand, REG_BLOCK_LOCK,
+ SKYHIGH_CONFIG_PROTECT_EN);
+}
+
+static const struct spinand_manufacturer_ops skyhigh_spinand_manuf_ops = {
+ .init = skyhigh_spinand_init,
+ };
+
+const struct spinand_manufacturer skyhigh_spinand_manufacturer = {
+ .id = SPINAND_MFR_SKYHIGH,
+ .name = "SkyHigh",
+ .chips = skyhigh_spinand_table,
+ .nchips = ARRAY_SIZE(skyhigh_spinand_table),
+ .ops = &skyhigh_spinand_manuf_ops,
+};
diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
old mode 100644
new mode 100755
index badb4c1ac079..0e135076df24
--- a/include/linux/mtd/spinand.h
+++ b/include/linux/mtd/spinand.h
@@ -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_write_reg_op(struct spinand_device *spinand, u8 reg, u8 val);
#endif /* __LINUX_MTD_SPINAND_H */
--
2.34.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re:
2024-03-07 6:07 KR Kim
@ 2024-03-07 8:01 ` Miquel Raynal
2024-03-08 1:27 ` Re: Kyeongrho.Kim
[not found] ` <SE2P216MB210205B301549661575720CC833A2@SE2P216MB2102.KORP216.PROD.OUTLOOK.COM>
0 siblings, 2 replies; 22+ messages in thread
From: Miquel Raynal @ 2024-03-07 8:01 UTC (permalink / raw)
To: KR Kim
Cc: richard, vigneshr, mmkurbanov, ddrokosov, gch981213, michael,
broonie, mika.westerberg, acelan.kao, linux-kernel, linux-mtd,
moh.sardi, changsub.shim
Hi,
kr.kim@skyhighmemory.com wrote on Thu, 7 Mar 2024 15:07:29 +0900:
> Feat: Add SkyHigh Memory Patch code
>
> Add SPI Nand Patch code of SkyHigh Memory
> - Add company dependent code with 'skyhigh.c'
> - Insert into 'core.c' so that 'always ECC on'
Patch formatting is still messed up.
> commit 6061b97a830af8cb5fd0917e833e779451f9046a (HEAD -> master)
> Author: KR Kim <kr.kim@skyhighmemory.com>
> Date: Thu Mar 7 13:24:11 2024 +0900
>
> SPI Nand Patch code of SkyHigh Momory
>
> Signed-off-by: KR Kim <kr.kim@skyhighmemory.com>
>
> From 6061b97a830af8cb5fd0917e833e779451f9046a Mon Sep 17 00:00:00 2001
> From: KR Kim <kr.kim@skyhighmemory.com>
> Date: Thu, 7 Mar 2024 13:24:11 +0900
> Subject: [PATCH] SPI Nand Patch code of SkyHigh Memory
>
> ---
> drivers/mtd/nand/spi/Makefile | 2 +-
> drivers/mtd/nand/spi/core.c | 7 +-
> drivers/mtd/nand/spi/skyhigh.c | 155 +++++++++++++++++++++++++++++++++
> include/linux/mtd/spinand.h | 3 +
> 4 files changed, 165 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
>
> diff --git a/drivers/mtd/nand/spi/Makefile b/drivers/mtd/nand/spi/Makefile
> old mode 100644
> new mode 100755
> index 19cc77288ebb..1e61ab21893a
> --- a/drivers/mtd/nand/spi/Makefile
> +++ b/drivers/mtd/nand/spi/Makefile
> @@ -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
> diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c
> old mode 100644
> new mode 100755
> index e0b6715e5dfe..e3f0a7544ba4
> --- a/drivers/mtd/nand/spi/core.c
> +++ b/drivers/mtd/nand/spi/core.c
> @@ -34,7 +34,7 @@ static int spinand_read_reg_op(struct spinand_device *spinand, u8 reg, u8 *val)
> return 0;
> }
>
> -static int spinand_write_reg_op(struct spinand_device *spinand, u8 reg, u8 val)
> +int spinand_write_reg_op(struct spinand_device *spinand, u8 reg, u8 val)
Please do this in a separate commit.
> {
> struct spi_mem_op op = SPINAND_SET_FEATURE_OP(reg,
> spinand->scratchbuf);
> @@ -196,6 +196,10 @@ static int spinand_init_quad_enable(struct spinand_device *spinand)
> static int spinand_ecc_enable(struct spinand_device *spinand,
> bool enable)
> {
> + /* SHM : always ECC enable */
> + if (spinand->flags & SPINAND_ON_DIE_ECC_MANDATORY)
> + return 0;
Silently always enabling ECC is not possible. If you cannot disable the
on-die engine, then:
- you should prevent any other engine type to be used
- you should error out if a raw access is requested
- these chips are broken, IMO
> +
> return spinand_upd_cfg(spinand, CFG_ECC_ENABLE,
> enable ? CFG_ECC_ENABLE : 0);
> }
> @@ -945,6 +949,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,
> diff --git a/drivers/mtd/nand/spi/skyhigh.c b/drivers/mtd/nand/spi/skyhigh.c
> new file mode 100644
> index 000000000000..92e7572094ff
> --- /dev/null
> +++ b/drivers/mtd/nand/spi/skyhigh.c
> @@ -0,0 +1,155 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2022 SkyHigh Memory Limited
> + *
> + * Author: Takahiro Kuwano <takahiro.kuwano@infineon.com>
> + */
> +
> +#include <linux/device.h>
> +#include <linux/kernel.h>
> +#include <linux/mtd/spinand.h>
> +
> +#define SPINAND_MFR_SKYHIGH 0x01
> +
> +#define SKYHIGH_STATUS_ECC_1TO2_BITFLIPS (1 << 4)
> +#define SKYHIGH_STATUS_ECC_3TO6_BITFLIPS (2 << 4)
> +#define SKYHIGH_STATUS_ECC_UNCOR_ERROR (3 << 4)
> +
> +#define SKYHIGH_CONFIG_PROTECT_EN BIT(1)
> +
> +static SPINAND_OP_VARIANTS(read_cache_variants,
> + SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 4, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 2, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
> +
> +static SPINAND_OP_VARIANTS(write_cache_variants,
> + SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
> + SPINAND_PROG_LOAD(true, 0, NULL, 0));
> +
> +static SPINAND_OP_VARIANTS(update_cache_variants,
> + SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
> + SPINAND_PROG_LOAD(false, 0, NULL, 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 and is not needed for them. */
ECC an
"needed" is wrong here. Just stop after "area"
> + region->length = 0;
> + region->offset = mtd->oobsize;
> +
> + return 0;
> +}
> +
> +static int skyhigh_spinand_ooblayout_free(struct mtd_info *mtd, int section,
> + struct mtd_oob_region *region)
> +{
> + if (section)
> + return -ERANGE;
> +
> + region->length = mtd->oobsize - 2;
> + region->offset = 2;
> +
> + return 0;
> +}
> +
> +static const struct mtd_ooblayout_ops skyhigh_spinand_ooblayout = {
> + .ecc = skyhigh_spinand_ooblayout_ecc,
> + .free = skyhigh_spinand_ooblayout_free,
> +};
> +
> +static int skyhigh_spinand_ecc_get_status(struct spinand_device *spinand,
> + u8 status)
> +{
> + /* SHM
> + * 00 : No bit-flip
> + * 01 : 1-2 errors corrected
> + * 10 : 3-6 errors corrected
> + * 11 : uncorrectable
> + */
Thanks for the comment but the switch case looks rather
straightforward, it is self-sufficient in this case.
> +
> + switch (status & STATUS_ECC_MASK) {
> + case STATUS_ECC_NO_BITFLIPS:
> + return 0;
> +
> + case SKYHIGH_STATUS_ECC_1TO2_BITFLIPS:
> + return 2;
> +
> + case SKYHIGH_STATUS_ECC_3TO6_BITFLIPS:
> + return 6;
> +
> + case SKYHIGH_STATUS_ECC_UNCOR_ERROR:
> + return -EBADMSG;;
> +
> + default:
> + break;
I guess you can directly call return -EINVAL here?
> + }
> +
> + return -EINVAL;
> +}
> +
> +static const struct spinand_info skyhigh_spinand_table[] = {
> + SPINAND_INFO("S35ML01G301",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x15),
> + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
> + NAND_ECCREQ(6, 32),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + SPINAND_ON_DIE_ECC_MANDATORY,
> + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
> + skyhigh_spinand_ecc_get_status)),
> + SPINAND_INFO("S35ML01G300",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14),
> + NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
> + NAND_ECCREQ(6, 32),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + SPINAND_ON_DIE_ECC_MANDATORY,
> + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
> + skyhigh_spinand_ecc_get_status)),
> + SPINAND_INFO("S35ML02G300",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x25),
> + NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1),
> + NAND_ECCREQ(6, 32),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + SPINAND_ON_DIE_ECC_MANDATORY,
> + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
> + skyhigh_spinand_ecc_get_status)),
> + SPINAND_INFO("S35ML04G300",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35),
> + NAND_MEMORG(1, 2048, 128, 64, 4096, 80, 2, 1, 1),
> + NAND_ECCREQ(6, 32),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + SPINAND_ON_DIE_ECC_MANDATORY,
> + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
> + skyhigh_spinand_ecc_get_status)),
> +};
> +
> +static int skyhigh_spinand_init(struct spinand_device *spinand)
> +{
> + return spinand_write_reg_op(spinand, REG_BLOCK_LOCK,
> + SKYHIGH_CONFIG_PROTECT_EN);
Is this really relevant? Isn't there an API for the block lock
mechanism?
> +}
> +
> +static const struct spinand_manufacturer_ops skyhigh_spinand_manuf_ops = {
> + .init = skyhigh_spinand_init,
> + };
> +
> +const struct spinand_manufacturer skyhigh_spinand_manufacturer = {
> + .id = SPINAND_MFR_SKYHIGH,
> + .name = "SkyHigh",
> + .chips = skyhigh_spinand_table,
> + .nchips = ARRAY_SIZE(skyhigh_spinand_table),
> + .ops = &skyhigh_spinand_manuf_ops,
> +};
> diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
> old mode 100644
> new mode 100755
> index badb4c1ac079..0e135076df24
> --- a/include/linux/mtd/spinand.h
> +++ b/include/linux/mtd/spinand.h
> @@ -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 */
If we go this route, then "mandatory" is not relevant here, we shall
convey the fact that the on-die ECC engine cannot be disabled and as
mentioned above, there are other impacts.
>
> /**
> * 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_write_reg_op(struct spinand_device *spinand, u8 reg, u8 val);
>
> #endif /* __LINUX_MTD_SPINAND_H */
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 22+ messages in thread* RE: Re:
2024-03-07 8:01 ` Miquel Raynal
@ 2024-03-08 1:27 ` Kyeongrho.Kim
[not found] ` <SE2P216MB210205B301549661575720CC833A2@SE2P216MB2102.KORP216.PROD.OUTLOOK.COM>
1 sibling, 0 replies; 22+ messages in thread
From: Kyeongrho.Kim @ 2024-03-08 1:27 UTC (permalink / raw)
To: Miquel Raynal
Cc: richard@nod.at, vigneshr@ti.com, mmkurbanov@salutedevices.com,
ddrokosov@sberdevices.ru, gch981213@gmail.com, michael@walle.cc,
broonie@kernel.org, mika.westerberg@linux.intel.com,
acelan.kao@canonical.com, linux-kernel@vger.kernel.org,
linux-mtd@lists.infradead.org, Mohamed Sardi, Changsub.Shim
Hi Miquel,
Thank you for your comment.
I tried to match the patch format, but it seems to be not enough yet.
Can you send me a good sample for the patch format?
Thanks,
KR
-----Original Message-----
From: Miquel Raynal <miquel.raynal@bootlin.com>
Sent: Thursday, March 7, 2024 5:01 PM
To: Kyeongrho.Kim <kr.kim@skyhighmemory.com>
Cc: richard@nod.at; vigneshr@ti.com; mmkurbanov@salutedevices.com; ddrokosov@sberdevices.ru; gch981213@gmail.com; michael@walle.cc; broonie@kernel.org; mika.westerberg@linux.intel.com; acelan.kao@canonical.com; linux-kernel@vger.kernel.org; linux-mtd@lists.infradead.org; Mohamed Sardi <moh.sardi@skyhighmemory.com>; Changsub.Shim <changsub.shim@skyhighmemory.com>
Subject: Re:
Hi,
kr.kim@skyhighmemory.com wrote on Thu, 7 Mar 2024 15:07:29 +0900:
> Feat: Add SkyHigh Memory Patch code
>
> Add SPI Nand Patch code of SkyHigh Memory
> - Add company dependent code with 'skyhigh.c'
> - Insert into 'core.c' so that 'always ECC on'
Patch formatting is still messed up.
> commit 6061b97a830af8cb5fd0917e833e779451f9046a (HEAD -> master)
> Author: KR Kim <kr.kim@skyhighmemory.com>
> Date: Thu Mar 7 13:24:11 2024 +0900
>
> SPI Nand Patch code of SkyHigh Momory
>
> Signed-off-by: KR Kim <kr.kim@skyhighmemory.com>
>
> From 6061b97a830af8cb5fd0917e833e779451f9046a Mon Sep 17 00:00:00 2001
> From: KR Kim <kr.kim@skyhighmemory.com>
> Date: Thu, 7 Mar 2024 13:24:11 +0900
> Subject: [PATCH] SPI Nand Patch code of SkyHigh Memory
>
> ---
> drivers/mtd/nand/spi/Makefile | 2 +-
> drivers/mtd/nand/spi/core.c | 7 +-
> drivers/mtd/nand/spi/skyhigh.c | 155 +++++++++++++++++++++++++++++++++
> include/linux/mtd/spinand.h | 3 +
> 4 files changed, 165 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
>
> diff --git a/drivers/mtd/nand/spi/Makefile
> b/drivers/mtd/nand/spi/Makefile old mode 100644 new mode 100755 index
> 19cc77288ebb..1e61ab21893a
> --- a/drivers/mtd/nand/spi/Makefile
> +++ b/drivers/mtd/nand/spi/Makefile
> @@ -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 diff --git
> a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c old mode
> 100644 new mode 100755 index e0b6715e5dfe..e3f0a7544ba4
> --- a/drivers/mtd/nand/spi/core.c
> +++ b/drivers/mtd/nand/spi/core.c
> @@ -34,7 +34,7 @@ static int spinand_read_reg_op(struct spinand_device *spinand, u8 reg, u8 *val)
> return 0;
> }
>
> -static int spinand_write_reg_op(struct spinand_device *spinand, u8
> reg, u8 val)
> +int spinand_write_reg_op(struct spinand_device *spinand, u8 reg, u8
> +val)
Please do this in a separate commit.
> {
> struct spi_mem_op op = SPINAND_SET_FEATURE_OP(reg,
> spinand->scratchbuf);
> @@ -196,6 +196,10 @@ static int spinand_init_quad_enable(struct
> spinand_device *spinand) static int spinand_ecc_enable(struct spinand_device *spinand,
> bool enable)
> {
> + /* SHM : always ECC enable */
> + if (spinand->flags & SPINAND_ON_DIE_ECC_MANDATORY)
> + return 0;
Silently always enabling ECC is not possible. If you cannot disable the on-die engine, then:
- you should prevent any other engine type to be used
- you should error out if a raw access is requested
- these chips are broken, IMO
> +
> return spinand_upd_cfg(spinand, CFG_ECC_ENABLE,
> enable ? CFG_ECC_ENABLE : 0); } @@ -945,6 +949,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,
> diff --git a/drivers/mtd/nand/spi/skyhigh.c
> b/drivers/mtd/nand/spi/skyhigh.c new file mode 100644 index
> 000000000000..92e7572094ff
> --- /dev/null
> +++ b/drivers/mtd/nand/spi/skyhigh.c
> @@ -0,0 +1,155 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2022 SkyHigh Memory Limited
> + *
> + * Author: Takahiro Kuwano <takahiro.kuwano@infineon.com> */
> +
> +#include <linux/device.h>
> +#include <linux/kernel.h>
> +#include <linux/mtd/spinand.h>
> +
> +#define SPINAND_MFR_SKYHIGH 0x01
> +
> +#define SKYHIGH_STATUS_ECC_1TO2_BITFLIPS (1 << 4)
> +#define SKYHIGH_STATUS_ECC_3TO6_BITFLIPS (2 << 4)
> +#define SKYHIGH_STATUS_ECC_UNCOR_ERROR (3 << 4)
> +
> +#define SKYHIGH_CONFIG_PROTECT_EN BIT(1)
> +
> +static SPINAND_OP_VARIANTS(read_cache_variants,
> + SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 4, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 2, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
> +
> +static SPINAND_OP_VARIANTS(write_cache_variants,
> + SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
> + SPINAND_PROG_LOAD(true, 0, NULL, 0));
> +
> +static SPINAND_OP_VARIANTS(update_cache_variants,
> + SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
> + SPINAND_PROG_LOAD(false, 0, NULL, 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 and is
> +not needed for them. */
ECC an
"needed" is wrong here. Just stop after "area"
> + region->length = 0;
> + region->offset = mtd->oobsize;
> +
> + return 0;
> +}
> +
> +static int skyhigh_spinand_ooblayout_free(struct mtd_info *mtd, int section,
> + struct mtd_oob_region *region) {
> + if (section)
> + return -ERANGE;
> +
> + region->length = mtd->oobsize - 2;
> + region->offset = 2;
> +
> + return 0;
> +}
> +
> +static const struct mtd_ooblayout_ops skyhigh_spinand_ooblayout = {
> + .ecc = skyhigh_spinand_ooblayout_ecc,
> + .free = skyhigh_spinand_ooblayout_free, };
> +
> +static int skyhigh_spinand_ecc_get_status(struct spinand_device *spinand,
> + u8 status)
> +{
> + /* SHM
> + * 00 : No bit-flip
> + * 01 : 1-2 errors corrected
> + * 10 : 3-6 errors corrected
> + * 11 : uncorrectable
> + */
Thanks for the comment but the switch case looks rather straightforward, it is self-sufficient in this case.
> +
> + switch (status & STATUS_ECC_MASK) {
> + case STATUS_ECC_NO_BITFLIPS:
> + return 0;
> +
> + case SKYHIGH_STATUS_ECC_1TO2_BITFLIPS:
> + return 2;
> +
> + case SKYHIGH_STATUS_ECC_3TO6_BITFLIPS:
> + return 6;
> +
> + case SKYHIGH_STATUS_ECC_UNCOR_ERROR:
> + return -EBADMSG;;
> +
> + default:
> + break;
I guess you can directly call return -EINVAL here?
> + }
> +
> + return -EINVAL;
> +}
> +
> +static const struct spinand_info skyhigh_spinand_table[] = {
> + SPINAND_INFO("S35ML01G301",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x15),
> + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
> + NAND_ECCREQ(6, 32),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + SPINAND_ON_DIE_ECC_MANDATORY,
> + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
> + skyhigh_spinand_ecc_get_status)),
> + SPINAND_INFO("S35ML01G300",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14),
> + NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
> + NAND_ECCREQ(6, 32),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + SPINAND_ON_DIE_ECC_MANDATORY,
> + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
> + skyhigh_spinand_ecc_get_status)),
> + SPINAND_INFO("S35ML02G300",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x25),
> + NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1),
> + NAND_ECCREQ(6, 32),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + SPINAND_ON_DIE_ECC_MANDATORY,
> + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
> + skyhigh_spinand_ecc_get_status)),
> + SPINAND_INFO("S35ML04G300",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35),
> + NAND_MEMORG(1, 2048, 128, 64, 4096, 80, 2, 1, 1),
> + NAND_ECCREQ(6, 32),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + SPINAND_ON_DIE_ECC_MANDATORY,
> + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
> + skyhigh_spinand_ecc_get_status)), };
> +
> +static int skyhigh_spinand_init(struct spinand_device *spinand) {
> + return spinand_write_reg_op(spinand, REG_BLOCK_LOCK,
> + SKYHIGH_CONFIG_PROTECT_EN);
Is this really relevant? Isn't there an API for the block lock mechanism?
> +}
> +
> +static const struct spinand_manufacturer_ops skyhigh_spinand_manuf_ops = {
> + .init = skyhigh_spinand_init,
> + };
> +
> +const struct spinand_manufacturer skyhigh_spinand_manufacturer = {
> + .id = SPINAND_MFR_SKYHIGH,
> + .name = "SkyHigh",
> + .chips = skyhigh_spinand_table,
> + .nchips = ARRAY_SIZE(skyhigh_spinand_table),
> + .ops = &skyhigh_spinand_manuf_ops,
> +};
> diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
> old mode 100644 new mode 100755 index badb4c1ac079..0e135076df24
> --- a/include/linux/mtd/spinand.h
> +++ b/include/linux/mtd/spinand.h
> @@ -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 */
If we go this route, then "mandatory" is not relevant here, we shall convey the fact that the on-die ECC engine cannot be disabled and as mentioned above, there are other impacts.
>
> /**
> * 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_write_reg_op(struct spinand_device *spinand, u8 reg, u8
> +val);
>
> #endif /* __LINUX_MTD_SPINAND_H */
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 22+ messages in thread[parent not found: <SE2P216MB210205B301549661575720CC833A2@SE2P216MB2102.KORP216.PROD.OUTLOOK.COM>]
* RE: Re:
[not found] ` <SE2P216MB210205B301549661575720CC833A2@SE2P216MB2102.KORP216.PROD.OUTLOOK.COM>
@ 2024-03-29 4:41 ` Kyeongrho.Kim
0 siblings, 0 replies; 22+ messages in thread
From: Kyeongrho.Kim @ 2024-03-29 4:41 UTC (permalink / raw)
To: Miquel Raynal
Cc: richard@nod.at, vigneshr@ti.com, mmkurbanov@salutedevices.com,
ddrokosov@sberdevices.ru, gch981213@gmail.com, michael@walle.cc,
broonie@kernel.org, mika.westerberg@linux.intel.com,
acelan.kao@canonical.com, linux-kernel@vger.kernel.org,
linux-mtd@lists.infradead.org, Mohamed Sardi, Changsub.Shim
(I send again this mail with plain text not HTML.)
Dear Miquel,
Please see my reply in below email.
And please comment if you have any others.
Thanks,
KR
-----Original Message-----
From: Miquel Raynal <mailto:miquel.raynal@bootlin.com>
Sent: Thursday, March 7, 2024 5:01 PM
To: Kyeongrho.Kim <mailto:kr.kim@skyhighmemory.com>
Cc: mailto:richard@nod.at; mailto:vigneshr@ti.com; mailto:mmkurbanov@salutedevices.com; mailto:ddrokosov@sberdevices.ru; mailto:gch981213@gmail.com; mailto:michael@walle.cc; mailto:broonie@kernel.org; mailto:mika.westerberg@linux.intel.com; mailto:acelan.kao@canonical.com; mailto:linux-kernel@vger.kernel.org; mailto:linux-mtd@lists.infradead.org; Mohamed Sardi <mailto:moh.sardi@skyhighmemory.com>; Changsub.Shim <mailto:changsub.shim@skyhighmemory.com>
Subject: Re:
Hi,
mailto:kr.kim@skyhighmemory.com wrote on Thu, 7 Mar 2024 15:07:29 +0900:
> Feat: Add SkyHigh Memory Patch code
>
> Add SPI Nand Patch code of SkyHigh Memory
> - Add company dependent code with 'skyhigh.c'
> - Insert into 'core.c' so that 'always ECC on'
Patch formatting is still messed up.
> commit 6061b97a830af8cb5fd0917e833e779451f9046a (HEAD -> master)
> Author: KR Kim <mailto:kr.kim@skyhighmemory.com>
> Date: Thu Mar 7 13:24:11 2024 +0900
>
> SPI Nand Patch code of SkyHigh Momory
>
> Signed-off-by: KR Kim <mailto:kr.kim@skyhighmemory.com>
>
> From 6061b97a830af8cb5fd0917e833e779451f9046a Mon Sep 17 00:00:00 2001
> From: KR Kim <mailto:kr.kim@skyhighmemory.com>
> Date: Thu, 7 Mar 2024 13:24:11 +0900
> Subject: [PATCH] SPI Nand Patch code of SkyHigh Memory
>
> ---
> drivers/mtd/nand/spi/Makefile | 2 +-
> drivers/mtd/nand/spi/core.c | 7 +-
> drivers/mtd/nand/spi/skyhigh.c | 155 +++++++++++++++++++++++++++++++++
> include/linux/mtd/spinand.h | 3 +
> 4 files changed, 165 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
>
> diff --git a/drivers/mtd/nand/spi/Makefile
> b/drivers/mtd/nand/spi/Makefile old mode 100644 new mode 100755 index
> 19cc77288ebb..1e61ab21893a
> --- a/drivers/mtd/nand/spi/Makefile
> +++ b/drivers/mtd/nand/spi/Makefile
> @@ -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 diff --git
> a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c old mode
> 100644 new mode 100755 index e0b6715e5dfe..e3f0a7544ba4
> --- a/drivers/mtd/nand/spi/core.c
> +++ b/drivers/mtd/nand/spi/core.c
> @@ -34,7 +34,7 @@ static int spinand_read_reg_op(struct spinand_device *spinand, u8 reg, u8 *val)
> return 0;
> }
>
> -static int spinand_write_reg_op(struct spinand_device *spinand, u8
> reg, u8 val)
> +int spinand_write_reg_op(struct spinand_device *spinand, u8 reg, u8
> +val)
Please do this in a separate commit.
[SHM] May I know why we need to do a separate commit?
Please elaborate for the reason.
> {
> struct spi_mem_op op = SPINAND_SET_FEATURE_OP(reg,
> spinand->scratchbuf);
> @@ -196,6 +196,10 @@ static int spinand_init_quad_enable(struct
> spinand_device *spinand) static int spinand_ecc_enable(struct spinand_device *spinand,
> bool enable)
> {
> + /* SHM : always ECC enable */
> + if (spinand->flags & SPINAND_ON_DIE_ECC_MANDATORY)
> + return 0;
Silently always enabling ECC is not possible. If you cannot disable the on-die engine, then:
- you should prevent any other engine type to be used
- you should error out if a raw access is requested
- these chips are broken, IMO
[SHM] I understand that you are concern.
We have already reviewed 'Always ECC on' to see if there was any problem in many aspects and confirmed that there was no problem.
> +
> return spinand_upd_cfg(spinand, CFG_ECC_ENABLE,
> enable ? CFG_ECC_ENABLE : 0); } @@ -945,6 +949,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,
> diff --git a/drivers/mtd/nand/spi/skyhigh.c
> b/drivers/mtd/nand/spi/skyhigh.c new file mode 100644 index
> 000000000000..92e7572094ff
> --- /dev/null
> +++ b/drivers/mtd/nand/spi/skyhigh.c
> @@ -0,0 +1,155 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (c) 2022 SkyHigh Memory Limited
> + *
> + * Author: Takahiro Kuwano <mailto:takahiro.kuwano@infineon.com> */
> +
> +#include <linux/device.h>
> +#include <linux/kernel.h>
> +#include <linux/mtd/spinand.h>
> +
> +#define SPINAND_MFR_SKYHIGH 0x01
> +
> +#define SKYHIGH_STATUS_ECC_1TO2_BITFLIPS (1 << 4)
> +#define SKYHIGH_STATUS_ECC_3TO6_BITFLIPS (2 << 4)
> +#define SKYHIGH_STATUS_ECC_UNCOR_ERROR (3 << 4)
> +
> +#define SKYHIGH_CONFIG_PROTECT_EN BIT(1)
> +
> +static SPINAND_OP_VARIANTS(read_cache_variants,
> + SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 4, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 2, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
> + SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
> +
> +static SPINAND_OP_VARIANTS(write_cache_variants,
> + SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
> + SPINAND_PROG_LOAD(true, 0, NULL, 0));
> +
> +static SPINAND_OP_VARIANTS(update_cache_variants,
> + SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
> + SPINAND_PROG_LOAD(false, 0, NULL, 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 and is
> +not needed for them. */
ECC an
"needed" is wrong here. Just stop after "area"
> + region->length = 0;
> + region->offset = mtd->oobsize;
> +
> + return 0;
> +}
> +
> +static int skyhigh_spinand_ooblayout_free(struct mtd_info *mtd, int section,
> + struct mtd_oob_region *region) {
> + if (section)
> + return -ERANGE;
> +
> + region->length = mtd->oobsize - 2;
> + region->offset = 2;
> +
> + return 0;
> +}
> +
> +static const struct mtd_ooblayout_ops skyhigh_spinand_ooblayout = {
> + .ecc = skyhigh_spinand_ooblayout_ecc,
> + .free = skyhigh_spinand_ooblayout_free, };
> +
> +static int skyhigh_spinand_ecc_get_status(struct spinand_device *spinand,
> + u8 status)
> +{
> + /* SHM
> + * 00 : No bit-flip
> + * 01 : 1-2 errors corrected
> + * 10 : 3-6 errors corrected
> + * 11 : uncorrectable
> + */
Thanks for the comment but the switch case looks rather straightforward, it is self-sufficient in this case.
> +
> + switch (status & STATUS_ECC_MASK) {
> + case STATUS_ECC_NO_BITFLIPS:
> + return 0;
> +
> + case SKYHIGH_STATUS_ECC_1TO2_BITFLIPS:
> + return 2;
> +
> + case SKYHIGH_STATUS_ECC_3TO6_BITFLIPS:
> + return 6;
> +
> + case SKYHIGH_STATUS_ECC_UNCOR_ERROR:
> + return -EBADMSG;;
> +
> + default:
> + break;
I guess you can directly call return -EINVAL here?
> + }
> +
> + return -EINVAL;
> +}
> +
> +static const struct spinand_info skyhigh_spinand_table[] = {
> + SPINAND_INFO("S35ML01G301",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x15),
> + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
> + NAND_ECCREQ(6, 32),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + SPINAND_ON_DIE_ECC_MANDATORY,
> + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
> + skyhigh_spinand_ecc_get_status)),
> + SPINAND_INFO("S35ML01G300",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x14),
> + NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
> + NAND_ECCREQ(6, 32),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + SPINAND_ON_DIE_ECC_MANDATORY,
> + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
> + skyhigh_spinand_ecc_get_status)),
> + SPINAND_INFO("S35ML02G300",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x25),
> + NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 2, 1, 1),
> + NAND_ECCREQ(6, 32),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + SPINAND_ON_DIE_ECC_MANDATORY,
> + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
> + skyhigh_spinand_ecc_get_status)),
> + SPINAND_INFO("S35ML04G300",
> + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x35),
> + NAND_MEMORG(1, 2048, 128, 64, 4096, 80, 2, 1, 1),
> + NAND_ECCREQ(6, 32),
> + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
> + &write_cache_variants,
> + &update_cache_variants),
> + SPINAND_ON_DIE_ECC_MANDATORY,
> + SPINAND_ECCINFO(&skyhigh_spinand_ooblayout,
> + skyhigh_spinand_ecc_get_status)), };
> +
> +static int skyhigh_spinand_init(struct spinand_device *spinand) {
> + return spinand_write_reg_op(spinand, REG_BLOCK_LOCK,
> + SKYHIGH_CONFIG_PROTECT_EN);
Is this really relevant? Isn't there an API for the block lock mechanism?
[SHM] SHM device should be done ‘Config Protect Enable’ first for unlock.
I changed to use the 'spinand_lock_block' function instead of the 'spinand_write_reg_op' function.
> +}
> +
> +static const struct spinand_manufacturer_ops skyhigh_spinand_manuf_ops = {
> + .init = skyhigh_spinand_init,
> + };
> +
> +const struct spinand_manufacturer skyhigh_spinand_manufacturer = {
> + .id = SPINAND_MFR_SKYHIGH,
> + .name = "SkyHigh",
> + .chips = skyhigh_spinand_table,
> + .nchips = ARRAY_SIZE(skyhigh_spinand_table),
> + .ops = &skyhigh_spinand_manuf_ops,
> +};
> diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
> old mode 100644 new mode 100755 index badb4c1ac079..0e135076df24
> --- a/include/linux/mtd/spinand.h
> +++ b/include/linux/mtd/spinand.h
> @@ -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 */
If we go this route, then "mandatory" is not relevant here, we shall convey the fact that the on-die ECC engine cannot be disabled and as mentioned above, there are other impacts.
[SHM] Please elaborate in more specific what I should do.
>
> /**
> * 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_write_reg_op(struct spinand_device *spinand, u8 reg, u8
> +val);
>
> #endif /* __LINUX_MTD_SPINAND_H */
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 22+ messages in thread
* (no subject)
@ 2018-12-21 15:22 kenneth johansson
2018-12-22 8:18 ` Richard Weinberger
0 siblings, 1 reply; 22+ messages in thread
From: kenneth johansson @ 2018-12-21 15:22 UTC (permalink / raw)
To: linux-mtd
>From 9815710fa078241c683de1b49d9a0c9631502e17 Mon Sep 17 00:00:00 2001
From: Kenneth Johansson <kenjo@kenjo.org>
Date: Fri, 21 Dec 2018 15:46:24 +0100
Subject: [PATCH] mtd: rawnand: nandsim: Add support to disable subpage writes.
X-IMAPbase: 1545405463 2
Status: O
X-UID: 1
This is needed if you try to use an already existing ubifs image that
is created for hardware that do not support subpage write.
It is not enough that you can select what nandchip to emulate as the
subpage support might not exist in the actual nand driver.
Signed-off-by: Kenneth Johansson <ken@kenjo.org>
---
drivers/mtd/nand/raw/nandsim.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
index c452819..858ef30b 100644
--- a/drivers/mtd/nand/raw/nandsim.c
+++ b/drivers/mtd/nand/raw/nandsim.c
@@ -110,6 +110,7 @@ static unsigned int overridesize = 0;
static char *cache_file = NULL;
static unsigned int bbt;
static unsigned int bch;
+static unsigned int no_subpage;
static u_char id_bytes[8] = {
[0] = CONFIG_NANDSIM_FIRST_ID_BYTE,
[1] = CONFIG_NANDSIM_SECOND_ID_BYTE,
@@ -142,6 +143,7 @@ module_param(overridesize, uint, 0400);
module_param(cache_file, charp, 0400);
module_param(bbt, uint, 0400);
module_param(bch, uint, 0400);
+module_param(no_subpage, uint, 0400);
MODULE_PARM_DESC(id_bytes, "The ID bytes returned by NAND Flash 'read ID' command");
MODULE_PARM_DESC(first_id_byte, "The first byte returned by NAND Flash 'read ID' command (manufacturer ID) (obsolete)");
@@ -177,6 +179,7 @@ MODULE_PARM_DESC(cache_file, "File to use to cache nand pages instead of mem
MODULE_PARM_DESC(bbt, "0 OOB, 1 BBT with marker in OOB, 2 BBT with marker in data area");
MODULE_PARM_DESC(bch, "Enable BCH ecc and set how many bits should "
"be correctable in 512-byte blocks");
+MODULE_PARM_DESC(no_subpage, "Disable use of subpage write");
/* The largest possible page size */
#define NS_LARGEST_PAGE_SIZE 4096
@@ -2260,6 +2263,10 @@ static int __init ns_init_module(void)
/* and 'badblocks' parameters to work */
chip->options |= NAND_SKIP_BBTSCAN;
+ /* turn off subpage to be able to read ubifs images created for hardware without subpage support */
+ if (no_subpage)
+ chip->options |= NAND_NO_SUBPAGE_WRITE;
+
switch (bbt) {
case 2:
chip->bbt_options |= NAND_BBT_NO_OOB;
--
2.7.4
^ permalink raw reply related [flat|nested] 22+ messages in thread* Re:
2018-12-21 15:22 kenneth johansson
@ 2018-12-22 8:18 ` Richard Weinberger
0 siblings, 0 replies; 22+ messages in thread
From: Richard Weinberger @ 2018-12-22 8:18 UTC (permalink / raw)
To: kenneth johansson; +Cc: linux-mtd
On Fri, Dec 21, 2018 at 4:24 PM kenneth johansson <kenjo@kenjo.org> wrote:
>
> From 9815710fa078241c683de1b49d9a0c9631502e17 Mon Sep 17 00:00:00 2001
> From: Kenneth Johansson <kenjo@kenjo.org>
> Date: Fri, 21 Dec 2018 15:46:24 +0100
> Subject: [PATCH] mtd: rawnand: nandsim: Add support to disable subpage writes.
> X-IMAPbase: 1545405463 2
> Status: O
> X-UID: 1
>
> This is needed if you try to use an already existing ubifs image that
> is created for hardware that do not support subpage write.
>
> It is not enough that you can select what nandchip to emulate as the
> subpage support might not exist in the actual nand driver.
Is this really needed? Usually using ubiattach's -O parameter does the trick.
--
Thanks,
//richard
^ permalink raw reply [flat|nested] 22+ messages in thread
* RE,
@ 2018-11-11 4:20 Miss Juliet Muhammad
0 siblings, 0 replies; 22+ messages in thread
From: Miss Juliet Muhammad @ 2018-11-11 4:20 UTC (permalink / raw)
To: Recipients
I have a deal for you, in your region.
^ permalink raw reply [flat|nested] 22+ messages in thread
* RE,
@ 2018-11-06 1:21 Miss Juliet Muhammad
0 siblings, 0 replies; 22+ messages in thread
From: Miss Juliet Muhammad @ 2018-11-06 1:21 UTC (permalink / raw)
To: Recipients
I have a deal for you, in your region.
^ permalink raw reply [flat|nested] 22+ messages in thread
[parent not found: <20170519213731.21484-1-mrugiero@gmail.com>]
* Re:
[not found] <20170519213731.21484-1-mrugiero@gmail.com>
@ 2017-05-20 8:48 ` Boris Brezillon
0 siblings, 0 replies; 22+ messages in thread
From: Boris Brezillon @ 2017-05-20 8:48 UTC (permalink / raw)
To: Mario J. Rugiero
Cc: "linux-mtd, computersforpeace, marek.vasut, richard,
cyrille.pitchen
Hi Mario,
Not sure how you created this patchset, but you miss a Subject, and the
diff-stat.
Please use
git format-patch -o <output-dir> -3 --cover-letter
to generate patches, then fill the cover letter in.
Once your cover letter is ready, you can send the patches with
git send-email --to ... --cc ... <output-dir>/*.patch
Regards,
Boris
Le Fri, 19 May 2017 18:37:28 -0300,
"Mario J. Rugiero" <mrugiero@gmail.com> a écrit :
> Some manufacturers use different layouts than MTD for the NAND, creating
> incompatibilities when going from a vendor-specific kernel to mainline.
> In particular, NAND devices for AllWinner boards write non-FF values to
> the bad block marker, and thus false positives arise when detecting bad
> blocks with the MTD driver. Sometimes there are enough false positives
> to make the device unusable.
> A proposed solution is NAND scrubbing, something a user who knows what
> she's doing (TM) could do to avoid this. It consists in erasing blocks
> disregarding the BBM. Since the user must know what she's doing, the
> only way to enable this feature is through a per-chip debugfs entry.
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* (no subject)
@ 2016-02-26 1:19 Fredrick Prashanth John Berchmans
2016-02-26 7:37 ` Richard Weinberger
0 siblings, 1 reply; 22+ messages in thread
From: Fredrick Prashanth John Berchmans @ 2016-02-26 1:19 UTC (permalink / raw)
To: dwmw2; +Cc: linux-mtd, Suresh Siddha
Hi,
We are using UBIFS on our NOR flash.
We are observing that a lot of times the filesystem goes to read-only
unable to recover.
Most of the time its due to
a) ubifs_scan_a_node failing due to bad crc or unclean free space.
b) ubifs_leb_write failing to erase due to erase timeout
[ The above would have happened due to unclean power cuts. In our
environment this happens often ]
I checked the code in jffs2. Looking at jffs2 code it looks like jffs2
tolerates the above two
failures and moves on without mounting read-only.
Is my understanding right ?
Could we change the ubifs_scan_a_node to skip corrupted bytes and move
to next node,
instead of returning error ?
Thanks,
Fredrick
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re:
2016-02-26 1:19 Fredrick Prashanth John Berchmans
@ 2016-02-26 7:37 ` Richard Weinberger
0 siblings, 0 replies; 22+ messages in thread
From: Richard Weinberger @ 2016-02-26 7:37 UTC (permalink / raw)
To: Fredrick Prashanth John Berchmans
Cc: David Woodhouse, linux-mtd@lists.infradead.org, Suresh Siddha
On Fri, Feb 26, 2016 at 2:19 AM, Fredrick Prashanth John Berchmans
<fredrickprashanth@gmail.com> wrote:
> We are using UBIFS on our NOR flash.
> We are observing that a lot of times the filesystem goes to read-only
> unable to recover.
> Most of the time its due to
> a) ubifs_scan_a_node failing due to bad crc or unclean free space.
> b) ubifs_leb_write failing to erase due to erase timeout
>
> [ The above would have happened due to unclean power cuts. In our
> environment this happens often ]
>
> I checked the code in jffs2. Looking at jffs2 code it looks like jffs2
> tolerates the above two
> failures and moves on without mounting read-only.
> Is my understanding right ?
>
> Could we change the ubifs_scan_a_node to skip corrupted bytes and move
> to next node,
> instead of returning error ?
Not without a detailed analysis what exactly is going on.
It sounds more like ad-hoc hack. :-)
--
Thanks,
//richard
^ permalink raw reply [flat|nested] 22+ messages in thread
[parent not found: <BEC3AE959B8BB340894B239B5A7882B929B02748@LPPTCPMXMBX02.LPCH.NET>]
* RE:
[not found] <BEC3AE959B8BB340894B239B5A7882B929B02748@LPPTCPMXMBX02.LPCH.NET>
@ 2014-10-30 9:26 ` Tarzon, Megan
0 siblings, 0 replies; 22+ messages in thread
From: Tarzon, Megan @ 2014-10-30 9:26 UTC (permalink / raw)
To: Tarzon, Megan
________________________________
From: Tarzon, Megan
Sent: Thursday, October 30, 2014 12:40 AM
To: Tarzon, Megan
Subject:
Good day.
l am the Chief Risk Officer and Executive Director of China Guangfa Bank in Hong Kong. I want to present you as the owner of 49.5 million USD In my bank since i am the only one aware of the funds due to my investigations. signify your interest by replying to this Email: morrowhkmorro1@rogers.com
James Morrow.
CONFIDENTIALITY NOTICE: This communication and any attachments may contain confidential or privileged information for the use by the designated recipient(s) named above. If you are not the intended recipient, you are hereby notified that you have received this communication in error and that any review, disclosure, dissemination, distribution or copying of it or the attachments is strictly prohibited. If you have received this communication in error, please contact the sender and destroy all copies of the communication and attachments. Thank you. MSG:104-123
^ permalink raw reply [flat|nested] 22+ messages in thread
* (no subject)
@ 2012-06-06 10:33 Sascha Hauer
2012-06-06 14:39 ` Artem Bityutskiy
0 siblings, 1 reply; 22+ messages in thread
From: Sascha Hauer @ 2012-06-06 10:33 UTC (permalink / raw)
To: linux-mtd; +Cc: Shawn Guo, linux-arm-kernel
The following adds i.MX53 nand support and generally devicetree
based probing for i.MX5 boards. The first three patches should go
via mtd, the last patch optionally aswell if all agree.
Sascha
The following changes since commit f8f5701bdaf9134b1f90e5044a82c66324d2073f:
Linux 3.5-rc1 (2012-06-02 18:29:26 -0700)
are available in the git repository at:
git://git.pengutronix.de/git/imx/linux-2.6.git imx/nand-mx53
for you to fetch changes up to d55d1479a3bfaedbb9f0c6c956f4dff6bb6d6d61:
ARM i.MX5: Add nand oftree support (2012-06-06 12:20:24 +0200)
----------------------------------------------------------------
Sascha Hauer (4):
mtd nand mxc_nand: Use managed resources
mtd nand mxc_nand: swap iomem resource order
mtd nand mxc_nand: add i.MX53 support
ARM i.MX5: Add nand oftree support
arch/arm/boot/dts/imx51.dtsi | 7 ++
arch/arm/boot/dts/imx53.dtsi | 7 ++
arch/arm/mach-imx/clk-imx51-imx53.c | 2 +
arch/arm/plat-mxc/devices/platform-mxc_nand.c | 11 +-
drivers/mtd/nand/mxc_nand.c | 137 ++++++++++++++-----------
5 files changed, 97 insertions(+), 67 deletions(-)
^ permalink raw reply [flat|nested] 22+ messages in thread* Re:
2012-06-06 10:33 Sascha Hauer
@ 2012-06-06 14:39 ` Artem Bityutskiy
2012-06-07 10:11 ` Re: Sascha Hauer
0 siblings, 1 reply; 22+ messages in thread
From: Artem Bityutskiy @ 2012-06-06 14:39 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Shawn Guo, linux-mtd, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 1679 bytes --]
On Wed, 2012-06-06 at 12:33 +0200, Sascha Hauer wrote:
> The following adds i.MX53 nand support and generally devicetree
> based probing for i.MX5 boards. The first three patches should go
> via mtd, the last patch optionally aswell if all agree.
>
> Sascha
>
> The following changes since commit f8f5701bdaf9134b1f90e5044a82c66324d2073f:
>
> Linux 3.5-rc1 (2012-06-02 18:29:26 -0700)
>
> are available in the git repository at:
>
> git://git.pengutronix.de/git/imx/linux-2.6.git imx/nand-mx53
>
> for you to fetch changes up to d55d1479a3bfaedbb9f0c6c956f4dff6bb6d6d61:
>
> ARM i.MX5: Add nand oftree support (2012-06-06 12:20:24 +0200)
Do you want this to go via the MTD tree? Would you be able to collect
acks for the arch/arm bits? Meanwhile, please, take a look at these
sparse warnings added by this patch-set and detected by aiaiai:
--------------------------------------------------------------------------------
Successfully built configuration "arm-mxc-imx_defconfig,arm,arm-unknown-linux-gnueabi-", results:
--- before_patching.log
+++ after_patching.log
@@ @@
+drivers/mtd/nand/mxc_nand.c:1289:26: warning: incorrect type in initializer (different modifiers) [sparse]
+drivers/mtd/nand/mxc_nand.c:1289:26: expected void *data [sparse]
+drivers/mtd/nand/mxc_nand.c:1289:26: got struct mxc_nand_devtype_data static const [toplevel] *<noident> [sparse]
+drivers/mtd/nand/mxc_nand.c:1289:3: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
--------------------------------------------------------------------------------
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re:
2012-06-06 14:39 ` Artem Bityutskiy
@ 2012-06-07 10:11 ` Sascha Hauer
2012-06-07 12:45 ` Re: Artem Bityutskiy
0 siblings, 1 reply; 22+ messages in thread
From: Sascha Hauer @ 2012-06-07 10:11 UTC (permalink / raw)
To: Artem Bityutskiy; +Cc: Shawn Guo, linux-mtd, linux-arm-kernel
Hi Artem,
On Wed, Jun 06, 2012 at 05:39:07PM +0300, Artem Bityutskiy wrote:
> On Wed, 2012-06-06 at 12:33 +0200, Sascha Hauer wrote:
> > The following adds i.MX53 nand support and generally devicetree
> > based probing for i.MX5 boards. The first three patches should go
> > via mtd, the last patch optionally aswell if all agree.
> >
> > Sascha
> >
> > The following changes since commit f8f5701bdaf9134b1f90e5044a82c66324d2073f:
> >
> > Linux 3.5-rc1 (2012-06-02 18:29:26 -0700)
> >
> > are available in the git repository at:
> >
> > git://git.pengutronix.de/git/imx/linux-2.6.git imx/nand-mx53
> >
> > for you to fetch changes up to d55d1479a3bfaedbb9f0c6c956f4dff6bb6d6d61:
> >
> > ARM i.MX5: Add nand oftree support (2012-06-06 12:20:24 +0200)
>
> Do you want this to go via the MTD tree? Would you be able to collect
> acks for the arch/arm bits? Meanwhile, please, take a look at these
> sparse warnings added by this patch-set and detected by aiaiai:
>
> --------------------------------------------------------------------------------
>
> Successfully built configuration "arm-mxc-imx_defconfig,arm,arm-unknown-linux-gnueabi-", results:
>
> --- before_patching.log
> +++ after_patching.log
> @@ @@
> +drivers/mtd/nand/mxc_nand.c:1289:26: warning: incorrect type in initializer (different modifiers) [sparse]
> +drivers/mtd/nand/mxc_nand.c:1289:26: expected void *data [sparse]
> +drivers/mtd/nand/mxc_nand.c:1289:26: got struct mxc_nand_devtype_data static const [toplevel] *<noident> [sparse]
> +drivers/mtd/nand/mxc_nand.c:1289:3: warning: initialization discards 'const' qualifier from pointer target type [enabled by default]
Fixing these warnings in the nand driver does not seem to be the correct
approach. Initializing mxc_nand_devtype_data as const seems sane, the
problem is that struct of_device_id expects a void * instead of a const
void *. A patch fixing this is outstanding here:
http://permalink.gmane.org/gmane.linux.drivers.devicetree/15069
(this will also fix the other sparse warnings from this driver)
I asked Uwe to resend this.
So I only added Shawns Ack to the arm-i.MX part, you can pull this into
the mtd tree:
The following changes since commit f8f5701bdaf9134b1f90e5044a82c66324d2073f:
Linux 3.5-rc1 (2012-06-02 18:29:26 -0700)
are available in the git repository at:
git://git.pengutronix.de/git/imx/linux-2.6.git tags/mtd-imx53-nand-support
for you to fetch changes up to 25d097d575d7c06b76e4e6e2488718976b70c432:
ARM i.MX5: Add nand oftree support (2012-06-07 11:59:19 +0200)
----------------------------------------------------------------
Nand support for i.MX53 and devicetree snippets for i.MX5 nand
----------------------------------------------------------------
Sascha Hauer (4):
mtd nand mxc_nand: Use managed resources
mtd nand mxc_nand: swap iomem resource order
mtd nand mxc_nand: add i.MX53 support
ARM i.MX5: Add nand oftree support
arch/arm/boot/dts/imx51.dtsi | 7 ++
arch/arm/boot/dts/imx53.dtsi | 7 ++
arch/arm/mach-imx/clk-imx51-imx53.c | 2 +
arch/arm/plat-mxc/devices/platform-mxc_nand.c | 11 +-
drivers/mtd/nand/mxc_nand.c | 137 ++++++++++++++-----------
5 files changed, 97 insertions(+), 67 deletions(-)
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 22+ messages in thread* Re: Re:
2012-06-07 10:11 ` Re: Sascha Hauer
@ 2012-06-07 12:45 ` Artem Bityutskiy
0 siblings, 0 replies; 22+ messages in thread
From: Artem Bityutskiy @ 2012-06-07 12:45 UTC (permalink / raw)
To: Sascha Hauer; +Cc: Shawn Guo, linux-mtd, linux-arm-kernel
[-- Attachment #1: Type: text/plain, Size: 582 bytes --]
On Thu, 2012-06-07 at 12:11 +0200, Sascha Hauer wrote:
> Fixing these warnings in the nand driver does not seem to be the correct
> approach. Initializing mxc_nand_devtype_data as const seems sane, the
> problem is that struct of_device_id expects a void * instead of a const
> void *. A patch fixing this is outstanding here:
>
> http://permalink.gmane.org/gmane.linux.drivers.devicetree/15069
>
> (this will also fix the other sparse warnings from this driver)
>
> I asked Uwe to resend this.
Pushed to l2-mtd.git, thanks!
--
Best Regards,
Artem Bityutskiy
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re !
@ 2010-07-01 16:09 BRITISH COLUMBIA
0 siblings, 0 replies; 22+ messages in thread
From: BRITISH COLUMBIA @ 2010-07-01 16:09 UTC (permalink / raw)
Your email has been awarded 1,263,584.00 GBP (One Million Two Hundred and Sixtythree Thousand,Five Hundred and Eightyfour Pounds Sterling) By British Columbia Lottery,Do send us Names, Address, Tel and Occupation for processing.
^ permalink raw reply [flat|nested] 22+ messages in thread
* (no subject)
@ 2008-01-14 7:32 Naveen Sattigeri
2008-01-14 13:00 ` Josh Boyer
0 siblings, 1 reply; 22+ messages in thread
From: Naveen Sattigeri @ 2008-01-14 7:32 UTC (permalink / raw)
To: Linux-MTD Linux
Hi,
I am using Linux kernel 2.4.20-8 as host.For the
target compact nand flash I am using 2.6.10 kernel.I
want the target flash detected as MTD for mounting
JFFS2 file system on it.
Please correct if I am wrong.The kernel 2.6.10 should
be patched for latest NAND mtd drivers.
I have tried the latest patch 2008-January.txt but it
was not successful because probably the patch is for
latest kernel.
Can I get the patch for 2.6.20?
What else I should do to detect the compact flash as
MTD device using a host or using NFS.
Thanking you,
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2024-03-29 4:41 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-03 2:56 Stanley.Miao
2010-02-03 2:56 ` [PATCH 1/5] clean up the legacy interfaces in nandwrite.c Stanley.Miao
2010-02-03 2:56 ` [PATCH 2/5] check if the start address is page-aligned Stanley.Miao
2010-02-03 2:56 ` [PATCH 3/5] Fix the bug of writing a yaffs2 image to NAND Stanley.Miao
2010-02-03 2:56 ` [PATCH 4/5] Discard the legacy interface MEMGETOOBSEL in flash_eraseall Stanley.Miao
2010-02-03 2:56 ` [PATCH 5/5] Place the cleanmarker in OOB area according to the mode MTD_OOB_AUTO Stanley.Miao
2010-02-03 3:16 ` Mike Frysinger
2010-02-03 4:31 ` Re: stanley.miao
-- strict thread matches above, loose matches on Subject: below --
2024-03-07 6:07 KR Kim
2024-03-07 8:01 ` Miquel Raynal
2024-03-08 1:27 ` Re: Kyeongrho.Kim
[not found] ` <SE2P216MB210205B301549661575720CC833A2@SE2P216MB2102.KORP216.PROD.OUTLOOK.COM>
2024-03-29 4:41 ` Re: Kyeongrho.Kim
2018-12-21 15:22 kenneth johansson
2018-12-22 8:18 ` Richard Weinberger
2018-11-11 4:20 RE, Miss Juliet Muhammad
2018-11-06 1:21 RE, Miss Juliet Muhammad
[not found] <20170519213731.21484-1-mrugiero@gmail.com>
2017-05-20 8:48 ` Boris Brezillon
2016-02-26 1:19 Fredrick Prashanth John Berchmans
2016-02-26 7:37 ` Richard Weinberger
[not found] <BEC3AE959B8BB340894B239B5A7882B929B02748@LPPTCPMXMBX02.LPCH.NET>
2014-10-30 9:26 ` Tarzon, Megan
2012-06-06 10:33 Sascha Hauer
2012-06-06 14:39 ` Artem Bityutskiy
2012-06-07 10:11 ` Re: Sascha Hauer
2012-06-07 12:45 ` Re: Artem Bityutskiy
2010-07-01 16:09 Re ! BRITISH COLUMBIA
2008-01-14 7:32 Naveen Sattigeri
2008-01-14 13:00 ` Josh Boyer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).