Microchip® Advanced Software Framework

nand_flash_model.h File Reference

Flash model definition.

This file contains flash model definitions and functions for NAND Flash module.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

Data Structures

struct  nand_flash_model
 
#define NAND_FLASH_MODEL_DATA_BUS_8   (0 << 0)
 Nand_Flash_Model_opts NAND Flash Model options. More...
 
#define NAND_FLASH_MODEL_DATA_BUS_16   (1 << 0)
 
#define NAND_FLASH_MODEL_COPY_BACK   (1 << 1)
 
#define NAND_FLASH_MODEL_LIST_SIZE   58
 
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...
 
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_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...
 
struct nand_flash_spare_schemenand_flash_model_get_scheme (const struct nand_flash_model *model)
 Returns the spare area placement scheme used by a particular NAND Flash model. 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...
 
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...
 
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_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_block_size_in_bytes (const struct nand_flash_model *model)
 Returns the size in bytes of one single block of a 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...
 
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...
 
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_copy_back (const struct nand_flash_model *model)
 Check if if the device supports the copy-back operation. More...
 

#define NAND_FLASH_MODEL_COPY_BACK   (1 << 1)
#define NAND_FLASH_MODEL_DATA_BUS_16   (1 << 0)
#define NAND_FLASH_MODEL_DATA_BUS_8   (0 << 0)

Nand_Flash_Model_opts NAND Flash Model options.

  • NAND_FLASH_MODEL_DATA_BUS_8
  • NAND_FLASH_MODEL_DATA_BUS_16
  • NAND_FLASH_MODEL_COPY_BACK
#define NAND_FLASH_MODEL_LIST_SIZE   58

uint32_t nand_flash_model_copy_back ( const struct nand_flash_model model)

Check if if the device supports the copy-back operation.

Parameters
modelPointer to a nand_flash_model instance.
Returns
1 if the model supports the copy-back operation; otherwise return 0.

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.

Parameters
model_listList of nand_flash_model instances.
sizeNumber of models in list.
chip_idIdentifier returned by the NAND (id1|(id2<<8)|(id3<<16)|(id4<<24)).
modelnand_flash_model instance to update with the model parameters.
Returns
0 if a matching model has been found; otherwise returns NAND_COMMON_ERROR_UNKNOWNMODEL.

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.

Parameters
modelPointer 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)
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.

Parameters
modelPointer to a nand_flash_model instance.

References NAND_FLASH_MODEL_DATA_BUS_16, and nand_flash_model::options.

Referenced by read_data(), write_column_address(), write_data(), and write_row_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.

Parameters
modelPointer 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.

Parameters
modelPointer 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).

Parameters
modelPointer 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).

Parameters
modelPointer 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.

Parameters
modelPointer 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 write_row_address().

uint16_t nand_flash_model_get_page_data_size ( const struct nand_flash_model model)
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.

Parameters
modelPointer 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.

Parameters
modelPointer 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".

Parameters
modelPointer to a nand_flash_model instance.
Returns
1 if the model uses the "small blocks/pages"; otherwise return 0.

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.

Parameters
modelnand_flash_model instance.
addressAccess address.
sizeAccess size in bytes.
blockStores the first accessed block number.
pageStores the first accessed page number inside the first block.
offsetStores the byte offset inside the first accessed page.
Returns
0 if the access is correct; otherwise returns NAND_COMMON_ERROR_OUTOFBOUNDS.
Note
The values are stored in the provided variables if their pointer is not 0.

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().