|
| | __attribute__ ((unused)) |
| | Dump the contents of the SFDP (Serial Flash Discoverable Parameters) data structure.
|
| |
| static int | spi_nor_read_sfdp (sunxi_spi_t *spi, sfdp_t *sfdp) |
| | Read the SFDP (Serial Flash Discoverable Parameters) data from a SPI NOR Flash chip.
|
| |
| static int | spinor_read_id (sunxi_spi_t *spi, uint32_t *id) |
| | Read the identification (ID) of the SPI NOR Flash chip.
|
| |
| static uint8_t | spi_nor_read_status_register (sunxi_spi_t *spi) |
| | Read the status register of the SPI NOR Flash chip.
|
| |
| static void | spi_nor_write_status_register (sunxi_spi_t *spi, uint8_t sr) |
| | Write to the status register of the SPI NOR Flash chip.
|
| |
| static void | spi_nor_wait_for_busy (sunxi_spi_t *spi) |
| | Wait for SPI NOR Flash to finish operation by checking its "busy" status.
|
| |
| static void | spi_nor_chip_reset (sunxi_spi_t *spi) |
| | Reset the SPI NOR Flash chip.
|
| |
| static void | spi_nor_set_write_enable (sunxi_spi_t *spi) |
| | Enable write operations on the SPI NOR Flash chip.
|
| |
| static int | spi_nor_get_info (sunxi_spi_t *spi) |
| | Retrieves the information of the SPI NOR flash.
|
| |
| static void | spi_nor_read_bytes (sunxi_spi_t *spi, uint32_t addr, uint8_t *buf, uint32_t count) |
| | Reads a specified number of bytes from the SPI NOR flash memory.
|
| |
| int | spi_nor_detect (sunxi_spi_t *spi) |
| | Detects the presence of an SPI NOR flash chip.
|
| |
| uint32_t | spi_nor_read_block (sunxi_spi_t *spi, uint8_t *buf, uint32_t blk_no, uint32_t blk_cnt) |
| | Reads a block or multiple blocks of data from the SPI NAND flash memory.
|
| |
| uint32_t | spi_nor_read (sunxi_spi_t *spi, uint8_t *buf, uint32_t addr, uint32_t rxlen) |
| | Reads data from the SPI NOR flash memory.
|
| |
Dump the contents of the SFDP (Serial Flash Discoverable Parameters) data structure.
This function prints the SFDP header, parameter headers, and the basic table information to the log. It will provide detailed output about the SFDP format, including version information, the number of parameter headers, and the contents of the basic table in the SFDP structure.
- Parameters
-
| sfdp | Pointer to an sfdp_t structure containing the SFDP data to be dumped. |
- Note
- This function is marked as
__attribute__((unused)) to avoid unused function warnings if not used.
- Warning
- If the provided
sfdp pointer is NULL, the function will print a trace log indicating the issue.
Retrieves the information of the SPI NOR flash.
This function reads the identification (ID) of the SPI NOR flash and attempts to fetch its detailed parameters using the Serial Flash Discoverable Parameters (SFDP)
table. Based on the flash type and capacity, it configures the address length, erase opcodes, write granularity, and other flash-specific parameters. If the SFDP table is unavailable, the function will fall back on a predefined lookup table using the flash's ID to find a match. It then populates the info structure with the gathered information.
- Parameters
-
| spi | The SPI interface structure representing the SPI controller to interact with the NOR flash. |
- Returns
- 1 if the flash information was successfully retrieved.
- 0 if the flash ID is not recognized or the SPI NOR flash could not be detected.
- Note
- If the SPI NOR flash is recognized using its ID, this function will populate the
info structure with its capabilities such as capacity, address length, erase block size, and supported opcodes. If the SFDP is valid, it also provides more granular details such as the opcode for 4K, 32K, 64K, and 256K erases, as well as write granularity.
- See also
- spinor_read_id(), spi_nor_read_sfdp(), spi_nor_dump_sfdp(), NOR_OPCODE_WREN, NOR_OPCODE_READ, NOR_OPCODE_PROG
Reads data from the SPI NOR flash memory.
This function reads a specified length of data from a given address in the SPI NOR flash memory into a provided buffer. The reading is performed in blocks, and it handles cases where the read address is not aligned to the block size.
- Parameters
-
| [in] | spi | Pointer to the SPI interface structure. |
| [out] | buf | Pointer to the buffer where the read data will be stored. |
| [in] | addr | The starting address from which to read data in the SPI NOR. |
| [in] | rxlen | The number of bytes to read from the SPI NOR. |
- Returns
- The number of bytes successfully read from the SPI NOR. This can be less than
rxlen if an error occurs or if the end of the memory space is reached.
- Note
- This function assumes that the buffer provided by the caller is large enough to accommodate the data being read.
The function first checks if the read address is misaligned with the block size. If so, it reads a partial block. Then, it reads as many complete blocks as possible before potentially reading another partial block at the end.
Reads a block or multiple blocks of data from the SPI NAND flash memory.
This function reads one or more contiguous blocks from the SPI NAND flash memory into a provided buffer. It handles reading the data in chunks defined by the read granularity and performs the necessary address calculations to handle multiple blocks.
- Parameters
-
| [in] | spi | Pointer to the SPI interface structure. |
| [out] | buf | Pointer to the buffer where the read data will be stored. |
| [in] | blk_no | The starting block number from which to read data. |
| [in] | blk_cnt | The number of blocks to read from the SPI NAND. |
- Returns
- The number of blocks successfully read. In case of an error, it will return the requested block count, indicating the operation was completed.
- Note
- This function assumes that the buffer provided by the caller is large enough to accommodate the data being read. If the block count is large, ensure the buffer has sufficient space for all the blocks.
The function reads data from the SPI NAND flash memory in chunks based on the configured read granularity (info.read_granularity). It waits for the SPI bus to be ready before each read operation. The function will continue reading until the requested number of blocks has been fetched. If the data to be read exceeds the maximum read length (0x7FFFFFFF bytes), it adjusts the size of each read operation accordingly.
Reads a specified number of bytes from the SPI NOR flash memory.
This function sends the read command and address to the SPI NOR flash memory and retrieves the requested data. It supports different address lengths (3 or 4 bytes) based on the configuration in the info structure.
- Parameters
-
| [in] | spi | Pointer to the SPI interface structure. |
| [in] | addr | The starting address to read data from in the SPI NOR. |
| [out] | buf | Pointer to the buffer where the read data will be stored. |
| [in] | count | The number of bytes to read from the SPI NOR. |
- Returns
- None
- Note
- This function uses the
sunxi_spi_transfer function to perform the SPI data transfer. The number of bytes transferred depends on the address length configuration, which is either 3 or 4 bytes.
This function first checks the address_length configuration (from info) to determine if the address is 3 bytes or 4 bytes long. Based on this configuration, it sends the appropriate number of address bytes and the read opcode to the SPI NOR. The data is then transferred to the provided buffer. The function supports 3-byte or 4-byte address modes, but any other address length is not supported.