qspips
Vitis Drivers API Documentation
 All Data Structures Files Functions Variables Typedefs Groups Pages
xqspips.h File Reference
#include "xstatus.h"
#include "xqspips_hw.h"
#include <string.h>

Data Structures

struct  XQspiPs_Config
 Holds the configuration information for the device. More...
 
struct  XQspiPs
 Holds the XQspiPs driver instance data. More...
 

Macros

#define XQspiPs_IsManualStart(InstancePtr)
 Checks in OptionsTable if Manual Start Option is enabled or disabled. More...
 
#define XQspiPs_IsManualChipSelect(InstancePtr)
 Checks in OptionsTable if Manual Chip Select Option is enabled or disabled. More...
 
#define XQspiPs_SetSlaveIdle(InstancePtr, RegisterValue)
 Sets the contents of the slave idle count register. More...
 
#define XQspiPs_GetSlaveIdle(InstancePtr)
 Gets the contents of the slave idle count register. More...
 
#define XQspiPs_SetTXWatermark(InstancePtr, RegisterValue)
 Sets the contents of the transmit FIFO watermark register. More...
 
#define XQspiPs_GetTXWatermark(InstancePtr)   XQspiPs_In32(((InstancePtr)->Config.BaseAddress) + XQSPIPS_TXWR_OFFSET)
 Gets the contents of the transmit FIFO watermark register. More...
 
#define XQspiPs_SetRXWatermark(InstancePtr, RegisterValue)
 Sets the contents of the receive FIFO watermark register. More...
 
#define XQspiPs_GetRXWatermark(InstancePtr)   XQspiPs_In32(((InstancePtr)->Config.BaseAddress) + XQSPIPS_RXWR_OFFSET)
 Gets the contents of the receive FIFO watermark register. More...
 
#define XQspiPs_Enable(InstancePtr)
 Enables the device and uninhibits master transactions. More...
 
#define XQspiPs_Disable(InstancePtr)   XQspiPs_Out32(((InstancePtr)->Config.BaseAddress) + XQSPIPS_ER_OFFSET, 0)
 Disables the device. More...
 
#define XQspiPs_SetLqspiConfigReg(InstancePtr, RegisterValue)
 Sets the contents of the Linear QSPI Configuration register. More...
 
#define XQspiPs_GetLqspiConfigReg(InstancePtr)
 Gets the contents of the Linear QSPI Configuration register. More...
 
Configuration options

The following options are supported to enable/disable certain features of an QSPI device.

Each of the options is a bit mask, so more than one may be specified.

The Active Low Clock option configures the device's clock polarity. Setting this option means the clock is active low and the SCK signal idles high. By default, the clock is active high and SCK idles low.

The Clock Phase option configures the QSPI device for one of two transfer formats. A clock phase of 0, the default, means data is valid on the first SCK edge (rising or falling) after the slave select (SS) signal has been asserted. A clock phase of 1 means data is valid on the second SCK edge (rising or falling) after SS has been asserted.

The QSPI Force Slave Select option enables manual control of the slave select signal. 0: The SPI_SS signal is controlled by the QSPI controller during transfers. (Default) 1: The SPI_SS signal is forced active (driven low) regardless of any transfers in progress.

NOTE: The driver handles setting and clearing the Slave Select when the user sets the "FORCE_SSELECT_OPTION". Using this option allows the QSPI clock to be set to a faster speed. If the QSPI clock is too fast, the processor cannot empty and refill the FIFOs before the TX FIFO is empty When the QSPI hardware is controlling the Slave Select signals, this causes the slave to be de-selected and terminates the transfer.

The Manual Start option enables manual control of the Start command to perform data transfer. 0: The Start command is controlled by the QSPI controller during transfers(Default). Data transmission starts as soon as there is data in the TXFIFO and stalls when the TXFIFO is empty 1: The Start command must be issued by software to perform data transfer. Bit 15 of Configuration register issues the Start command. This bit must be set whenever TXFIFO is filled with new data.

NOTE: The driver sets the Manual Start Enable bit in Configuration Register, if Manual Start option is selected. Software issues Manual Start command whenever TXFIFO is filled with data. When there is no further data, driver clears the Manual Start Enable bit.

#define XQSPIPS_CLK_ACTIVE_LOW_OPTION   0x2
 Active Low Clock option. More...
 
#define XQSPIPS_CLK_PHASE_1_OPTION   0x4
 Clock Phase one option. More...
 
#define XQSPIPS_FORCE_SSELECT_OPTION   0x10
 Force Slave Select. More...
 
#define XQSPIPS_MANUAL_START_OPTION   0x20
 Manual Start enable. More...
 
#define XQSPIPS_LQSPI_MODE_OPTION   0x80
 Linear QPSI mode. More...
 
#define XQSPIPS_HOLD_B_DRIVE_OPTION   0x100
 Drive HOLD_B Pin. More...
 
QSPI Clock Prescaler options

The QSPI Clock Prescaler Configuration bits are used to program master mode bit rate.

The bit rate can be programmed in divide-by-two decrements from pclk/2 to pclk/256.

#define XQSPIPS_CLK_PRESCALE_2   0x00
 PCLK/2 Prescaler. More...
 
#define XQSPIPS_CLK_PRESCALE_4   0x01
 PCLK/4 Prescaler. More...
 
#define XQSPIPS_CLK_PRESCALE_8   0x02
 PCLK/8 Prescaler. More...
 
#define XQSPIPS_CLK_PRESCALE_16   0x03
 PCLK/16 Prescaler. More...
 
#define XQSPIPS_CLK_PRESCALE_32   0x04
 PCLK/32 Prescaler. More...
 
#define XQSPIPS_CLK_PRESCALE_64   0x05
 PCLK/64 Prescaler. More...
 
#define XQSPIPS_CLK_PRESCALE_128   0x06
 PCLK/128 Prescaler. More...
 
#define XQSPIPS_CLK_PRESCALE_256   0x07
 PCLK/256 Prescaler. More...
 
Callback events

These constants specify the handler events that are passed to a handler from the driver.

These constants are not bit masks such that only one is passed at a time to the handler.

#define XQSPIPS_EVENT_TRANSFER_DONE   2
 Transfer done. More...
 
#define XQSPIPS_EVENT_TRANSMIT_UNDERRUN   3
 TX FIFO empty. More...
 
#define XQSPIPS_EVENT_RECEIVE_OVERRUN   4
 Receive data loss because RX FIFO full. More...
 
Flash commands

The following constants define most of the commands supported by flash devices.

Users can add more commands supported by the flash devices

#define XQSPIPS_FLASH_OPCODE_WRSR   0x01
 Write status register. More...
 
#define XQSPIPS_FLASH_OPCODE_PP   0x02
 Page program. More...
 
#define XQSPIPS_FLASH_OPCODE_NORM_READ   0x03
 Normal read data bytes. More...
 
#define XQSPIPS_FLASH_OPCODE_WRDS   0x04
 Write disable. More...
 
#define XQSPIPS_FLASH_OPCODE_RDSR1   0x05
 Read status register 1. More...
 
#define XQSPIPS_FLASH_OPCODE_WREN   0x06
 Write enable. More...
 
#define XQSPIPS_FLASH_OPCODE_FAST_READ   0x0B
 Fast read data bytes. More...
 
#define XQSPIPS_FLASH_OPCODE_BE_4K   0x20
 Erase 4KiB block. More...
 
#define XQSPIPS_FLASH_OPCODE_RDSR2   0x35
 Read status register 2. More...
 
#define XQSPIPS_FLASH_OPCODE_DUAL_READ   0x3B
 Dual read data bytes. More...
 
#define XQSPIPS_FLASH_OPCODE_BE_32K   0x52
 Erase 32KiB block. More...
 
#define XQSPIPS_FLASH_OPCODE_QUAD_READ   0x6B
 Quad read data bytes. More...
 
#define XQSPIPS_FLASH_OPCODE_ERASE_SUS   0x75
 Erase suspend. More...
 
#define XQSPIPS_FLASH_OPCODE_ERASE_RES   0x7A
 Erase resume. More...
 
#define XQSPIPS_FLASH_OPCODE_RDID   0x9F
 Read JEDEC ID. More...
 
#define XQSPIPS_FLASH_OPCODE_BE   0xC7
 Erase whole flash block. More...
 
#define XQSPIPS_FLASH_OPCODE_SE   0xD8
 Sector erase (usually 64KB). More...
 
#define XQSPIPS_FLASH_OPCODE_DUAL_IO_READ   0xBB
 Read data using Dual I/O. More...
 
#define XQSPIPS_FLASH_OPCODE_QUAD_IO_READ   0xEB
 Read data using Quad I/O. More...
 
#define XQSPIPS_FLASH_OPCODE_BRWR   0x17
 Bank Register Write. More...
 
#define XQSPIPS_FLASH_OPCODE_BRRD   0x16
 Bank Register Read. More...
 
#define XQSPIPS_FLASH_OPCODE_EARWR   0xC5
 Extended Address Register Write - Micron's equivalent of Bank Register. More...
 
#define XQSPIPS_FLASH_OPCODE_EARRD   0xC8
 Extended Address Register Read - Micron's equivalent of Bank Register. More...
 
#define XQSPIPS_FLASH_OPCODE_DIE_ERASE   0xC4
 Die erase. More...
 
#define XQSPIPS_FLASH_OPCODE_READ_FLAG_SR   0x70
 Read flag status register. More...
 
#define XQSPIPS_FLASH_OPCODE_CLEAR_FLAG_SR   0x50
 Clear flag status register. More...
 
#define XQSPIPS_FLASH_OPCODE_READ_LOCK_REG   0xE8
 Lock Reg Read. More...
 
#define XQSPIPS_FLASH_OPCODE_WRITE_LOCK_REG   0xE5
 Lock Reg Write. More...
 
Instruction size

The following constants define numbers 1 to 4.

Used to identify whether TXD0,1,2 or 3 is to be used.

#define XQSPIPS_SIZE_ONE   1
 Instruction size of one byte. More...
 
#define XQSPIPS_SIZE_TWO   2
 Instruction size of two bytes. More...
 
#define XQSPIPS_SIZE_THREE   3
 Instruction size of three bytes. More...
 
#define XQSPIPS_SIZE_FOUR   4
 Instruction size of four bytes. More...
 
ConnectionMode

The following constants are the possible values of ConnectionMode in Config structure.

#define XQSPIPS_CONNECTION_MODE_SINGLE   0
 Single mode. More...
 
#define XQSPIPS_CONNECTION_MODE_STACKED   1
 Stacked mode. More...
 
#define XQSPIPS_CONNECTION_MODE_PARALLEL   2
 Parallel mode. More...
 
FIFO threshold value

This is the Rx FIFO threshold (in words) that was found to be most optimal in terms of performance

#define XQSPIPS_RXFIFO_THRESHOLD_OPT   32
 Optimal Rx FIFO threshold in words. More...
 

Typedefs

typedef void(* XQspiPs_StatusHandler )(void *CallBackRef, u32 StatusEvent, unsigned ByteCount)
 Describes the status callback handler type for the QSPI device. More...
 

Functions

XQspiPs_Config * XQspiPs_LookupConfig (UINTPTR BaseAddress)
 Looks up the device configuration based on the unique device ID/BaseAddress. More...
 
int XQspiPs_CfgInitialize (XQspiPs *InstancePtr, XQspiPs_Config *Config, u32 EffectiveAddr)
 Initializes a specific XQspiPs instance such that the driver is ready to use. More...
 
void XQspiPs_Reset (XQspiPs *InstancePtr)
 Resets the QSPI device. More...
 
void XQspiPs_Abort (XQspiPs *InstancePtr)
 Aborts a transfer in progress by disabling the device and flushing the RxFIFO. More...
 
s32 XQspiPs_Transfer (XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, u32 ByteCount)
 Transfers specified data on the QSPI bus. More...
 
s32 XQspiPs_PolledTransfer (XQspiPs *InstancePtr, u8 *SendBufPtr, u8 *RecvBufPtr, u32 ByteCount)
 Transfers specified data on the QSPI bus in polled mode. More...
 
int XQspiPs_LqspiRead (XQspiPs *InstancePtr, u8 *RecvBufPtr, u32 Address, unsigned ByteCount)
 Reads the flash in Linear QSPI mode. More...
 
int XQspiPs_SetSlaveSelect (XQspiPs *InstancePtr)
 Selects the slave with which the master communicates. More...
 
void XQspiPs_SetStatusHandler (XQspiPs *InstancePtr, void *CallBackRef, XQspiPs_StatusHandler FuncPtr)
 Sets the status callback function, the status handler, which the driver calls when it encounters conditions that should be reported to upper layer software. More...
 
void XQspiPs_InterruptHandler (void *InstancePtr)
 Handles QSPI interrupts. More...
 
int XQspiPs_SelfTest (XQspiPs *InstancePtr)
 Runs a self-test on the driver/device. More...
 
s32 XQspiPs_SetOptions (XQspiPs *InstancePtr, u32 Options)
 Sets the options for the QSPI device driver. More...
 
u32 XQspiPs_GetOptions (XQspiPs *InstancePtr)
 Gets the options for the QSPI device. More...
 
s32 XQspiPs_SetClkPrescaler (XQspiPs *InstancePtr, u8 Prescaler)
 Sets the clock prescaler for an QSPI device. More...
 
u8 XQspiPs_GetClkPrescaler (XQspiPs *InstancePtr)
 Gets the clock prescaler of an QSPI device. More...
 
int XQspiPs_SetDelays (XQspiPs *InstancePtr, u8 DelayNss, u8 DelayBtwn, u8 DelayAfter, u8 DelayInit)
 Sets the delay register for the QSPI device driver. More...
 
void XQspiPs_GetDelays (XQspiPs *InstancePtr, u8 *DelayNss, u8 *DelayBtwn, u8 *DelayAfter, u8 *DelayInit)
 Gets the delay settings for an QSPI device. More...