xref: /openbmc/u-boot/doc/README.atmel_pmecc (revision 09c2b8f3e39925e5bdff12cb90add09bc9e117d4)
1bdfd59aaSWu, JoshHow to enable PMECC(Programmable Multibit ECC) for nand on Atmel SoCs
2bdfd59aaSWu, Josh-----------------------------------------------------------
3bdfd59aaSWu, Josh2012-08-22 Josh Wu <josh.wu@atmel.com>
4bdfd59aaSWu, Josh
5bdfd59aaSWu, JoshThe Programmable Multibit ECC (PMECC) controller is a programmable binary
6bdfd59aaSWu, JoshBCH(Bose, Chaudhuri and Hocquenghem) encoder and decoder. This controller
7bdfd59aaSWu, Joshcan be used to support both SLC and MLC NAND Flash devices. It supports to
8bdfd59aaSWu, Joshgenerate ECC to correct 2, 4, 8, 12 or 24 bits of error per sector (512 or
9bdfd59aaSWu, Josh1024 bytes) of data.
10bdfd59aaSWu, Josh
11bdfd59aaSWu, JoshFollowing Atmel AT91 products support PMECC.
12bdfd59aaSWu, Josh- AT91SAM9X25, X35, G25, G15, G35 (tested)
13bdfd59aaSWu, Josh- AT91SAM9N12 (not tested, Should work)
14bdfd59aaSWu, Josh
15bdfd59aaSWu, JoshAs soon as your nand flash software ECC works, you can enable PMECC.
16bdfd59aaSWu, Josh
17bdfd59aaSWu, JoshTo use PMECC in this driver, the user needs to set:
18bdfd59aaSWu, Josh	1. the PMECC correction error bits capability: CONFIG_PMECC_CAP.
19bdfd59aaSWu, Josh	   It can be 2, 4, 8, 12 or 24.
20bdfd59aaSWu, Josh	2. The PMECC sector size: CONFIG_PMECC_SECTOR_SIZE.
21bdfd59aaSWu, Josh	   It only can be 512 or 1024.
22bdfd59aaSWu, Josh
23bdfd59aaSWu, JoshTake AT91SAM9X5EK as an example, the board definition file likes:
24bdfd59aaSWu, Josh
25bdfd59aaSWu, Josh/* PMECC & PMERRLOC */
26bdfd59aaSWu, Josh#define CONFIG_ATMEL_NAND_HWECC		1
27bdfd59aaSWu, Josh#define CONFIG_ATMEL_NAND_HW_PMECC	1
28bdfd59aaSWu, Josh#define CONFIG_PMECC_CAP		2
29bdfd59aaSWu, Josh#define CONFIG_PMECC_SECTOR_SIZE	512
305c390a5bSAndreas Bießmann
315c390a5bSAndreas BießmannHow to enable PMECC header for direct programmable boot.bin
325c390a5bSAndreas Bießmann-----------------------------------------------------------
33*09c2b8f3SAndreas Bießmann2014-05-19 Andreas Bießmann <andreas@biessmann.org>
345c390a5bSAndreas Bießmann
355c390a5bSAndreas BießmannThe usual way to program SPL into NAND flash is to use the SAM-BA Atmel tool.
365c390a5bSAndreas BießmannThis however is often not usable when doing field updates. To be able to
375c390a5bSAndreas Bießmannprogram a SPL binary into NAND flash we need to add the PMECC header to the
385c390a5bSAndreas Bießmannbinary before. Chapter '12.4.4.1 NAND Flash Boot: NAND Flash Detection' in
395c390a5bSAndreas Bießmannsama5d3 SoC spec (as of 03. April 2014) defines how this PMECC header has to
405c390a5bSAndreas Bießmannlook like. In order to do so we have a new image type added to mkimage to
415c390a5bSAndreas Bießmanngenerate this PMECC header and integrated this into the build process of SPL.
425c390a5bSAndreas Bießmann
435c390a5bSAndreas BießmannTo enable the generation of atmel PMECC header for SPL one need to define
445c390a5bSAndreas BießmannCONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER. The required parameters are taken from
455c390a5bSAndreas Bießmannboard configuration and compiled into the host tools atmel_pmecc_params. This
465c390a5bSAndreas Bießmanntool will be called in build process to parametrize mkimage for atmelimage
475c390a5bSAndreas Bießmanntype. The mkimage tool has intentionally _not_ compiled in those parameters.
485c390a5bSAndreas Bießmann
495c390a5bSAndreas BießmannThe mkimage image type atmelimage also set the 6'th interrupt vector to the
505c390a5bSAndreas Bießmanncorrect value. This feature can also be used to setup a boot.bin for MMC boot.
51