1 /******************************************************************************
3 * Copyright (C) 2010 - 2015 Xilinx, Inc. All rights reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
31 ******************************************************************************/
32 /*****************************************************************************/
36 * @addtogroup qspips_v3_4
39 * This header file contains the identifiers and basic HW access driver
40 * functions (or macros) that can be used to access the device. Other driver
41 * functions are defined in xqspips.h.
44 * MODIFICATION HISTORY:
46 * Ver Who Date Changes
47 * ----- --- -------- -----------------------------------------------
48 * 1.00 sdm 11/25/10 First release
49 * 2.00a ka 07/25/12 Added a few register defines for CR 670297
50 * and removed some defines of reserved fields for
52 * Added define XQSPIPS_CR_HOLD_B_MASK for Holdb_dr
53 * bit in Configuration register.
54 * 2.01a sg 02/03/13 Added defines for DelayNss,Rx Watermark,Interrupts
55 * which need write to clear. Removed Read zeros mask from
56 * LQSPI Config register.
57 * 2.03a hk 08/22/13 Added prototypes of API's for QSPI reset and
58 * linear mode initialization for boot. Added related
59 * constant definitions.
60 * 3.1 hk 08/13/14 Changed definition of CR reset value masks to set/reset
61 * required bits leaving reserved bits untouched. CR# 796813.
62 * 3.2 sk 02/05/15 Add SLCR reset in abort function as a workaround because
63 * controller does not update FIFO status flags as expected
64 * when thresholds are used.
68 ******************************************************************************/
69 #ifndef XQSPIPS_HW_H /* prevent circular inclusions */
70 #define XQSPIPS_HW_H /* by using protection macros */
76 /***************************** Include Files *********************************/
78 #include "xil_types.h"
79 #include "xil_assert.h"
81 #include "xparameters.h"
83 /************************** Constant Definitions *****************************/
85 /** @name Register Map
87 * Register offsets from the base address of an QSPI device.
90 #define XQSPIPS_CR_OFFSET 0x00 /**< Configuration Register */
91 #define XQSPIPS_SR_OFFSET 0x04 /**< Interrupt Status */
92 #define XQSPIPS_IER_OFFSET 0x08 /**< Interrupt Enable */
93 #define XQSPIPS_IDR_OFFSET 0x0c /**< Interrupt Disable */
94 #define XQSPIPS_IMR_OFFSET 0x10 /**< Interrupt Enabled Mask */
95 #define XQSPIPS_ER_OFFSET 0x14 /**< Enable/Disable Register */
96 #define XQSPIPS_DR_OFFSET 0x18 /**< Delay Register */
97 #define XQSPIPS_TXD_00_OFFSET 0x1C /**< Transmit 4-byte inst/data */
98 #define XQSPIPS_RXD_OFFSET 0x20 /**< Data Receive Register */
99 #define XQSPIPS_SICR_OFFSET 0x24 /**< Slave Idle Count */
100 #define XQSPIPS_TXWR_OFFSET 0x28 /**< Transmit FIFO Watermark */
101 #define XQSPIPS_RXWR_OFFSET 0x2C /**< Receive FIFO Watermark */
102 #define XQSPIPS_GPIO_OFFSET 0x30 /**< GPIO Register */
103 #define XQSPIPS_LPBK_DLY_ADJ_OFFSET 0x38 /**< Loopback Delay Adjust Reg */
104 #define XQSPIPS_TXD_01_OFFSET 0x80 /**< Transmit 1-byte inst */
105 #define XQSPIPS_TXD_10_OFFSET 0x84 /**< Transmit 2-byte inst */
106 #define XQSPIPS_TXD_11_OFFSET 0x88 /**< Transmit 3-byte inst */
107 #define XQSPIPS_LQSPI_CR_OFFSET 0xA0 /**< Linear QSPI config register */
108 #define XQSPIPS_LQSPI_SR_OFFSET 0xA4 /**< Linear QSPI status register */
109 #define XQSPIPS_MOD_ID_OFFSET 0xFC /**< Module ID register */
113 /** @name Configuration Register
115 * This register contains various control bits that
116 * affect the operation of the QSPI device. Read/Write.
120 #define XQSPIPS_CR_IFMODE_MASK 0x80000000 /**< Flash mem interface mode */
121 #define XQSPIPS_CR_ENDIAN_MASK 0x04000000 /**< Tx/Rx FIFO endianness */
122 #define XQSPIPS_CR_MANSTRT_MASK 0x00010000 /**< Manual Transmission Start */
123 #define XQSPIPS_CR_MANSTRTEN_MASK 0x00008000 /**< Manual Transmission Start
125 #define XQSPIPS_CR_SSFORCE_MASK 0x00004000 /**< Force Slave Select */
126 #define XQSPIPS_CR_SSCTRL_MASK 0x00000400 /**< Slave Select Decode */
127 #define XQSPIPS_CR_SSCTRL_SHIFT 10 /**< Slave Select Decode shift */
128 #define XQSPIPS_CR_DATA_SZ_MASK 0x000000C0 /**< Size of word to be
130 #define XQSPIPS_CR_PRESC_MASK 0x00000038 /**< Prescaler Setting */
131 #define XQSPIPS_CR_PRESC_SHIFT 3 /**< Prescaler shift */
132 #define XQSPIPS_CR_PRESC_MAXIMUM 0x07 /**< Prescaler maximum value */
134 #define XQSPIPS_CR_CPHA_MASK 0x00000004 /**< Phase Configuration */
135 #define XQSPIPS_CR_CPOL_MASK 0x00000002 /**< Polarity Configuration */
137 #define XQSPIPS_CR_MSTREN_MASK 0x00000001 /**< Master Mode Enable */
139 #define XQSPIPS_CR_HOLD_B_MASK 0x00080000 /**< HOLD_B Pin Drive Enable */
141 #define XQSPIPS_CR_REF_CLK_MASK 0x00000100 /**< Ref clk bit - should be 0 */
143 /* Deselect the Slave select line and set the transfer size to 32 at reset */
144 #define XQSPIPS_CR_RESET_MASK_SET XQSPIPS_CR_IFMODE_MASK | \
145 XQSPIPS_CR_SSCTRL_MASK | \
146 XQSPIPS_CR_DATA_SZ_MASK | \
147 XQSPIPS_CR_MSTREN_MASK | \
148 XQSPIPS_CR_SSFORCE_MASK | \
149 XQSPIPS_CR_HOLD_B_MASK
150 #define XQSPIPS_CR_RESET_MASK_CLR XQSPIPS_CR_CPOL_MASK | \
151 XQSPIPS_CR_CPHA_MASK | \
152 XQSPIPS_CR_PRESC_MASK | \
153 XQSPIPS_CR_MANSTRTEN_MASK | \
154 XQSPIPS_CR_MANSTRT_MASK | \
155 XQSPIPS_CR_ENDIAN_MASK | \
156 XQSPIPS_CR_REF_CLK_MASK
160 /** @name QSPI Interrupt Registers
162 * <b>QSPI Status Register</b>
164 * This register holds the interrupt status flags for an QSPI device. Some
165 * of the flags are level triggered, which means that they are set as long
166 * as the interrupt condition exists. Other flags are edge triggered,
167 * which means they are set once the interrupt condition occurs and remain
168 * set until they are cleared by software. The interrupts are cleared by
169 * writing a '1' to the interrupt bit position in the Status Register.
172 * <b>QSPI Interrupt Enable Register</b>
174 * This register is used to enable chosen interrupts for an QSPI device.
175 * Writing a '1' to a bit in this register sets the corresponding bit in the
176 * QSPI Interrupt Mask register. Write only.
178 * <b>QSPI Interrupt Disable Register </b>
180 * This register is used to disable chosen interrupts for an QSPI device.
181 * Writing a '1' to a bit in this register clears the corresponding bit in the
182 * QSPI Interrupt Mask register. Write only.
184 * <b>QSPI Interrupt Mask Register</b>
186 * This register shows the enabled/disabled interrupts of an QSPI device.
189 * All four registers have the same bit definitions. They are only defined once
190 * for each of the Interrupt Enable Register, Interrupt Disable Register,
191 * Interrupt Mask Register, and Channel Interrupt Status Register
195 #define XQSPIPS_IXR_TXUF_MASK 0x00000040 /**< QSPI Tx FIFO Underflow */
196 #define XQSPIPS_IXR_RXFULL_MASK 0x00000020 /**< QSPI Rx FIFO Full */
197 #define XQSPIPS_IXR_RXNEMPTY_MASK 0x00000010 /**< QSPI Rx FIFO Not Empty */
198 #define XQSPIPS_IXR_TXFULL_MASK 0x00000008 /**< QSPI Tx FIFO Full */
199 #define XQSPIPS_IXR_TXOW_MASK 0x00000004 /**< QSPI Tx FIFO Overwater */
200 #define XQSPIPS_IXR_RXOVR_MASK 0x00000001 /**< QSPI Rx FIFO Overrun */
201 #define XQSPIPS_IXR_DFLT_MASK 0x00000025 /**< QSPI default interrupts
203 #define XQSPIPS_IXR_WR_TO_CLR_MASK 0x00000041 /**< Interrupts which
204 need write to clear */
205 #define XQSPIPS_ISR_RESET_STATE 0x00000004 /**< Default to tx/rx empty */
206 #define XQSPIPS_IXR_DISABLE_ALL 0x0000007D /**< Disable all interrupts */
210 /** @name Enable Register
212 * This register is used to enable or disable an QSPI device.
216 #define XQSPIPS_ER_ENABLE_MASK 0x00000001 /**< QSPI Enable Bit Mask */
220 /** @name Delay Register
222 * This register is used to program timing delays in
223 * slave mode. Read/Write
226 #define XQSPIPS_DR_NSS_MASK 0xFF000000 /**< Delay to de-assert slave select
227 between two words mask */
228 #define XQSPIPS_DR_NSS_SHIFT 24 /**< Delay to de-assert slave select
229 between two words shift */
230 #define XQSPIPS_DR_BTWN_MASK 0x00FF0000 /**< Delay Between Transfers
232 #define XQSPIPS_DR_BTWN_SHIFT 16 /**< Delay Between Transfers shift */
233 #define XQSPIPS_DR_AFTER_MASK 0x0000FF00 /**< Delay After Transfers mask */
234 #define XQSPIPS_DR_AFTER_SHIFT 8 /**< Delay After Transfers shift */
235 #define XQSPIPS_DR_INIT_MASK 0x000000FF /**< Delay Initially mask */
238 /** @name Slave Idle Count Registers
240 * This register defines the number of pclk cycles the slave waits for a the
241 * QSPI clock to become stable in quiescent state before it can detect the start
242 * of the next transfer in CPHA = 1 mode.
247 #define XQSPIPS_SICR_MASK 0x000000FF /**< Slave Idle Count Mask */
251 /** @name Transmit FIFO Watermark Register
253 * This register defines the watermark setting for the Transmit FIFO.
257 #define XQSPIPS_TXWR_MASK 0x0000003F /**< Transmit Watermark Mask */
258 #define XQSPIPS_TXWR_RESET_VALUE 0x00000001 /**< Transmit Watermark
259 * register reset value */
263 /** @name Receive FIFO Watermark Register
265 * This register defines the watermark setting for the Receive FIFO.
269 #define XQSPIPS_RXWR_MASK 0x0000003F /**< Receive Watermark Mask */
270 #define XQSPIPS_RXWR_RESET_VALUE 0x00000001 /**< Receive Watermark
271 * register reset value */
277 * This macro provides the depth of transmit FIFO and receive FIFO.
281 #define XQSPIPS_FIFO_DEPTH 63 /**< FIFO depth (words) */
285 /** @name Linear QSPI Configuration Register
287 * This register contains various control bits that
288 * affect the operation of the Linear QSPI controller. Read/Write.
292 #define XQSPIPS_LQSPI_CR_LINEAR_MASK 0x80000000 /**< LQSPI mode enable */
293 #define XQSPIPS_LQSPI_CR_TWO_MEM_MASK 0x40000000 /**< Both memories or one */
294 #define XQSPIPS_LQSPI_CR_SEP_BUS_MASK 0x20000000 /**< Seperate memory bus */
295 #define XQSPIPS_LQSPI_CR_U_PAGE_MASK 0x10000000 /**< Upper memory page */
296 #define XQSPIPS_LQSPI_CR_MODE_EN_MASK 0x02000000 /**< Enable mode bits */
297 #define XQSPIPS_LQSPI_CR_MODE_ON_MASK 0x01000000 /**< Mode on */
298 #define XQSPIPS_LQSPI_CR_MODE_BITS_MASK 0x00FF0000 /**< Mode value for dual I/O
300 #define XQSPIPS_LQSPI_CR_DUMMY_MASK 0x00000700 /**< Number of dummy bytes
301 between addr and return
303 #define XQSPIPS_LQSPI_CR_INST_MASK 0x000000FF /**< Read instr code */
304 #define XQSPIPS_LQSPI_CR_RST_STATE 0x8000016B /**< Default CR value */
307 /** @name Linear QSPI Status Register
309 * This register contains various status bits of the Linear QSPI controller.
314 #define XQSPIPS_LQSPI_SR_D_FSM_ERR_MASK 0x00000004 /**< AXI Data FSM Error
316 #define XQSPIPS_LQSPI_SR_WR_RECVD_MASK 0x00000002 /**< AXI write command
321 /** @name Loopback Delay Adjust Register
323 * This register contains various bit masks of Loopback Delay Adjust Register.
328 #define XQSPIPS_LPBK_DLY_ADJ_USE_LPBK_MASK 0x00000020 /**< Loopback Bit */
333 /** @name SLCR Register
335 * Register offsets from SLCR base address.
340 #define SLCR_LOCK 0x00000004 /**< SLCR Write Protection Lock */
341 #define SLCR_UNLOCK 0x00000008 /**< SLCR Write Protection Unlock */
342 #define LQSPI_RST_CTRL 0x00000230 /**< Quad SPI Software Reset Control */
343 #define SLCR_LOCKSTA 0x0000000C /**< SLCR Write Protection status */
348 /** @name SLCR Register
350 * Bit Masks of above SLCR Registers .
355 #ifndef XPAR_XSLCR_0_BASEADDR
356 #define XPAR_XSLCR_0_BASEADDR 0xF8000000
358 #define SLCR_LOCK_MASK 0x767B /**< Write Protection Lock mask*/
359 #define SLCR_UNLOCK_MASK 0xDF0D /**< SLCR Write Protection Unlock */
360 #define LQSPI_RST_CTRL_MASK 0x3 /**< Quad SPI Software Reset Control */
365 /**************************** Type Definitions *******************************/
367 /***************** Macros (Inline Functions) Definitions *********************/
369 #define XQspiPs_In32 Xil_In32
370 #define XQspiPs_Out32 Xil_Out32
372 /****************************************************************************/
376 * @param BaseAddress contains the base address of the device.
377 * @param RegOffset contains the offset from the 1st register of the
378 * device to the target register.
380 * @return The value read from the register.
382 * @note C-Style signature:
383 * u32 XQspiPs_ReadReg(u32 BaseAddress. int RegOffset)
385 ******************************************************************************/
386 #define XQspiPs_ReadReg(BaseAddress, RegOffset) \
387 XQspiPs_In32((BaseAddress) + (RegOffset))
389 /***************************************************************************/
391 * Write to a register.
393 * @param BaseAddress contains the base address of the device.
394 * @param RegOffset contains the offset from the 1st register of the
395 * device to target register.
396 * @param RegisterValue is the value to be written to the register.
400 * @note C-Style signature:
401 * void XQspiPs_WriteReg(u32 BaseAddress, int RegOffset,
404 ******************************************************************************/
405 #define XQspiPs_WriteReg(BaseAddress, RegOffset, RegisterValue) \
406 XQspiPs_Out32((BaseAddress) + (RegOffset), (RegisterValue))
408 /************************** Function Prototypes ******************************/
411 * Functions implemented in xqspips_hw.c
413 void XQspiPs_ResetHw(u32 BaseAddress);
414 void XQspiPs_LinearInit(u32 BaseAddress);
416 /************************** Variable Definitions *****************************/
422 #endif /* end of protection macro */