ECC flash operation.
This file contains definitions and functions for ECC NAND Flash operation.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | MODEL(ecc) ((struct nand_flash_model *)ecc) |
#define | RAW(ecc) ((struct nand_flash_raw *)ecc) |
Functions | |
uint32_t | nand_flash_ecc_initialize (struct nand_flash_ecc *ecc, const struct nand_flash_model *model, uint32_t command_address, uint32_t address_address, uint32_t data_address) |
Initialize a nand_flash_ecc instance. More... | |
uint32_t | nand_flash_ecc_read_page (const struct nand_flash_ecc *ecc, uint16_t block, uint16_t page, uint8_t *data, uint8_t *spare) |
Read the data and/or spare of a page of a NAND Flash chip, and verify that the data is valid using the ECC information contained in the spare. More... | |
uint32_t | nand_flash_ecc_write_page (const struct nand_flash_ecc *ecc, uint16_t block, uint16_t page, uint8_t *data, uint8_t *spare) |
Write the data and/or spare area of a NAND Flash page, after calculating an ECC for the data area and storing it in the spare. More... | |
#define MODEL | ( | ecc | ) | ((struct nand_flash_model *)ecc) |
Referenced by nand_flash_ecc_read_page(), and nand_flash_ecc_write_page().
#define RAW | ( | ecc | ) | ((struct nand_flash_raw *)ecc) |
Referenced by nand_flash_ecc_initialize(), nand_flash_ecc_read_page(), and nand_flash_ecc_write_page().
uint32_t nand_flash_ecc_initialize | ( | struct nand_flash_ecc * | ecc, |
const struct nand_flash_model * | model, | ||
uint32_t | command_address, | ||
uint32_t | address_address, | ||
uint32_t | data_address | ||
) |
Initialize a nand_flash_ecc instance.
ecc | Pointer to an nand_flash_ecc instance. |
model | Pointer to the underlying NAND chip model. Can be 0. |
command_address | Address at which commands are sent. |
address_address | Address at which addresses are sent. |
data_address | Address at which data is sent. |
References nand_flash_raw_initialize(), and RAW.
uint32_t nand_flash_ecc_read_page | ( | const struct nand_flash_ecc * | ecc, |
uint16_t | block, | ||
uint16_t | page, | ||
uint8_t * | data, | ||
uint8_t * | spare | ||
) |
Read the data and/or spare of a page of a NAND Flash chip, and verify that the data is valid using the ECC information contained in the spare.
If one buffer pointer is 0, the corresponding area is not saved.
ecc | Pointer to an nand_flash_ecc instance. |
block | Number of block to read from. |
page | Number of page to read inside given block. |
data | Data area buffer. |
spare | Spare area buffer. |
References error(), HAMMING_ERROR_SINGLE_BIT, hamming_verify_256x(), MODEL, NAND_COMMON_ERROR_CORRUPTEDDATA, NAND_COMMON_MAX_PAGE_SPARE_SIZE, NAND_COMMON_MAX_SPARE_ECC_BYTES, nand_flash_model_get_page_data_size(), nand_flash_model_get_scheme(), nand_flash_raw_read_page(), nand_flash_spare_scheme_read_ecc(), RAW, and spare_buffer.
Referenced by run_test_software_ecc().
uint32_t nand_flash_ecc_write_page | ( | const struct nand_flash_ecc * | ecc, |
uint16_t | block, | ||
uint16_t | page, | ||
uint8_t * | data, | ||
uint8_t * | spare | ||
) |
Write the data and/or spare area of a NAND Flash page, after calculating an ECC for the data area and storing it in the spare.
If no data buffer is provided, the ECC is read from the existing page spare. If no spare buffer is provided, the spare area is still written with the ECC information calculated on the data buffer.
ecc | Pointer to an nand_flash_ecc instance. |
block | Number of block to read from. |
page | Number of page to read inside given block. |
data | Data area buffer. |
spare | Spare area buffer. |
Compute ECC on the new data, if provided. If not provided, hamming code set to 0xFFFF.. to keep existing bytes.
References error(), hamming_compute_256x(), MODEL, NAND_COMMON_MAX_PAGE_SPARE_SIZE, NAND_COMMON_MAX_SPARE_ECC_BYTES, nand_flash_model_get_page_data_size(), nand_flash_model_get_scheme(), nand_flash_raw_write_page(), nand_flash_spare_scheme_write_ecc(), RAW, and spare_buffer.
Referenced by run_test_software_ecc().