Raw flash operation.
This file contains definitions and functions for raw NAND Flash operation.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include "nand_flash_model.h"
Data Structures | |
struct | nand_flash_raw |
The raw NAND Flash layer drives hardware-specific Bus Read and Bus Write operations to communicate with the NAND Flash device. More... | |
Functions | |
uint32_t | nand_flash_raw_copy_block (const struct nand_flash_raw *raw, uint16_t source_block, uint16_t dest_block) |
Copy the data of one whole block of a NAND Flash device to another block. More... | |
uint32_t | nand_flash_raw_copy_page (const struct nand_flash_raw *raw, uint16_t source_block, uint16_t source_page, uint16_t dest_block, uint16_t dest_page) |
Copy the data in a page of the NAND Flash device to an other page on that same chip. More... | |
uint32_t | nand_flash_raw_erase_block (const struct nand_flash_raw *raw, uint16_t block) |
Erase the specified block of the device, retrying several time if it fails. More... | |
uint32_t | nand_flash_raw_initialize (struct nand_flash_raw *raw, const struct nand_flash_model *model, uint32_t command_address, uint32_t address_address, uint32_t data_address) |
Initialize a nand_flash_raw instance based on the given model and physical interface. More... | |
uint32_t | nand_flash_raw_read_id (const struct nand_flash_raw *raw) |
Reads and returns the identifiers of a NAND Flash chip. More... | |
void | nand_flash_raw_read_page (const struct nand_flash_raw *raw, uint16_t block, uint16_t page, uint8_t *data, uint8_t *spare) |
Read the data and/or the spare areas of a page of a NAND Flash into the provided buffers. More... | |
void | nand_flash_raw_reset (const struct nand_flash_raw *raw) |
Reset a NAND Flash device. More... | |
uint32_t | nand_flash_raw_write_page (const struct nand_flash_raw *raw, uint16_t block, uint16_t page, uint8_t *data, uint8_t *spare) |
Write the data and/or the spare areas of a page of a NAND Flash into the provided buffers. More... | |
uint32_t nand_flash_raw_copy_block | ( | const struct nand_flash_raw * | raw, |
uint16_t | source_block, | ||
uint16_t | dest_block | ||
) |
Copy the data of one whole block of a NAND Flash device to another block.
raw | Pointer to a nand_flash_raw instance. |
source_block | Source block number. |
dest_block | Destination block number. |
References Assert, MODEL, NAND_COMMON_ERROR_BADBLOCK, nand_flash_model_get_block_size_in_pages(), and nand_flash_raw_copy_page().
uint32_t nand_flash_raw_copy_page | ( | const struct nand_flash_raw * | raw, |
uint16_t | source_block, | ||
uint16_t | source_page, | ||
uint16_t | dest_block, | ||
uint16_t | dest_page | ||
) |
Copy the data in a page of the NAND Flash device to an other page on that same chip.
raw | Pointer to a nand_flash_raw instance. |
source_block | Source block number. |
source_page | Source page number inside the source block. |
dest_block | Destination block number. |
dest_page | Destination page number inside the destination block. |
References copy_page(), and NAND_COMMON_ERROR_BADBLOCK.
Referenced by nand_flash_raw_copy_block().
uint32_t nand_flash_raw_erase_block | ( | const struct nand_flash_raw * | raw, |
uint16_t | block | ||
) |
Erase the specified block of the device, retrying several time if it fails.
raw | Pointer to a nand_flash_raw instance. |
block | Number of the physical block to erase. |
References erase_block(), and NAND_COMMON_ERROR_BADBLOCK.
Referenced by main(), run_test_raw_read_write(), and run_test_software_ecc().
uint32_t nand_flash_raw_initialize | ( | struct nand_flash_raw * | raw, |
const struct nand_flash_model * | model, | ||
uint32_t | command_address, | ||
uint32_t | address_address, | ||
uint32_t | data_address | ||
) |
Initialize a nand_flash_raw instance based on the given model and physical interface.
raw | Pointer to a nand_flash_raw 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::address_address, nand_flash_raw::command_address, CONF_NF_DMA_CHANNEL, nand_flash_raw::data_address, data_address, delay_ms, dmac_channel_set_configuration(), dmac_enable(), dmac_init(), DMAC_PRIORITY_ROUND_ROBIN, dmac_set_priority_mode(), nand_flash_raw::model, NAND_COMMON_ERROR_UNKNOWNMODEL, nand_flash_model_find(), nand_flash_model_list, NAND_FLASH_MODEL_LIST_SIZE, nand_flash_raw_read_id(), nand_flash_raw_reset(), nand_flash_model::page_size_in_bytes, pmc_enable_periph_clk(), smc_nfc_enable(), smc_nfc_init(), smc_set_cycle_timing(), smc_set_mode(), smc_set_nand_timing(), smc_set_pulse_timing(), and smc_set_setup_timing().
Referenced by main(), nand_flash_ecc_initialize(), and run_test_initialization().
uint32_t nand_flash_raw_read_id | ( | const struct nand_flash_raw * | raw | ) |
Reads and returns the identifiers of a NAND Flash chip.
raw | Pointer to a nand_flash_raw instance. |
References delay_us, NAND_COMMAND_READID, NFCADDR_CMD_ACYCLE_ONE, NFCADDR_CMD_CSID, NFCADDR_CMD_NFC_READ, NFCADDR_CMD_NFCCMD, READ_DATA8, and smc_nfc_send_command().
Referenced by nand_flash_raw_initialize(), and run_test_initialization().
void nand_flash_raw_read_page | ( | const struct nand_flash_raw * | raw, |
uint16_t | block, | ||
uint16_t | page, | ||
uint8_t * | data, | ||
uint8_t * | spare | ||
) |
Read the data and/or the spare areas of a page of a NAND Flash into the provided buffers.
raw | Pointer to a nand_flash_raw instance. |
block | Number of the physical block to read. |
page | Number of the page to read inside the given block. |
data | Buffer where the data area will be read. |
spare | Buffer where the spare area will be read. |
References CONF_NF_ADDRESS_CYCLE_CMD, MODEL, NAND_COMMAND_READ_1, NAND_COMMAND_READ_2, NAND_COMMAND_READ_A, nand_flash_model_get_block_size_in_pages(), nand_flash_model_get_page_data_size(), nand_flash_model_get_page_spare_size(), nand_flash_model_small_block(), nfc_copy_data_from_internal_sram(), nfc_translate_address(), NFCADDR_CMD_CSID, NFCADDR_CMD_NFC_READ, NFCADDR_CMD_NFCCMD, NFCADDR_CMD_NFCEN, NFCADDR_CMD_VCMD2, smc_nfc_disable_spare_read(), smc_nfc_enable_spare_read(), smc_nfc_get_status(), and smc_nfc_send_command().
Referenced by copy_page(), main(), nand_flash_ecc_read_page(), run_test_raw_read_write(), and run_test_software_ecc().
void nand_flash_raw_reset | ( | const struct nand_flash_raw * | raw | ) |
Reset a NAND Flash device.
raw | Pointer to a nand_flash_raw instance. |
References NAND_COMMAND_RESET, NFCADDR_CMD_ACYCLE_NONE, NFCADDR_CMD_CSID, NFCADDR_CMD_NFC_READ, NFCADDR_CMD_NFCCMD, smc_nfc_get_status(), smc_nfc_send_command(), and UNUSED.
Referenced by nand_flash_raw_initialize().
uint32_t nand_flash_raw_write_page | ( | const struct nand_flash_raw * | raw, |
uint16_t | block, | ||
uint16_t | page, | ||
uint8_t * | data, | ||
uint8_t * | spare | ||
) |
Write the data and/or the spare areas of a page of a NAND Flash into the provided buffers.
raw | Pointer to a nand_flash_raw instance. |
block | Number of the physical block to write resides. |
page | Number of the page to write inside the given block. |
data | Buffer where the data area will be stored. |
spare | Buffer where the spare area will be stored. |
References NAND_COMMON_ERROR_BADBLOCK, and write_page().
Referenced by copy_page(), main(), nand_flash_ecc_write_page(), and run_test_raw_read_write().