* [U-Boot] [PATCH 0/4] Add CONFIG_SPL_NAND_IDENT
@ 2018-01-14 16:14 Jörg Krause
2018-01-14 16:14 ` [U-Boot] [PATCH 1/4] mtd: nand: export nand_get_flash_type function Jörg Krause
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Jörg Krause @ 2018-01-14 16:14 UTC (permalink / raw)
To: u-boot
When adding SPL support to a custom i.MX6ULL board with Toshiba
TC58NVG0S3 NAND chip the MXS NAND SPL loader failed with "Failed to
identify". This reason is that the SPL MXS NAND driver only supports
ONFi-compliant NAND chips and the mentioned Toshiba NAND chip is
non-ONFi.
This patch set makes `nand_get_flash_type()` from `nand_base.c` public,
so it can be used by any SPL NAND driver, introduced a new config option
`CONFIG_SPL_NAND_IDENT` to enable the lookup for supported NAND chips in
the chip ID list. Finally, the MXS NAND SPL driver is refactored so that
the original ONFi-only identification routine is enabled by default. For
non-ONFi NAND chips the newly introduced config option can be used.
In my setup the binary size of `u-boot-spl.bin` is increased by about
13 kB when `CONFIG_SPL_NAND_IDENT` is enabled. As the i.MX6, as well as
the i.MX28, both have an OCRAM of 128 kB the increase in the binary size
is reasonable.
Jörg Krause (4):
mtd: nand: export nand_get_flash_type function
spl, nand: add option CONFIG_SPL_NAND_IDENT to lookup for supported
NAND chips
mtd: nand: mxs_nand_spl: refactor mxs_flash_ident
mtd: nand: mxs_nand_spl: add mxs_flash_full_ident
README | 4 ++++
drivers/mtd/nand/Makefile | 1 +
drivers/mtd/nand/mxs_nand_spl.c | 37 ++++++++++++++++++++++++++++++++++++-
drivers/mtd/nand/nand_base.c | 3 ++-
include/linux/mtd/rawnand.h | 10 +++++++---
scripts/config_whitelist.txt | 1 +
6 files changed, 51 insertions(+), 5 deletions(-)
--
2.15.1
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/4] mtd: nand: export nand_get_flash_type function
2018-01-14 16:14 [U-Boot] [PATCH 0/4] Add CONFIG_SPL_NAND_IDENT Jörg Krause
@ 2018-01-14 16:14 ` Jörg Krause
2018-01-14 17:55 ` Fabio Estevam
2018-01-14 16:14 ` [U-Boot] [PATCH 2/4] spl, nand: add option CONFIG_SPL_NAND_IDENT to lookup for supported NAND chips Jörg Krause
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Jörg Krause @ 2018-01-14 16:14 UTC (permalink / raw)
To: u-boot
`nand_get_flash_type()` allows identification of supported NAND flashs.
The function is useful in SPL (like mxs_nand_spl.c) to lookup for a NAND
flash (which does not support ONFi) instead of using nand_simple.c and
hard-coding all required NAND parameters.
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
---
drivers/mtd/nand/nand_base.c | 3 ++-
include/linux/mtd/rawnand.h | 10 +++++++---
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index eb9f121f81..64e4621aaa 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3755,7 +3755,7 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip,
/*
* Get the flash and manufacturer id and lookup if the type is supported.
*/
-static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
+struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
struct nand_chip *chip,
int *maf_id, int *dev_id,
struct nand_flash_dev *type)
@@ -3927,6 +3927,7 @@ ident_done:
mtd->erasesize >> 10, mtd->writesize, mtd->oobsize);
return type;
}
+EXPORT_SYMBOL(nand_get_flash_type);
#if CONFIG_IS_ENABLED(OF_CONTROL)
DECLARE_GLOBAL_DATA_PTR;
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index 6c3e838d80..3871379fb1 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -23,9 +23,16 @@
#include <asm/cache.h>
struct mtd_info;
+struct nand_chip;
struct nand_flash_dev;
struct device_node;
+/* Get the flash and manufacturer id and lookup if the type is supported. */
+struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
+ struct nand_chip *chip,
+ int *maf_id, int *dev_id,
+ struct nand_flash_dev *type);
+
/* Scan and identify a NAND device */
int nand_scan(struct mtd_info *mtd, int max_chips);
/*
@@ -248,9 +255,6 @@ typedef enum {
#define NAND_CI_CELLTYPE_MSK 0x0C
#define NAND_CI_CELLTYPE_SHIFT 2
-/* Keep gcc happy */
-struct nand_chip;
-
/* ONFI features */
#define ONFI_FEATURE_16_BIT_BUS (1 << 0)
#define ONFI_FEATURE_EXT_PARAM_PAGE (1 << 7)
--
2.15.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 2/4] spl, nand: add option CONFIG_SPL_NAND_IDENT to lookup for supported NAND chips
2018-01-14 16:14 [U-Boot] [PATCH 0/4] Add CONFIG_SPL_NAND_IDENT Jörg Krause
2018-01-14 16:14 ` [U-Boot] [PATCH 1/4] mtd: nand: export nand_get_flash_type function Jörg Krause
@ 2018-01-14 16:14 ` Jörg Krause
2018-01-14 16:14 ` [U-Boot] [PATCH 3/4] mtd: nand: mxs_nand_spl: refactor mxs_flash_ident Jörg Krause
2018-01-14 16:14 ` [U-Boot] [PATCH 4/4] mtd: nand: mxs_nand_spl: add mxs_flash_full_ident Jörg Krause
3 siblings, 0 replies; 7+ messages in thread
From: Jörg Krause @ 2018-01-14 16:14 UTC (permalink / raw)
To: u-boot
Add the config option `CONFIG_SPL_NAND_IDENT` for using the NAND chip ID list
to identify the NAND flash in SPL.
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
---
README | 4 ++++
drivers/mtd/nand/Makefile | 1 +
scripts/config_whitelist.txt | 1 +
3 files changed, 6 insertions(+)
diff --git a/README b/README
index 06f3ed057d..9ca5086097 100644
--- a/README
+++ b/README
@@ -2786,6 +2786,10 @@ FIT uImage format:
CONFIG_SPL_NAND_DRIVERS
SPL uses normal NAND drivers, not minimal drivers.
+ CONFIG_SPL_NAND_IDENT
+ SPL uses the chip ID list to identify the NAND flash.
+ Requires CONFIG_SPL_NAND_BASE.
+
CONFIG_SPL_NAND_ECC
Include standard software ECC in the SPL
diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index 9f7d9d6ff7..4ed4afde10 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o
obj-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o
obj-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o
obj-$(CONFIG_SPL_NAND_BASE) += nand_base.o
+obj-$(CONFIG_SPL_NAND_IDENT) += nand_ids.o nand_timings.o
obj-$(CONFIG_SPL_NAND_INIT) += nand.o
ifeq ($(CONFIG_SPL_ENV_SUPPORT),y)
obj-$(CONFIG_ENV_IS_IN_NAND) += nand_util.o
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 4e87d66bea..b01d196f5a 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -2092,6 +2092,7 @@ CONFIG_SPL_NAND_BASE
CONFIG_SPL_NAND_BOOT
CONFIG_SPL_NAND_DRIVERS
CONFIG_SPL_NAND_ECC
+CONFIG_SPL_NAND_IDENT
CONFIG_SPL_NAND_INIT
CONFIG_SPL_NAND_LOAD
CONFIG_SPL_NAND_MINIMAL
--
2.15.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 3/4] mtd: nand: mxs_nand_spl: refactor mxs_flash_ident
2018-01-14 16:14 [U-Boot] [PATCH 0/4] Add CONFIG_SPL_NAND_IDENT Jörg Krause
2018-01-14 16:14 ` [U-Boot] [PATCH 1/4] mtd: nand: export nand_get_flash_type function Jörg Krause
2018-01-14 16:14 ` [U-Boot] [PATCH 2/4] spl, nand: add option CONFIG_SPL_NAND_IDENT to lookup for supported NAND chips Jörg Krause
@ 2018-01-14 16:14 ` Jörg Krause
2018-01-14 16:14 ` [U-Boot] [PATCH 4/4] mtd: nand: mxs_nand_spl: add mxs_flash_full_ident Jörg Krause
3 siblings, 0 replies; 7+ messages in thread
From: Jörg Krause @ 2018-01-14 16:14 UTC (permalink / raw)
To: u-boot
The existing `mxs_flash_ident()` is limited to identify ONFi compliant
NAND chips only. In order to support non-ONFi NAND chips refactor the
function and rename it to `mxs_flash_onfi_ident()`.
A follow-up patch will add `mxs_flash_full_ident()` which allows to use
the chip ID list to lookup for supported NAND flashs.
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
---
drivers/mtd/nand/mxs_nand_spl.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/mxs_nand_spl.c b/drivers/mtd/nand/mxs_nand_spl.c
index 910f76dd9d..11d8503127 100644
--- a/drivers/mtd/nand/mxs_nand_spl.c
+++ b/drivers/mtd/nand/mxs_nand_spl.c
@@ -49,7 +49,7 @@ static void mxs_nand_command(struct mtd_info *mtd, unsigned int command,
}
}
-static int mxs_flash_ident(struct mtd_info *mtd)
+static int mxs_flash_onfi_ident(struct mtd_info *mtd)
{
register struct nand_chip *chip = mtd_to_nand(mtd);
int i;
@@ -109,6 +109,13 @@ static int mxs_flash_ident(struct mtd_info *mtd)
return 0;
}
+static int mxs_flash_ident(struct mtd_info *mtd)
+{
+ int ret;
+ ret = mxs_flash_onfi_ident(mtd);
+ return ret;
+}
+
static int mxs_read_page_ecc(struct mtd_info *mtd, void *buf, unsigned int page)
{
register struct nand_chip *chip = mtd_to_nand(mtd);
--
2.15.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 4/4] mtd: nand: mxs_nand_spl: add mxs_flash_full_ident
2018-01-14 16:14 [U-Boot] [PATCH 0/4] Add CONFIG_SPL_NAND_IDENT Jörg Krause
` (2 preceding siblings ...)
2018-01-14 16:14 ` [U-Boot] [PATCH 3/4] mtd: nand: mxs_nand_spl: refactor mxs_flash_ident Jörg Krause
@ 2018-01-14 16:14 ` Jörg Krause
3 siblings, 0 replies; 7+ messages in thread
From: Jörg Krause @ 2018-01-14 16:14 UTC (permalink / raw)
To: u-boot
For now, the existing SPL MXS NAND driver only supports to identify
ONFi-compliant NAND chips. In order to allow identifying
non-ONFi-compliant chips add `mxs_flash_full_ident()` which uses the
`nand_get_flash_type()` functionality from `nand_base.c` to lookup
for supported NAND chips in the chip ID list.
For compatibility reason the full identification support is only
available if the config option `CONFIG_SPL_NAND_IDENT` is enabled.
The lookup was tested on a custom i.MX6ULL board with a Toshiba
TC58NVG1S3HTAI0 NAND chip.
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
---
drivers/mtd/nand/mxs_nand_spl.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/mtd/nand/mxs_nand_spl.c b/drivers/mtd/nand/mxs_nand_spl.c
index 11d8503127..0c56d9ffc3 100644
--- a/drivers/mtd/nand/mxs_nand_spl.c
+++ b/drivers/mtd/nand/mxs_nand_spl.c
@@ -49,6 +49,28 @@ static void mxs_nand_command(struct mtd_info *mtd, unsigned int command,
}
}
+#if defined (CONFIG_SPL_NAND_IDENT)
+
+/* Trying to detect the NAND flash using ONFi, JEDEC, and (extended) IDs */
+static int mxs_flash_full_ident(struct mtd_info *mtd)
+{
+ int nand_maf_id, nand_dev_id;
+ struct nand_chip *chip = mtd_to_nand(mtd);
+ struct nand_flash_dev *type;
+
+ type = nand_get_flash_type(mtd, chip, &nand_maf_id, &nand_dev_id, NULL);
+
+ if (IS_ERR(type)) {
+ chip->select_chip(mtd, -1);
+ return PTR_ERR(type);
+ }
+
+ return 0;
+}
+
+#else
+
+/* Trying to detect the NAND flash using ONFi only */
static int mxs_flash_onfi_ident(struct mtd_info *mtd)
{
register struct nand_chip *chip = mtd_to_nand(mtd);
@@ -109,10 +131,16 @@ static int mxs_flash_onfi_ident(struct mtd_info *mtd)
return 0;
}
+#endif /* CONFIG_SPL_NAND_IDENT */
+
static int mxs_flash_ident(struct mtd_info *mtd)
{
int ret;
+#if defined (CONFIG_SPL_NAND_IDENT)
+ ret = mxs_flash_full_ident(mtd);
+#else
ret = mxs_flash_onfi_ident(mtd);
+#endif
return ret;
}
--
2.15.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/4] mtd: nand: export nand_get_flash_type function
2018-01-14 16:14 ` [U-Boot] [PATCH 1/4] mtd: nand: export nand_get_flash_type function Jörg Krause
@ 2018-01-14 17:55 ` Fabio Estevam
2018-01-14 18:22 ` Jörg Krause
0 siblings, 1 reply; 7+ messages in thread
From: Fabio Estevam @ 2018-01-14 17:55 UTC (permalink / raw)
To: u-boot
Hi Jörg,
On Sun, Jan 14, 2018 at 2:14 PM, Jörg Krause
<joerg.krause@embedded.rocks> wrote:
> `nand_get_flash_type()` allows identification of supported NAND flashs.
> The function is useful in SPL (like mxs_nand_spl.c) to lookup for a NAND
> flash (which does not support ONFi) instead of using nand_simple.c and
> hard-coding all required NAND parameters.
>
> Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
Thanks for your series.
You missed to add the U-Boot NAND maintainer (Scott Wood).
Please resend the series with him on Cc.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [U-Boot] [PATCH 1/4] mtd: nand: export nand_get_flash_type function
2018-01-14 17:55 ` Fabio Estevam
@ 2018-01-14 18:22 ` Jörg Krause
0 siblings, 0 replies; 7+ messages in thread
From: Jörg Krause @ 2018-01-14 18:22 UTC (permalink / raw)
To: u-boot
On Sun, 2018-01-14 at 15:55 -0200, Fabio Estevam wrote:
> Hi Jörg,
>
> On Sun, Jan 14, 2018 at 2:14 PM, Jörg Krause
> <joerg.krause@embedded.rocks> wrote:
> > `nand_get_flash_type()` allows identification of supported NAND flashs.
> > The function is useful in SPL (like mxs_nand_spl.c) to lookup for a NAND
> > flash (which does not support ONFi) instead of using nand_simple.c and
> > hard-coding all required NAND parameters.
> >
> > Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
>
> Thanks for your series.
>
> You missed to add the U-Boot NAND maintainer (Scott Wood).
>
> Please resend the series with him on Cc.
Thanks, will do! I missed him because the custodian git repos last
change is from 2016.
Jörg
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-01-14 18:22 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-14 16:14 [U-Boot] [PATCH 0/4] Add CONFIG_SPL_NAND_IDENT Jörg Krause
2018-01-14 16:14 ` [U-Boot] [PATCH 1/4] mtd: nand: export nand_get_flash_type function Jörg Krause
2018-01-14 17:55 ` Fabio Estevam
2018-01-14 18:22 ` Jörg Krause
2018-01-14 16:14 ` [U-Boot] [PATCH 2/4] spl, nand: add option CONFIG_SPL_NAND_IDENT to lookup for supported NAND chips Jörg Krause
2018-01-14 16:14 ` [U-Boot] [PATCH 3/4] mtd: nand: mxs_nand_spl: refactor mxs_flash_ident Jörg Krause
2018-01-14 16:14 ` [U-Boot] [PATCH 4/4] mtd: nand: mxs_nand_spl: add mxs_flash_full_ident Jörg Krause
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox