summaryrefslogtreecommitdiffstats
path: root/bsps/include/dev/nand/xnandpsu_hw.h
blob: 47e6c8fddc773e39a22b3c80d1bb8e69e7990038 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
/******************************************************************************
* Copyright (C) 2015 - 2022 Xilinx, Inc.  All rights reserved.
* SPDX-License-Identifier: MIT
******************************************************************************/

/*****************************************************************************/
/**
*
* @file xnandpsu_hw.h
* @addtogroup nandpsu_v1_10
* @{
*
* This file contains identifiers and low-level macros/functions for the Arasan
* NAND flash controller driver.
*
* See xnandpsu.h for more information.
*
* @note		None
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver   Who    Date        Changes
* ----- ----   ----------  -----------------------------------------------
* 1.0   nm     05/06/2014  First Release
* 2.0   sb     11/04/2014  Changed XNANDPSU_ECC_SLC_MLC_MASK to
*			   XNANDPSU_ECC_HAMMING_BCH_MASK.
* 1.7	akm    09/03/20    Updated the Makefile to support parallel make
* 			   execution.
* </pre>
*
******************************************************************************/

#ifndef XNANDPSU_HW_H		/* prevent circular inclusions */
#define XNANDPSU_HW_H		/* by using protection macros */

#ifdef __cplusplus
extern "C" {
#endif

/***************************** Include Files *********************************/
#include "xil_io.h"

/************************** Constant Definitions *****************************/

/************************** Register Offset Definitions **********************/

#define XNANDPSU_PKT_OFFSET		0x00U	/**< Packet Register */
#define XNANDPSU_MEM_ADDR1_OFFSET	0x04U	/**< Memory Address
						  Register 1 */
#define XNANDPSU_MEM_ADDR2_OFFSET	0x08U	/**< Memory Address
						  Register 2 */
#define XNANDPSU_CMD_OFFSET		0x0CU	/**< Command Register */
#define XNANDPSU_PROG_OFFSET		0x10U	/**< Program Register */
#define XNANDPSU_INTR_STS_EN_OFFSET	0x14U	/**< Interrupt Status
						     Enable Register */
#define XNANDPSU_INTR_SIG_EN_OFFSET	0x18U	/**< Interrupt Signal
						     Enable Register */
#define XNANDPSU_INTR_STS_OFFSET	0x1CU	/**< Interrupt Status
						  Register */
#define XNANDPSU_READY_BUSY_OFFSET	0x20U	/**< Ready/Busy status
						  Register */
#define XNANDPSU_FLASH_STS_OFFSET	0x28U	/**< Flash Status Register */
#define XNANDPSU_TIMING_OFFSET		0x2CU	/**< Timing Register */
#define XNANDPSU_BUF_DATA_PORT_OFFSET	0x30U	/**< Buffer Data Port
						  Register */
#define XNANDPSU_ECC_OFFSET		0x34U	/**< ECC Register */
#define XNANDPSU_ECC_ERR_CNT_OFFSET	0x38U	/**< ECC Error Count
						  Register */
#define XNANDPSU_ECC_SPR_CMD_OFFSET	0x3CU	/**< ECC Spare Command
						     Register */
#define XNANDPSU_ECC_CNT_1BIT_OFFSET	0x40U	/**< Error Count 1bit
						  Register */
#define XNANDPSU_ECC_CNT_2BIT_OFFSET	0x44U	/**< Error Count 2bit
						  Register */
#define XNANDPSU_ECC_CNT_3BIT_OFFSET	0x48U	/**< Error Count 3bit
						  Register */
#define XNANDPSU_ECC_CNT_4BIT_OFFSET	0x4CU	/**< Error Count 4bit
						  Register */
#define XNANDPSU_CPU_REL_OFFSET		0x58U	/**< CPU Release Register */
#define XNANDPSU_ECC_CNT_5BIT_OFFSET	0x5CU	/**< Error Count 5bit
						  Register */
#define XNANDPSU_ECC_CNT_6BIT_OFFSET	0x60U	/**< Error Count 6bit
						  Register */
#define XNANDPSU_ECC_CNT_7BIT_OFFSET	0x64U	/**< Error Count 7bit
						  Register */
#define XNANDPSU_ECC_CNT_8BIT_OFFSET	0x68U	/**< Error Count 8bit
						  Register */
#define XNANDPSU_DATA_INTF_OFFSET	0x6CU	/**< Data Interface Register */
#define XNANDPSU_DMA_SYS_ADDR0_OFFSET	0x50U	/**< DMA System Address 0
						  Register */
#define XNANDPSU_DMA_SYS_ADDR1_OFFSET	0x24U	/**< DMA System Address 1
						  Register */
#define XNANDPSU_DMA_BUF_BND_OFFSET	0x54U	/**< DMA Buffer Boundary
						  Register */
#define XNANDPSU_SLV_DMA_CONF_OFFSET	0x80U	/**< Slave DMA Configuration
						  Register */

/** @name Packet Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_PKT_PKT_SIZE_MASK		0x000007FFU /**< Packet Size */
#define XNANDPSU_PKT_PKT_CNT_MASK		0x00FFF000U /**< Packet Count*/
#define XNANDPSU_PKT_PKT_CNT_SHIFT		12U /**< Packet Count Shift */
/* @} */

/** @name Memory Address Register 1 bit definitions and masks
 *  @{
 */
#define XNANDPSU_MEM_ADDR1_COL_ADDR_MASK	0x0000FFFFU /**< Column Address
							     Mask */
#define XNANDPSU_MEM_ADDR1_PG_ADDR_MASK		0xFFFF0000U /**< Page, Block
							     Address Mask */
#define XNANDPSU_MEM_ADDR1_PG_ADDR_SHIFT	16U /**< Page Shift */
/* @} */

/** @name Memory Address Register 2 bit definitions and masks
 *  @{
 */
#define XNANDPSU_MEM_ADDR2_MEM_ADDR_MASK	0x000000FFU /**< Memory Address
								*/
#define XNANDPSU_MEM_ADDR2_BUS_WIDTH_MASK	0x01000000U /**< Bus Width */
#define XNANDPSU_MEM_ADDR2_NFC_BCH_MODE_MASK	0x0E000000U /**< BCH Mode
							     Value */
#define XNANDPSU_MEM_ADDR2_MODE_MASK		0x30000000U /**< Flash
							     Connection Mode */
#define XNANDPSU_MEM_ADDR2_CHIP_SEL_MASK	0xC0000000U /**< Chip Select */
#define XNANDPSU_MEM_ADDR2_CHIP_SEL_SHIFT	30U	/**< Chip select
							shift */
#define XNANDPSU_MEM_ADDR2_BUS_WIDTH_SHIFT	24U	/**< Bus width shift */
#define XNANDPSU_MEM_ADDR2_NFC_BCH_MODE_SHIFT	25U
/* @} */

/** @name Command Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_CMD_CMD1_MASK			0x000000FFU /**< 1st Cycle
							     Command */
#define XNANDPSU_CMD_CMD2_MASK			0x0000FF00U /**< 2nd Cycle
							     Command */
#define XNANDPSU_CMD_PG_SIZE_MASK		0x03800000U /**< Page Size */
#define XNANDPSU_CMD_DMA_EN_MASK		0x0C000000U /**< DMA Enable
							     Mode */
#define XNANDPSU_CMD_ADDR_CYCLES_MASK		0x70000000U /**< Number of
							     Address Cycles */
#define XNANDPSU_CMD_ECC_ON_MASK		0x80000000U /**< ECC ON/OFF */
#define XNANDPSU_CMD_CMD2_SHIFT			8U /**< 2nd Cycle Command
						    Shift */
#define XNANDPSU_CMD_PG_SIZE_SHIFT		23U /**< Page Size Shift */
#define XNANDPSU_CMD_DMA_EN_SHIFT		26U /**< DMA Enable Shift */
#define XNANDPSU_CMD_ADDR_CYCLES_SHIFT		28U /**< Number of Address
						     Cycles Shift */
#define XNANDPSU_CMD_ECC_ON_SHIFT		31U /**< ECC ON/OFF */
/* @} */

/** @name Program Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_PROG_RD_MASK			0x00000001U /**< Read */
#define XNANDPSU_PROG_MUL_DIE_MASK		0x00000002U /**< Multi Die */
#define XNANDPSU_PROG_BLK_ERASE_MASK		0x00000004U /**< Block Erase */
#define XNANDPSU_PROG_RD_STS_MASK		0x00000008U /**< Read Status */
#define XNANDPSU_PROG_PG_PROG_MASK		0x00000010U /**< Page Program */
#define XNANDPSU_PROG_MUL_DIE_RD_MASK		0x00000020U /**< Multi Die Rd */
#define XNANDPSU_PROG_RD_ID_MASK		0x00000040U /**< Read ID */
#define XNANDPSU_PROG_RD_PRM_PG_MASK		0x00000080U /**< Read Param
							     Page */
#define XNANDPSU_PROG_RST_MASK			0x00000100U /**< Reset */
#define XNANDPSU_PROG_GET_FEATURES_MASK		0x00000200U /**< Get Features */
#define XNANDPSU_PROG_SET_FEATURES_MASK		0x00000400U /**< Set Features */
#define XNANDPSU_PROG_RD_UNQ_ID_MASK		0x00000800U /**< Read Unique
							     ID */
#define XNANDPSU_PROG_RD_STS_ENH_MASK		0x00001000U /**< Read Status
							     Enhanced */
#define XNANDPSU_PROG_RD_INTRLVD_MASK		0x00002000U /**< Read
							     Interleaved */
#define XNANDPSU_PROG_CHNG_RD_COL_ENH_MASK	0x00004000U /**< Change Read
								Column
								Enhanced */
#define XNANDPSU_PROG_COPY_BACK_INTRLVD_MASK	0x00008000U /**< Copy Back
								Interleaved */
#define XNANDPSU_PROG_RD_CACHE_START_MASK	0x00010000U /**< Read Cache
							     Start */
#define XNANDPSU_PROG_RD_CACHE_SEQ_MASK		0x00020000U /**< Read Cache
							     Sequential */
#define XNANDPSU_PROG_RD_CACHE_RAND_MASK	0x00040000U /**< Read Cache
								Random */
#define XNANDPSU_PROG_RD_CACHE_END_MASK		0x00080000U /**< Read Cache
							     End */
#define XNANDPSU_PROG_SMALL_DATA_MOVE_MASK	0x00100000U /**< Small Data
							     Move */
#define XNANDPSU_PROG_CHNG_ROW_ADDR_MASK	0x00200000U /**< Change Row
								Address */
#define XNANDPSU_PROG_CHNG_ROW_ADDR_END_MASK	0x00400000U /**< Change Row
								Address End */
#define XNANDPSU_PROG_RST_LUN_MASK		0x00800000U /**< Reset LUN */
#define XNANDPSU_PROG_PGM_PG_CLR_MASK		0x01000000U /**< Enhanced
							     Program Page
							     Register Clear */
#define XNANDPSU_PROG_VOL_SEL_MASK		0x02000000U /**< Volume Select */
#define XNANDPSU_PROG_ODT_CONF_MASK		0x04000000U /**< ODT Configure */
/* @} */

/** @name Interrupt Status Enable Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_INTR_STS_EN_BUFF_WR_RDY_STS_EN_MASK	0x00000001U /**< Buffer
								     Write Ready
								     Status
								     Enable */
#define XNANDPSU_INTR_STS_EN_BUFF_RD_RDY_STS_EN_MASK	0x00000002U /**< Buffer
								     Read Ready
								     Status
								     Enable */
#define XNANDPSU_INTR_STS_EN_TRANS_COMP_STS_EN_MASK	0x00000004U /**< Transfer
								     Complete
								     Status
								     Enable */
#define XNANDPSU_INTR_STS_EN_MUL_BIT_ERR_STS_EN_MASK	0x00000008U /**< Multi
								     Bit Error
								     Status
								     Enable */
#define XNANDPSU_INTR_STS_EN_ERR_INTR_STS_EN_MASK	0x00000010U /**< Single
								     Bit Error
								     Status
								     Enable,
								     BCH Detect
								     Error
								     Status
								     Enable */
#define XNANDPSU_INTR_STS_EN_DMA_INT_STS_EN_MASK	0x00000040U /**< DMA
								     Status
								     Enable */
#define XNANDPSU_INTR_STS_EN_ERR_AHB_STS_EN_MASK	0x00000080U /**< Error
								     AHB Status
								     Enable */
/* @} */

/** @name Interrupt Signal Enable Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_INTR_SIG_EN_BUFF_WR_RDY_STS_EN_MASK	0x00000001U /**< Buffer
								     Write Ready
								     Signal
								     Enable */
#define XNANDPSU_INTR_SIG_EN_BUFF_RD_RDY_STS_EN_MASK	0x00000002U /**< Buffer
								     Read Ready
								     Signal
								     Enable */
#define XNANDPSU_INTR_SIG_EN_TRANS_COMP_STS_EN_MASK	0x00000004U /**< Transfer
								     Complete
								     Signal
								     Enable */
#define XNANDPSU_INTR_SIG_EN_MUL_BIT_ERR_STS_EN_MASK	0x00000008U /**< Multi
								     Bit Error
								     Signal
								     Enable */
#define XNANDPSU_INTR_SIG_EN_ERR_INTR_STS_EN_MASK	0x00000010U /**< Single
								     Bit Error
								     Signal
								     Enable,
								     BCH Detect
								     Error
								     Signal
								     Enable */
#define XNANDPSU_INTR_SIG_EN_DMA_INT_STS_EN_MASK	0x00000040U /**< DMA
								     Signal
								     Enable */
#define XNANDPSU_INTR_SIG_EN_ERR_AHB_STS_EN_MASK	0x00000080U /**< Error
								     AHB Signal
								     Enable */
/* @} */

/** @name Interrupt Status Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_INTR_STS_BUFF_WR_RDY_STS_EN_MASK	0x00000001U /**< Buffer
								     Write
								     Ready */
#define XNANDPSU_INTR_STS_BUFF_RD_RDY_STS_EN_MASK	0x00000002U /**< Buffer
								     Read
								     Ready */
#define XNANDPSU_INTR_STS_TRANS_COMP_STS_EN_MASK	0x00000004U /**< Transfer
								     Complete */
#define XNANDPSU_INTR_STS_MUL_BIT_ERR_STS_EN_MASK	0x00000008U /**< Multi
								    Bit Error */
#define XNANDPSU_INTR_STS_ERR_INTR_STS_EN_MASK		0x00000010U /**< Single
								     Bit Error,
								     BCH Detect
								     Error */
#define XNANDPSU_INTR_STS_DMA_INT_STS_EN_MASK		0x00000040U /**< DMA
								     Interrupt
								     */
#define XNANDPSU_INTR_STS_ERR_AHB_STS_EN_MASK		0x00000080U /**< Error
								     AHB */
/* @} */

/** @name Interrupt bit definitions and masks
 *  @{
 */
#define XNANDPSU_INTR_BUFF_WR_RDY_STS_EN_MASK	0x00000001U /**< Buffer Write
								Ready Status
								Enable */
#define XNANDPSU_INTR_BUFF_RD_RDY_STS_EN_MASK	0x00000002U /**< Buffer Read
								Ready Status
								Enable */
#define XNANDPSU_INTR_TRANS_COMP_STS_EN_MASK	0x00000004U /**< Transfer
								Complete Status
								Enable */
#define XNANDPSU_INTR_MUL_BIT_ERR_STS_EN_MASK	0x00000008U /**< Multi Bit Error
								Status Enable */
#define XNANDPSU_INTR_ERR_INTR_STS_EN_MASK	0x00000010U /**< Single Bit Error
								Status Enable,
								BCH Detect Error
								Status Enable */
#define XNANDPSU_INTR_DMA_INT_STS_EN_MASK	0x00000040U /**< DMA Status
								Enable */
#define XNANDPSU_INTR_ERR_AHB_STS_EN_MASK	0x00000080U /**< Error AHB Status
								Enable */
/* @} */

/** @name ID2 Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_ID2_DEVICE_ID2_MASK		0x000000FFU /**< MSB Device ID */
/* @} */

/** @name Flash Status Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_FLASH_STS_FLASH_STS_MASK	0x0000FFFFU /**< Flash Status
							     Value */
/* @} */

/** @name Timing Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_TIMING_TCCS_TIME_MASK		0x00000003U /**< Change column
							     setup time */
#define XNANDPSU_TIMING_SLOW_FAST_TCAD_MASK	0x00000004U /**< Slow/Fast device
							     */
#define XNANDPSU_TIMING_DQS_BUFF_SEL_MASK	0x00000078U /**< Write/Read data
							     transaction value
							     */
#define XNANDPSU_TIMING_TADL_TIME_MASK		0x00007F80U /**< Address latch
							     enable to Data
							     loading time */
/* @} */

/** @name ECC Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_ECC_ADDR_MASK			0x0000FFFFU /**< ECC address */
#define XNANDPSU_ECC_SIZE_MASK			0x01FF0000U /**< ECC size */
#define XNANDPSU_ECC_HAMMING_BCH_MASK		0x02000000U /**< Hamming/BCH
							     support */
/* @} */

/** @name ECC Error Count Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_ECC_ERR_CNT_PKT_BND_ERR_CNT_MASK	0x000000FFU /**< Packet
								     bound error
								     count */
#define XNANDPSU_ECC_ERR_CNT_PG_BND_ERR_CNT_MASK	0x0000FF00U /**< Page
								     bound error
								     count */
/* @} */

/** @name ECC Spare Command Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_ECC_SPR_CMD_SPR_CMD_MASK		0x000000FFU /**< ECC
								     spare
								     command */
#define XNANDPSU_ECC_SPR_CMD_ECC_ADDR_CYCLES_MASK	0x70000000U /**< Number
								     of ECC/
								     spare
								     address
								     cycles */
/* @} */

/** @name Data Interface Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_DATA_INTF_SDR_MASK		0x00000007U /**< SDR mode */
#define XNANDPSU_DATA_INTF_NVDDR_MASK		0x00000038U /**< NVDDR mode */
#define XNANDPSU_DATA_INTF_NVDDR2_MASK		0x000001C0U /**< NVDDR2 mode */
#define XNANDPSU_DATA_INTF_DATA_INTF_MASK	0x00000600U /**< Data
							     Interface */
#define XNANDPSU_DATA_INTF_NVDDR_SHIFT		3U /**< NVDDR mode shift */
#define XNANDPSU_DATA_INTF_DATA_INTF_SHIFT	9U /**< Data Interface Shift */
/* @} */

/** @name DMA Buffer Boundary Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_DMA_BUF_BND_BND_MASK		0x00000007U /**< DMA buffer
							     boundary */
#define XNANDPSU_DMA_BUF_BND_4K			0x0U
#define XNANDPSU_DMA_BUF_BND_8K			0x1U
#define XNANDPSU_DMA_BUF_BND_16K		0x2U
#define XNANDPSU_DMA_BUF_BND_32K		0x3U
#define XNANDPSU_DMA_BUF_BND_64K		0x4U
#define XNANDPSU_DMA_BUF_BND_128K		0x5U
#define XNANDPSU_DMA_BUF_BND_256K		0x6U
#define XNANDPSU_DMA_BUF_BND_512K		0x7U
/* @} */

/** @name Slave DMA Configuration Register bit definitions and masks
 *  @{
 */
#define XNANDPSU_SLV_DMA_CONF_SDMA_TX_RX_MASK		0x00000001U /**< Slave
								     DMA
								     Transfer
								     Direction
								     */
#define XNANDPSU_SLV_DMA_CONF_DMA_TRANS_CNT_MASK	0x001FFFFEU /**< Slave
								     DMA
								     Transfer
								     Count */
#define XNANDPSU_SLV_DMA_CONF_DMA_BURST_SIZE_MASK	0x00E00000U /**< Slave
								     DMA
								     Burst
								     Size */
#define XNANDPSU_SLV_DMA_CONF_DMA_TMOUT_CNT_VAL_MASK	0x0F000000U /**< DMA
								     Timeout
								     Counter
								     Value */
#define XNANDPSU_SLV_DMA_CONF_SDMA_EN_MASK		0x10000000U /**< Slave
								     DMA
								     Enable */
/* @} */

/**************************** Type Definitions *******************************/

/***************** Macros (Inline Functions) Definitions *********************/

/****************************************************************************/
/**
*
* This macro reads the given register.
*
* @param	BaseAddress is the base address of controller registers.
* @param	RegOffset is the register offset to be read.
*
* @return	The 32-bit value of the register.
*
* @note		C-style signature:
*		u32 XNandPsu_ReadReg(u32 BaseAddress, u32 RegOffset)
*
*****************************************************************************/
#define XNandPsu_ReadReg(BaseAddress, RegOffset)			\
			Xil_In32((BaseAddress) + (RegOffset))

/****************************************************************************/
/**
*
* This macro writes the given register.
*
* @param	BaseAddress is the the base address of controller registers.
* @param	RegOffset is the register offset to be written.
* @param	Data is the the 32-bit value to write to the register.
*
* @return	None.
*
* @note		C-style signature:
*		void XNandPsu_WriteReg(u32 BaseAddress, u32 RegOffset, u32 Data)
*
******************************************************************************/
#define XNandPsu_WriteReg(BaseAddress, RegOffset, Data)			\
			Xil_Out32(((BaseAddress) + (RegOffset)), (Data))

/************************** Function Prototypes ******************************/

/************************** Variable Definitions *****************************/

#ifdef __cplusplus
}
#endif

#endif /* XNANDPSU_HW_H end of protection macro */
/** @} */