RTEMS 6.1-rc2
Loading...
Searching...
No Matches
xqspipsu_flash_config.h
Go to the documentation of this file.
1/******************************************************************************
2* Copyright (C) 2020 - 2022 Xilinx, Inc. All rights reserved.
3* SPDX-License-Identifier: MIT
4******************************************************************************/
5/*****************************************************************************/
35#ifndef XQSPIPSU_FLASH_CONFIG_H_ /* prevent circular inclusions */
36#define XQSPIPSU_FLASH_CONFIG_H_ /* by using protection macros */
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/***************************** Include Files *********************************/
43
44#include "xparameters.h" /* SDK generated parameters */
45#include "xqspipsu.h" /* QSPIPSU device driver */
46
47/************************** Constant Definitions *****************************/
48
49/*
50 * The following constants define the commands which may be sent to the Flash
51 * device.
52 */
53#define WRITE_STATUS_CMD 0x01
54#define WRITE_CMD 0x02
55#define READ_CMD 0x03
56#define WRITE_DISABLE_CMD 0x04
57#define READ_STATUS_CMD 0x05
58#define WRITE_ENABLE_CMD 0x06
59#define VOLATILE_WRITE_ENABLE_CMD 0x50
60#define QUAD_MODE_ENABLE_BIT 0x06
61#define FAST_READ_CMD 0x0B
62#define DUAL_READ_CMD 0x3B
63#define QUAD_READ_CMD 0x6B
64#define BULK_ERASE_CMD 0xC7
65#define SEC_ERASE_CMD 0xD8
66#define READ_ID 0x9F
67#define READ_SFDP 0x5A
68#define READ_CONFIG_CMD 0x35
69#define WRITE_CONFIG_CMD 0x01
70#define ENTER_4B_ADDR_MODE 0xB7
71#define EXIT_4B_ADDR_MODE 0xE9
72#define EXIT_4B_ADDR_MODE_ISSI 0x29
73/* 4-byte address opcodes */
74#define READ_CMD_4B 0x13
75#define FAST_READ_CMD_4B 0x0C
76#define DUAL_READ_CMD_4B 0x3C
77#define QUAD_READ_CMD_4B 0x6C
78#define WRITE_CMD_4B 0x12
79#define SEC_ERASE_CMD_4B 0xDC
80
81#define BANK_REG_RD 0x16
82#define BANK_REG_WR 0x17
83#define READ_ECCSR 0x18
84/* Bank register is called Extended Address Register in Micron */
85#define EXTADD_REG_RD 0xC8
86#define EXTADD_REG_WR 0xC5
87#define DIE_ERASE_CMD 0xC4
88#define READ_FLAG_STATUS_CMD 0x70
89
90#define WRITE_STATUS_REG_2_CMD 0x31
91#define READ_STATUS_REG_2_CMD 0x35
92#define WB_QUAD_MODE_ENABLE_BIT 0x01
93
94/*
95 * The following constants define the offsets within a FlashBuffer data
96 * type for each kind of data. Note that the read data offset is not the
97 * same as the write data because the QSPIPSU driver is designed to allow full
98 * duplex transfers such that the number of bytes received is the number
99 * sent and received.
100 */
101#define COMMAND_OFFSET 0 /* Flash instruction */
102#define ADDRESS_1_OFFSET 1 /* MSB byte of address to read or write */
103#define ADDRESS_2_OFFSET 2 /* Middle byte of address to read or write */
104#define ADDRESS_3_OFFSET 3 /* LSB byte of address to read or write */
105#define ADDRESS_4_OFFSET 4 /* LSB byte of address to read or write
106 * when 4 byte address
107 */
108#define DATA_OFFSET 5 /* Start of Data for Read/Write */
109#define DUMMY_OFFSET 4 /* Dummy byte offset for fast, dual and quad
110 * reads
111 */
112#define DUMMY_SIZE 1 /* Number of dummy bytes for fast, dual and
113 * quad reads
114 */
115#define DUMMY_CLOCKS 8 /* Number of dummy bytes for fast, dual and
116 * quad reads
117 */
118#define RD_ID_SIZE 4 /* Read ID command + 3 bytes ID response */
119#define BULK_ERASE_SIZE 1 /* Bulk Erase command size */
120#define SEC_ERASE_SIZE 4 /* Sector Erase command + Sector address */
121#define BANK_SEL_SIZE 2 /* BRWR or EARWR command + 1 byte bank
122 * value
123 */
124#define RD_CFG_SIZE 2 /* 1 byte Configuration register + RD CFG
125 * command
126 */
127#define WR_CFG_SIZE 3 /* WRR command + 1 byte each Status and
128 * Config Reg
129 */
130#define DIE_ERASE_SIZE 4 /* Die Erase command + Die address */
131
132/*
133 * The following constants specify the extra bytes which are sent to the
134 * Flash on the QSPIPSu interface, that are not data, but control information
135 * which includes the command and address
136 */
137#define OVERHEAD_SIZE 4
138
139/*
140 * Base address of Flash1
141 */
142#define FLASH1BASE 0x0000000
143
144/*
145 * Sixteen MB
146 */
147#define SIXTEENMB 0x1000000
148
149
150/*
151 * Mask for quad enable bit in Flash configuration register
152 */
153#define FLASH_QUAD_EN_MASK 0x02
154
155#define FLASH_SRWD_MASK 0x80
156
157/*
158 * Bank mask
159 */
160#define BANKMASK 0xF000000
161
162/*
163 * Bus width
164 */
165#define BUSWIDTH_SINGLE 0
166#define BUSWIDTH_DOUBLE 1
167
168/*
169 * Identification of Flash
170 * Micron:
171 * Byte 0 is Manufacturer ID;
172 * Byte 1 is first byte of Device ID - 0xBB or 0xBA
173 * Byte 2 is second byte of Device ID describes flash size:
174 * 128Mbit : 0x18; 256Mbit : 0x19; 512Mbit : 0x20
175 * Spansion:
176 * Byte 0 is Manufacturer ID;
177 * Byte 1 is Device ID - Memory Interface type - 0x20 or 0x02
178 * Byte 2 is second byte of Device ID describes flash size:
179 * 128Mbit : 0x18; 256Mbit : 0x19; 512Mbit : 0x20
180 */
181#define MICRON_ID_BYTE0 0x20
182#define SPANSION_ID_BYTE0 0x01
183#define WINBOND_ID_BYTE0 0xEF
184#define MACRONIX_ID_BYTE0 0xC2
185#define ISSI_ID_BYTE0 0x9D
186
187/**************************** Type Definitions *******************************/
188
189typedef struct{
190 u32 jedec_id; /* JEDEC ID */
191
192 u32 SectSize; /* Individual sector size or combined sector
193 * size in case of parallel config
194 */
195 u32 NumSect; /* Total no. of sectors in one/two
196 * flash devices
197 */
198 u32 PageSize; /* Individual page size or
199 * combined page size in case of parallel
200 * config
201 */
202 u32 NumPage; /* Total no. of pages in one/two flash
203 * devices
204 */
205 u32 FlashDeviceSize; /* This is the size of one flash device
206 * NOT the combination of both devices,
207 * if present
208 */
209 u32 SectMask; /* Mask to get sector start address */
210 u8 NumDie; /* No. of die forming a single flash */
211} FlashInfo;
212
213/************************** Variable Definitions *****************************/
214FlashInfo Flash_Config_Table[] = {
215 /* Spansion */
216 /*s25fl064l*/
218 0x8000, 0x800000, 0xFFFF0000, 1},
219 /*s25fl128l*/
221 0x10000, 0x1000000, 0xFFFF0000, 1},
222 /*s25fl256l*/
224 0x20000, 0x2000000, 0xFFFF0000, 1},
225 /*s25fl512s*/
227 0x20000, 0x4000000, 0xFFFC0000, 1},
228 /* Spansion 1Gbit is handled as 512Mbit stacked */
229 /* Micron */
230 /*n25q128a11*/
232 0x10000, 0x1000000, 0xFFFF0000, 1},
233 /*n25q128a13*/
235 0x10000, 0x1000000, 0xFFFF0000, 1},
236 /*n25q256ax1*/
238 0x20000, 0x2000000, 0xFFFF0000, 1},
239 /*n25q256a*/
241 0x20000, 0x2000000, 0xFFFF0000, 1},
242 /*mt25qu512a*/
244 0x40000, 0x4000000, 0xFFFF0000, 2},
245 /*n25q512ax3*/
247 0x40000, 0x4000000, 0xFFFF0000, 2},
248 /*n25q00a*/
250 0x80000, 0x8000000, 0xFFFF0000, 4},
251 /*n25q00*/
253 0x80000, 0x8000000, 0xFFFF0000, 4},
254 /*mt25qu02g*/
256 0x100000, 0x10000000, 0xFFFF0000, 4},
257 /*mt25ql02g*/
259 0x100000, 0x10000000, 0xFFFF0000, 4},
260 /* Winbond */
261 /*w25q128fw*/
263 0x10000, 0x1000000, 0xFFFF0000, 1},
264 /*w25q128jv*/
266 0x10000, 0x1000000, 0xFFFF0000, 1},
267 /*w25h02jv*/
269 0x100000, 0x10000000, 0xFFFF0000, 4},
270 /* Macronix */
271 /*mx66l1g45g*/
273 0x80000, 0x8000000, 0xFFFF0000, 4},
274 /*mx66l1g55g*/
276 0x80000, 0x8000000, 0xFFFF0000, 4},
277 /*mx66u1g45g*/
279 0x80000, 0x8000000, 0xFFFF0000, 4},
280 /*mx66l2g45g*/
282 0x100000, 0x10000000, 0xFFFF0000, 1},
283 /*mx66u2g45g*/
285 0x100000, 0x10000000, 0xFFFF0000, 1},
286 /* ISSI */
287 /*is25wp080d*/
289 0x1000, 0x100000, 0xFFFF0000, 1},
290 /*is25lp080d*/
292 0x1000, 0x100000, 0xFFFF0000, 1},
293 /*is25wp016d*/
295 0x2000, 0x200000, 0xFFFF0000, 1},
296 /*is25lp016d*/
298 0x2000, 0x200000, 0xFFFF0000, 1},
299 /*is25wp032*/
301 0x4000, 0x400000, 0xFFFF0000, 1},
302 /*is25lp032*/
304 0x4000, 0x400000, 0xFFFF0000, 1},
305 /*is25wp064*/
307 0x8000, 0x800000, 0xFFFF0000, 1},
308 /*is25lp064*/
310 0x8000, 0x800000, 0xFFFF0000, 1},
311 /*is25wp128*/
313 0x10000, 0x1000000, 0xFFFF0000, 1},
314 /*is25lp128*/
316 0x10000, 0x1000000, 0xFFFF0000, 1},
317 /*is25lp256d*/
319 0x20000, 0x2000000, 0xFFFF0000, 1},
320 /*is25wp256d*/
322 0x20000, 0x2000000, 0xFFFF0000, 1},
323 /*is25lp512m*/
325 0x40000, 0x4000000, 0xFFFF0000, 2},
326 /*is25wp512m*/
328 0x40000, 0x4000000, 0xFFFF0000, 2},
329 /*is25lp01g*/
331 0x80000, 0x8000000, 0xFFFF0000, 1},
332 /*is25wp01g*/
334 0x80000, 0x8000000, 0xFFFF0000, 1}
335};
336
337static INLINE u32 CalculateFCTIndex(u32 ReadId, u32 *FCTIndex)
338{
339 u32 Index;
340
341 for (Index = 0; Index < sizeof(Flash_Config_Table)/sizeof(Flash_Config_Table[0]);
342 Index++) {
343 if (ReadId == Flash_Config_Table[Index].jedec_id) {
344 *FCTIndex = Index;
345 return XST_SUCCESS;
346 }
347 }
348
349 return XST_FAILURE;
350}
351
352#ifdef __cplusplus
353}
354#endif
355
356#endif /* XQSPIPSU_FLASH_CONFIG_H_ */
#define NUM_OF_SECTORS512
Definition: xqspipsu.h:300
#define NUM_OF_SECTORS16
Definition: xqspipsu.h:295
#define SECTOR_SIZE_256K
Definition: xqspipsu.h:307
#define NUM_OF_SECTORS1024
Definition: xqspipsu.h:301
#define NUM_OF_SECTORS256
Definition: xqspipsu.h:299
#define NUM_OF_SECTORS64
Definition: xqspipsu.h:297
#define NUM_OF_SECTORS2048
Definition: xqspipsu.h:302
#define NUM_OF_SECTORS32
Definition: xqspipsu.h:296
#define NUM_OF_SECTORS4096
Definition: xqspipsu.h:303
#define BYTES256_PER_PAGE
Definition: xqspipsu.h:284
#define NUM_OF_SECTORS128
Definition: xqspipsu.h:298
#define SECTOR_SIZE_64K
Definition: xqspipsu.h:305
#define BYTES512_PER_PAGE
Definition: xqspipsu.h:285
Definition: xqspipsu_flash_config.h:175