From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v6 06/11] spl, nand: add 4bit HW ecc oob first nand_read_page function
Date: Wed, 2 Nov 2011 07:00:30 +0100 [thread overview]
Message-ID: <1320213635-8056-7-git-send-email-hs@denx.de> (raw)
In-Reply-To: <1320213635-8056-1-git-send-email-hs@denx.de>
similiar to commit dc7cd8e59ba077f3b4c1a4557c9cd86a31b9ab1f, only
adapted for the new spl framework.
Signed-off-by: Heiko Schocher <hs@denx.de>
Acked-by: Tom Rini <trini@ti.com>
Acked-by: Scott Wood <scottwood@freescale.com>
Cc: Albert ARIBAUD <albert.u.boot@aribaud.net>
Cc: Sandeep Paulraj <s-paulraj@ti.com>
---
changes for v2:
- add comment from Scott Wood:
as BSS is cleared, no need for intializing vars with 0
remove this.
changes for v3:
- add comment from Scoot Wood and Tom Rini
- rename CONFIG_SYS_NAND_4BIT_HW_ECC_OOBFIRST to
CONFIG_SYS_NAND_HW_ECC_OOBFIRST
- add dokumentation in README
changes for v4:
- added Acked-by: Tom Rini <trini@ti.com>
changes for v5:
- added Acked-by: Scott Wood <scottwood@freescale.com>
README | 5 ++++
drivers/mtd/nand/nand_spl_simple.c | 43 +++++++++++++++++++++++++++++++++++-
2 files changed, 47 insertions(+), 1 deletions(-)
diff --git a/README b/README
index 62ef0a7..f4366e6 100644
--- a/README
+++ b/README
@@ -3261,6 +3261,11 @@ Low Level (hardware related) configuration options:
that is executed before the actual U-Boot. E.g. when
compiling a NAND SPL.
+- CONFIG_SYS_NAND_HW_ECC_OOBFIRST
+ define this, if you want to read first the oob data
+ and then the data. This is used for example on
+ davinci plattforms.
+
- CONFIG_USE_ARCH_MEMCPY
CONFIG_USE_ARCH_MEMSET
If these options are used a optimized version of memcpy/memset will
diff --git a/drivers/mtd/nand/nand_spl_simple.c b/drivers/mtd/nand/nand_spl_simple.c
index 71491d4..e5003e6 100644
--- a/drivers/mtd/nand/nand_spl_simple.c
+++ b/drivers/mtd/nand/nand_spl_simple.c
@@ -140,6 +140,47 @@ static int nand_is_bad_block(int block)
return 0;
}
+#if defined(CONFIG_SYS_NAND_HW_ECC_OOBFIRST)
+static int nand_read_page(int block, int page, uchar *dst)
+{
+ struct nand_chip *this = mtd.priv;
+ u_char *ecc_calc;
+ u_char *ecc_code;
+ u_char *oob_data;
+ int i;
+ int eccsize = CONFIG_SYS_NAND_ECCSIZE;
+ int eccbytes = CONFIG_SYS_NAND_ECCBYTES;
+ int eccsteps = CONFIG_SYS_NAND_ECCSTEPS;
+ uint8_t *p = dst;
+ int stat;
+
+ /*
+ * No malloc available for now, just use some temporary locations
+ * in SDRAM
+ */
+ ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE + 0x10000);
+ ecc_code = ecc_calc + 0x100;
+ oob_data = ecc_calc + 0x200;
+
+ nand_command(block, page, 0, NAND_CMD_READOOB);
+ this->read_buf(&mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE);
+ nand_command(block, page, 0, NAND_CMD_READ0);
+
+ /* Pick the ECC bytes out of the oob data */
+ for (i = 0; i < CONFIG_SYS_NAND_ECCTOTAL; i++)
+ ecc_code[i] = oob_data[nand_ecc_pos[i]];
+
+
+ for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
+ this->ecc.hwctl(&mtd, NAND_ECC_READ);
+ this->read_buf(&mtd, p, eccsize);
+ this->ecc.calculate(&mtd, p, &ecc_calc[i]);
+ stat = this->ecc.correct(&mtd, p, &ecc_code[i], &ecc_calc[i]);
+ }
+
+ return 0;
+}
+#else
static int nand_read_page(int block, int page, void *dst)
{
struct nand_chip *this = mtd.priv;
@@ -186,6 +227,7 @@ static int nand_read_page(int block, int page, void *dst)
return 0;
}
+#endif
int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst)
{
@@ -230,7 +272,6 @@ void nand_init(void)
mtd.priv = &nand_chip;
nand_chip.IO_ADDR_R = nand_chip.IO_ADDR_W =
(void __iomem *)CONFIG_SYS_NAND_BASE;
- nand_chip.options = 0;
board_nand_init(&nand_chip);
if (nand_chip.select_chip)
--
1.7.6.4
next prev parent reply other threads:[~2011-11-02 6:00 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-02 6:00 [U-Boot] [PATCH v6 00/11] arm, davinci: add support for dm368 based cam_enc_4xx board Heiko Schocher
2011-11-02 6:00 ` [U-Boot] [PATCH v6 01/11] usb, davinci: add enable_vbus() weak function Heiko Schocher
2011-11-02 6:00 ` [U-Boot] [PATCH v6 02/11] arm, usb, davinci: make USBPHY_CTL register configurable Heiko Schocher
2011-11-02 6:00 ` [U-Boot] [PATCH v6 03/11] net, davinci_emac: make clock divider in MDIO control " Heiko Schocher
2011-11-02 6:00 ` [U-Boot] [PATCH v6 04/11] spl: add option for adding post memory test to the SPL framework Heiko Schocher
2011-11-02 6:00 ` [U-Boot] [PATCH v6 05/11] arm, davinci: add support for new spl framework Heiko Schocher
2011-11-02 22:53 ` Scott Wood
2011-11-03 5:31 ` [U-Boot] [PATCH v7 " Heiko Schocher
2011-11-02 6:00 ` Heiko Schocher [this message]
2011-11-02 6:00 ` [U-Boot] [PATCH v6 07/11] arm, davinci: add header files for dm365 Heiko Schocher
2011-11-02 6:00 ` [U-Boot] [PATCH v6 08/11] arm, davinci: add lowlevel function for dm365 soc Heiko Schocher
2011-11-02 6:00 ` [U-Boot] [PATCH v6 09/11] arm926ejs, davinci: add cpuinfo for dm365 Heiko Schocher
2011-11-02 6:00 ` [U-Boot] [PATCH v6 10/11] arm926ejs, davinci: add missing spi defines " Heiko Schocher
2011-11-02 6:00 ` [U-Boot] [PATCH v6 11/11] arm, davinci: add cam_enc_4xx support Heiko Schocher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1320213635-8056-7-git-send-email-hs@denx.de \
--to=hs@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox