![]() |
|
|||
File indexing completed on 2025-05-11 08:23:42
0001 /****************************************************************************** 0002 * Copyright (C) 2014 - 2022 Xilinx, Inc. All rights reserved. 0003 * SPDX-License-Identifier: MIT 0004 ******************************************************************************/ 0005 0006 0007 /*****************************************************************************/ 0008 /** 0009 * 0010 * @file xqspipsu.h 0011 * @addtogroup Overview 0012 * @{ 0013 * @details 0014 * 0015 * This section explains the implementation the functions required to use the 0016 * QSPIPSU hardware to perform a transfer. These are accessible to the user 0017 * via xqspipsu.h. 0018 * 0019 * Generic QSPI interface allows for communication to any QSPI slave device. 0020 * GQSPI contains a GENFIFO into which the bus transfers required are to be 0021 * pushed with appropriate configuration. The controller provides TX and RX 0022 * FIFO's and a DMA to be used for RX transfers. The controller executes each 0023 * GENFIFO entry noting the configuration and places data on the bus as required 0024 * 0025 * The different options in GENFIFO are as follows: 0026 * - IMM_DATA : Can be one byte of data to be transmitted, number of clocks or 0027 * number of bytes in transfer. 0028 * - DATA_XFER : Indicates that data/clocks need to be transmitted or received. 0029 * - EXPONENT : e when 2^e bytes are involved in transfer. 0030 * - SPI_MODE : SPI/Dual SPI/Quad SPI 0031 * - CS : Lower or Upper CS or Both 0032 * - Bus : Lower or Upper Bus or Both 0033 * - TX : When selected, controller transmits data in IMM or fetches number of 0034 * bytes mentioned form TX FIFO. If not selected, dummies are pumped. 0035 * - RX : When selected, controller receives and fills the RX FIFO/allows RX DMA 0036 * of requested number of bytes. If not selected, RX data is discarded. 0037 * - Stripe : Byte stripe over lower and upper bus or not. 0038 * - Poll : Polls response to match for to a set value (used along with POLL_CFG 0039 * registers) and then proceeds to next GENFIFO entry. 0040 * This feature is not currently used in the driver. 0041 * 0042 * GENFIFO has manual and auto start options. 0043 * All DMA requests need a 4-byte aligned destination address buffer and 0044 * size of transfer should also be a multiple of 4. 0045 * This driver supports DMA RX and IO RX. 0046 * 0047 * <b>Initialization & Configuration</b> 0048 * 0049 * This driver uses the GQSPI controller with RX DMA. It supports both 0050 * interrupt and polled transfers. Manual start of GENFIFO is used. 0051 * XQspiPsu_CfgInitialize() initializes the instance variables. 0052 * Additional setting can be done using SetOptions/ClearOptions functions 0053 * and SelectSlave function. 0054 * 0055 * <b>Transfer</b> 0056 * 0057 * Polled or Interrupt transfers can be done. The transfer function needs the 0058 * message(s) to be transmitted in the form of an array of type XQspiPsu_Msg. 0059 * This is supposed to contain the byte count and any TX/RX buffers as required. 0060 * Flags can be used indicate further information such as whether the message 0061 * should be striped. The transfer functions form and write GENFIFO entries, 0062 * check the status of the transfer and report back to the application 0063 * when done. 0064 * 0065 * <pre> 0066 * MODIFICATION HISTORY: 0067 * 0068 * Ver Who Date Changes 0069 * ----- --- -------- -----------------------------------------------. 0070 * 1.0 hk 08/21/14 First release 0071 * sk 03/13/15 Added IO mode support. 0072 * hk 03/18/15 Switch to I/O mode before clearing RX FIFO. 0073 * Clear and disable DMA interrupts/status in abort. 0074 * Use DMA DONE bit instead of BUSY as recommended. 0075 * sk 04/24/15 Modified the code according to MISRAC-2012. 0076 * sk 06/17/15 Removed NULL checks for Rx/Tx buffers. As 0077 * writing/reading from 0x0 location is permitted. 0078 * 1.1 sk 04/12/16 Added debug message prints. 0079 * 1.2 nsk 07/01/16 Added LQSPI support 0080 * Modified XQspiPsu_Select() macro in xqspipsu.h 0081 * Added XQspiPsu_GetLqspiConfigReg() in xqspipsu.h 0082 * Added required macros in xqspipsu_hw.h 0083 * Modified XQspiPsu_SetOptions() to support 0084 * LQSPI options and updated OptionsTable in 0085 * xqspipsu_options.c 0086 * rk 07/15/16 Added support for TapDelays at different frequencies. 0087 * nsk 08/05/16 Added example support PollData and PollTimeout 0088 * Added XQSPIPSU_MSG_FLAG_POLL macro in xqspipsu.h 0089 * Added XQspiPsu_Create_PollConfigData and 0090 * XQspiPsu_PollData() functions in xqspipsu.c 0091 * 1.3 nsk 09/16/16 Update PollData and Polltimeout support for dual parallel 0092 * configuration. Updated XQspiPsu_PollData() and 0093 * XQspiPsu_Create_PollConfigData() functions in xqspipsu.c 0094 * and also modified the polldata example 0095 * ms 03/17/17 Added readme.txt file in examples folder for doxygen 0096 * generation. 0097 * ms 04/05/17 Modified Comment lines in functions of qspipsu 0098 * examples to recognize it as documentation block 0099 * and modified filename tag to include them in 0100 * doxygen examples. 0101 * 1.4 tjs 05/26/17 Added support for accessing upper DDR (0x800000000) 0102 * while booting images from QSPI 0103 * 1.5 tjs 08/08/17 Added index.html file for importing examples 0104 * from system.mss 0105 * 1.5 nsk 08/14/17 Added CCI support 0106 * 1.5 tjs 09/14/17 Modified the checks for 4 byte addressing and commands. 0107 * 1.6 tjs 10/16/17 Flow for accessing flash is made similar to u-boot 0108 * and linux For CR-984966 0109 * 1.6 tjs 11/02/17 Resolved the compilation errors for ICCARM. CR-988625 0110 * 1.7 tjs 11/16/17 Removed the unsupported 4 Byte write and sector erase 0111 * commands. 0112 * 1.7 tjs 12/01/17 Added support for MT25QL02G Flash from Micron. CR-990642 0113 * 1.7 tjs 12/19/17 Added support for S25FL064L from Spansion. CR-990724 0114 * 1.7 tjs 01/11/18 Added support for MX66L1G45G flash from Macronix CR-992367 0115 * 1.7 tjs 01/16/18 Removed the check for DMA MSB to be written. (CR#992560) 0116 * 1.7 tjs 01/17/18 Added support to toggle the WP pin of flash. (PR#2448) 0117 * Added XQspiPsu_SetWP() in xqspipsu_options.c 0118 * Added XQspiPsu_WriteProtectToggle() in xqspipsu.c and 0119 * also added write protect example. 0120 * 1.7 tjs 03/14/18 Added support in EL1 NS mode (CR#974882) 0121 * 1.7 tjs 26/03/18 In dual parallel mode enable both CS when issuing Write 0122 * enable command. CR-998478 0123 * 1.8 tjs 05/02/18 Added support for IS25LP064 and IS25WP064. 0124 * 1.8 tjs 06/26/18 Added an example for accessing 64bit dma within 0125 * 32 bit application. CR#1004701 0126 * 1.8 tjs 06/26/18 Removed checkpatch warnings 0127 * 1.8 tjs 07/09/19 Fixed cppcheck, doxygen and gcc warnings. 0128 * 1.8 tjs 07/18/18 Setup64BRxDma() should be called only if the RxAddress is 0129 * greater than 32 bit address space. (CR#1006862) 0130 * 1.8 tjs 07/18/18 Added support for the low density ISSI flash parts. 0131 * 1.8 tjs 09/06/18 Fixed the code in XQspiPsu_GenFifoEntryData() for data 0132 * transfer length up to 255 for reducing the extra loop. 0133 * 1.9 tjs 11/22/17 Added the check for A72 and R5 processors (CR-987075) 0134 * 1.9 tjs 04/17/18 Updated register addresses as per the latest revision 0135 * of versal (CR#999610) 0136 * 1.9 aru 01/17/19 Fixed the violations for MISRAC-2012 0137 * in safety mode .Done changes such as added U suffix, 0138 * Declared pointer param as const. 0139 * 1.9 nsk 02/01/19 Clear DMA_DST_ADDR_MSB register on 32bit machine, if the 0140 * address is of only 32bit (CR#1020031) 0141 * 1.9 nsk 02/01/19 Added QSPI idling support 0142 * 0143 * 1.9 akm 03/08/19 Set recommended clock and data tap delay values for 40MHZ, 0144 * 100MHZ and 150MHZ frequencies(CR#1023187) 0145 * 1.9 nsk 03/27/19 Update 64bit dma support 0146 * (CR#1018102). 0147 * 1.9 akm 04/03/19 Fixed data alignment warnings on IAR compiler. 0148 * 1.9 akm 04/03/19 Fixed compilation error in XQspiPsu_LqspiRead() 0149 * function on IAR compiler. 0150 * 1.10 sk 08/20/19 Fixed issues in poll timeout feature. 0151 * 1.10 akm 08/22/19 Set recommended tap delay values for 37.5MHZ, 100MHZ and 0152 * 150MHZ frequencies in Versal. 0153 * 1.10 akm 09/05/19 Added Multi Die Erase and Muti Die Read support. 0154 * 1.11 akm 11/07/19 Removed LQSPI register access in Versal. 0155 * 1.11 akm 11/15/19 Fixed Coverity deadcode warning in 0156 * XQspipsu_Calculate_Tapdelay(). 0157 * 1.11 akm 02/19/20 Added XQspiPsu_StartDmaTransfer() and XQspiPsu_CheckDmaDone() 0158 * APIs for non-blocking transfer. 0159 * 1.11 sd 01/02/20 Added clocking support 0160 * 1.11 akm 03/09/20 Reorganize the source code, enable qspi controller and 0161 * interrupts in XQspiPsu_CfgInitialize() API. 0162 * 1.11 akm 03/26/20 Fixed issue by updating XQspiPsu_CfgInitialize to return 0163 * XST_DEVICE_IS_STARTED instead of asserting, when the 0164 * instance is already configured(CR#1058525). 0165 * 1.12 akm 09/02/20 Updated the Makefile to support parallel make execution. 0166 * 1.13 akm 01/04/21 Fix MISRA-C violations. 0167 * 1.13 sne 04/23/21 Fixed doxygen warnings. 0168 * 1.14 akm 06/24/21 Allow enough time for the controller to reset the FIFOs. 0169 * 1.14 akm 08/12/21 Perform Dcache invalidate at the end of the DMA transfer. 0170 * 0171 * </pre> 0172 * 0173 ******************************************************************************/ 0174 0175 #ifndef XQSPIPSU_H_ /**< prevent circular inclusions */ 0176 #define XQSPIPSU_H_ /**< by using protection macros */ 0177 0178 #ifdef __cplusplus 0179 extern "C" { 0180 #endif 0181 0182 /***************************** Include Files *********************************/ 0183 0184 #ifndef __rtems__ 0185 #include "xstatus.h" 0186 #endif 0187 #include "xqspipsu_hw.h" 0188 #ifndef __rtems__ 0189 #include "xil_cache.h" 0190 #include "xil_mem.h" 0191 #if defined (XCLOCKING) 0192 #include "xil_clocking.h" 0193 #endif 0194 #else 0195 #include <bsp/xil-compat.h> 0196 #endif 0197 0198 /**************************** Type Definitions *******************************/ 0199 /** 0200 * The handler data type allows the user to define a callback function to 0201 * handle the asynchronous processing for the QSPIPSU device. The application 0202 * using this driver is expected to define a handler of this type to support 0203 * interrupt driven mode. The handler executes in an interrupt context, so 0204 * only minimal processing should be performed. 0205 * 0206 * @param CallBackRef is the callback reference passed in by the upper 0207 * layer when setting the callback functions, and passed back to 0208 * the upper layer when the callback is invoked. Its type is 0209 * not important to the driver, so it is a void pointer. 0210 * @param StatusEvent holds one or more status events that have occurred. 0211 * See the XQspiPsu_SetStatusHandler() for details on the status 0212 * events that can be passed in the callback. 0213 * @param ByteCount indicates how many bytes of data were successfully 0214 * transferred. This may be less than the number of bytes 0215 * requested if the status event indicates an error. 0216 */ 0217 typedef void (*XQspiPsu_StatusHandler) (const void *CallBackRef, u32 StatusEvent, 0218 u32 ByteCount); 0219 0220 /** 0221 * This typedef contains configuration information for a flash message. 0222 */ 0223 typedef struct { 0224 u8 *TxBfrPtr; /**< Tx Buffer pointer */ 0225 u8 *RxBfrPtr; /**< Rx Buffer pointer */ 0226 u32 ByteCount; /**< Byte Count */ 0227 u32 BusWidth; /**< Bus Width */ 0228 u32 Flags; /**< Flags */ 0229 u8 PollData; /**< Poll Data */ 0230 u32 PollTimeout;/**< Poll Timeout */ 0231 u8 PollStatusCmd; /**< Poll Status command */ 0232 u8 PollBusMask; /**< Poll Bus mask */ 0233 u64 RxAddr64bit; /**< 64 bit Rx address */ 0234 u8 Xfer64bit; /**< 64 bit Tx address */ 0235 } XQspiPsu_Msg; 0236 0237 /** 0238 * This typedef contains configuration information for the device. 0239 */ 0240 typedef struct { 0241 u16 DeviceId; /**< Unique ID of device */ 0242 UINTPTR BaseAddress; /**< Base address of the device */ 0243 u32 InputClockHz; /**< Input clock frequency */ 0244 u8 ConnectionMode; /**< Single, Stacked and Parallel mode */ 0245 u8 BusWidth; /**< Bus width available on board */ 0246 u8 IsCacheCoherent; /**< Describes whether Cache Coherent or not */ 0247 #if defined (XCLOCKING) 0248 u32 RefClk; /**< Input clocks */ 0249 #endif 0250 } XQspiPsu_Config; 0251 0252 /** 0253 * The XQspiPsu driver instance data. The user is required to allocate a 0254 * variable of this type for every QSPIPSU device in the system. A pointer 0255 * to a variable of this type is then passed to the driver API functions. 0256 */ 0257 typedef struct { 0258 XQspiPsu_Config Config; /**< Configuration structure */ 0259 u32 IsReady; /**< Device is initialized and ready */ 0260 0261 u8 *SendBufferPtr; /**< Buffer to send (state) */ 0262 u8 *RecvBufferPtr; /**< Buffer to receive (state) */ 0263 u64 RecvBuffer; /**< Buffer Address to receive (state) */ 0264 u8 *GenFifoBufferPtr; /**< Gen FIFO entries */ 0265 s32 TxBytes; /**< Number of bytes to transfer (state) */ 0266 s32 RxBytes; /**< Number of bytes left to transfer(state) */ 0267 s32 GenFifoEntries; /**< Number of Gen FIFO entries remaining */ 0268 #ifdef __rtems__ 0269 volatile 0270 #endif 0271 u32 IsBusy; /**< A transfer is in progress (state) */ 0272 u32 ReadMode; /**< DMA or IO mode */ 0273 u32 GenFifoCS; /**< Gen FIFO chip selection */ 0274 u32 GenFifoBus; /**< Gen FIFO bus */ 0275 s32 NumMsg; /**< Number of messages */ 0276 s32 MsgCnt; /**< Message Count */ 0277 s32 IsUnaligned; /**< Unaligned information */ 0278 u8 IsManualstart; /**< Manual start information */ 0279 XQspiPsu_Msg *Msg; /**< Message */ 0280 XQspiPsu_StatusHandler StatusHandler; /**< Status Handler */ 0281 void *StatusRef; /**< Callback reference for status handler */ 0282 } XQspiPsu; 0283 0284 /***************** Macros (Inline Functions) Definitions *********************/ 0285 0286 /** 0287 * Definitions for Intel, STM, Winbond and Spansion Serial Flash Device 0288 * geometry. 0289 */ 0290 #define BYTES256_PER_PAGE 256U /**< 256 Bytes per Page */ 0291 #define BYTES512_PER_PAGE 512U /**< 512 Bytes per Page */ 0292 #define BYTES1024_PER_PAGE 1024U /**< 1024 Bytes per Page */ 0293 #define PAGES16_PER_SECTOR 16U /**< 16 Pages per Sector */ 0294 #define PAGES128_PER_SECTOR 128U /**< 128 Pages per Sector */ 0295 #define PAGES256_PER_SECTOR 256U /**< 256 Pages per Sector */ 0296 #define PAGES512_PER_SECTOR 512U /**< 512 Pages per Sector */ 0297 #define PAGES1024_PER_SECTOR 1024U /**< 1024 Pages per Sector */ 0298 #define NUM_OF_SECTORS2 2U /**< 2 Sectors */ 0299 #define NUM_OF_SECTORS4 4U /**< 4 Sectors */ 0300 #define NUM_OF_SECTORS8 8U /**< 8 Sector */ 0301 #define NUM_OF_SECTORS16 16U /**< 16 Sectors */ 0302 #define NUM_OF_SECTORS32 32U /**< 32 Sectors */ 0303 #define NUM_OF_SECTORS64 64U /**< 64 Sectors */ 0304 #define NUM_OF_SECTORS128 128U /**< 128 Sectors */ 0305 #define NUM_OF_SECTORS256 256U /**< 256 Sectors */ 0306 #define NUM_OF_SECTORS512 512U /**< 512 Sectors */ 0307 #define NUM_OF_SECTORS1024 1024U /**< 1024 Sectors */ 0308 #define NUM_OF_SECTORS2048 2048U /**< 2048 Sectors */ 0309 #define NUM_OF_SECTORS4096 4096U /**< 4096 Sectors */ 0310 #define NUM_OF_SECTORS8192 8192U /**< 8192 Sectors */ 0311 #define SECTOR_SIZE_64K 0X10000U /**< 64K Sector */ 0312 #define SECTOR_SIZE_128K 0X20000U /**< 128K Sector */ 0313 #define SECTOR_SIZE_256K 0X40000U /**< 256K Sector */ 0314 #define SECTOR_SIZE_512K 0X80000U /**< 512K Sector */ 0315 0316 0317 #define XQSPIPSU_READMODE_DMA 0x0U /**< DMA read mode */ 0318 #define XQSPIPSU_READMODE_IO 0x1U /**< IO read mode */ 0319 0320 #define XQSPIPSU_SELECT_FLASH_CS_LOWER 0x1U /**< Select lower flash */ 0321 #define XQSPIPSU_SELECT_FLASH_CS_UPPER 0x2U /**< Select upper flash */ 0322 #define XQSPIPSU_SELECT_FLASH_CS_BOTH 0x3U /**< Select both flash */ 0323 0324 #define XQSPIPSU_SELECT_FLASH_BUS_LOWER 0x1U /**< Select lower bus flash */ 0325 #define XQSPIPSU_SELECT_FLASH_BUS_UPPER 0x2U /**< Select upper bus flash */ 0326 #define XQSPIPSU_SELECT_FLASH_BUS_BOTH 0x3U /**< Select both bus flash */ 0327 0328 #define XQSPIPSU_SELECT_MODE_SPI 0x1U /**< Select SPI mode */ 0329 #define XQSPIPSU_SELECT_MODE_DUALSPI 0x2U /**< Select dual SPI mode */ 0330 #define XQSPIPSU_SELECT_MODE_QUADSPI 0x4U /**< Select quad SPI mode */ 0331 0332 #define XQSPIPSU_GENFIFO_CS_SETUP 0x05U /**< Chip select setup in GENFIO */ 0333 #define XQSPIPSU_GENFIFO_CS_HOLD 0x04U /**< Chip select hold in GENFIFO */ 0334 0335 #define XQSPIPSU_CLK_ACTIVE_LOW_OPTION 0x2U /**< Clk Active low option */ 0336 #define XQSPIPSU_CLK_PHASE_1_OPTION 0x4U /**< Clk phase 1 option */ 0337 #define XQSPIPSU_MANUAL_START_OPTION 0x8U /**< Manual start option */ 0338 #if !defined (versal) 0339 #define XQSPIPSU_LQSPI_MODE_OPTION 0x20U /**< LQSPI mode option */ 0340 0341 #define XQSPIPSU_LQSPI_LESS_THEN_SIXTEENMB 1U /**< LQSPI less Than 16 MB */ 0342 #endif 0343 0344 #define XQSPIPSU_GENFIFO_EXP_START 0x100U /**< Genfifo start */ 0345 0346 #define XQSPIPSU_DMA_BYTES_MAX 0x10000000U /**< DMA bytes max */ 0347 0348 #define XQSPIPSU_CLK_PRESCALE_2 0x00U /**< Clock prescale 2 */ 0349 #define XQSPIPSU_CLK_PRESCALE_4 0x01U /**< Clock prescale 4 */ 0350 #define XQSPIPSU_CLK_PRESCALE_8 0x02U /**< Clock prescale 8 */ 0351 #define XQSPIPSU_CLK_PRESCALE_16 0x03U /**< Clock prescale 16 */ 0352 #define XQSPIPSU_CLK_PRESCALE_32 0x04U /**< Clock prescale 32 */ 0353 #define XQSPIPSU_CLK_PRESCALE_64 0x05U /**< Clock prescale 64 */ 0354 #define XQSPIPSU_CLK_PRESCALE_128 0x06U /**< Clock prescale 128 */ 0355 #define XQSPIPSU_CLK_PRESCALE_256 0x07U /**< Clock prescale 256 */ 0356 #define XQSPIPSU_CR_PRESC_MAXIMUM 7U /**< Prescale max */ 0357 0358 #define XQSPIPSU_CONNECTION_MODE_SINGLE 0U /**< Single mode connection */ 0359 #define XQSPIPSU_CONNECTION_MODE_STACKED 1U /**< Stacked mode connection */ 0360 #define XQSPIPSU_CONNECTION_MODE_PARALLEL 2U /**< Parallel mode connection */ 0361 0362 /*QSPI Frequencies*/ 0363 #define XQSPIPSU_FREQ_37_5MHZ 37500000U /**< Frequency 375 Mhz */ 0364 #define XQSPIPSU_FREQ_40MHZ 40000000U /**< Frequency 40 Mhz */ 0365 #define XQSPIPSU_FREQ_100MHZ 100000000U /**< Frequency 100 Mhz */ 0366 #define XQSPIPSU_FREQ_150MHZ 150000000U /**< Frequency 150 Mhz */ 0367 0368 /* Add more flags as required */ 0369 #define XQSPIPSU_MSG_FLAG_STRIPE 0x1U /**< Stripe Msg flag */ 0370 #define XQSPIPSU_MSG_FLAG_RX 0x2U /**< Rx Msg flag */ 0371 #define XQSPIPSU_MSG_FLAG_TX 0x4U /**< Tx Msg flag */ 0372 #define XQSPIPSU_MSG_FLAG_POLL 0x8U /**< POLL Msg flag */ 0373 0374 #define XQSPIPSU_RXADDR_OVER_32BIT 0x100000000U /**< Rx address over 32 bit */ 0375 0376 #define XQSPIPSU_SET_WP 1 /**< GQSPI configuration to toggle WP of flash */ 0377 0378 /** 0379 * select QSPI controller 0380 */ 0381 #define XQspiPsu_Select(InstancePtr, Mask) \ 0382 XQspiPsu_Out32(((InstancePtr)->Config.BaseAddress) + \ 0383 XQSPIPSU_SEL_OFFSET, (Mask)) 0384 0385 /** 0386 * Enable QSPI Controller 0387 */ 0388 #define XQspiPsu_Enable(InstancePtr) \ 0389 XQspiPsu_Out32(((InstancePtr)->Config.BaseAddress) + \ 0390 XQSPIPSU_EN_OFFSET, XQSPIPSU_EN_MASK) 0391 0392 /** 0393 * Disable QSPI controller */ 0394 #define XQspiPsu_Disable(InstancePtr) \ 0395 XQspiPsu_Out32(((InstancePtr)->Config.BaseAddress) + \ 0396 XQSPIPSU_EN_OFFSET, 0x0U) 0397 0398 /** 0399 * Read Configuration register of LQSPI Controller 0400 */ 0401 #if !defined (versal) 0402 #define XQspiPsu_GetLqspiConfigReg(InstancePtr) \ 0403 XQspiPsu_In32((XQSPIPS_BASEADDR) + \ 0404 XQSPIPSU_LQSPI_CR_OFFSET) 0405 #endif 0406 0407 /*****************************************************************************/ 0408 /** 0409 * 0410 * This function enables the manual start option 0411 * 0412 * @param InstancePtr is a pointer to the XQspiPsu instance. 0413 * 0414 * @return None 0415 * 0416 * @note None. 0417 * 0418 ******************************************************************************/ 0419 static inline void XQspiPsu_ManualStartEnable(XQspiPsu *InstancePtr) 0420 { 0421 Xil_AssertVoid(InstancePtr != NULL); 0422 Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); 0423 #ifdef DEBUG 0424 xil_printf("\nXQspiPsu_ManualStartEnable\r\n"); 0425 #endif 0426 0427 if (InstancePtr->IsManualstart == (u8)TRUE) { 0428 #ifdef DEBUG 0429 xil_printf("\nManual Start\r\n"); 0430 #endif 0431 XQspiPsu_WriteReg(InstancePtr->Config.BaseAddress, XQSPIPSU_CFG_OFFSET, 0432 XQspiPsu_ReadReg(InstancePtr->Config.BaseAddress, XQSPIPSU_CFG_OFFSET) | 0433 XQSPIPSU_CFG_START_GEN_FIFO_MASK); 0434 } 0435 } 0436 /*****************************************************************************/ 0437 /** 0438 * 0439 * This function writes the GENFIFO entry to assert CS. 0440 * 0441 * @param InstancePtr is a pointer to the XQspiPsu instance. 0442 * 0443 * @return None 0444 * 0445 * @note None. 0446 * 0447 ******************************************************************************/ 0448 static inline void XQspiPsu_GenFifoEntryCSAssert(const XQspiPsu *InstancePtr) 0449 { 0450 u32 GenFifoEntry; 0451 0452 Xil_AssertVoid(InstancePtr != NULL); 0453 Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); 0454 #ifdef DEBUG 0455 xil_printf("\nXQspiPsu_GenFifoEntryCSAssert\r\n"); 0456 #endif 0457 0458 GenFifoEntry = 0x0U; 0459 GenFifoEntry |= (XQSPIPSU_GENFIFO_MODE_SPI | InstancePtr->GenFifoCS | 0460 InstancePtr->GenFifoBus | XQSPIPSU_GENFIFO_CS_SETUP); 0461 #ifdef DEBUG 0462 xil_printf("\nFifoEntry=%08x\r\n", GenFifoEntry); 0463 #endif 0464 XQspiPsu_WriteReg(InstancePtr->Config.BaseAddress, 0465 XQSPIPSU_GEN_FIFO_OFFSET, GenFifoEntry); 0466 } 0467 0468 /*****************************************************************************/ 0469 /** 0470 * 0471 * This function writes the GENFIFO entry to de-assert CS. 0472 * 0473 * @param InstancePtr is a pointer to the XQspiPsu instance. 0474 * 0475 * @return None 0476 * 0477 * @note None. 0478 * 0479 ******************************************************************************/ 0480 static inline void XQspiPsu_GenFifoEntryCSDeAssert(const XQspiPsu *InstancePtr) 0481 { 0482 u32 GenFifoEntry; 0483 0484 Xil_AssertVoid(InstancePtr != NULL); 0485 Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY); 0486 #ifdef DEBUG 0487 xil_printf("\nXQspiPsu_GenFifoEntryCSDeAssert\r\n"); 0488 #endif 0489 0490 GenFifoEntry = 0x0U; 0491 GenFifoEntry |= (XQSPIPSU_GENFIFO_MODE_SPI | InstancePtr->GenFifoBus | 0492 XQSPIPSU_GENFIFO_CS_HOLD); 0493 #ifdef DEBUG 0494 xil_printf("\nFifoEntry=%08x\r\n", GenFifoEntry); 0495 #endif 0496 XQspiPsu_WriteReg(InstancePtr->Config.BaseAddress, 0497 XQSPIPSU_GEN_FIFO_OFFSET, GenFifoEntry); 0498 } 0499 0500 /*****************************************************************************/ 0501 /** 0502 * 0503 * This is a stub for the status callback. The stub is here in case the upper 0504 * layers forget to set the handler. 0505 * 0506 * @param CallBackRef is a pointer to the upper layer callback reference 0507 * @param StatusEvent is the event that just occurred. 0508 * @param ByteCount is the number of bytes transferred up until the event 0509 * occurred. 0510 * 0511 * @return None. 0512 * 0513 * @note None. 0514 * 0515 ******************************************************************************/ 0516 static inline void StubStatusHandler(const void *CallBackRef, u32 StatusEvent, 0517 u32 ByteCount) 0518 { 0519 (const void) CallBackRef; 0520 (void) StatusEvent; 0521 (void) ByteCount; 0522 0523 Xil_AssertVoidAlways(); 0524 } 0525 /************************** Function Prototypes ******************************/ 0526 0527 /* Initialization and reset */ 0528 XQspiPsu_Config *XQspiPsu_LookupConfig(u16 DeviceId); 0529 s32 XQspiPsu_CfgInitialize(XQspiPsu *InstancePtr, 0530 const XQspiPsu_Config *ConfigPtr, 0531 UINTPTR EffectiveAddr); 0532 void XQspiPsu_Reset(XQspiPsu *InstancePtr); 0533 void XQspiPsu_Abort(XQspiPsu *InstancePtr); 0534 0535 /* Transfer functions and handlers */ 0536 s32 XQspiPsu_PolledTransfer(XQspiPsu *InstancePtr, XQspiPsu_Msg *Msg, 0537 u32 NumMsg); 0538 s32 XQspiPsu_InterruptTransfer(XQspiPsu *InstancePtr, XQspiPsu_Msg *Msg, 0539 u32 NumMsg); 0540 s32 XQspiPsu_InterruptHandler(XQspiPsu *InstancePtr); 0541 void XQspiPsu_SetStatusHandler(XQspiPsu *InstancePtr, void *CallBackRef, 0542 XQspiPsu_StatusHandler FuncPointer); 0543 0544 /* Non blocking Transfer functions */ 0545 s32 XQspiPsu_StartDmaTransfer(XQspiPsu *InstancePtr, XQspiPsu_Msg *Msg, 0546 u32 NumMsg); 0547 s32 XQspiPsu_CheckDmaDone(XQspiPsu *InstancePtr); 0548 0549 /* Configuration functions */ 0550 s32 XQspiPsu_SetClkPrescaler(const XQspiPsu *InstancePtr, u8 Prescaler); 0551 void XQspiPsu_SelectFlash(XQspiPsu *InstancePtr, u8 FlashCS, u8 FlashBus); 0552 s32 XQspiPsu_SetOptions(XQspiPsu *InstancePtr, u32 Options); 0553 s32 XQspiPsu_ClearOptions(XQspiPsu *InstancePtr, u32 Options); 0554 u32 XQspiPsu_GetOptions(const XQspiPsu *InstancePtr); 0555 s32 XQspiPsu_SetReadMode(XQspiPsu *InstancePtr, u32 Mode); 0556 void XQspiPsu_SetWP(const XQspiPsu *InstancePtr, u8 Value); 0557 void XQspiPsu_WriteProtectToggle(const XQspiPsu *InstancePtr, u32 Toggle); 0558 void XQspiPsu_Idle(const XQspiPsu *InstancePtr); 0559 0560 /************************** Variable Prototypes ******************************/ 0561 0562 /** 0563 * This table contains configuration information for each QSPIPSU device 0564 * in the system. 0565 */ 0566 #ifndef __rtems__ 0567 extern XQspiPsu_Config XQspiPsu_ConfigTable[XPAR_XQSPIPSU_NUM_INSTANCES]; 0568 #endif /* __rtems__ */ 0569 0570 #ifdef __cplusplus 0571 } 0572 #endif 0573 0574 0575 #endif /* XQSPIPSU_H_ */ 0576 /** @} */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |