![]() |
qspipsu
Vitis Drivers API Documentation
|
This file contains a design example using the QSPIPSU driver (XQspiPsu) The example writes to flash in IO mode and reads it back using non-blocking APIs in DMA mode.
This examples runs with GENFIFO Manual start. It runs in polled mode. This example illustrates single, parallel and stacked modes. Both the flash devices have to be of the same make and size. The hardware which this example runs on, must have a serial Flash (Micron N25Q) for it to run. In order to test in single, parallel or stacked flash configurations the necessary HW must be present and QSPI_MODE (also reflected in ConnectionMode in the instance) has to be in sync with HW flash configuration being tested.
This example has been tested with the Micron Serial Flash (N25Q512) and ISSI Serial Flash parts of IS25WP and IS25LP series flashes in single and parallel modes using A53 and R5 processors.
None.
MODIFICATION HISTORY:
Ver Who Date Changes
1.11 akm 02/19/20 First release 1.13 akm 11/30/20 Removed unwanted header files. 1.13 akm 12/10/20 Set Read command as per the qspi bus width. 1.14 akm 07/16/21 Enable Quad Mode for Winbond flashes. 1.15 akm 11/19/21 Fix read/write failures on Spansion flash parts. 1.15 akm 12/22/21 Initialize variables before use. 1.16 akm 08/16/22 Fix logical error in NumSect calculation. 1.17 akm 12/16/22 Add timeout in QSPIPSU driver examples. 1.18 sb 05/19/23 Update number of sector calculation logic in flash erase API. 1.18 sb 06/07/23 Added support for system device-tree flow. 1.18 sb 07/24/23 Fix wrong init sequence for spansion byte ID. 1.18 sb 08/02/23 Add status check for XQspiPsu_SetClkPrescaler API. 1.19 sb 01/12/24 Added support to set QSPI clock based on baud rate divisior 1.20 sb 09/13/24 Updated examples to configure correct baud rate value
Functions | |
int | QspiPsuFlashNonBlockingReadExample (XQspiPsu *QspiPsuInstancePtr, u16 QspiPsuDeviceId) |
The purpose of this function is to illustrate how to use the XQspiPsu device driver in single, parallel and stacked modes using flash devices greater than or equal to 128Mb. More... | |
int | FlashReadID (XQspiPsu *QspiPsuPtr) |
Reads the flash ID and identifies the flash in FCT table. More... | |
int | FlashErase (XQspiPsu *QspiPsuPtr, u32 Address, u32 ByteCount, u8 *WriteBfrPtr) |
This function erases the sectors in the serial Flash connected to the QSPIPSU interface. More... | |
int | FlashWrite (XQspiPsu *QspiPsuPtr, u32 Address, u32 ByteCount, u8 Command, u8 *WriteBfrPtr) |
This function writes to the serial Flash connected to the QSPIPSU interface. More... | |
int | FlashRead (XQspiPsu *QspiPsuPtr, u32 Address, u32 ByteCount, u8 Command, u8 *WriteBfrPtr, u8 *ReadBfrPtr) |
This function performs read. More... | |
int | MultiDieRead (XQspiPsu *QspiPsuPtr, u32 Address, u32 ByteCount, u8 Command, u8 *WriteBfrPtr, u8 *ReadBfrPtr) |
This functions performs a read operation for multi die flash devices. More... | |
u32 | GetRealAddr (XQspiPsu *QspiPsuPtr, u32 Address) |
This functions translates the address based on the type of interconnection. More... | |
int | BulkErase (XQspiPsu *QspiPsuPtr, u8 *WriteBfrPtr) |
This functions performs a bulk erase operation when the flash device has a single die. More... | |
int | DieErase (XQspiPsu *QspiPsuPtr, u8 *WriteBfrPtr) |
This functions performs a die erase operation on all the die in the flash device. More... | |
int | FlashRegisterRead (XQspiPsu *QspiPsuPtr, u32 ByteCount, u8 Command, u8 *ReadBfrPtr) |
This API can be used to write to a flash register. More... | |
int | FlashRegisterWrite (XQspiPsu *QspiPsuPtr, u32 ByteCount, u8 Command, u8 *WriteBfrPtr, u8 WrEn) |
This API can be used to write to a flash register. More... | |
int | FlashEnterExit4BAddMode (XQspiPsu *QspiPsuPtr, unsigned int Enable) |
This API enters the flash device into 4 bytes addressing mode. More... | |
int | FlashEnableQuadMode (XQspiPsu *QspiPsuPtr) |
This API enables Quad mode for the flash parts which require to enable quad mode before using Quad commands. More... | |
int | main (void) |
Main function to call the QSPIPSU Flash Polled example. More... | |
int BulkErase | ( | XQspiPsu * | QspiPsuPtr, |
u8 * | WriteBfrPtr | ||
) |
This functions performs a bulk erase operation when the flash device has a single die.
Works for both Spansion and Micron
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
WriteBfrPtr | is the pointer to command+address to be sent |
int DieErase | ( | XQspiPsu * | QspiPsuPtr, |
u8 * | WriteBfrPtr | ||
) |
This functions performs a die erase operation on all the die in the flash device.
This function uses the die erase command for Micron 512Mbit and 1Gbit
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
WriteBfrPtr | is the pointer to command+address to be sent |
int FlashEnableQuadMode | ( | XQspiPsu * | QspiPsuPtr | ) |
This API enables Quad mode for the flash parts which require to enable quad mode before using Quad commands.
For S25FL-L series flash parts this is required as the default configuration is x1/x2 mode.
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
int FlashEnterExit4BAddMode | ( | XQspiPsu * | QspiPsuPtr, |
unsigned int | Enable | ||
) |
This API enters the flash device into 4 bytes addressing mode.
As per the Micron and ISSI spec, before issuing the command to enter into 4 byte addr mode, a write enable command is issued. For Macronix and Winbond flash parts write enable is not required.
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
Enable | is a either 1 or 0 if 1 then enters 4 byte if 0 exits. |
int FlashErase | ( | XQspiPsu * | QspiPsuPtr, |
u32 | Address, | ||
u32 | ByteCount, | ||
u8 * | WriteBfrPtr | ||
) |
This function erases the sectors in the serial Flash connected to the QSPIPSU interface.
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
Address | contains the address of the first sector which needs to be erased. |
ByteCount | contains the total size to be erased. |
WriteBfrPtr | is pointer to the write buffer (which is to be transmitted) |
int FlashRead | ( | XQspiPsu * | QspiPsuPtr, |
u32 | Address, | ||
u32 | ByteCount, | ||
u8 | Command, | ||
u8 * | WriteBfrPtr, | ||
u8 * | ReadBfrPtr | ||
) |
This function performs read.
DMA is the default setting.
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
Address | contains the address of the first sector which needs to be erased. |
ByteCount | contains the total size to be erased. |
Command | is the command used to read data from the flash. Supports normal, fast, dual and quad read commands. |
WriteBfrPtr | is Pointer to the write buffer which contains data to be transmitted |
ReadBfrPtr | is Pointer to the read buffer to which valid received data should be written |
int FlashReadID | ( | XQspiPsu * | QspiPsuPtr | ) |
Reads the flash ID and identifies the flash in FCT table.
QspiPsuPtr | is a pointer to the instance of the QspiPsu device. |
int FlashRegisterRead | ( | XQspiPsu * | QspiPsuPtr, |
u32 | ByteCount, | ||
u8 | Command, | ||
u8 * | ReadBfrPtr | ||
) |
This API can be used to write to a flash register.
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
ByteCount | is the number of bytes to write. |
Command | is specific register write command. |
ReadBfrPtr | is Pointer to the read buffer to which valid received data should be written |
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
ByteCount | is the number of bytes to write. |
Command | is specific register write command. |
ReadBfrPtr | is the pointer to value to be read. |
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
ByteCount | is the number of bytes to write. |
Command | is specific register write command. |
ReadBfrPtr | is the pointer to value to be written. |
References XQspiPsu_Msg::BusWidth, XQspiPsu_Msg::ByteCount, XQspiPsu_Msg::Flags, XQspiPsu_Msg::RxBfrPtr, XQspiPsu_Msg::TxBfrPtr, XQSPIPSU_MSG_FLAG_RX, XQSPIPSU_MSG_FLAG_TX, XQspiPsu_PolledTransfer(), and XQSPIPSU_SELECT_MODE_SPI.
int FlashRegisterWrite | ( | XQspiPsu * | QspiPsuPtr, |
u32 | ByteCount, | ||
u8 | Command, | ||
u8 * | WriteBfrPtr, | ||
u8 | WrEn | ||
) |
This API can be used to write to a flash register.
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
ByteCount | is the number of bytes to write. |
Command | is specific register write command. |
WriteBfrPtr | is the pointer to value to be written. |
WrEn | is a flag to mention if WREN has to be sent before write. |
References XQspiPsu_Msg::BusWidth, XQspiPsu_Msg::ByteCount, XQspiPsu_Msg::Flags, MAX_DELAY_CNT, XQspiPsu_Msg::RxBfrPtr, XQspiPsu_Msg::TxBfrPtr, XQSPIPSU_MSG_FLAG_RX, XQSPIPSU_MSG_FLAG_TX, XQspiPsu_PolledTransfer(), and XQSPIPSU_SELECT_MODE_SPI.
int FlashWrite | ( | XQspiPsu * | QspiPsuPtr, |
u32 | Address, | ||
u32 | ByteCount, | ||
u8 | Command, | ||
u8 * | WriteBfrPtr | ||
) |
This function writes to the serial Flash connected to the QSPIPSU interface.
All the data put into the buffer must be in the same page of the device with page boundaries being on 256 byte boundaries.
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
Address | contains the address to write data to in the Flash. |
ByteCount | contains the number of bytes to write. |
Command | is the command used to write data to the flash. QSPIPSU device supports only Page Program command to write data to the flash. |
WriteBfrPtr | is Pointer to the write buffer (which is to be transmitted) |
u32 GetRealAddr | ( | XQspiPsu * | QspiPsuPtr, |
u32 | Address | ||
) |
This functions translates the address based on the type of interconnection.
In case of stacked, this function asserts the corresponding slave select.
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
Address | which is to be accessed (for erase, write or read) |
int main | ( | void | ) |
Main function to call the QSPIPSU Flash Polled example.
References QspiPsuFlashNonBlockingReadExample().
int MultiDieRead | ( | XQspiPsu * | QspiPsuPtr, |
u32 | Address, | ||
u32 | ByteCount, | ||
u8 | Command, | ||
u8 * | WriteBfrPtr, | ||
u8 * | ReadBfrPtr | ||
) |
This functions performs a read operation for multi die flash devices.
QspiPsuPtr | is a pointer to the QSPIPSU driver component to use. |
Address | contains the address of the first sector which needs to be erased. |
ByteCount | contains the total size to be erased. |
Command | is the command used to read data from the flash. Supports normal, fast, dual and quad read commands. |
WriteBfrPtr | is pointer to the write buffer which contains data to be transmitted |
ReadBfrPtr | is pointer to the read buffer to which valid received data should be written. |
int QspiPsuFlashNonBlockingReadExample | ( | XQspiPsu * | QspiPsuInstancePtr, |
u16 | QspiPsuDeviceId | ||
) |
The purpose of this function is to illustrate how to use the XQspiPsu device driver in single, parallel and stacked modes using flash devices greater than or equal to 128Mb.
This function reads data in DMA mode.
QspiPsuInstancePtr | is a pointer to the instance of the QspiPsu device. |
QspiPsuDeviceId | is the Device ID of the Qspi Device and is the XPAR_<QSPI_instance>_DEVICE_ID value from xparameters.h. |
References XQspiPsu_Config::BaseAddress, XQspiPsu_Config::BaudRateDiv, XQspiPsu_Config::BusWidth, XQspiPsu::Config, XQspiPsu_Config::ConnectionMode, FlashEnableQuadMode(), FlashEnterExit4BAddMode(), FlashErase(), FlashRead(), FlashReadID(), FlashWrite(), XQspiPsu_CfgInitialize(), XQSPIPSU_CLK_PRESCALE_8, XQSPIPSU_CONNECTION_MODE_PARALLEL, XQspiPsu_LookupConfig(), XQSPIPSU_MANUAL_START_OPTION, XQSPIPSU_SELECT_FLASH_BUS_LOWER, XQSPIPSU_SELECT_FLASH_CS_LOWER, XQspiPsu_SelectFlash(), XQspiPsu_SetClkPrescaler(), and XQspiPsu_SetOptions().
Referenced by main().