keystone: nand: add additional nand ecclayout
Subsystems (3)
v3 cover keystone: nand: add additional nand ecclayout
For keystyone k2hk board the default nand layout is different from davinci. So swich ecc layout at init in board file.
To do this the series adds a nand ecclayout command to davinci nand that allows the ecclayout of the current nand device to be changed during run time. This feature is useful when using u-boot to write something to nand flash that will be read by other applications, such as ROM bootloader, that expects a different ECC layout. In that case, change the current nand device ecclayout using the "nand ecclayout set" command before writing the data to nand flash.
Based on git://git.denx.de/u-boot-ti.git master
v3..v2:
mtd: nand: davinci: allow to change ecclayout by ecclayout command
- fix board_nand_set_ecclayout()
v2..v1:
k2hk: change default nand ecc layout
- new patch
mtd: nand: davinci: allow to change ecclayout by ecclayout command
- aligned pattern.
- used ARRAY_SIZE instead of definition of size
- added some comments
- rename board_nand_ecclayout_get_layout() to shorter name
- don't change default ecc layout at init
common: cmd_nand: add nand ecclayout command
- impove format of ecc layout printing
- improve description of nand ecclayout command
- add description of CONFIG_CMD_NAND_ECCLAYOUT config
- move some code stuff to board_nand_ecclayout_set()
- don't wrap user-visible string
- remove #ifdef of function prototypes
Ivan Khoronzhuk (1):
k2hk: change default nand ecc layout
WingMan Kwok (2):
mtd: nand: davinci: allow to change ecclayout by ecclayout command
common: cmd_nand: add nand ecclayout command
arch/arm/include/asm/ti-common/davinci_nand.h | 4 ++ board/ti/k2hk_evm/board.c | 11 ++++ common/cmd_nand.c | 91 ++++++++++++++++++++++++++ doc/README.nand | 12 ++++ drivers/mtd/nand/davinci_nand.c | 94 +++++++++++++++++++++++++++ include/nand.h | 7 ++ 6 files changed, 219 insertions(+)
Signature · 1 line
1.8.3.2
PATCH v3 1/3 mtd: nand: davinci: allow to change ecclayout by ecclayout command
From: WingMan Kwok <[email protected]>
This patch adds opportunity to change ecclayout of current nand device during runtime. So we can change the current nand device ecclayout using the "nand ecclayout set" command before writing the data to nand flash.
--- arch/arm/include/asm/ti-common/davinci_nand.h | 4 ++ drivers/mtd/nand/davinci_nand.c | 94 +++++++++++++++++++++++++++ 2 files changed, 98 insertions(+)
arch/arm/include/asm/ti-common/davinci_nand.h +4 -0
@@ -93,6 +93,10 @@ struct davinci_emif_regs {#define DAVINCI_ABCR_ASIZE_16BIT 1#define DAVINCI_ABCR_ASIZE_8BIT 0 +/* Layouts */ +#define NAND_DAVINCI_4BIT_LAYOUT 0 +#define NAND_KEYSTONE_RBL_4BIT_LAYOUT 1 +void davinci_nand_init (struct nand_chip *nand);#endif
drivers/mtd/nand/davinci_nand.c +94 -0
100 lines not on this page · raw message
Signature · 1 line
1.8.3.2
PATCH v3 1/3 mtd: nand: davinci: allow to change ecclayout by ecclayout command
Quoted 10 lines · Ivan
From: WingMan Kwok <[email protected]>
This patch adds opportunity to change ecclayout of current nand device during runtime. So we can change the current nand device ecclayout using the "nand ecclayout set" command before writing the data to nand flash.
Signed-off-by Hao Zhang <[email protected]>Signed-off-by WingMan Kwok <[email protected]>Signed-off-by Ivan Khoronzhuk <[email protected]>
Applied to u-boot-ti/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140825/5b3ce79e/attachment.pgp>
PATCH v3 1/3 mtd: nand: davinci: allow to change ecclayout by ecclayout command
Quoted 9 lines · Tom Rini
Quoted 7 lines · Ivan
From: WingMan Kwok <[email protected]>
This patch adds opportunity to change ecclayout of current nand device during runtime. So we can change the current nand device ecclayout using the "nand ecclayout set" command before writing the data to nand flash.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Hao Zhang <[email protected]>Signed-off-by WingMan Kwok <[email protected]>Signed-off-by Ivan Khoronzhuk <[email protected]>Applied to u-boot-ti/master, thanks!
Sorry Tom, but the subj patch as
entire "[U-boot] [Patch v3 0/3] keystone: nand: add additional nand ecclayout" series
was completely replaced by "[U-boot] [Patch 0/3] Add support for NAND U-boot image upgrade" series
(http://lists.denx.de/pipermail/u-boot/2014-July/182956.html)
which has been applied already.
Hence, this patch as all patches from this series would be better to remove...
Once again sorry. I should specify here about this.
Signature · 2 lines
Regards, Ivan Khoronzhuk
PATCH v3 2/3 common: cmd_nand: add nand ecclayout command
In reply to Ivan KhoronzhukFrom: WingMan Kwok <[email protected]>
This commit adds a nand ecclayout command that allows the ecclayout of the current nand device to be changed during run time. This feature is useful when using u-boot to write something to nand flash that will be read by other applications, such as ROM bootloader, that expects a different ECC layout. In that case, change the current nand device ecclayout using the "nand ecclayout set" command before writing the data to nand flash.
--- common/cmd_nand.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/README.nand | 12 ++++++++ include/nand.h | 7 +++++ 3 files changed, 110 insertions(+)
common/cmd_nand.c +91 -0
@@ -462,6 +462,51 @@ static void adjust_size_for_badblocks(loff_t *size, loff_t offset, int dev) } } +#ifdef CONFIG_CMD_NAND_ECCLAYOUT +static void nand_print_ecclayout_info (struct nand_ecclayout *layout) +{ +int i; +struct nand_oobfree *oobfree; + +if (!layout) +return ; + +printf (" num ecc bytes: %d\n" , layout->eccbytes); +puts (" ecc pos:\n " ); +for (i =0 ; i < layout->eccbytes; i++) { +if (i && !(i %8 )) +printf ("\n " ); + +printf ("%4d " , layout->eccpos[i]); + } + +puts ("\n oobfree:\n" ); +puts (" offset length\n" ); + oobfree = layout->oobfree; +for (i =0 ; oobfree->length && i <MTD_MAX_OOBFREE_ENTRIES_LARGE ; i++) { +printf (" %3d %3d\n" , oobfree->offset, oobfree->length); + oobfree++; + } +} + +static void nand_print_device_ecclayout (int dev) +{ +int idx; +nand_info_t *nand = &nand_info[dev]; +struct nand_chip *chip = nand->priv; + + idx =board_nand_get_ecclayout_idx (chip, chip->ecc.layout); + +if (idx <0 ) { +puts ("no ecc layout\n" ); +return ; + } + +printf ("\necc layout %d:\n" , idx); +nand_print_ecclayout_info (chip->ecc.layout); +} +#endif +static int do_nand (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) {int i, ret =0 ;
@@ -830,6 +875,45 @@ static int do_nand(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) }#endif +#ifdef CONFIG_CMD_NAND_ECCLAYOUT +if (strcmp (cmd,"ecclayout" ) ==0 ) { +int i; +struct nand_ecclayout *lt; +nand_info_t *nand = &nand_info[dev]; + +if (argc <3 ) { +puts ("Current device ecclayout:\n" ); +nand_print_device_ecclayout (dev); +return 0 ; + } + +if (!strcmp (argv[2 ],"set" )) { +if (argc <4 ) +return 1 ; + + i = (int )simple_strtoul (argv[3 ],NULL ,10 ); +if (board_nand_set_ecclayout (nand, i)) +printf ("Setting current device to ecc layout %d FAILED!\n" , i); + +return 0 ; + } + +if (strcmp (argv[2 ],"all" ) !=0 ) +return 1 ; + +/* show all available ecc layouts */ +puts ("Available ecc layouts:\n" ); + +for (i =0 ; (lt =board_nand_get_ecclayout (i)); i++) { + +printf ("\n ecc laytout %d:\n" , i); +nand_print_ecclayout_info (lt); + } + +return 0 ; + } +#endif + usage:return CMD_RET_USAGE ; }
@@ -884,6 +968,13 @@ static char nand_help_text[] ="nand env.oob set off|partition - set enviromnent offset\n" "nand env.oob get - get environment offset"#endif +#ifdef CONFIG_CMD_NAND_ECCLAYOUT +"\n" +"nand ecclayout [all] - show ecclayout, 'all' shows all \n" +" available ecc layouts for setting to current device\n" +"nand ecclayout set idx - sets current device ecc layout \n" + " to layout indexed by idx\n" +#endif "" ;#endif
doc/README.nand +12 -0
@@ -87,6 +87,15 @@ Commands: a packed sequence of "data, oob, data, oob, ..." -- no alignment of individual pages is maintained. + nand ecclayout [all] + Enabled by the CONFIG_CMD_NAND_ECCLAYOUT macro. This command show current + ecclayout, "all" shows all available ecc layouts for setting to current + device. + + nand ecclayout set idx + Enabled by the CONFIG_CMD_NAND_ECCLAYOUT macro. This command set current + device ecc layout to layout indexed by idx. + Configuration Options: CONFIG_CMD_NAND
@@ -208,6 +217,9 @@ Configuration Options: drivers/mtd/nand/ndfc.c drivers/mtd/nand/omap_gpmc.c + CONFIG_CMD_NAND_ECCLAYOUT + Enables support of nand ecclayout commands. + Platform specific options =========================
include/nand.h +7 -0
@@ -155,6 +155,13 @@ void nand_deselect(void);void board_nand_select_device (struct nand_chip *nand,int chip);#endif +int board_nand_get_ecclayout_idx (struct nand_chip *nand, +struct nand_ecclayout *layout); + +struct nand_ecclayout *board_nand_get_ecclayout (int idx); + +int board_nand_set_ecclayout (struct mtd_info *mtd,int idx); + __attribute__((noreturn))void nand_boot (void );#endif
Signature · 1 line
1.8.3.2
PATCH v3 2/3 common: cmd_nand: add nand ecclayout command
Quoted 10 lines · Ivan
From: WingMan Kwok <[email protected]>
This commit adds a nand ecclayout command that allows the ecclayout of the current nand device to be changed during run time. This feature is useful when using u-boot to write something to nand flash that will be read by other applications, such as ROM bootloader, that expects a different ECC layout. In that case, change the current nand device ecclayout using the "nand ecclayout set" command before writing the data to nand flash.
Quoted 2 lines
Signed-off-by WingMan Kwok <[email protected]>Signed-off-by Ivan Khoronzhuk <[email protected]>
Applied to u-boot-ti/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140825/aeb5e735/attachment.pgp>
PATCH v3 2/3 common: cmd_nand: add nand ecclayout command
Quoted 12 lines · Tom Rini
Quoted 10 lines · Ivan
From: WingMan Kwok <[email protected]>
This commit adds a nand ecclayout command that allows the ecclayout of the current nand device to be changed during run time. This feature is useful when using u-boot to write something to nand flash that will be read by other applications, such as ROM bootloader, that expects a different ECC layout. In that case, change the current nand device ecclayout using the "nand ecclayout set" command before writing the data to nand flash.
Quoted 4 lines
Quoted 2 lines
Signed-off-by WingMan Kwok <[email protected]>Signed-off-by Ivan Khoronzhuk <[email protected]>Applied to u-boot-ti/master, thanks!
Sorry Tom, but the subj patch as
entire "[U-boot] [Patch v3 0/3] keystone: nand: add additional nand ecclayout" series
was completely replaced by "[U-boot] [Patch 0/3] Add support for NAND U-boot image upgrade" series
(http://lists.denx.de/pipermail/u-boot/2014-July/182956.html)
which has been applied already.
This patch is not needed.
Signature · 2 lines
Regards, Ivan Khoronzhuk
PATCH v3 2/3 common: cmd_nand: add nand ecclayout command
Quoted 26 lines · Ivan Khoronzhuk
Quoted 12 lines · Tom Rini
Quoted 10 lines · Ivan
From: WingMan Kwok <[email protected]>
This commit adds a nand ecclayout command that allows the ecclayout of the current nand device to be changed during run time. This feature is useful when using u-boot to write something to nand flash that will be read by other applications, such as ROM bootloader, that expects a different ECC layout. In that case, change the current nand device ecclayout using the "nand ecclayout set" command before writing the data to nand flash.
Quoted 4 lines
Quoted 2 lines
Signed-off-by WingMan Kwok <[email protected]>Signed-off-by Ivan Khoronzhuk <[email protected]>Applied to u-boot-ti/master, thanks!
Sorry Tom, but the subj patch as
entire "[U-boot] [Patch v3 0/3] keystone: nand: add additional nand ecclayout" series
was completely replaced by "[U-boot] [Patch 0/3] Add support for NAND U-boot image upgrade" series
(http://lists.denx.de/pipermail/u-boot/2014-July/182956.html)
which has been applied already.
Quoted 1 line
This patch is not needed.
OK, thanks, I've updated the tree and dropped both parts of this series. In the future can you please reply to the old series when you move to a new one? By which I mean these still applied and it was't clear to me that the new v2 series replaced this v3 series since the numbering changed. Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20140825/0b4e4602/attachment.pgp>
PATCH v3 3/3 k2hk: change default nand ecc layout
In reply to Ivan KhoronzhukFor keystyone k2hk board the default nand layout is different from davinci. So swich ecc layout at init in board file.
--- board/ti/k2hk_evm/board.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
board/ti/k2hk_evm/board.c +11 -0
@@ -11,6 +11,7 @@#include <exports.h> #include <fdt_support.h> #include <libfdt.h> +#include <nand.h> #include <asm/arch/hardware.h> #include <asm/arch/clock.h>
@@ -19,6 +20,7 @@#include <asm/arch/emac_defs.h> #include <asm/arch/psc_defs.h> #include <asm/ti-common/ti-aemif.h> +#include <asm/ti-common/davinci_nand.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -147,6 +149,15 @@ int cpu_to_bus(u32 *ptr, u32 length)return 0 ; } +int board_nand_init (struct nand_chip *chip) +{ +davinci_nand_init (chip); + chip->ecc.layout = +board_nand_get_ecclayout (NAND_KEYSTONE_RBL_4BIT_LAYOUT ); + +return 0 ; +} +#if defined(CONFIG_BOARD_EARLY_INIT_F )int board_early_init_f (void ) {
Signature · 1 line
1.8.3.2
PATCH v3 3/3 k2hk: change default nand ecc layout
Quoted 29 lines · Ivan Khoronzhuk
For keystyone k2hk board the default nand layout is different from davinci. So swich ecc layout at init in board file.
Signed-off-by Ivan Khoronzhuk <[email protected]>--- board/ti/k2hk_evm/board.c | 11 +++++++++++ 1 file changed, 11 insertions(+)board/ti/k2hk_evm/board.c +2
-0@@ -11,6 +11,7 @@#include <exports.h> #include <fdt_support.h> #include <libfdt.h> +#include <nand.h> #include <asm/arch/hardware.h> #include <asm/arch/clock.h> @@ -19,6 +20,7 @@#include <asm/arch/emac_defs.h> #include <asm/arch/psc_defs.h> #include <asm/ti-common/ti-aemif.h> +#include <asm/ti-common/davinci_nand.h> DECLARE_GLOBAL_DATA_PTR ;
board/ti/k2hk_evm/board.c int cpu_to_bus(u32 *ptr, u32 length) · line 156
Quoted 8 lines
board/ti/k2hk_evm/board.c +5
-0@@ -147,6 +149,15 @@ int cpu_to_bus(u32 *ptr, u32 length)return 0 ; } +int board_nand_init (struct nand_chip *chip) +{ +davinci_nand_init (chip); + chip->ecc.layout = +board_nand_get_ecclayout (NAND_KEYSTONE_RBL_4BIT_LAYOUT );
Again, why not use board_nand_set_ecclayout()?
-Scott
PATCH v3 3/3 k2hk: change default nand ecc layout
Quoted 33 lines · Scott Wood
Quoted 32 lines · Ivan Khoronzhuk
For keystyone k2hk board the default nand layout is different from davinci. So swich ecc layout at init in board file.
Signed-off-by Ivan Khoronzhuk <[email protected]>--- board/ti/k2hk_evm/board.c | 11 +++++++++++ 1 file changed, 11 insertions(+)board/ti/k2hk_evm/board.c +2
-0@@ -11,6 +11,7 @@#include <exports.h> #include <fdt_support.h> #include <libfdt.h> +#include <nand.h> #include <asm/arch/hardware.h> #include <asm/arch/clock.h> @@ -19,6 +20,7 @@#include <asm/arch/emac_defs.h> #include <asm/arch/psc_defs.h> #include <asm/ti-common/ti-aemif.h> +#include <asm/ti-common/davinci_nand.h> DECLARE_GLOBAL_DATA_PTR ;@@ -147,6 +149,15 @@ int cpu_to_bus(u32 *ptr, u32 length)return 0 ; }
Quoted 10 lines
board/ti/k2hk_evm/board.c int cpu_to_bus(u32 *ptr, u32 length) · line 156
Quoted 5 lines
board/ti/k2hk_evm/board.c +5
-0+int board_nand_init (struct nand_chip *chip) +{ +davinci_nand_init (chip); + chip->ecc.layout = +board_nand_get_ecclayout (NAND_KEYSTONE_RBL_4BIT_LAYOUT );Again, why not use
board_nand_set_ecclayout()?-Scott
Because oobavail is updated in nand_scan_tail(), which is called later.
Sorry for the mess, but it doesn't matter already, seems I can start with default
layout and switch later if needed. So I'm going to remove subj patch.
Thanks.
Signature · 2 lines
Regards, Ivan Khoronzhuk