Flash model definition.
This file contains flash model definitions and functions for NAND Flash module.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | OPTIONS 0 |
Functions | |
uint32_t | nand_flash_model_copy_back (const struct nand_flash_model *model) |
Check if if the device supports the copy-back operation. More... | |
uint32_t | nand_flash_model_find (const struct nand_flash_model *model_list, uint32_t size, uint32_t chip_id, struct nand_flash_model *model) |
Looks for a NAND Flash Model corresponding to the given ID inside a list of model. More... | |
uint32_t | nand_flash_model_get_block_size_in_bytes (const struct nand_flash_model *model) |
Returns the size in bytes of one single block of a device. More... | |
uint32_t | nand_flash_model_get_block_size_in_pages (const struct nand_flash_model *model) |
Returns the number of pages in one single block of a device. More... | |
uint32_t | nand_flash_model_get_data_bus_width (const struct nand_flash_model *model) |
Returns the number of bits used by the data bus of a NAND Flash device. More... | |
uint8_t | nand_flash_model_get_device_id (const struct nand_flash_model *model) |
Returns the device ID of a particular NAND Flash model. More... | |
uint16_t | nand_flash_model_get_device_size_in_blocks (const struct nand_flash_model *model) |
Returns the number of blocks in the entire device. More... | |
uint64_t | nand_flash_model_get_device_size_in_bytes (const struct nand_flash_model *model) |
Returns the size of the whole device in bytes (this does not include the size of the spare zones). More... | |
uint16_t | nand_flash_model_get_device_size_in_megabytes (const struct nand_flash_model *model) |
Returns the size of the whole device in Mega bytes (this does not include the size of the spare zones). More... | |
uint32_t | nand_flash_model_get_device_size_in_pages (const struct nand_flash_model *model) |
Returns the number of pages in the entire device. More... | |
uint16_t | nand_flash_model_get_page_data_size (const struct nand_flash_model *model) |
Returns the size of the data area of a page in bytes. More... | |
uint16_t | nand_flash_model_get_page_spare_size (const struct nand_flash_model *model) |
Returns the size of the spare area of a page in bytes. More... | |
struct nand_flash_spare_scheme * | nand_flash_model_get_scheme (const struct nand_flash_model *model) |
Returns the spare area placement scheme used by a particular NAND Flash model. More... | |
uint32_t | nand_flash_model_small_block (const struct nand_flash_model *model) |
Check if the given NAND Flash model uses the "small blocks/pages". More... | |
uint32_t | nand_flash_model_translate_access (const struct nand_flash_model *model, uint32_t address, uint32_t size, uint16_t *block, uint16_t *page, uint16_t *offset) |
Translates address/size access of a nand_flash_model to block, page and offset values. More... | |
Variables | |
struct nand_flash_model | nand_flash_model_list [NAND_FLASH_MODEL_LIST_SIZE] |
List of NAND Flash models which can be recognized by the software. More... | |
#define OPTIONS 0 |
uint32_t nand_flash_model_copy_back | ( | const struct nand_flash_model * | model | ) |
Check if if the device supports the copy-back operation.
model | Pointer to a nand_flash_model instance. |
References NAND_FLASH_MODEL_COPY_BACK, and nand_flash_model::options.
Referenced by copy_page().
uint32_t nand_flash_model_find | ( | const struct nand_flash_model * | model_list, |
uint32_t | size, | ||
uint32_t | chip_id, | ||
struct nand_flash_model * | model | ||
) |
Looks for a NAND Flash Model corresponding to the given ID inside a list of model.
If found, the model variable is filled with the correct values.
model_list | List of nand_flash_model instances. |
size | Number of models in list. |
chip_id | Identifier returned by the NAND (id1|(id2<<8)|(id3<<16)|(id4<<24)). |
model | nand_flash_model instance to update with the model parameters. |
References nand_flash_model::block_size_in_kilobytes, nand_flash_model::device_id, NAND_COMMON_ERROR_UNKNOWNMODEL, and nand_flash_model::page_size_in_bytes.
Referenced by nand_flash_raw_initialize().
uint32_t nand_flash_model_get_block_size_in_bytes | ( | const struct nand_flash_model * | model | ) |
Returns the size in bytes of one single block of a device.
This does not take into account the spare zones size.
model | Pointer to a nand_flash_model instance. |
References nand_flash_model::block_size_in_kilobytes.
Referenced by main(), and nand_flash_model_translate_access().
uint32_t nand_flash_model_get_block_size_in_pages | ( | const struct nand_flash_model * | model | ) |
Returns the number of pages in one single block of a device.
model | Pointer to a nand_flash_model instance. |
References nand_flash_model::block_size_in_kilobytes, and nand_flash_model::page_size_in_bytes.
Referenced by copy_page(), erase_block(), main(), nand_flash_model_get_device_size_in_pages(), nand_flash_raw_copy_block(), nand_flash_raw_read_page(), and write_page().
uint32_t nand_flash_model_get_data_bus_width | ( | const struct nand_flash_model * | model | ) |
Returns the number of bits used by the data bus of a NAND Flash device.
model | Pointer to a nand_flash_model instance. |
References NAND_FLASH_MODEL_DATA_BUS_16, and nand_flash_model::options.
Referenced by nfc_translate_address().
uint8_t nand_flash_model_get_device_id | ( | const struct nand_flash_model * | model | ) |
Returns the device ID of a particular NAND Flash model.
model | Pointer to a nand_flash_model instance. |
References nand_flash_model::device_id.
uint16_t nand_flash_model_get_device_size_in_blocks | ( | const struct nand_flash_model * | model | ) |
Returns the number of blocks in the entire device.
model | Pointer to a nand_flash_model instance. |
References nand_flash_model::block_size_in_kilobytes, and nand_flash_model::device_size_in_megabytes.
Referenced by main(), nand_flash_model_get_device_size_in_pages(), and run_test_initialization().
uint64_t nand_flash_model_get_device_size_in_bytes | ( | const struct nand_flash_model * | model | ) |
Returns the size of the whole device in bytes (this does not include the size of the spare zones).
model | Pointer to a nand_flash_model instance. |
References nand_flash_model::device_size_in_megabytes.
Referenced by main(), and nand_flash_model_translate_access().
uint16_t nand_flash_model_get_device_size_in_megabytes | ( | const struct nand_flash_model * | model | ) |
Returns the size of the whole device in Mega bytes (this does not include the size of the spare zones).
model | Pointer to a nand_flash_model instance. |
References nand_flash_model::device_size_in_megabytes.
uint32_t nand_flash_model_get_device_size_in_pages | ( | const struct nand_flash_model * | model | ) |
Returns the number of pages in the entire device.
model | Pointer to a nand_flash_model instance. |
References nand_flash_model_get_block_size_in_pages(), and nand_flash_model_get_device_size_in_blocks().
Referenced by nfc_translate_address().
uint16_t nand_flash_model_get_page_data_size | ( | const struct nand_flash_model * | model | ) |
Returns the size of the data area of a page in bytes.
take into account the spare zones size.
model | Pointer to a nand_flash_model instance. |
References nand_flash_model::page_size_in_bytes.
Referenced by main(), nand_flash_ecc_read_page(), nand_flash_ecc_write_page(), nand_flash_model_translate_access(), nand_flash_raw_read_page(), nand_flash_usb_read_10(), nand_flash_usb_write_10(), nfc_translate_address(), run_test_initialization(), and write_page().
uint16_t nand_flash_model_get_page_spare_size | ( | const struct nand_flash_model * | model | ) |
Returns the size of the spare area of a page in bytes.
model | Pointer to a nand_flash_model instance. |
References nand_flash_model::page_size_in_bytes.
Referenced by nand_flash_raw_read_page(), and write_page().
struct nand_flash_spare_scheme* nand_flash_model_get_scheme | ( | const struct nand_flash_model * | model | ) |
Returns the spare area placement scheme used by a particular NAND Flash model.
model | Pointer to a nand_flash_model instance. |
References nand_flash_model::scheme.
Referenced by nand_flash_ecc_read_page(), and nand_flash_ecc_write_page().
uint32_t nand_flash_model_small_block | ( | const struct nand_flash_model * | model | ) |
Check if the given NAND Flash model uses the "small blocks/pages".
model | Pointer to a nand_flash_model instance. |
References nand_flash_model::page_size_in_bytes.
Referenced by nand_flash_raw_read_page().
uint32_t nand_flash_model_translate_access | ( | const struct nand_flash_model * | model, |
uint32_t | address, | ||
uint32_t | size, | ||
uint16_t * | block, | ||
uint16_t * | page, | ||
uint16_t * | offset | ||
) |
Translates address/size access of a nand_flash_model to block, page and offset values.
model | nand_flash_model instance. |
address | Access address. |
size | Access size in bytes. |
block | Stores the first accessed block number. |
page | Stores the first accessed page number inside the first block. |
offset | Stores the byte offset inside the first accessed page. |
References block_size, NAND_COMMON_ERROR_OUTOFBOUNDS, nand_flash_model_get_block_size_in_bytes(), nand_flash_model_get_device_size_in_bytes(), nand_flash_model_get_page_data_size(), and page_size.
struct nand_flash_model nand_flash_model_list[NAND_FLASH_MODEL_LIST_SIZE] |
List of NAND Flash models which can be recognized by the software.
Referenced by nand_flash_raw_initialize().