]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo_bsp/ps7_cortexa9_0/libsrc/qspips_v3_0/src/xqspips_hw.h
FreeRTOS source updates:
[freertos] / FreeRTOS / Demo / CORTEX_A9_Zynq_ZC702 / RTOSDemo_bsp / ps7_cortexa9_0 / libsrc / qspips_v3_0 / src / xqspips_hw.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2010 - 2014 Xilinx, Inc.  All rights reserved.
4 *
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:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
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.
18 *
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
25 * SOFTWARE.
26 *
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.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 *
35 * @file xqspips_hw.h
36 * @addtogroup qspips_v3_0
37 * @{
38 *
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.
42 *
43 * <pre>
44 * MODIFICATION HISTORY:
45 *
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
51 *                    CR 671468
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 *
61 * </pre>
62 *
63 ******************************************************************************/
64 #ifndef XQSPIPS_HW_H            /* prevent circular inclusions */
65 #define XQSPIPS_HW_H            /* by using protection macros */
66
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70
71 /***************************** Include Files *********************************/
72
73 #include "xil_types.h"
74 #include "xil_assert.h"
75 #include "xil_io.h"
76 #include "xparameters.h"
77
78 /************************** Constant Definitions *****************************/
79
80 /** @name Register Map
81  *
82  * Register offsets from the base address of an QSPI device.
83  * @{
84  */
85 #define XQSPIPS_CR_OFFSET               0x00 /**< Configuration Register */
86 #define XQSPIPS_SR_OFFSET               0x04 /**< Interrupt Status */
87 #define XQSPIPS_IER_OFFSET              0x08 /**< Interrupt Enable */
88 #define XQSPIPS_IDR_OFFSET              0x0c /**< Interrupt Disable */
89 #define XQSPIPS_IMR_OFFSET              0x10 /**< Interrupt Enabled Mask */
90 #define XQSPIPS_ER_OFFSET               0x14 /**< Enable/Disable Register */
91 #define XQSPIPS_DR_OFFSET               0x18 /**< Delay Register */
92 #define XQSPIPS_TXD_00_OFFSET           0x1C /**< Transmit 4-byte inst/data */
93 #define XQSPIPS_RXD_OFFSET              0x20 /**< Data Receive Register */
94 #define XQSPIPS_SICR_OFFSET             0x24 /**< Slave Idle Count */
95 #define XQSPIPS_TXWR_OFFSET             0x28 /**< Transmit FIFO Watermark */
96 #define XQSPIPS_RXWR_OFFSET             0x2C /**< Receive FIFO Watermark */
97 #define XQSPIPS_GPIO_OFFSET             0x30 /**< GPIO Register */
98 #define XQSPIPS_LPBK_DLY_ADJ_OFFSET     0x38 /**< Loopback Delay Adjust Reg */
99 #define XQSPIPS_TXD_01_OFFSET           0x80 /**< Transmit 1-byte inst */
100 #define XQSPIPS_TXD_10_OFFSET           0x84 /**< Transmit 2-byte inst */
101 #define XQSPIPS_TXD_11_OFFSET           0x88 /**< Transmit 3-byte inst */
102 #define XQSPIPS_LQSPI_CR_OFFSET         0xA0 /**< Linear QSPI config register */
103 #define XQSPIPS_LQSPI_SR_OFFSET         0xA4 /**< Linear QSPI status register */
104 #define XQSPIPS_MOD_ID_OFFSET           0xFC /**< Module ID register */
105
106 /* @} */
107
108 /** @name Configuration Register
109  *
110  * This register contains various control bits that
111  * affect the operation of the QSPI device. Read/Write.
112  * @{
113  */
114
115 #define XQSPIPS_CR_IFMODE_MASK    0x80000000 /**< Flash mem interface mode */
116 #define XQSPIPS_CR_ENDIAN_MASK    0x04000000 /**< Tx/Rx FIFO endianness */
117 #define XQSPIPS_CR_MANSTRT_MASK   0x00010000 /**< Manual Transmission Start */
118 #define XQSPIPS_CR_MANSTRTEN_MASK 0x00008000 /**< Manual Transmission Start
119                                                    Enable */
120 #define XQSPIPS_CR_SSFORCE_MASK   0x00004000 /**< Force Slave Select */
121 #define XQSPIPS_CR_SSCTRL_MASK    0x00000400 /**< Slave Select Decode */
122 #define XQSPIPS_CR_SSCTRL_SHIFT   10          /**< Slave Select Decode shift */
123 #define XQSPIPS_CR_DATA_SZ_MASK   0x000000C0 /**< Size of word to be
124                                                    transferred */
125 #define XQSPIPS_CR_PRESC_MASK     0x00000038 /**< Prescaler Setting */
126 #define XQSPIPS_CR_PRESC_SHIFT    3           /**< Prescaler shift */
127 #define XQSPIPS_CR_PRESC_MAXIMUM  0x07        /**< Prescaler maximum value */
128
129 #define XQSPIPS_CR_CPHA_MASK      0x00000004 /**< Phase Configuration */
130 #define XQSPIPS_CR_CPOL_MASK      0x00000002 /**< Polarity Configuration */
131
132 #define XQSPIPS_CR_MSTREN_MASK    0x00000001 /**< Master Mode Enable */
133
134 #define XQSPIPS_CR_HOLD_B_MASK    0x00080000 /**< HOLD_B Pin Drive Enable */
135
136 /* Deselect the Slave select line and set the transfer size to 32 at reset */
137 #define XQSPIPS_CR_RESET_STATE    (XQSPIPS_CR_IFMODE_MASK | \
138                                    XQSPIPS_CR_SSCTRL_MASK | \
139                                    XQSPIPS_CR_DATA_SZ_MASK | \
140                                    XQSPIPS_CR_MSTREN_MASK)
141 /* @} */
142
143
144 /** @name QSPI Interrupt Registers
145  *
146  * <b>QSPI Status Register</b>
147  *
148  * This register holds the interrupt status flags for an QSPI device. Some
149  * of the flags are level triggered, which means that they are set as long
150  * as the interrupt condition exists. Other flags are edge triggered,
151  * which means they are set once the interrupt condition occurs and remain
152  * set until they are cleared by software. The interrupts are cleared by
153  * writing a '1' to the interrupt bit position in the Status Register.
154  * Read/Write.
155  *
156  * <b>QSPI Interrupt Enable Register</b>
157  *
158  * This register is used to enable chosen interrupts for an QSPI device.
159  * Writing a '1' to a bit in this register sets the corresponding bit in the
160  * QSPI Interrupt Mask register.  Write only.
161  *
162  * <b>QSPI Interrupt Disable Register </b>
163  *
164  * This register is used to disable chosen interrupts for an QSPI device.
165  * Writing a '1' to a bit in this register clears the corresponding bit in the
166  * QSPI Interrupt Mask register. Write only.
167  *
168  * <b>QSPI Interrupt Mask Register</b>
169  *
170  * This register shows the enabled/disabled interrupts of an QSPI device.
171  * Read only.
172  *
173  * All four registers have the same bit definitions. They are only defined once
174  * for each of the Interrupt Enable Register, Interrupt Disable Register,
175  * Interrupt Mask Register, and Channel Interrupt Status Register
176  * @{
177  */
178
179 #define XQSPIPS_IXR_TXUF_MASK      0x00000040  /**< QSPI Tx FIFO Underflow */
180 #define XQSPIPS_IXR_RXFULL_MASK    0x00000020  /**< QSPI Rx FIFO Full */
181 #define XQSPIPS_IXR_RXNEMPTY_MASK  0x00000010  /**< QSPI Rx FIFO Not Empty */
182 #define XQSPIPS_IXR_TXFULL_MASK    0x00000008  /**< QSPI Tx FIFO Full */
183 #define XQSPIPS_IXR_TXOW_MASK      0x00000004  /**< QSPI Tx FIFO Overwater */
184 #define XQSPIPS_IXR_RXOVR_MASK     0x00000001  /**< QSPI Rx FIFO Overrun */
185 #define XQSPIPS_IXR_DFLT_MASK      0x00000025  /**< QSPI default interrupts
186                                                     mask */
187 #define XQSPIPS_IXR_WR_TO_CLR_MASK 0x00000041  /**< Interrupts which
188                                                     need write to clear */
189 #define XQSPIPS_ISR_RESET_STATE    0x00000004  /**< Default to tx/rx empty */
190 #define XQSPIPS_IXR_DISABLE_ALL    0x0000007D  /**< Disable all interrupts */
191 /* @} */
192
193
194 /** @name Enable Register
195  *
196  * This register is used to enable or disable an QSPI device.
197  * Read/Write
198  * @{
199  */
200 #define XQSPIPS_ER_ENABLE_MASK    0x00000001 /**< QSPI Enable Bit Mask */
201 /* @} */
202
203
204 /** @name Delay Register
205  *
206  * This register is used to program timing delays in
207  * slave mode. Read/Write
208  * @{
209  */
210 #define XQSPIPS_DR_NSS_MASK     0xFF000000 /**< Delay to de-assert slave select
211                                                 between two words mask */
212 #define XQSPIPS_DR_NSS_SHIFT    24         /**< Delay to de-assert slave select
213                                                 between two words shift */
214 #define XQSPIPS_DR_BTWN_MASK    0x00FF0000 /**< Delay Between Transfers
215                                                 mask */
216 #define XQSPIPS_DR_BTWN_SHIFT   16         /**< Delay Between Transfers shift */
217 #define XQSPIPS_DR_AFTER_MASK   0x0000FF00 /**< Delay After Transfers mask */
218 #define XQSPIPS_DR_AFTER_SHIFT  8          /**< Delay After Transfers shift */
219 #define XQSPIPS_DR_INIT_MASK    0x000000FF /**< Delay Initially mask */
220 /* @} */
221
222 /** @name Slave Idle Count Registers
223  *
224  * This register defines the number of pclk cycles the slave waits for a the
225  * QSPI clock to become stable in quiescent state before it can detect the start
226  * of the next transfer in CPHA = 1 mode.
227  * Read/Write
228  *
229  * @{
230  */
231 #define XQSPIPS_SICR_MASK       0x000000FF /**< Slave Idle Count Mask */
232 /* @} */
233
234
235 /** @name Transmit FIFO Watermark Register
236  *
237  * This register defines the watermark setting for the Transmit FIFO.
238  *
239  * @{
240  */
241 #define XQSPIPS_TXWR_MASK           0x0000003F /**< Transmit Watermark Mask */
242 #define XQSPIPS_TXWR_RESET_VALUE    0x00000001 /**< Transmit Watermark
243                                                   * register reset value */
244
245 /* @} */
246
247 /** @name Receive FIFO Watermark Register
248  *
249  * This register defines the watermark setting for the Receive FIFO.
250  *
251  * @{
252  */
253 #define XQSPIPS_RXWR_MASK           0x0000003F /**< Receive Watermark Mask */
254 #define XQSPIPS_RXWR_RESET_VALUE    0x00000001 /**< Receive Watermark
255                                                   * register reset value */
256
257 /* @} */
258
259 /** @name FIFO Depth
260  *
261  * This macro provides the depth of transmit FIFO and receive FIFO.
262  *
263  * @{
264  */
265 #define XQSPIPS_FIFO_DEPTH      63      /**< FIFO depth (words) */
266 /* @} */
267
268
269 /** @name Linear QSPI Configuration Register
270  *
271  * This register contains various control bits that
272  * affect the operation of the Linear QSPI controller. Read/Write.
273  *
274  * @{
275  */
276 #define XQSPIPS_LQSPI_CR_LINEAR_MASK     0x80000000 /**< LQSPI mode enable */
277 #define XQSPIPS_LQSPI_CR_TWO_MEM_MASK    0x40000000 /**< Both memories or one */
278 #define XQSPIPS_LQSPI_CR_SEP_BUS_MASK    0x20000000 /**< Seperate memory bus */
279 #define XQSPIPS_LQSPI_CR_U_PAGE_MASK     0x10000000 /**< Upper memory page */
280 #define XQSPIPS_LQSPI_CR_MODE_EN_MASK    0x02000000 /**< Enable mode bits */
281 #define XQSPIPS_LQSPI_CR_MODE_ON_MASK    0x01000000 /**< Mode on */
282 #define XQSPIPS_LQSPI_CR_MODE_BITS_MASK  0x00FF0000 /**< Mode value for dual I/O
283                                                          or quad I/O */
284 #define XQSPIPS_LQSPI_CR_DUMMY_MASK      0x00000700 /**< Number of dummy bytes
285                                                          between addr and return
286                                                          read data */
287 #define XQSPIPS_LQSPI_CR_INST_MASK       0x000000FF /**< Read instr code */
288 #define XQSPIPS_LQSPI_CR_RST_STATE       0x8000016B /**< Default CR value */
289 /* @} */
290
291 /** @name Linear QSPI Status Register
292  *
293  * This register contains various status bits of the Linear QSPI controller.
294  * Read/Write.
295  *
296  * @{
297  */
298 #define XQSPIPS_LQSPI_SR_D_FSM_ERR_MASK   0x00000004 /**< AXI Data FSM Error
299                                                           received */
300 #define XQSPIPS_LQSPI_SR_WR_RECVD_MASK    0x00000002 /**< AXI write command
301                                                           received */
302 /* @} */
303
304
305 /** @name Loopback Delay Adjust Register
306  *
307  * This register contains various bit masks of Loopback Delay Adjust Register.
308  *
309  * @{
310  */
311
312 #define XQSPIPS_LPBK_DLY_ADJ_USE_LPBK_MASK 0x00000020 /**< Loopback Bit */
313
314 /* @} */
315
316
317 /**************************** Type Definitions *******************************/
318
319 /***************** Macros (Inline Functions) Definitions *********************/
320
321 #define XQspiPs_In32 Xil_In32
322 #define XQspiPs_Out32 Xil_Out32
323
324 /****************************************************************************/
325 /**
326 * Read a register.
327 *
328 * @param        BaseAddress contains the base address of the device.
329 * @param        RegOffset contains the offset from the 1st register of the
330 *               device to the target register.
331 *
332 * @return       The value read from the register.
333 *
334 * @note         C-Style signature:
335 *               u32 XQspiPs_ReadReg(u32 BaseAddress. int RegOffset)
336 *
337 ******************************************************************************/
338 #define XQspiPs_ReadReg(BaseAddress, RegOffset) \
339         XQspiPs_In32((BaseAddress) + (RegOffset))
340
341 /***************************************************************************/
342 /**
343 * Write to a register.
344 *
345 * @param        BaseAddress contains the base address of the device.
346 * @param        RegOffset contains the offset from the 1st register of the
347 *               device to target register.
348 * @param        RegisterValue is the value to be written to the register.
349 *
350 * @return       None.
351 *
352 * @note         C-Style signature:
353 *               void XQspiPs_WriteReg(u32 BaseAddress, int RegOffset,
354 *               u32 RegisterValue)
355 *
356 ******************************************************************************/
357 #define XQspiPs_WriteReg(BaseAddress, RegOffset, RegisterValue) \
358         XQspiPs_Out32((BaseAddress) + (RegOffset), (RegisterValue))
359
360 /************************** Function Prototypes ******************************/
361
362 /*
363  * Functions implemented in xqspips_hw.c
364  */
365 void XQspiPs_ResetHw(u32 BaseAddress);
366 void XQspiPs_LinearInit(u32 BaseAddress);
367
368 /************************** Variable Definitions *****************************/
369
370 #ifdef __cplusplus
371 }
372 #endif
373
374 #endif /* end of protection macro */
375 /** @} */