• Thomas Petazzoni's avatar
    mtd: nand: add support for Micron on-die ECC · 9748e1d8
    Thomas Petazzoni authored
    Now that the core NAND subsystem has support for on-die ECC, this commit
    brings the necessary code to support on-die ECC on Micron NANDs.
    
    In micron_nand_init(), we detect if the Micron NAND chip supports on-die
    ECC mode, by checking a number of conditions:
    
     - It must be an ONFI NAND
     - It must be a SLC NAND
    
     - Enabling *and* disabling on-die ECC must work
    
     - The on-die ECC must be correcting 4 bits per 512 bytes of data. Some
       Micron NAND chips have an on-die ECC able to correct 8 bits per 512
       bytes of data, but they work slightly differently and therefore we
       don't support them in this patch.
    
    Then, if the on-die ECC cannot be disabled (some Micron NAND have on-die
    ECC forcefully enabled), we bail out, as we don't support such
    NANDs. Indeed, the implementation of raw_read()/raw_write() make the
    assumption that on-die ECC can be disabled. Support for Micron NANDs
    with on-die ECC forcefully enabled can easily be added, but in the
    absence of such HW for testing, we preferred to simply bail out.
    
    If the on-die ECC is supported, and requested in the Device Tree, then
    it is indeed enabled, by using custom implementations of the
    ->read_page(), ->read_page_raw(), ->write_page() and ->write_page_raw()
    operation to properly handle the on-die ECC.
    
    In the non-raw functions, we need to enable the internal ECC engine
    before issuing the NAND_CMD_READ0 or NAND_CMD_SEQIN commands, which is
    why we set the NAND_ECC_CUSTOM_PAGE_ACCESS option at initialization
    time (it asks the NAND core to let the NAND driver issue those
    commands).
    Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
    Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
    9748e1d8
nand_micron.c 7.74 KB