📄 xqspips.h
字号:
/* $Id: xqspips.h,v 1.1.2.2 2011/01/20 06:52:24 sadanan Exp $ *//******************************************************************************** (c) Copyright 2010 Xilinx, Inc. All rights reserved.** This file contains confidential and proprietary information of Xilinx, Inc.* and is protected under U.S. and international copyright and other* intellectual property laws.** DISCLAIMER* This disclaimer is not a license and does not grant any rights to the* materials distributed herewith. Except as otherwise provided in a valid* license issued to you by Xilinx, and to the maximum extent permitted by* applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL* FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,* IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF* MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE;* and (2) Xilinx shall not be liable (whether in contract or tort, including* negligence, or under any other theory of liability) for any loss or damage* of any kind or nature related to, arising under or in connection with these* materials, including for any direct, or any indirect, special, incidental,* or consequential loss or damage (including loss of data, profits, goodwill,* or any type of loss or damage suffered as a result of any action brought by* a third party) even if such damage or loss was reasonably foreseeable or* Xilinx had been advised of the possibility of the same.** CRITICAL APPLICATIONS* Xilinx products are not designed or intended to be fail-safe, or for use in* any application requiring fail-safe performance, such as life-support or* safety devices or systems, Class III medical devices, nuclear facilities,* applications related to the deployment of airbags, or any other applications* that could lead to death, personal injury, or severe property or* environmental damage (individually and collectively, "Critical* Applications"). Customer assumes the sole risk and liability of any use of* Xilinx products in Critical Applications, subject only to applicable laws* and regulations governing limitations on product liability.** THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE* AT ALL TIMES.*******************************************************************************//*****************************************************************************//**** @file xqspips.h** This file contains the implementation of the XQspiPs driver. It works for* both the master and slave mode. User documentation for the driver functions* is contained in this file in the form of comment blocks at the front of each* function.** A QSPI device connects to an QSPI bus through a 4-wire serial interface.* The QSPI bus is a full-duplex, synchronous bus that facilitates communication* between one master and one slave. The device is always full-duplex,* which means that for every byte sent, one is received, and vice-versa.* The master controls the clock, so it can regulate when it wants to* send or receive data. The slave is under control of the master, it must* respond quickly since it has no control of the clock and must send/receive* data as fast or as slow as the master does.** <b> Linear Mode </b>* The Linear Quad-SPI Controller extends the existing Quad-SPI Controller抯* functionality by adding a linear addressing scheme that allows the SPI flash* memory subsystem to behave like a typical ROM device. The new feature hides* the normal SPI protocol from a master reading from the SPI flash memory. The* feature improves both the user friendliness and the overall read memory* throughput over that of the current Quad-SPI Controller by lessening the* amount of software overheads required and by the use of the faster AXI* interface.** <b>Initialization & Configuration</b>** The XQspiPs_Config structure is used by the driver to configure itself. This* configuration structure is typically created by the tool-chain based on HW* build properties.** To support multiple runtime loading and initialization strategies employed by* various operating systems, the driver instance can be initialized in the* following way:* - XQspiPs_LookupConfig(DeviceId) - Use the devide identifier to find* static configuration structure defined in xqspips_g.c. This is setup* by the tools. For some operating systems the config structure will be* initialized by the software and this call is not needed.* - XQspiPs_CfgInitialize(InstancePtr, CfgPtr, EffectiveAddr) - Uses a* configuration structure provided by the caller. If running in a system* with address translation, the provided virtual memory base address* replaces the physical address present in the configuration structure.** <b>Multiple Masters</b>** More than one master can exist, but arbitration is the responsibility of* the higher layer software. The device driver does not perform any type of* arbitration.** <b>Slave Mode</b>* The QSPI device supports slave mode, but only SPI protocol transactions will* be supported in slave mode.** <b>Multiple Slaves</b>** Contention between multiple masters is detected by the hardware, in which* case a mode fault occurs on the device. The device is disabled immediately* by hardware, and the current word transfer is stopped. The Aborted word* transfer due to the mode fault is resumed once the devie is enabled again.** <b>Interrupts</b>** The user must connect the interrupt handler of the driver,* XQspiPs_InterruptHandler, to an interrupt system such that it will be* called when an interrupt occurs. This function does not save and restore* the processor context such that the user must provide this processing.** The driver handles the following interrupts:* - Data Transmit Register/FIFO Underflow* - Data Receive Register/FIFO Not Empty* - Data Transmit Register/FIFO Overwater* - Mode Fault Error* - Data Receive Register/FIFO Overrun** The Data Transmit Register/FIFO Overwater interrupt -- indicates that the* QSPI device has transmitted the data available to transmit, and now its data* register and FIFO is ready to accept more data. The driver uses this* interrupt to indicate progress while sending data. The driver may have* more data to send, in which case the data transmit register and FIFO is* filled for subsequent transmission. When this interrupt arrives and all* the data has been sent, the driver invokes the status callback with a* value of XST_SPI_TRANSFER_DONE to inform the upper layer software that* all data has been sent.** The Data Transmit Register/FIFO Underflow interrupt -- indicates that,* as slave, the QSPI device was required to transmit but there was no data* available to transmit in the transmit register (or FIFO). This may not* be an error if the master is not expecting data. But in the case where* the master is expecting data, this serves as a notification of such a* condition. The driver reports this condition to the upper layer* software through the status handler.** The Data Receive Register/FIFO Overrun interrupt -- indicates that the QSPI* device received data and subsequently dropped the data because the data* receive register and FIFO was full. The interrupt applies to both master* and slave operation. The driver reports this condition to the upper layer* software through the status handler. This likely indicates a problem with* the higher layer protocol, or a problem with the slave performance.** The Mode Fault Error interrupt -- indicates that while configured as a* master, the device was selected as a slave by another master. This can be* used by the application for arbitration in a multimaster environment or to* indicate a problem with arbitration. When this interrupt occurs, the* driver invokes the status callback with a status value of* XST_SPI_MODE_FAULT. It is up to the application to resolve the conflict.* When configured as a slave, Mode Fault Error interrupt indicates that a slave* device was selected as a slave by a master, but the slave device was* disabled. When configured as a master, Mode Fault Error interrupt indicates* that another QSPI device is acting as a master on the bus.*** <b>Polled Operation</b>** Transfer in polled mode is supported through a separate interface function* XQspiPs_PolledTransfer(). Unlike the transfer function in the interrupt mode,* this function blocks until all data has been sent/received.** <b>Device Busy</b>** Some operations are disallowed when the device is busy. The driver tracks* whether a device is busy. The device is considered busy when a data transfer* request is outstanding, and is considered not busy only when that transfer* completes (or is aborted with a mode fault error). This applies to both* master and slave devices.** <b>Device Configuration</b>** The device can be configured in various ways during the FPGA implementation* process. Configuration parameters are stored in the xqspips_g.c file or* passed in via XQspiPs_CfgInitialize(). A table is defined where each entry* contains configuration information for an QSPI device, including the base* address for the device.** <b>RTOS Independence</b>** This driver is intended to be RTOS and processor independent. It works with* physical addresses only. Any needs for dynamic memory management, threads or* thread mutual exclusion, virtual memory, or cache control must be satisfied* by the layer above this driver.** <pre>* MODIFICATION HISTORY:** Ver Who Date Changes* ----- --- -------- -----------------------------------------------* 1.00 sdm 11/25/10 First release, based on the PS SPI driver.* </pre>*******************************************************************************/#ifndef XQSPIPS_H /* prevent circular inclusions */#define XQSPIPS_H /* by using protection macros */#ifdef __cplusplusextern "C" {#endif/***************************** Include Files *********************************/#include "xstatus.h"#include "xqspips_hw.h"#include <string.h>/************************** Constant Definitions *****************************//** @name 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. * * <b>The Master option</b> configures the QSPI device as a master. * By default, the device is a slave. * * The <b>Active Low Clock option</b> 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 <b>Clock Phase option</b> 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 <b>Slave Select Decode Enable option</b> selects how the SPI_SS_outN are * controlled by the QSPI Slave Select Decode bits. * 0: Use this setting for the standard configuration of up to four slave * select outputs. Only one of the four slave select outputs will be low. * (Default) * 1: Use this setting for the optional configuration of an additional decoder * to support 16 slave select outputs. SPI_SS_outN reflects the value in the * register. * * The <b>QSPI Force Slave Select option</b> is used to enable manual control of * the signals SPI_SS_outN. * 0: The SPI_SS_outN signals are controlled by the QSPI controller during * transfers. (Default) * 1: The SPI_SS_outN signal indicated by the Slave Select Control bit is * forced active (driven low) regardless of any transfers in progress. * * NOTE: The driver will handle setting and clearing the Slave Select when * the user sets the "FORCE_SSELECT_OPTION". Using this option will allow 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 * will cause slave to be de-selected and terminate the transfer. * * @{ */#define XQSPIPS_MASTER_OPTION 0x1 /**< Master mode option */#define XQSPIPS_CLK_ACTIVE_LOW_OPTION 0x2 /**< Active Low Clock option */#define XQSPIPS_CLK_PHASE_1_OPTION 0x4 /**< Clock Phase one option */#define XQSPIPS_DECODE_SSELECT_OPTION 0x8 /**< Select 16 slaves Option */#define XQSPIPS_FORCE_SSELECT_OPTION 0x10 /**< Force Slave Select */#define XQSPIPS_MANUAL_START_OPTION 0x20 /**< Manual Start enable */#define XQSPIPS_FLASH_MODE_OPTION 0x40 /**< Flash mode or legacy mode */#define XQSPIPS_LQSPI_MODE_OPTION 0x80 /**< Linear QPSI mode *//*@}*//** @name 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 */#define XQSPIPS_CLK_PRESCALE_4 0x01 /**< PCLK/4 Prescaler */#define XQSPIPS_CLK_PRESCALE_8 0x02 /**< PCLK/8 Prescaler */#define XQSPIPS_CLK_PRESCALE_16 0x03 /**< PCLK/16 Prescaler */#define XQSPIPS_CLK_PRESCALE_32 0x04 /**< PCLK/32 Prescaler */#define XQSPIPS_CLK_PRESCALE_64 0x05 /**< PCLK/64 Prescaler */#define XQSPIPS_CLK_PRESCALE_128 0x06 /**< PCLK/128 Prescaler */#define XQSPIPS_CLK_PRESCALE_256 0x07 /**< PCLK/256 Prescaler *//*@}*//** @name 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 will be passed at a time to the handler. * * @{ */#define XQSPIPS_EVENT_MODE_FAULT 1 /**< Mode fault error */#define XQSPIPS_EVENT_TRANSFER_DONE 2 /**< Transfer done */#define XQSPIPS_EVENT_TRANSMIT_UNDERRUN 3 /**< TX FIFO empty */#define XQSPIPS_EVENT_RECEIVE_OVERRUN 4 /**< Receive data loss because RX FIFO full *//*@}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -