1 /******************************************************************************
3 * Copyright (C) 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 /*****************************************************************************/
37 * This file contains identifiers and low-level macros/functions for the Arasan
38 * NAND flash controller driver.
40 * See xnandpsu.h for more information.
45 * MODIFICATION HISTORY:
47 * Ver Who Date Changes
48 * ----- ---- ---------- -----------------------------------------------
49 * 1.0 nm 05/06/2014 First Release
50 * 2.0 sb 11/04/2014 Changed XNANDPSU_ECC_SLC_MLC_MASK to
51 * XNANDPSU_ECC_HAMMING_BCH_MASK.
54 ******************************************************************************/
56 #ifndef XNANDPSU_HW_H /* prevent circular inclusions */
57 #define XNANDPSU_HW_H /* by using protection macros */
63 /***************************** Include Files *********************************/
66 /************************** Constant Definitions *****************************/
68 /************************** Register Offset Definitions **********************/
70 #define XNANDPSU_PKT_OFFSET 0x00U /**< Packet Register */
71 #define XNANDPSU_MEM_ADDR1_OFFSET 0x04U /**< Memory Address
73 #define XNANDPSU_MEM_ADDR2_OFFSET 0x08U /**< Memory Address
75 #define XNANDPSU_CMD_OFFSET 0x0CU /**< Command Register */
76 #define XNANDPSU_PROG_OFFSET 0x10U /**< Program Register */
77 #define XNANDPSU_INTR_STS_EN_OFFSET 0x14U /**< Interrupt Status
79 #define XNANDPSU_INTR_SIG_EN_OFFSET 0x18U /**< Interrupt Signal
81 #define XNANDPSU_INTR_STS_OFFSET 0x1CU /**< Interrupt Status
83 #define XNANDPSU_READY_BUSY_OFFSET 0x20U /**< Ready/Busy status
85 #define XNANDPSU_FLASH_STS_OFFSET 0x28U /**< Flash Status Register */
86 #define XNANDPSU_TIMING_OFFSET 0x2CU /**< Timing Register */
87 #define XNANDPSU_BUF_DATA_PORT_OFFSET 0x30U /**< Buffer Data Port
89 #define XNANDPSU_ECC_OFFSET 0x34U /**< ECC Register */
90 #define XNANDPSU_ECC_ERR_CNT_OFFSET 0x38U /**< ECC Error Count
92 #define XNANDPSU_ECC_SPR_CMD_OFFSET 0x3CU /**< ECC Spare Command
94 #define XNANDPSU_ECC_CNT_1BIT_OFFSET 0x40U /**< Error Count 1bit
96 #define XNANDPSU_ECC_CNT_2BIT_OFFSET 0x44U /**< Error Count 2bit
98 #define XNANDPSU_ECC_CNT_3BIT_OFFSET 0x48U /**< Error Count 3bit
100 #define XNANDPSU_ECC_CNT_4BIT_OFFSET 0x4CU /**< Error Count 4bit
102 #define XNANDPSU_CPU_REL_OFFSET 0x58U /**< CPU Release Register */
103 #define XNANDPSU_ECC_CNT_5BIT_OFFSET 0x5CU /**< Error Count 5bit
105 #define XNANDPSU_ECC_CNT_6BIT_OFFSET 0x60U /**< Error Count 6bit
107 #define XNANDPSU_ECC_CNT_7BIT_OFFSET 0x64U /**< Error Count 7bit
109 #define XNANDPSU_ECC_CNT_8BIT_OFFSET 0x68U /**< Error Count 8bit
111 #define XNANDPSU_DATA_INTF_OFFSET 0x6CU /**< Data Interface Register */
112 #define XNANDPSU_DMA_SYS_ADDR0_OFFSET 0x50U /**< DMA System Address 0
114 #define XNANDPSU_DMA_SYS_ADDR1_OFFSET 0x24U /**< DMA System Address 1
116 #define XNANDPSU_DMA_BUF_BND_OFFSET 0x54U /**< DMA Buffer Boundary
118 #define XNANDPSU_SLV_DMA_CONF_OFFSET 0x80U /**< Slave DMA Configuration
121 /** @name Packet Register bit definitions and masks
124 #define XNANDPSU_PKT_PKT_SIZE_MASK 0x000007FFU /**< Packet Size */
125 #define XNANDPSU_PKT_PKT_CNT_MASK 0x00FFF000U /**< Packet Count*/
126 #define XNANDPSU_PKT_PKT_CNT_SHIFT 12U /**< Packet Count Shift */
129 /** @name Memory Address Register 1 bit definitions and masks
132 #define XNANDPSU_MEM_ADDR1_COL_ADDR_MASK 0x0000FFFFU /**< Column Address
134 #define XNANDPSU_MEM_ADDR1_PG_ADDR_MASK 0xFFFF0000U /**< Page, Block
136 #define XNANDPSU_MEM_ADDR1_PG_ADDR_SHIFT 16U /**< Page Shift */
139 /** @name Memory Address Register 2 bit definitions and masks
142 #define XNANDPSU_MEM_ADDR2_MEM_ADDR_MASK 0x000000FFU /**< Memory Address
144 #define XNANDPSU_MEM_ADDR2_BUS_WIDTH_MASK 0x01000000U /**< Bus Width */
145 #define XNANDPSU_MEM_ADDR2_NFC_BCH_MODE_MASK 0x0E000000U /**< BCH Mode
147 #define XNANDPSU_MEM_ADDR2_MODE_MASK 0x30000000U /**< Flash
149 #define XNANDPSU_MEM_ADDR2_CHIP_SEL_MASK 0xC0000000U /**< Chip Select */
150 #define XNANDPSU_MEM_ADDR2_CHIP_SEL_SHIFT 30U /**< Chip select
152 #define XNANDPSU_MEM_ADDR2_BUS_WIDTH_SHIFT 24U /**< Bus width shift */
153 #define XNANDPSU_MEM_ADDR2_NFC_BCH_MODE_SHIFT 25U
156 /** @name Command Register bit definitions and masks
159 #define XNANDPSU_CMD_CMD1_MASK 0x000000FFU /**< 1st Cycle
161 #define XNANDPSU_CMD_CMD2_MASK 0x0000FF00U /**< 2nd Cycle
163 #define XNANDPSU_CMD_PG_SIZE_MASK 0x03800000U /**< Page Size */
164 #define XNANDPSU_CMD_DMA_EN_MASK 0x0C000000U /**< DMA Enable
166 #define XNANDPSU_CMD_ADDR_CYCLES_MASK 0x70000000U /**< Number of
168 #define XNANDPSU_CMD_ECC_ON_MASK 0x80000000U /**< ECC ON/OFF */
169 #define XNANDPSU_CMD_CMD2_SHIFT 8U /**< 2nd Cycle Command
171 #define XNANDPSU_CMD_PG_SIZE_SHIFT 23U /**< Page Size Shift */
172 #define XNANDPSU_CMD_DMA_EN_SHIFT 26U /**< DMA Enable Shift */
173 #define XNANDPSU_CMD_ADDR_CYCLES_SHIFT 28U /**< Number of Address
175 #define XNANDPSU_CMD_ECC_ON_SHIFT 31U /**< ECC ON/OFF */
178 /** @name Program Register bit definitions and masks
181 #define XNANDPSU_PROG_RD_MASK 0x00000001U /**< Read */
182 #define XNANDPSU_PROG_MUL_DIE_MASK 0x00000002U /**< Multi Die */
183 #define XNANDPSU_PROG_BLK_ERASE_MASK 0x00000004U /**< Block Erase */
184 #define XNANDPSU_PROG_RD_STS_MASK 0x00000008U /**< Read Status */
185 #define XNANDPSU_PROG_PG_PROG_MASK 0x00000010U /**< Page Program */
186 #define XNANDPSU_PROG_MUL_DIE_RD_MASK 0x00000020U /**< Multi Die Rd */
187 #define XNANDPSU_PROG_RD_ID_MASK 0x00000040U /**< Read ID */
188 #define XNANDPSU_PROG_RD_PRM_PG_MASK 0x00000080U /**< Read Param
190 #define XNANDPSU_PROG_RST_MASK 0x00000100U /**< Reset */
191 #define XNANDPSU_PROG_GET_FEATURES_MASK 0x00000200U /**< Get Features */
192 #define XNANDPSU_PROG_SET_FEATURES_MASK 0x00000400U /**< Set Features */
193 #define XNANDPSU_PROG_RD_UNQ_ID_MASK 0x00000800U /**< Read Unique
195 #define XNANDPSU_PROG_RD_STS_ENH_MASK 0x00001000U /**< Read Status
197 #define XNANDPSU_PROG_RD_INTRLVD_MASK 0x00002000U /**< Read
199 #define XNANDPSU_PROG_CHNG_RD_COL_ENH_MASK 0x00004000U /**< Change Read
202 #define XNANDPSU_PROG_COPY_BACK_INTRLVD_MASK 0x00008000U /**< Copy Back
204 #define XNANDPSU_PROG_RD_CACHE_START_MASK 0x00010000U /**< Read Cache
206 #define XNANDPSU_PROG_RD_CACHE_SEQ_MASK 0x00020000U /**< Read Cache
208 #define XNANDPSU_PROG_RD_CACHE_RAND_MASK 0x00040000U /**< Read Cache
210 #define XNANDPSU_PROG_RD_CACHE_END_MASK 0x00080000U /**< Read Cache
212 #define XNANDPSU_PROG_SMALL_DATA_MOVE_MASK 0x00100000U /**< Small Data
214 #define XNANDPSU_PROG_CHNG_ROW_ADDR_MASK 0x00200000U /**< Change Row
216 #define XNANDPSU_PROG_CHNG_ROW_ADDR_END_MASK 0x00400000U /**< Change Row
218 #define XNANDPSU_PROG_RST_LUN_MASK 0x00800000U /**< Reset LUN */
219 #define XNANDPSU_PROG_PGM_PG_CLR_MASK 0x01000000U /**< Enhanced
222 #define XNANDPSU_PROG_VOL_SEL_MASK 0x02000000U /**< Volume Select */
223 #define XNANDPSU_PROG_ODT_CONF_MASK 0x04000000U /**< ODT Configure */
226 /** @name Interrupt Status Enable Register bit definitions and masks
229 #define XNANDPSU_INTR_STS_EN_BUFF_WR_RDY_STS_EN_MASK 0x00000001U /**< Buffer
233 #define XNANDPSU_INTR_STS_EN_BUFF_RD_RDY_STS_EN_MASK 0x00000002U /**< Buffer
237 #define XNANDPSU_INTR_STS_EN_TRANS_COMP_STS_EN_MASK 0x00000004U /**< Transfer
241 #define XNANDPSU_INTR_STS_EN_MUL_BIT_ERR_STS_EN_MASK 0x00000008U /**< Multi
245 #define XNANDPSU_INTR_STS_EN_ERR_INTR_STS_EN_MASK 0x00000010U /**< Single
253 #define XNANDPSU_INTR_STS_EN_DMA_INT_STS_EN_MASK 0x00000040U /**< DMA
256 #define XNANDPSU_INTR_STS_EN_ERR_AHB_STS_EN_MASK 0x00000080U /**< Error
261 /** @name Interrupt Signal Enable Register bit definitions and masks
264 #define XNANDPSU_INTR_SIG_EN_BUFF_WR_RDY_STS_EN_MASK 0x00000001U /**< Buffer
268 #define XNANDPSU_INTR_SIG_EN_BUFF_RD_RDY_STS_EN_MASK 0x00000002U /**< Buffer
272 #define XNANDPSU_INTR_SIG_EN_TRANS_COMP_STS_EN_MASK 0x00000004U /**< Transfer
276 #define XNANDPSU_INTR_SIG_EN_MUL_BIT_ERR_STS_EN_MASK 0x00000008U /**< Multi
280 #define XNANDPSU_INTR_SIG_EN_ERR_INTR_STS_EN_MASK 0x00000010U /**< Single
288 #define XNANDPSU_INTR_SIG_EN_DMA_INT_STS_EN_MASK 0x00000040U /**< DMA
291 #define XNANDPSU_INTR_SIG_EN_ERR_AHB_STS_EN_MASK 0x00000080U /**< Error
296 /** @name Interrupt Status Register bit definitions and masks
299 #define XNANDPSU_INTR_STS_BUFF_WR_RDY_STS_EN_MASK 0x00000001U /**< Buffer
302 #define XNANDPSU_INTR_STS_BUFF_RD_RDY_STS_EN_MASK 0x00000002U /**< Buffer
305 #define XNANDPSU_INTR_STS_TRANS_COMP_STS_EN_MASK 0x00000004U /**< Transfer
307 #define XNANDPSU_INTR_STS_MUL_BIT_ERR_STS_EN_MASK 0x00000008U /**< Multi
309 #define XNANDPSU_INTR_STS_ERR_INTR_STS_EN_MASK 0x00000010U /**< Single
313 #define XNANDPSU_INTR_STS_DMA_INT_STS_EN_MASK 0x00000040U /**< DMA
316 #define XNANDPSU_INTR_STS_ERR_AHB_STS_EN_MASK 0x00000080U /**< Error
320 /** @name Interrupt bit definitions and masks
323 #define XNANDPSU_INTR_BUFF_WR_RDY_STS_EN_MASK 0x00000001U /**< Buffer Write
326 #define XNANDPSU_INTR_BUFF_RD_RDY_STS_EN_MASK 0x00000002U /**< Buffer Read
329 #define XNANDPSU_INTR_TRANS_COMP_STS_EN_MASK 0x00000004U /**< Transfer
332 #define XNANDPSU_INTR_MUL_BIT_ERR_STS_EN_MASK 0x00000008U /**< Multi Bit Error
334 #define XNANDPSU_INTR_ERR_INTR_STS_EN_MASK 0x00000010U /**< Single Bit Error
338 #define XNANDPSU_INTR_DMA_INT_STS_EN_MASK 0x00000040U /**< DMA Status
340 #define XNANDPSU_INTR_ERR_AHB_STS_EN_MASK 0x00000080U /**< Error AHB Status
344 /** @name ID2 Register bit definitions and masks
347 #define XNANDPSU_ID2_DEVICE_ID2_MASK 0x000000FFU /**< MSB Device ID */
350 /** @name Flash Status Register bit definitions and masks
353 #define XNANDPSU_FLASH_STS_FLASH_STS_MASK 0x0000FFFFU /**< Flash Status
357 /** @name Timing Register bit definitions and masks
360 #define XNANDPSU_TIMING_TCCS_TIME_MASK 0x00000003U /**< Change column
362 #define XNANDPSU_TIMING_SLOW_FAST_TCAD_MASK 0x00000004U /**< Slow/Fast device
364 #define XNANDPSU_TIMING_DQS_BUFF_SEL_MASK 0x00000078U /**< Write/Read data
367 #define XNANDPSU_TIMING_TADL_TIME_MASK 0x00007F80U /**< Address latch
372 /** @name ECC Register bit definitions and masks
375 #define XNANDPSU_ECC_ADDR_MASK 0x0000FFFFU /**< ECC address */
376 #define XNANDPSU_ECC_SIZE_MASK 0x01FF0000U /**< ECC size */
377 #define XNANDPSU_ECC_HAMMING_BCH_MASK 0x02000000U /**< Hamming/BCH
381 /** @name ECC Error Count Register bit definitions and masks
384 #define XNANDPSU_ECC_ERR_CNT_PKT_BND_ERR_CNT_MASK 0x000000FFU /**< Packet
387 #define XNANDPSU_ECC_ERR_CNT_PG_BND_ERR_CNT_MASK 0x0000FF00U /**< Page
392 /** @name ECC Spare Command Register bit definitions and masks
395 #define XNANDPSU_ECC_SPR_CMD_SPR_CMD_MASK 0x000000FFU /**< ECC
398 #define XNANDPSU_ECC_SPR_CMD_ECC_ADDR_CYCLES_MASK 0x70000000U /**< Number
405 /** @name Data Interface Register bit definitions and masks
408 #define XNANDPSU_DATA_INTF_SDR_MASK 0x00000007U /**< SDR mode */
409 #define XNANDPSU_DATA_INTF_NVDDR_MASK 0x00000038U /**< NVDDR mode */
410 #define XNANDPSU_DATA_INTF_NVDDR2_MASK 0x000001C0U /**< NVDDR2 mode */
411 #define XNANDPSU_DATA_INTF_DATA_INTF_MASK 0x00000600U /**< Data
413 #define XNANDPSU_DATA_INTF_NVDDR_SHIFT 3U /**< NVDDR mode shift */
414 #define XNANDPSU_DATA_INTF_DATA_INTF_SHIFT 9U /**< Data Interface Shift */
417 /** @name DMA Buffer Boundary Register bit definitions and masks
420 #define XNANDPSU_DMA_BUF_BND_BND_MASK 0x00000007U /**< DMA buffer
422 #define XNANDPSU_DMA_BUF_BND_4K 0x0U
423 #define XNANDPSU_DMA_BUF_BND_8K 0x1U
424 #define XNANDPSU_DMA_BUF_BND_16K 0x2U
425 #define XNANDPSU_DMA_BUF_BND_32K 0x3U
426 #define XNANDPSU_DMA_BUF_BND_64K 0x4U
427 #define XNANDPSU_DMA_BUF_BND_128K 0x5U
428 #define XNANDPSU_DMA_BUF_BND_256K 0x6U
429 #define XNANDPSU_DMA_BUF_BND_512K 0x7U
432 /** @name Slave DMA Configuration Register bit definitions and masks
435 #define XNANDPSU_SLV_DMA_CONF_SDMA_TX_RX_MASK 0x00000001U /**< Slave
440 #define XNANDPSU_SLV_DMA_CONF_DMA_TRANS_CNT_MASK 0x001FFFFEU /**< Slave
444 #define XNANDPSU_SLV_DMA_CONF_DMA_BURST_SIZE_MASK 0x00E00000U /**< Slave
448 #define XNANDPSU_SLV_DMA_CONF_DMA_TMOUT_CNT_VAL_MASK 0x0F000000U /**< DMA
452 #define XNANDPSU_SLV_DMA_CONF_SDMA_EN_MASK 0x10000000U /**< Slave
457 /**************************** Type Definitions *******************************/
459 /***************** Macros (Inline Functions) Definitions *********************/
461 /****************************************************************************/
464 * This macro reads the given register.
466 * @param BaseAddress is the base address of controller registers.
467 * @param RegOffset is the register offset to be read.
469 * @return The 32-bit value of the register.
471 * @note C-style signature:
472 * u32 XNandPsu_ReadReg(u32 BaseAddress, u32 RegOffset)
474 *****************************************************************************/
475 #define XNandPsu_ReadReg(BaseAddress, RegOffset) \
476 Xil_In32((BaseAddress) + (RegOffset))
478 /****************************************************************************/
481 * This macro writes the given register.
483 * @param BaseAddress is the the base address of controller registers.
484 * @param RegOffset is the register offset to be written.
485 * @param Data is the the 32-bit value to write to the register.
489 * @note C-style signature:
490 * void XNandPsu_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data)
492 ******************************************************************************/
493 #define XNandPsu_WriteReg(BaseAddress, RegOffset, Data) \
494 Xil_Out32(((BaseAddress) + (RegOffset)), (Data))
496 /************************** Function Prototypes ******************************/
498 /************************** Variable Definitions *****************************/
504 #endif /* XNANDPSU_HW_H end of protection macro */