ospipsv
Vitis Drivers API Documentation
|
This file contains a design example using the OSPIPSV driver (xospipsv) The example writes to flash in IO mode and reads it back in DMA mode.
It runs in interrupt mode. The hardware which this example runs on, must have an octal serial Flash (Micron) for it to run.
This example has been tested with the Micron Octal Serial Flash (mt35xu01gbba).
None.
MODIFICATION HISTORY:
Ver Who Date Changes
1.0 sk 01/09/19 First release 1.0 akm 03/29/19 Fixed data alignment issues on IAR compiler 1.1 sk 07/23/19 Based on RX Tuning, updated the dummy cycles. sk 08/08/19 Issue device reset to bring back to default state. 1.3 sk 05/27/20 Added Stacked mode support. 1.4 sk 02/18/21 Added support for Macronix flash and DualByte commands. 1.9 sb 06/06/23 Added support for system device-tree flow.
Functions | |
int | OspiPsvInterruptFlashExample (XScuGic *IntcInstancePtr, XOspiPsv *OspiPsvInstancePtr, u16 OspiPsvDeviceId) |
The purpose of this function is to illustrate how to use the XOspiPsv device driver using OSPI flash devices greater than or equal to 128Mb. More... | |
void | OspiPsvHandler (void *CallBackRef, u32 StatusEvent) |
Callback handler. More... | |
int | FlashReadID (XOspiPsv *OspiPsvPtr) |
Reads the flash ID and identifies the flash in FCT table. More... | |
int | FlashErase (XOspiPsv *OspiPsvPtr, u32 Address, u32 ByteCount, u8 *WriteBfrPtr) |
This function erases the sectors in the serial Flash connected to the OSPIPSV interface. More... | |
int | FlashIoWrite (XOspiPsv *OspiPsvPtr, u32 Address, u32 ByteCount, u8 *WriteBfrPtr) |
This function writes to the serial Flash connected to the OSPIPSV interface. More... | |
int | FlashLinearWrite (XOspiPsv *OspiPsvPtr, u32 Address, u32 ByteCount, u8 *WriteBfrPtr) |
This function writes to the serial Flash connected to the OSPIPSV interface. More... | |
int | FlashRead (XOspiPsv *OspiPsvPtr, u32 Address, u32 ByteCount, u8 *WriteBfrPtr, u8 *ReadBfrPtr) |
This function performs read. More... | |
u32 | GetRealAddr (XOspiPsv *OspiPsvPtr, u32 Address) |
This functions translates the address based on the type of interconnection. More... | |
int | BulkErase (XOspiPsv *OspiPsvPtr, u8 *WriteBfrPtr) |
This functions performs a bulk erase operation when the flash device has a single die. More... | |
int | DieErase (XOspiPsv *OspiPsvPtr, u8 *WriteBfrPtr) |
This functions performs a die erase operation on all the die in the flash device. More... | |
int | FlashEnterExit4BAddMode (XOspiPsv *OspiPsvPtr, int Enable) |
This API enters the flash device into 4 bytes addressing mode. More... | |
int | FlashSetSDRDDRMode (XOspiPsv *OspiPsvPtr, int Mode) |
This API enters the flash device into Octal DDR mode or exit from octal DDR mode (switches to Extended SPI mode). More... | |
int | main (void) |
Main function to call the OSPIPSV Flash Interrupt example. More... | |
u32 | XOspiPsv_Get_Proto (XOspiPsv *OspiPsvInstancePtr, int Read) |
The purpose of this function is to determine the number of lines used for command, address and data. More... | |
int BulkErase | ( | XOspiPsv * | OspiPsvPtr, |
u8 * | WriteBfrPtr | ||
) |
This functions performs a bulk erase operation when the flash device has a single die.
Works for both Spansion and Micron
OspiPsvPtr | is a pointer to the OSPIPSV driver component to use. |
WriteBfrPtr | is the pointer to command+address to be sent |
References XOspiPsv_Msg::Addrsize, XOspiPsv_Msg::Addrvalid, XOspiPsv_Msg::ByteCount, XOspiPsv::DualByteOpcodeEn, XOspiPsv_Msg::Dummy, XOspiPsv_Msg::ExtendedOpcode, XOspiPsv::Extra_DummyCycle, XOspiPsv_Msg::Flags, XOspiPsv_Msg::IsDDROpCode, XOspiPsv_Msg::Opcode, XOspiPsv_Msg::Proto, XOspiPsv_Msg::RxBfrPtr, XOspiPsv::SdrDdrMode, XOspiPsv_Msg::TxBfrPtr, XOspiPsv_IntrTransfer(), and XOSPIPSV_MSG_FLAG_RX.
Referenced by FlashErase().
int DieErase | ( | XOspiPsv * | OspiPsvPtr, |
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
OspiPsvPtr | is a pointer to the OSPIPSV driver component to use. |
WriteBfrPtr | is the pointer to command+address to be sent |
References XOspiPsv_Msg::Addrsize, XOspiPsv_Msg::Addrvalid, XOspiPsv_Msg::ByteCount, XOspiPsv::DualByteOpcodeEn, XOspiPsv_Msg::Dummy, XOspiPsv_Msg::ExtendedOpcode, XOspiPsv::Extra_DummyCycle, XOspiPsv_Msg::Flags, XOspiPsv_Msg::IsDDROpCode, XOspiPsv_Msg::Opcode, XOspiPsv_Msg::Proto, XOspiPsv_Msg::RxBfrPtr, XOspiPsv::SdrDdrMode, XOspiPsv_Msg::TxBfrPtr, XOspiPsv_IntrTransfer(), and XOSPIPSV_MSG_FLAG_RX.
Referenced by FlashErase().
int FlashEnterExit4BAddMode | ( | XOspiPsv * | OspiPsvPtr, |
int | Enable | ||
) |
This API enters the flash device into 4 bytes addressing mode.
As per the Micron spec, before issuing the command to enter into 4 byte addr mode, a write enable command is issued.
OspiPsvPtr | is a pointer to the OSPIPSV driver component to use. |
Enable | is a either 1 or 0 if 1 then enters 4 byte if 0 exits. |
References XOspiPsv_Msg::Addrsize, XOspiPsv_Msg::Addrvalid, XOspiPsv_Msg::ByteCount, XOspiPsv::DualByteOpcodeEn, XOspiPsv_Msg::Dummy, XOspiPsv_Msg::ExtendedOpcode, XOspiPsv::Extra_DummyCycle, XOspiPsv_Msg::Flags, XOspiPsv_Msg::IsDDROpCode, XOspiPsv_Msg::Opcode, XOspiPsv_Msg::Proto, XOspiPsv_Msg::RxBfrPtr, XOspiPsv::SdrDdrMode, XOspiPsv_Msg::TxBfrPtr, XOspiPsv_IntrTransfer(), and XOSPIPSV_MSG_FLAG_RX.
Referenced by OspiPsvFlashNonBlockingReadExample(), OspiPsvInterruptFlashExample(), and OspiPsvPolledFlashExample().
int FlashErase | ( | XOspiPsv * | OspiPsvPtr, |
u32 | Address, | ||
u32 | ByteCount, | ||
u8 * | WriteBfrPtr | ||
) |
This function erases the sectors in the serial Flash connected to the OSPIPSV interface.
OspiPsvPtr | is a pointer to the OSPIPSV 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) |
References XOspiPsv_Msg::Addr, XOspiPsv_Msg::Addrsize, XOspiPsv_Msg::Addrvalid, BulkErase(), XOspiPsv_Msg::ByteCount, XOspiPsv::Config, XOspiPsv_Config::ConnectionMode, DieErase(), XOspiPsv::DualByteOpcodeEn, XOspiPsv_Msg::Dummy, XOspiPsv_Msg::ExtendedOpcode, XOspiPsv::Extra_DummyCycle, XOspiPsv_Msg::Flags, GetRealAddr(), XOspiPsv_Msg::IsDDROpCode, XOspiPsv_Msg::Opcode, XOspiPsv_Msg::Proto, XOspiPsv_Msg::RxBfrPtr, XOspiPsv::SdrDdrMode, XOspiPsv_Msg::TxBfrPtr, XOspiPsv_IntrTransfer(), XOSPIPSV_MSG_FLAG_RX, XOSPIPSV_SELECT_FLASH_CS0, and XOspiPsv_SelectFlash().
Referenced by MicronBlockProtectTest(), OspiPsvFlashNonBlockingReadExample(), OspiPsvInterruptFlashExample(), and OspiPsvPolledFlashExample().
int FlashIoWrite | ( | XOspiPsv * | OspiPsvPtr, |
u32 | Address, | ||
u32 | ByteCount, | ||
u8 * | WriteBfrPtr | ||
) |
This function writes to the serial Flash connected to the OSPIPSV 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. This can be used in IO or DMA mode.
OspiPsvPtr | is a pointer to the OSPIPSV driver component to use. |
Address | contains the address to write data to in the Flash. |
ByteCount | contains the number of bytes to write. |
WriteBfrPtr | is Pointer to the write buffer (which is to be transmitted) |
All the data put into the buffer must be in the same page of the device with page boundaries being on 256 byte boundaries. This can be used in IO or DMA mode.
OspiPsvPtr | is a pointer to the OSPIPSV driver component to use. |
Address | contains the address to write data to in the Flash. |
ByteCount | contains the number of bytes to write. |
WriteBfrPtr | Pointer to the write buffer (which is to be transmitted) |
References XOspiPsv_Msg::Addr, XOspiPsv_Msg::Addrsize, XOspiPsv_Msg::Addrvalid, XOspiPsv_Msg::ByteCount, XOspiPsv::DualByteOpcodeEn, XOspiPsv_Msg::Dummy, XOspiPsv_Msg::ExtendedOpcode, XOspiPsv::Extra_DummyCycle, XOspiPsv_Msg::Flags, GetRealAddr(), XOspiPsv_Msg::IsDDROpCode, XOspiPsv_Msg::Opcode, XOspiPsv_Msg::Proto, XOspiPsv_Msg::RxBfrPtr, XOspiPsv::SdrDdrMode, XOspiPsv_Msg::TxBfrPtr, XOspiPsv_Get_Proto(), XOspiPsv_IntrTransfer(), and XOSPIPSV_MSG_FLAG_RX.
Referenced by MicronBlockProtectTest(), OspiPsvFlashNonBlockingReadExample(), OspiPsvInterruptFlashExample(), and OspiPsvPolledFlashExample().
int FlashLinearWrite | ( | XOspiPsv * | OspiPsvPtr, |
u32 | Address, | ||
u32 | ByteCount, | ||
u8 * | WriteBfrPtr | ||
) |
This function writes to the serial Flash connected to the OSPIPSV 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. This can be used when controller is in Linear mode.
OspiPsvPtr | is a pointer to the OSPIPSV driver component to use. |
Address | contains the address to write data to in the Flash. |
ByteCount | contains the number of bytes to write. |
WriteBfrPtr | is Pointer to the write buffer (which is to be transmitted) |
References XOspiPsv_Msg::Addr, XOspiPsv_Msg::Addrsize, XOspiPsv_Msg::Addrvalid, XOspiPsv_Msg::ByteCount, XOspiPsv::DualByteOpcodeEn, XOspiPsv_Msg::Dummy, XOspiPsv_Msg::ExtendedOpcode, XOspiPsv_Msg::Flags, XOspiPsv_Msg::IsDDROpCode, XOspiPsv_Msg::Opcode, XOspiPsv_Msg::Proto, XOspiPsv_Msg::RxBfrPtr, XOspiPsv::SdrDdrMode, XOspiPsv_Msg::TxBfrPtr, XOspiPsv_Get_Proto(), and XOspiPsv_PollTransfer().
Referenced by MicronBlockProtectTest(), OspiPsvFlashNonBlockingReadExample(), and OspiPsvPolledFlashExample().
int FlashRead | ( | XOspiPsv * | OspiPsvPtr, |
u32 | Address, | ||
u32 | ByteCount, | ||
u8 * | WriteBfrPtr, | ||
u8 * | ReadBfrPtr | ||
) |
This function performs read.
DMA is the default setting.
OspiPsvPtr | is a pointer to the OSPIPSV 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 contains data to be transmitted |
ReadBfrPtr | isPointer to the read buffer to which valid received data should be written |
DMA is the default setting.
OspiPsvPtr | is a pointer to the OSPIPSV 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 contains data to be transmitted |
ReadBfrPtr | is Pointer to the read buffer to which valid received data should be written |
References XOspiPsv_Msg::Addr, XOspiPsv_Msg::Addrsize, XOspiPsv_Msg::Addrvalid, XOspiPsv_Msg::ByteCount, XOspiPsv::Config, XOspiPsv_Config::ConnectionMode, XOspiPsv::DualByteOpcodeEn, XOspiPsv_Msg::Dummy, XOspiPsv_Msg::ExtendedOpcode, XOspiPsv::Extra_DummyCycle, XOspiPsv_Msg::Flags, GetRealAddr(), XOspiPsv_Msg::IsDDROpCode, XOspiPsv_Msg::Opcode, XOspiPsv_Msg::Proto, XOspiPsv_Msg::RxBfrPtr, XOspiPsv::SdrDdrMode, XOspiPsv_Msg::TxBfrPtr, XOspiPsv_Get_Proto(), XOspiPsv_IntrTransfer(), and XOSPIPSV_MSG_FLAG_RX.
Referenced by MicronBlockProtectTest(), OspiPsvFlashNonBlockingReadExample(), OspiPsvInterruptFlashExample(), and OspiPsvPolledFlashExample().
int FlashReadID | ( | XOspiPsv * | OspiPsvPtr | ) |
Reads the flash ID and identifies the flash in FCT table.
OspiPsvPtr | is a pointer to the OSPIPSV driver component to use. |
References XOspiPsv_Msg::Addrsize, XOspiPsv_Msg::Addrvalid, XOspiPsv_Msg::ByteCount, XOspiPsv::DeviceIdData, XOspiPsv::DualByteOpcodeEn, XOspiPsv_Msg::Dummy, XOspiPsv_Msg::ExtendedOpcode, XOspiPsv::Extra_DummyCycle, XOspiPsv_Msg::Flags, XOspiPsv_Msg::IsDDROpCode, XOspiPsv_Msg::Opcode, XOspiPsv_Msg::Proto, READ_ID, XOspiPsv_Msg::RxBfrPtr, XOspiPsv::SdrDdrMode, XOspiPsv_Msg::TxBfrPtr, XOspiPsv_IntrTransfer(), and XOSPIPSV_MSG_FLAG_RX.
Referenced by OspiPsvFlashNonBlockingReadExample(), OspiPsvInterruptFlashExample(), and OspiPsvPolledFlashExample().
int FlashSetSDRDDRMode | ( | XOspiPsv * | OspiPsvPtr, |
int | Mode | ||
) |
This API enters the flash device into Octal DDR mode or exit from octal DDR mode (switches to Extended SPI mode).
OspiPsvPtr | is a pointer to the OSPIPSV driver component to use. |
Mode | is either 1 or 0 if 1 then enter octal DDR mode if 0 exits. |
References XOspiPsv_Msg::Addr, XOspiPsv_Msg::Addrsize, XOspiPsv_Msg::Addrvalid, XOspiPsv_Msg::ByteCount, XOspiPsv::Config, XOspiPsv::DeviceIdData, XOspiPsv::DualByteOpcodeEn, XOspiPsv_Msg::Dummy, XOspiPsv_Msg::ExtendedOpcode, XOspiPsv::Extra_DummyCycle, XOspiPsv_Msg::Flags, XOspiPsv_Msg::IsDDROpCode, XOspiPsv_Msg::Opcode, XOspiPsv::OpMode, XOspiPsv_Msg::Proto, XOspiPsv_Msg::RxBfrPtr, XOspiPsv::SdrDdrMode, XOspiPsv_Msg::TxBfrPtr, XOspiPsv_ConfigDualByteOpcode(), XOspiPsv_ConfigureAutoPolling(), XOSPIPSV_DAC_EN_OPTION, XOSPIPSV_DUAL_BYTE_OP_DISABLE, XOspiPsv_IntrTransfer(), XOSPIPSV_MSG_FLAG_RX, and XOspiPsv_SetSdrDdrMode().
Referenced by OspiPsvFlashNonBlockingReadExample(), OspiPsvInterruptFlashExample(), and OspiPsvPolledFlashExample().
u32 GetRealAddr | ( | XOspiPsv * | OspiPsvPtr, |
u32 | Address | ||
) |
This functions translates the address based on the type of interconnection.
In case of stacked, this function asserts the corresponding slave select.
OspiPsvPtr | is a pointer to the OSPIPSV driver component to use. |
Address | which is to be accessed (for erase, write or read) |
References XOspiPsv::Config, XOspiPsv_Config::ConnectionMode, XOSPIPSV_SELECT_FLASH_CS0, and XOspiPsv_SelectFlash().
Referenced by FlashErase(), FlashIoWrite(), and FlashRead().
int main | ( | void | ) |
Main function to call the OSPIPSV Flash Interrupt example.
References OspiPsvInterruptFlashExample().
void OspiPsvHandler | ( | void * | CallBackRef, |
u32 | StatusEvent | ||
) |
Callback handler.
CallBackRef | is the upper layer callback reference passed back when the callback function is invoked. |
StatusEvent | is the event that just occurred. |
Referenced by OspiPsvInterruptFlashExample().
int OspiPsvInterruptFlashExample | ( | XScuGic * | IntcInstancePtr, |
XOspiPsv * | OspiPsvInstancePtr, | ||
u16 | OspiPsvDeviceId | ||
) |
The purpose of this function is to illustrate how to use the XOspiPsv device driver using OSPI flash devices greater than or equal to 128Mb.
This function reads data in either DMA or DAC mode.
IntcInstancePtr | is a pointer to the instance of the Intc device. |
OspiPsvInstancePtr | is a pointer to the instance of the Ospi device. |
OspiPsvDeviceId | is the Device ID of the Ospi Device and is the XPAR_<OSPI_instance>_DEVICE_ID value from xparameters.h. |
References XOspiPsv::Config, XOspiPsv_Config::ConnectionMode, FlashEnterExit4BAddMode(), FlashErase(), FlashIoWrite(), FlashRead(), FlashReadID(), FlashSetSDRDDRMode(), OspiPsvHandler(), XOspiPsv_CfgInitialize(), XOspiPsv_DeviceReset(), XOSPIPSV_HWPIN_RESET, XOspiPsv_IntrHandler(), XOspiPsv_LookupConfig(), XOSPIPSV_SELECT_FLASH_CS0, XOspiPsv_SelectFlash(), XOspiPsv_SetClkPrescaler(), XOspiPsv_SetOptions(), XOspiPsv_SetSdrDdrMode(), and XOspiPsv_SetStatusHandler().
Referenced by main().
u32 XOspiPsv_Get_Proto | ( | XOspiPsv * | OspiPsvInstancePtr, |
int | Read | ||
) |
The purpose of this function is to determine the number of lines used for command, address and data.
OspiPsvInstancePtr | is a pointer to the OSPIPSV driver component to use. |
Read | is to tell whether a read or write |
References XOspiPsv::OpMode, XOSPIPSV_IDAC_MODE, and XOSPIPSV_READ_1_1_1.
Referenced by FlashIoWrite(), FlashLinearWrite(), and FlashRead().