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