blob: 4991d93220074d7ea3d31b178b8afe9a694e2575 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Dipen Dudhat00c42942011-01-20 16:29:35 +05302/*
3 * Copyright 2010-2011 Freescale Semiconductor, Inc.
4 * Author: Dipen Dudhat <dipen.dudhat@freescale.com>
Dipen Dudhat00c42942011-01-20 16:29:35 +05305 */
6
York Sun37562f62013-10-22 12:39:02 -07007#ifndef __FSL_IFC_H
8#define __FSL_IFC_H
Dipen Dudhat00c42942011-01-20 16:29:35 +05309
Mingkai Hu6f024c92013-05-16 10:18:13 +080010#ifdef CONFIG_FSL_IFC
Dipen Dudhat00c42942011-01-20 16:29:35 +053011#include <config.h>
Simon Glass655306c2020-05-10 11:39:58 -060012#include <part.h>
Simon Glass89e0a3a2017-05-17 08:23:10 -060013#ifdef CONFIG_ARM
14#include <asm/arch/soc.h>
Tom Rinidec7ea02024-05-20 13:35:03 -060015#else
16#include <asm/ppc.h>
Simon Glass89e0a3a2017-05-17 08:23:10 -060017#endif
Dipen Dudhat00c42942011-01-20 16:29:35 +053018
Prabhakar Kushwaha5c23a822014-06-14 08:48:19 +053019#define FSL_IFC_V1_1_0 0x01010000
20#define FSL_IFC_V2_0_0 0x02000000
Prabhakar Kushwaha62908c22014-01-18 12:28:30 +053021
22#ifdef CONFIG_SYS_FSL_IFC_LE
23#define ifc_in32(a) in_le32(a)
24#define ifc_out32(a, v) out_le32(a, v)
25#define ifc_in16(a) in_le16(a)
Scott Wood3ea94ed2015-06-26 19:03:26 -050026#define ifc_out16(a, v) out_le16(a, v)
Prabhakar Kushwaha62908c22014-01-18 12:28:30 +053027#elif defined(CONFIG_SYS_FSL_IFC_BE)
28#define ifc_in32(a) in_be32(a)
29#define ifc_out32(a, v) out_be32(a, v)
30#define ifc_in16(a) in_be16(a)
Scott Wood3ea94ed2015-06-26 19:03:26 -050031#define ifc_out16(a, v) out_be16(a, v)
Prabhakar Kushwaha62908c22014-01-18 12:28:30 +053032#else
33#error Neither CONFIG_SYS_FSL_IFC_LE nor CONFIG_SYS_FSL_IFC_BE is defined
34#endif
35
36
Dipen Dudhat00c42942011-01-20 16:29:35 +053037/*
38 * CSPR - Chip Select Property Register
39 */
40#define CSPR_BA 0xFFFF0000
41#define CSPR_BA_SHIFT 16
42#define CSPR_PORT_SIZE 0x00000180
43#define CSPR_PORT_SIZE_SHIFT 7
44/* Port Size 8 bit */
45#define CSPR_PORT_SIZE_8 0x00000080
46/* Port Size 16 bit */
47#define CSPR_PORT_SIZE_16 0x00000100
48/* Port Size 32 bit */
49#define CSPR_PORT_SIZE_32 0x00000180
50/* Write Protect */
51#define CSPR_WP 0x00000040
52#define CSPR_WP_SHIFT 6
53/* Machine Select */
54#define CSPR_MSEL 0x00000006
55#define CSPR_MSEL_SHIFT 1
Aleksandar Gerasimovskia944fc12020-11-26 10:45:16 +000056/* External Transceiver Enable */
57#define CSPR_TE 0x00000010
Dipen Dudhat00c42942011-01-20 16:29:35 +053058/* NOR */
59#define CSPR_MSEL_NOR 0x00000000
60/* NAND */
61#define CSPR_MSEL_NAND 0x00000002
62/* GPCM */
63#define CSPR_MSEL_GPCM 0x00000004
64/* Bank Valid */
65#define CSPR_V 0x00000001
66#define CSPR_V_SHIFT 0
67
68/* Convert an address into the right format for the CSPR Registers */
69#define CSPR_PHYS_ADDR(x) (((uint64_t)x) & 0xffff0000)
70
71/*
72 * Address Mask Register
73 */
74#define IFC_AMASK_MASK 0xFFFF0000
75#define IFC_AMASK_SHIFT 16
76#define IFC_AMASK(n) (IFC_AMASK_MASK << \
Rajesh Bhagat28663d82018-11-05 18:01:19 +000077 (LOG2(n) - IFC_AMASK_SHIFT))
Dipen Dudhat00c42942011-01-20 16:29:35 +053078
79/*
80 * Chip Select Option Register IFC_NAND Machine
81 */
82/* Enable ECC Encoder */
83#define CSOR_NAND_ECC_ENC_EN 0x80000000
Dipen Dudhat9eae0832011-03-22 09:27:39 +053084#define CSOR_NAND_ECC_MODE_MASK 0x30000000
Dipen Dudhat00c42942011-01-20 16:29:35 +053085/* 4 bit correction per 520 Byte sector */
86#define CSOR_NAND_ECC_MODE_4 0x00000000
87/* 8 bit correction per 528 Byte sector */
88#define CSOR_NAND_ECC_MODE_8 0x10000000
89/* Enable ECC Decoder */
90#define CSOR_NAND_ECC_DEC_EN 0x04000000
91/* Row Address Length */
92#define CSOR_NAND_RAL_MASK 0x01800000
93#define CSOR_NAND_RAL_SHIFT 20
94#define CSOR_NAND_RAL_1 0x00000000
95#define CSOR_NAND_RAL_2 0x00800000
96#define CSOR_NAND_RAL_3 0x01000000
97#define CSOR_NAND_RAL_4 0x01800000
98/* Page Size 512b, 2k, 4k */
99#define CSOR_NAND_PGS_MASK 0x00180000
100#define CSOR_NAND_PGS_SHIFT 16
101#define CSOR_NAND_PGS_512 0x00000000
102#define CSOR_NAND_PGS_2K 0x00080000
103#define CSOR_NAND_PGS_4K 0x00100000
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530104#define CSOR_NAND_PGS_8K 0x00180000
Dipen Dudhat00c42942011-01-20 16:29:35 +0530105/* Spare region Size */
106#define CSOR_NAND_SPRZ_MASK 0x0000E000
107#define CSOR_NAND_SPRZ_SHIFT 13
108#define CSOR_NAND_SPRZ_16 0x00000000
109#define CSOR_NAND_SPRZ_64 0x00002000
110#define CSOR_NAND_SPRZ_128 0x00004000
111#define CSOR_NAND_SPRZ_210 0x00006000
112#define CSOR_NAND_SPRZ_218 0x00008000
113#define CSOR_NAND_SPRZ_224 0x0000A000
Prabhakar Kushwahaa3aaf1d2013-10-04 10:05:36 +0530114#define CSOR_NAND_SPRZ_CSOR_EXT 0x0000C000
Dipen Dudhat00c42942011-01-20 16:29:35 +0530115/* Pages Per Block */
116#define CSOR_NAND_PB_MASK 0x00000700
117#define CSOR_NAND_PB_SHIFT 8
Rajesh Bhagat28663d82018-11-05 18:01:19 +0000118#define CSOR_NAND_PB(n) ((LOG2(n) - 5) << CSOR_NAND_PB_SHIFT)
Dipen Dudhat00c42942011-01-20 16:29:35 +0530119/* Time for Read Enable High to Output High Impedance */
120#define CSOR_NAND_TRHZ_MASK 0x0000001C
121#define CSOR_NAND_TRHZ_SHIFT 2
122#define CSOR_NAND_TRHZ_20 0x00000000
123#define CSOR_NAND_TRHZ_40 0x00000004
124#define CSOR_NAND_TRHZ_60 0x00000008
125#define CSOR_NAND_TRHZ_80 0x0000000C
126#define CSOR_NAND_TRHZ_100 0x00000010
127/* Buffer control disable */
128#define CSOR_NAND_BCTLD 0x00000001
129
130/*
131 * Chip Select Option Register - NOR Flash Mode
132 */
133/* Enable Address shift Mode */
134#define CSOR_NOR_ADM_SHFT_MODE_EN 0x80000000
135/* Page Read Enable from NOR device */
136#define CSOR_NOR_PGRD_EN 0x10000000
137/* AVD Toggle Enable during Burst Program */
138#define CSOR_NOR_AVD_TGL_PGM_EN 0x01000000
139/* Address Data Multiplexing Shift */
140#define CSOR_NOR_ADM_MASK 0x0003E000
141#define CSOR_NOR_ADM_SHIFT_SHIFT 13
142#define CSOR_NOR_ADM_SHIFT(n) ((n) << CSOR_NOR_ADM_SHIFT_SHIFT)
143/* Type of the NOR device hooked */
Aleksandar Gerasimovski5b98a3b2021-02-22 18:15:58 +0000144#define CSOR_NOR_NOR_MODE_ASYNC_NOR 0x00000000
Dipen Dudhat00c42942011-01-20 16:29:35 +0530145#define CSOR_NOR_NOR_MODE_AVD_NOR 0x00000020
146/* Time for Read Enable High to Output High Impedance */
147#define CSOR_NOR_TRHZ_MASK 0x0000001C
148#define CSOR_NOR_TRHZ_SHIFT 2
149#define CSOR_NOR_TRHZ_20 0x00000000
150#define CSOR_NOR_TRHZ_40 0x00000004
151#define CSOR_NOR_TRHZ_60 0x00000008
152#define CSOR_NOR_TRHZ_80 0x0000000C
153#define CSOR_NOR_TRHZ_100 0x00000010
154/* Buffer control disable */
155#define CSOR_NOR_BCTLD 0x00000001
156
157/*
158 * Chip Select Option Register - GPCM Mode
159 */
160/* GPCM Mode - Normal */
161#define CSOR_GPCM_GPMODE_NORMAL 0x00000000
162/* GPCM Mode - GenericASIC */
163#define CSOR_GPCM_GPMODE_ASIC 0x80000000
164/* Parity Mode odd/even */
165#define CSOR_GPCM_PARITY_EVEN 0x40000000
166/* Parity Checking enable/disable */
167#define CSOR_GPCM_PAR_EN 0x20000000
168/* GPCM Timeout Count */
169#define CSOR_GPCM_GPTO_MASK 0x0F000000
170#define CSOR_GPCM_GPTO_SHIFT 24
Rajesh Bhagat28663d82018-11-05 18:01:19 +0000171#define CSOR_GPCM_GPTO(n) ((LOG2(n) - 8) << CSOR_GPCM_GPTO_SHIFT)
Dipen Dudhat00c42942011-01-20 16:29:35 +0530172/* GPCM External Access Termination mode for read access */
173#define CSOR_GPCM_RGETA_EXT 0x00080000
174/* GPCM External Access Termination mode for write access */
175#define CSOR_GPCM_WGETA_EXT 0x00040000
176/* Address Data Multiplexing Shift */
177#define CSOR_GPCM_ADM_MASK 0x0003E000
178#define CSOR_GPCM_ADM_SHIFT_SHIFT 13
179#define CSOR_GPCM_ADM_SHIFT(n) ((n) << CSOR_GPCM_ADM_SHIFT_SHIFT)
180/* Generic ASIC Parity error indication delay */
181#define CSOR_GPCM_GAPERRD_MASK 0x00000180
182#define CSOR_GPCM_GAPERRD_SHIFT 7
183#define CSOR_GPCM_GAPERRD(n) (((n) - 1) << CSOR_GPCM_GAPERRD_SHIFT)
184/* Time for Read Enable High to Output High Impedance */
185#define CSOR_GPCM_TRHZ_MASK 0x0000001C
186#define CSOR_GPCM_TRHZ_20 0x00000000
187#define CSOR_GPCM_TRHZ_40 0x00000004
188#define CSOR_GPCM_TRHZ_60 0x00000008
189#define CSOR_GPCM_TRHZ_80 0x0000000C
190#define CSOR_GPCM_TRHZ_100 0x00000010
191/* Buffer control disable */
192#define CSOR_GPCM_BCTLD 0x00000001
193
194/*
195 * Flash Timing Registers (FTIM0 - FTIM2_CSn)
196 */
197/*
198 * FTIM0 - NAND Flash Mode
199 */
200#define FTIM0_NAND 0x7EFF3F3F
201#define FTIM0_NAND_TCCST_SHIFT 25
202#define FTIM0_NAND_TCCST(n) ((n) << FTIM0_NAND_TCCST_SHIFT)
203#define FTIM0_NAND_TWP_SHIFT 16
204#define FTIM0_NAND_TWP(n) ((n) << FTIM0_NAND_TWP_SHIFT)
205#define FTIM0_NAND_TWCHT_SHIFT 8
206#define FTIM0_NAND_TWCHT(n) ((n) << FTIM0_NAND_TWCHT_SHIFT)
207#define FTIM0_NAND_TWH_SHIFT 0
208#define FTIM0_NAND_TWH(n) ((n) << FTIM0_NAND_TWH_SHIFT)
209/*
210 * FTIM1 - NAND Flash Mode
211 */
212#define FTIM1_NAND 0xFFFF3FFF
213#define FTIM1_NAND_TADLE_SHIFT 24
214#define FTIM1_NAND_TADLE(n) ((n) << FTIM1_NAND_TADLE_SHIFT)
215#define FTIM1_NAND_TWBE_SHIFT 16
216#define FTIM1_NAND_TWBE(n) ((n) << FTIM1_NAND_TWBE_SHIFT)
217#define FTIM1_NAND_TRR_SHIFT 8
218#define FTIM1_NAND_TRR(n) ((n) << FTIM1_NAND_TRR_SHIFT)
219#define FTIM1_NAND_TRP_SHIFT 0
220#define FTIM1_NAND_TRP(n) ((n) << FTIM1_NAND_TRP_SHIFT)
221/*
222 * FTIM2 - NAND Flash Mode
223 */
224#define FTIM2_NAND 0x1FE1F8FF
225#define FTIM2_NAND_TRAD_SHIFT 21
226#define FTIM2_NAND_TRAD(n) ((n) << FTIM2_NAND_TRAD_SHIFT)
227#define FTIM2_NAND_TREH_SHIFT 11
228#define FTIM2_NAND_TREH(n) ((n) << FTIM2_NAND_TREH_SHIFT)
229#define FTIM2_NAND_TWHRE_SHIFT 0
230#define FTIM2_NAND_TWHRE(n) ((n) << FTIM2_NAND_TWHRE_SHIFT)
231/*
232 * FTIM3 - NAND Flash Mode
233 */
234#define FTIM3_NAND 0xFF000000
235#define FTIM3_NAND_TWW_SHIFT 24
236#define FTIM3_NAND_TWW(n) ((n) << FTIM3_NAND_TWW_SHIFT)
237
238/*
239 * FTIM0 - NOR Flash Mode
240 */
241#define FTIM0_NOR 0xF03F3F3F
242#define FTIM0_NOR_TACSE_SHIFT 28
243#define FTIM0_NOR_TACSE(n) ((n) << FTIM0_NOR_TACSE_SHIFT)
244#define FTIM0_NOR_TEADC_SHIFT 16
245#define FTIM0_NOR_TEADC(n) ((n) << FTIM0_NOR_TEADC_SHIFT)
246#define FTIM0_NOR_TAVDS_SHIFT 8
247#define FTIM0_NOR_TAVDS(n) ((n) << FTIM0_NOR_TAVDS_SHIFT)
248#define FTIM0_NOR_TEAHC_SHIFT 0
249#define FTIM0_NOR_TEAHC(n) ((n) << FTIM0_NOR_TEAHC_SHIFT)
250/*
251 * FTIM1 - NOR Flash Mode
252 */
253#define FTIM1_NOR 0xFF003F3F
254#define FTIM1_NOR_TACO_SHIFT 24
255#define FTIM1_NOR_TACO(n) ((n) << FTIM1_NOR_TACO_SHIFT)
256#define FTIM1_NOR_TRAD_NOR_SHIFT 8
257#define FTIM1_NOR_TRAD_NOR(n) ((n) << FTIM1_NOR_TRAD_NOR_SHIFT)
258#define FTIM1_NOR_TSEQRAD_NOR_SHIFT 0
259#define FTIM1_NOR_TSEQRAD_NOR(n) ((n) << FTIM1_NOR_TSEQRAD_NOR_SHIFT)
260/*
261 * FTIM2 - NOR Flash Mode
262 */
263#define FTIM2_NOR 0x0F3CFCFF
264#define FTIM2_NOR_TCS_SHIFT 24
265#define FTIM2_NOR_TCS(n) ((n) << FTIM2_NOR_TCS_SHIFT)
266#define FTIM2_NOR_TCH_SHIFT 18
267#define FTIM2_NOR_TCH(n) ((n) << FTIM2_NOR_TCH_SHIFT)
268#define FTIM2_NOR_TWPH_SHIFT 10
269#define FTIM2_NOR_TWPH(n) ((n) << FTIM2_NOR_TWPH_SHIFT)
270#define FTIM2_NOR_TWP_SHIFT 0
271#define FTIM2_NOR_TWP(n) ((n) << FTIM2_NOR_TWP_SHIFT)
272
273/*
274 * FTIM0 - Normal GPCM Mode
275 */
276#define FTIM0_GPCM 0xF03F3F3F
277#define FTIM0_GPCM_TACSE_SHIFT 28
278#define FTIM0_GPCM_TACSE(n) ((n) << FTIM0_GPCM_TACSE_SHIFT)
279#define FTIM0_GPCM_TEADC_SHIFT 16
280#define FTIM0_GPCM_TEADC(n) ((n) << FTIM0_GPCM_TEADC_SHIFT)
281#define FTIM0_GPCM_TAVDS_SHIFT 8
282#define FTIM0_GPCM_TAVDS(n) ((n) << FTIM0_GPCM_TAVDS_SHIFT)
283#define FTIM0_GPCM_TEAHC_SHIFT 0
284#define FTIM0_GPCM_TEAHC(n) ((n) << FTIM0_GPCM_TEAHC_SHIFT)
285/*
286 * FTIM1 - Normal GPCM Mode
287 */
288#define FTIM1_GPCM 0xFF003F00
289#define FTIM1_GPCM_TACO_SHIFT 24
290#define FTIM1_GPCM_TACO(n) ((n) << FTIM1_GPCM_TACO_SHIFT)
291#define FTIM1_GPCM_TRAD_SHIFT 8
292#define FTIM1_GPCM_TRAD(n) ((n) << FTIM1_GPCM_TRAD_SHIFT)
293/*
294 * FTIM2 - Normal GPCM Mode
295 */
296#define FTIM2_GPCM 0x0F3C00FF
297#define FTIM2_GPCM_TCS_SHIFT 24
298#define FTIM2_GPCM_TCS(n) ((n) << FTIM2_GPCM_TCS_SHIFT)
299#define FTIM2_GPCM_TCH_SHIFT 18
300#define FTIM2_GPCM_TCH(n) ((n) << FTIM2_GPCM_TCH_SHIFT)
301#define FTIM2_GPCM_TWP_SHIFT 0
302#define FTIM2_GPCM_TWP(n) ((n) << FTIM2_GPCM_TWP_SHIFT)
303
304/*
305 * Ready Busy Status Register (RB_STAT)
306 */
307/* CSn is READY */
308#define IFC_RB_STAT_READY_CS0 0x80000000
309#define IFC_RB_STAT_READY_CS1 0x40000000
310#define IFC_RB_STAT_READY_CS2 0x20000000
311#define IFC_RB_STAT_READY_CS3 0x10000000
312
313/*
314 * General Control Register (GCR)
315 */
316#define IFC_GCR_MASK 0x8000F800
317/* reset all IFC hardware */
318#define IFC_GCR_SOFT_RST_ALL 0x80000000
319/* Turnaroud Time of external buffer */
320#define IFC_GCR_TBCTL_TRN_TIME 0x0000F800
321#define IFC_GCR_TBCTL_TRN_TIME_SHIFT 11
322
323/*
324 * Common Event and Error Status Register (CM_EVTER_STAT)
325 */
326/* Chip select error */
327#define IFC_CM_EVTER_STAT_CSER 0x80000000
328
329/*
330 * Common Event and Error Enable Register (CM_EVTER_EN)
331 */
332/* Chip select error checking enable */
333#define IFC_CM_EVTER_EN_CSEREN 0x80000000
334
335/*
336 * Common Event and Error Interrupt Enable Register (CM_EVTER_INTR_EN)
337 */
338/* Chip select error interrupt enable */
339#define IFC_CM_EVTER_INTR_EN_CSERIREN 0x80000000
340
341/*
342 * Common Transfer Error Attribute Register-0 (CM_ERATTR0)
343 */
344/* transaction type of error Read/Write */
345#define IFC_CM_ERATTR0_ERTYP_READ 0x80000000
346#define IFC_CM_ERATTR0_ERAID 0x0FF00000
347#define IFC_CM_ERATTR0_ESRCID 0x0000FF00
348
349/*
350 * Clock Control Register (CCR)
351 */
352#define IFC_CCR_MASK 0x0F0F8800
353/* Clock division ratio */
354#define IFC_CCR_CLK_DIV_MASK 0x0F000000
355#define IFC_CCR_CLK_DIV_SHIFT 24
356#define IFC_CCR_CLK_DIV(n) ((n-1) << IFC_CCR_CLK_DIV_SHIFT)
357/* IFC Clock Delay */
358#define IFC_CCR_CLK_DLY_MASK 0x000F0000
359#define IFC_CCR_CLK_DLY_SHIFT 16
360#define IFC_CCR_CLK_DLY(n) ((n) << IFC_CCR_CLK_DLY_SHIFT)
361/* Invert IFC clock before sending out */
362#define IFC_CCR_INV_CLK_EN 0x00008000
363/* Fedback IFC Clock */
364#define IFC_CCR_FB_IFC_CLK_SEL 0x00000800
365
366/*
367 * Clock Status Register (CSR)
368 */
369/* Clk is stable */
370#define IFC_CSR_CLK_STAT_STABLE 0x80000000
371
372/*
373 * IFC_NAND Machine Specific Registers
374 */
375/*
376 * NAND Configuration Register (NCFGR)
377 */
378/* Auto Boot Mode */
379#define IFC_NAND_NCFGR_BOOT 0x80000000
Prabhakar Kushwaha82efc812014-06-12 12:14:00 +0530380/* SRAM INIT EN */
381#define IFC_NAND_SRAM_INIT_EN 0x20000000
Dipen Dudhat00c42942011-01-20 16:29:35 +0530382/* Addressing Mode-ROW0+n/COL0 */
383#define IFC_NAND_NCFGR_ADDR_MODE_RC0 0x00000000
384/* Addressing Mode-ROW0+n/COL0+n */
385#define IFC_NAND_NCFGR_ADDR_MODE_RC1 0x00400000
386/* Number of loop iterations of FIR sequences for multi page operations */
387#define IFC_NAND_NCFGR_NUM_LOOP_MASK 0x0000F000
388#define IFC_NAND_NCFGR_NUM_LOOP_SHIFT 12
389#define IFC_NAND_NCFGR_NUM_LOOP(n) ((n) << IFC_NAND_NCFGR_NUM_LOOP_SHIFT)
390/* Number of wait cycles */
391#define IFC_NAND_NCFGR_NUM_WAIT_MASK 0x000000FF
392#define IFC_NAND_NCFGR_NUM_WAIT_SHIFT 0
393
394/*
395 * NAND Flash Command Registers (NAND_FCR0/NAND_FCR1)
396 */
397/* General purpose FCM flash command bytes CMD0-CMD7 */
398#define IFC_NAND_FCR0_CMD0 0xFF000000
399#define IFC_NAND_FCR0_CMD0_SHIFT 24
400#define IFC_NAND_FCR0_CMD1 0x00FF0000
401#define IFC_NAND_FCR0_CMD1_SHIFT 16
402#define IFC_NAND_FCR0_CMD2 0x0000FF00
403#define IFC_NAND_FCR0_CMD2_SHIFT 8
404#define IFC_NAND_FCR0_CMD3 0x000000FF
405#define IFC_NAND_FCR0_CMD3_SHIFT 0
406#define IFC_NAND_FCR1_CMD4 0xFF000000
407#define IFC_NAND_FCR1_CMD4_SHIFT 24
408#define IFC_NAND_FCR1_CMD5 0x00FF0000
409#define IFC_NAND_FCR1_CMD5_SHIFT 16
410#define IFC_NAND_FCR1_CMD6 0x0000FF00
411#define IFC_NAND_FCR1_CMD6_SHIFT 8
412#define IFC_NAND_FCR1_CMD7 0x000000FF
413#define IFC_NAND_FCR1_CMD7_SHIFT 0
414
415/*
416 * Flash ROW and COL Address Register (ROWn, COLn)
417 */
418/* Main/spare region locator */
419#define IFC_NAND_COL_MS 0x80000000
420/* Column Address */
421#define IFC_NAND_COL_CA_MASK 0x00000FFF
422
423/*
424 * NAND Flash Byte Count Register (NAND_BC)
425 */
426/* Byte Count for read/Write */
427#define IFC_NAND_BC 0x000001FF
428
429/*
430 * NAND Flash Instruction Registers (NAND_FIR0/NAND_FIR1/NAND_FIR2)
431 */
432/* NAND Machine specific opcodes OP0-OP14*/
433#define IFC_NAND_FIR0_OP0 0xFC000000
434#define IFC_NAND_FIR0_OP0_SHIFT 26
435#define IFC_NAND_FIR0_OP1 0x03F00000
436#define IFC_NAND_FIR0_OP1_SHIFT 20
437#define IFC_NAND_FIR0_OP2 0x000FC000
438#define IFC_NAND_FIR0_OP2_SHIFT 14
439#define IFC_NAND_FIR0_OP3 0x00003F00
440#define IFC_NAND_FIR0_OP3_SHIFT 8
441#define IFC_NAND_FIR0_OP4 0x000000FC
442#define IFC_NAND_FIR0_OP4_SHIFT 2
443#define IFC_NAND_FIR1_OP5 0xFC000000
444#define IFC_NAND_FIR1_OP5_SHIFT 26
445#define IFC_NAND_FIR1_OP6 0x03F00000
446#define IFC_NAND_FIR1_OP6_SHIFT 20
447#define IFC_NAND_FIR1_OP7 0x000FC000
448#define IFC_NAND_FIR1_OP7_SHIFT 14
449#define IFC_NAND_FIR1_OP8 0x00003F00
450#define IFC_NAND_FIR1_OP8_SHIFT 8
451#define IFC_NAND_FIR1_OP9 0x000000FC
452#define IFC_NAND_FIR1_OP9_SHIFT 2
453#define IFC_NAND_FIR2_OP10 0xFC000000
454#define IFC_NAND_FIR2_OP10_SHIFT 26
455#define IFC_NAND_FIR2_OP11 0x03F00000
456#define IFC_NAND_FIR2_OP11_SHIFT 20
457#define IFC_NAND_FIR2_OP12 0x000FC000
458#define IFC_NAND_FIR2_OP12_SHIFT 14
459#define IFC_NAND_FIR2_OP13 0x00003F00
460#define IFC_NAND_FIR2_OP13_SHIFT 8
461#define IFC_NAND_FIR2_OP14 0x000000FC
462#define IFC_NAND_FIR2_OP14_SHIFT 2
463
464/*
465 * Instruction opcodes to be programmed
466 * in FIR registers- 6bits
467 */
468enum ifc_nand_fir_opcodes {
469 IFC_FIR_OP_NOP,
470 IFC_FIR_OP_CA0,
471 IFC_FIR_OP_CA1,
472 IFC_FIR_OP_CA2,
473 IFC_FIR_OP_CA3,
474 IFC_FIR_OP_RA0,
475 IFC_FIR_OP_RA1,
476 IFC_FIR_OP_RA2,
477 IFC_FIR_OP_RA3,
478 IFC_FIR_OP_CMD0,
479 IFC_FIR_OP_CMD1,
480 IFC_FIR_OP_CMD2,
481 IFC_FIR_OP_CMD3,
482 IFC_FIR_OP_CMD4,
483 IFC_FIR_OP_CMD5,
484 IFC_FIR_OP_CMD6,
485 IFC_FIR_OP_CMD7,
486 IFC_FIR_OP_CW0,
487 IFC_FIR_OP_CW1,
488 IFC_FIR_OP_CW2,
489 IFC_FIR_OP_CW3,
490 IFC_FIR_OP_CW4,
491 IFC_FIR_OP_CW5,
492 IFC_FIR_OP_CW6,
493 IFC_FIR_OP_CW7,
494 IFC_FIR_OP_WBCD,
495 IFC_FIR_OP_RBCD,
496 IFC_FIR_OP_BTRD,
497 IFC_FIR_OP_RDSTAT,
498 IFC_FIR_OP_NWAIT,
499 IFC_FIR_OP_WFR,
500 IFC_FIR_OP_SBRD,
501 IFC_FIR_OP_UA,
502 IFC_FIR_OP_RB,
503};
504
505/*
506 * NAND Chip Select Register (NAND_CSEL)
507 */
508#define IFC_NAND_CSEL 0x0C000000
509#define IFC_NAND_CSEL_SHIFT 26
510#define IFC_NAND_CSEL_CS0 0x00000000
511#define IFC_NAND_CSEL_CS1 0x04000000
512#define IFC_NAND_CSEL_CS2 0x08000000
513#define IFC_NAND_CSEL_CS3 0x0C000000
514
515/*
516 * NAND Operation Sequence Start (NANDSEQ_STRT)
517 */
518/* NAND Flash Operation Start */
519#define IFC_NAND_SEQ_STRT_FIR_STRT 0x80000000
520/* Automatic Erase */
521#define IFC_NAND_SEQ_STRT_AUTO_ERS 0x00800000
522/* Automatic Program */
523#define IFC_NAND_SEQ_STRT_AUTO_PGM 0x00100000
524/* Automatic Copyback */
525#define IFC_NAND_SEQ_STRT_AUTO_CPB 0x00020000
526/* Automatic Read Operation */
527#define IFC_NAND_SEQ_STRT_AUTO_RD 0x00004000
528/* Automatic Status Read */
529#define IFC_NAND_SEQ_STRT_AUTO_STAT_RD 0x00000800
530
531/*
532 * NAND Event and Error Status Register (NAND_EVTER_STAT)
533 */
534/* Operation Complete */
535#define IFC_NAND_EVTER_STAT_OPC 0x80000000
536/* Flash Timeout Error */
537#define IFC_NAND_EVTER_STAT_FTOER 0x08000000
538/* Write Protect Error */
539#define IFC_NAND_EVTER_STAT_WPER 0x04000000
540/* ECC Error */
541#define IFC_NAND_EVTER_STAT_ECCER 0x02000000
542/* RCW Load Done */
543#define IFC_NAND_EVTER_STAT_RCW_DN 0x00008000
544/* Boot Loadr Done */
545#define IFC_NAND_EVTER_STAT_BOOT_DN 0x00004000
546/* Bad Block Indicator search select */
547#define IFC_NAND_EVTER_STAT_BBI_SRCH_SE 0x00000800
548
549/*
550 * NAND Flash Page Read Completion Event Status Register
551 * (PGRDCMPL_EVT_STAT)
552 */
553#define PGRDCMPL_EVT_STAT_MASK 0xFFFF0000
554/* Small Page 0-15 Done */
555#define PGRDCMPL_EVT_STAT_SECTION_SP(n) (1 << (31 - (n)))
556/* Large Page(2K) 0-3 Done */
557#define PGRDCMPL_EVT_STAT_LP_2K(n) (0xF << (28 - (n)*4))
558/* Large Page(4K) 0-1 Done */
559#define PGRDCMPL_EVT_STAT_LP_4K(n) (0xFF << (24 - (n)*8))
560
561/*
562 * NAND Event and Error Enable Register (NAND_EVTER_EN)
563 */
564/* Operation complete event enable */
565#define IFC_NAND_EVTER_EN_OPC_EN 0x80000000
566/* Page read complete event enable */
567#define IFC_NAND_EVTER_EN_PGRDCMPL_EN 0x20000000
568/* Flash Timeout error enable */
569#define IFC_NAND_EVTER_EN_FTOER_EN 0x08000000
570/* Write Protect error enable */
571#define IFC_NAND_EVTER_EN_WPER_EN 0x04000000
572/* ECC error logging enable */
573#define IFC_NAND_EVTER_EN_ECCER_EN 0x02000000
574
575/*
576 * NAND Event and Error Interrupt Enable Register (NAND_EVTER_INTR_EN)
577 */
578/* Enable interrupt for operation complete */
579#define IFC_NAND_EVTER_INTR_OPCIR_EN 0x80000000
580/* Enable interrupt for Page read complete */
581#define IFC_NAND_EVTER_INTR_PGRDCMPLIR_EN 0x20000000
582/* Enable interrupt for Flash timeout error */
583#define IFC_NAND_EVTER_INTR_FTOERIR_EN 0x08000000
584/* Enable interrupt for Write protect error */
585#define IFC_NAND_EVTER_INTR_WPERIR_EN 0x04000000
586/* Enable interrupt for ECC error*/
587#define IFC_NAND_EVTER_INTR_ECCERIR_EN 0x02000000
588
589/*
590 * NAND Transfer Error Attribute Register-0 (NAND_ERATTR0)
591 */
592#define IFC_NAND_ERATTR0_MASK 0x0C080000
593/* Error on CS0-3 for NAND */
594#define IFC_NAND_ERATTR0_ERCS_CS0 0x00000000
595#define IFC_NAND_ERATTR0_ERCS_CS1 0x04000000
596#define IFC_NAND_ERATTR0_ERCS_CS2 0x08000000
597#define IFC_NAND_ERATTR0_ERCS_CS3 0x0C000000
598/* Transaction type of error Read/Write */
599#define IFC_NAND_ERATTR0_ERTTYPE_READ 0x00080000
600
601/*
602 * NAND Flash Status Register (NAND_FSR)
603 */
604/* First byte of data read from read status op */
605#define IFC_NAND_NFSR_RS0 0xFF000000
606/* Second byte of data read from read status op */
607#define IFC_NAND_NFSR_RS1 0x00FF0000
608
609/*
610 * ECC Error Status Registers (ECCSTAT0-ECCSTAT3)
611 */
612/* Number of ECC errors on sector n (n = 0-15) */
613#define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR0_MASK 0x0F000000
614#define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR0_SHIFT 24
615#define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR1_MASK 0x000F0000
616#define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR1_SHIFT 16
617#define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR2_MASK 0x00000F00
618#define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR2_SHIFT 8
619#define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR3_MASK 0x0000000F
620#define IFC_NAND_ECCSTAT0_ERRCNT_SECTOR3_SHIFT 0
621#define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR4_MASK 0x0F000000
622#define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR4_SHIFT 24
623#define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR5_MASK 0x000F0000
624#define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR5_SHIFT 16
625#define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR6_MASK 0x00000F00
626#define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR6_SHIFT 8
627#define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR7_MASK 0x0000000F
628#define IFC_NAND_ECCSTAT1_ERRCNT_SECTOR7_SHIFT 0
629#define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR8_MASK 0x0F000000
630#define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR8_SHIFT 24
631#define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR9_MASK 0x000F0000
632#define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR9_SHIFT 16
633#define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR10_MASK 0x00000F00
634#define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR10_SHIFT 8
635#define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR11_MASK 0x0000000F
636#define IFC_NAND_ECCSTAT2_ERRCNT_SECTOR11_SHIFT 0
637#define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR12_MASK 0x0F000000
638#define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR12_SHIFT 24
639#define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR13_MASK 0x000F0000
640#define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR13_SHIFT 16
641#define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR14_MASK 0x00000F00
642#define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR14_SHIFT 8
643#define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR15_MASK 0x0000000F
644#define IFC_NAND_ECCSTAT3_ERRCNT_SECTOR15_SHIFT 0
645
646/*
647 * NAND Control Register (NANDCR)
648 */
649#define IFC_NAND_NCR_FTOCNT_MASK 0x1E000000
650#define IFC_NAND_NCR_FTOCNT_SHIFT 25
Rajesh Bhagat28663d82018-11-05 18:01:19 +0000651#define IFC_NAND_NCR_FTOCNT(n) ((LOG2(n) - 8) << IFC_NAND_NCR_FTOCNT_SHIFT)
Dipen Dudhat00c42942011-01-20 16:29:35 +0530652
653/*
654 * NAND_AUTOBOOT_TRGR
655 */
656/* Trigger RCW load */
657#define IFC_NAND_AUTOBOOT_TRGR_RCW_LD 0x80000000
658/* Trigget Auto Boot */
659#define IFC_NAND_AUTOBOOT_TRGR_BOOT_LD 0x20000000
660
661/*
662 * NAND_MDR
663 */
664/* 1st read data byte when opcode SBRD */
665#define IFC_NAND_MDR_RDATA0 0xFF000000
666/* 2nd read data byte when opcode SBRD */
667#define IFC_NAND_MDR_RDATA1 0x00FF0000
668
669/*
670 * NOR Machine Specific Registers
671 */
672/*
673 * NOR Event and Error Status Register (NOR_EVTER_STAT)
674 */
675/* NOR Command Sequence Operation Complete */
676#define IFC_NOR_EVTER_STAT_OPC_NOR 0x80000000
677/* Write Protect Error */
678#define IFC_NOR_EVTER_STAT_WPER 0x04000000
679/* Command Sequence Timeout Error */
680#define IFC_NOR_EVTER_STAT_STOER 0x01000000
681
682/*
683 * NOR Event and Error Enable Register (NOR_EVTER_EN)
684 */
685/* NOR Command Seq complete event enable */
686#define IFC_NOR_EVTER_EN_OPCEN_NOR 0x80000000
687/* Write Protect Error Checking Enable */
688#define IFC_NOR_EVTER_EN_WPEREN 0x04000000
689/* Timeout Error Enable */
690#define IFC_NOR_EVTER_EN_STOEREN 0x01000000
691
692/*
693 * NOR Event and Error Interrupt Enable Register (NOR_EVTER_INTR_EN)
694 */
695/* Enable interrupt for OPC complete */
696#define IFC_NOR_EVTER_INTR_OPCEN_NOR 0x80000000
697/* Enable interrupt for write protect error */
698#define IFC_NOR_EVTER_INTR_WPEREN 0x04000000
699/* Enable interrupt for timeout error */
700#define IFC_NOR_EVTER_INTR_STOEREN 0x01000000
701
702/*
703 * NOR Transfer Error Attribute Register-0 (NOR_ERATTR0)
704 */
705/* Source ID for error transaction */
706#define IFC_NOR_ERATTR0_ERSRCID 0xFF000000
707/* AXI ID for error transation */
708#define IFC_NOR_ERATTR0_ERAID 0x000FF000
709/* Chip select corresponds to NOR error */
710#define IFC_NOR_ERATTR0_ERCS_CS0 0x00000000
711#define IFC_NOR_ERATTR0_ERCS_CS1 0x00000010
712#define IFC_NOR_ERATTR0_ERCS_CS2 0x00000020
713#define IFC_NOR_ERATTR0_ERCS_CS3 0x00000030
714/* Type of transaction read/write */
715#define IFC_NOR_ERATTR0_ERTYPE_READ 0x00000001
716
717/*
718 * NOR Transfer Error Attribute Register-2 (NOR_ERATTR2)
719 */
720#define IFC_NOR_ERATTR2_ER_NUM_PHASE_EXP 0x000F0000
721#define IFC_NOR_ERATTR2_ER_NUM_PHASE_PER 0x00000F00
722
723/*
724 * NOR Control Register (NORCR)
725 */
726#define IFC_NORCR_MASK 0x0F0F0000
727/* No. of Address/Data Phase */
728#define IFC_NORCR_NUM_PHASE_MASK 0x0F000000
729#define IFC_NORCR_NUM_PHASE_SHIFT 24
730#define IFC_NORCR_NUM_PHASE(n) ((n-1) << IFC_NORCR_NUM_PHASE_SHIFT)
731/* Sequence Timeout Count */
732#define IFC_NORCR_STOCNT_MASK 0x000F0000
733#define IFC_NORCR_STOCNT_SHIFT 16
Rajesh Bhagat28663d82018-11-05 18:01:19 +0000734#define IFC_NORCR_STOCNT(n) ((LOG2(n) - 8) << IFC_NORCR_STOCNT_SHIFT)
Dipen Dudhat00c42942011-01-20 16:29:35 +0530735
736/*
737 * GPCM Machine specific registers
738 */
739/*
740 * GPCM Event and Error Status Register (GPCM_EVTER_STAT)
741 */
742/* Timeout error */
743#define IFC_GPCM_EVTER_STAT_TOER 0x04000000
744/* Parity error */
745#define IFC_GPCM_EVTER_STAT_PER 0x01000000
746
747/*
748 * GPCM Event and Error Enable Register (GPCM_EVTER_EN)
749 */
750/* Timeout error enable */
751#define IFC_GPCM_EVTER_EN_TOER_EN 0x04000000
752/* Parity error enable */
753#define IFC_GPCM_EVTER_EN_PER_EN 0x01000000
754
755/*
756 * GPCM Event and Error Interrupt Enable Register (GPCM_EVTER_INTR_EN)
757 */
758/* Enable Interrupt for timeout error */
759#define IFC_GPCM_EEIER_TOERIR_EN 0x04000000
760/* Enable Interrupt for Parity error */
761#define IFC_GPCM_EEIER_PERIR_EN 0x01000000
762
763/*
764 * GPCM Transfer Error Attribute Register-0 (GPCM_ERATTR0)
765 */
766/* Source ID for error transaction */
767#define IFC_GPCM_ERATTR0_ERSRCID 0xFF000000
768/* AXI ID for error transaction */
769#define IFC_GPCM_ERATTR0_ERAID 0x000FF000
770/* Chip select corresponds to GPCM error */
771#define IFC_GPCM_ERATTR0_ERCS_CS0 0x00000000
772#define IFC_GPCM_ERATTR0_ERCS_CS1 0x00000040
773#define IFC_GPCM_ERATTR0_ERCS_CS2 0x00000080
774#define IFC_GPCM_ERATTR0_ERCS_CS3 0x000000C0
775/* Type of transaction read/Write */
776#define IFC_GPCM_ERATTR0_ERTYPE_READ 0x00000001
777
778/*
779 * GPCM Transfer Error Attribute Register-2 (GPCM_ERATTR2)
780 */
781/* On which beat of address/data parity error is observed */
782#define IFC_GPCM_ERATTR2_PERR_BEAT 0x00000C00
783/* Parity Error on byte */
784#define IFC_GPCM_ERATTR2_PERR_BYTE 0x000000F0
785/* Parity Error reported in addr or data phase */
786#define IFC_GPCM_ERATTR2_PERR_DATA_PHASE 0x00000001
787
788/*
789 * GPCM Status Register (GPCM_STAT)
790 */
791#define IFC_GPCM_STAT_BSY 0x80000000 /* GPCM is busy */
792
793
794#ifndef __ASSEMBLY__
795#include <asm/io.h>
796
797extern void print_ifc_regs(void);
798extern void init_early_memctl_regs(void);
York Sund377b612014-03-19 13:52:34 -0700799void init_final_memctl_regs(void);
Dipen Dudhat00c42942011-01-20 16:29:35 +0530800
Jaiprakash Singhdd888062015-03-20 19:28:27 -0700801#define IFC_RREGS_4KOFFSET (4*1024)
802#define IFC_RREGS_64KOFFSET (64*1024)
Dipen Dudhat00c42942011-01-20 16:29:35 +0530803
Jaiprakash Singhdd888062015-03-20 19:28:27 -0700804#define IFC_FCM_BASE_ADDR \
Tom Rini6a5dccc2022-11-16 13:10:41 -0500805 ((struct fsl_ifc_fcm *)CFG_SYS_IFC_ADDR)
Dipen Dudhat00c42942011-01-20 16:29:35 +0530806
Jaiprakash Singhdd888062015-03-20 19:28:27 -0700807#define get_ifc_cspr_ext(i) \
808 (ifc_in32(&(IFC_FCM_BASE_ADDR)->cspr_cs[i].cspr_ext))
809#define get_ifc_cspr(i) \
810 (ifc_in32(&(IFC_FCM_BASE_ADDR)->cspr_cs[i].cspr))
811#define get_ifc_csor_ext(i) \
812 (ifc_in32(&(IFC_FCM_BASE_ADDR)->csor_cs[i].csor_ext))
813#define get_ifc_csor(i) \
814 (ifc_in32(&(IFC_FCM_BASE_ADDR)->csor_cs[i].csor))
815#define get_ifc_amask(i) \
816 (ifc_in32(&(IFC_FCM_BASE_ADDR)->amask_cs[i].amask))
817#define get_ifc_ftim(i, j) \
818 (ifc_in32(&(IFC_FCM_BASE_ADDR)->ftim_cs[i].ftim[j]))
819#define set_ifc_cspr_ext(i, v) \
820 (ifc_out32(&(IFC_FCM_BASE_ADDR)->cspr_cs[i].cspr_ext, v))
821#define set_ifc_cspr(i, v) \
822 (ifc_out32(&(IFC_FCM_BASE_ADDR)->cspr_cs[i].cspr, v))
823#define set_ifc_csor_ext(i, v) \
824 (ifc_out32(&(IFC_FCM_BASE_ADDR)->csor_cs[i].csor_ext, v))
825#define set_ifc_csor(i, v) \
826 (ifc_out32(&(IFC_FCM_BASE_ADDR)->csor_cs[i].csor, v))
827#define set_ifc_amask(i, v) \
828 (ifc_out32(&(IFC_FCM_BASE_ADDR)->amask_cs[i].amask, v))
829#define set_ifc_ftim(i, j, v) \
830 (ifc_out32(&(IFC_FCM_BASE_ADDR)->ftim_cs[i].ftim[j], v))
Dipen Dudhat00c42942011-01-20 16:29:35 +0530831
Dipen Dudhat00c42942011-01-20 16:29:35 +0530832enum ifc_chip_sel {
833 IFC_CS0,
834 IFC_CS1,
835 IFC_CS2,
836 IFC_CS3,
Mingkai Hu6f024c92013-05-16 10:18:13 +0800837 IFC_CS4,
838 IFC_CS5,
839 IFC_CS6,
840 IFC_CS7,
Dipen Dudhat00c42942011-01-20 16:29:35 +0530841};
842
843enum ifc_ftims {
844 IFC_FTIM0,
845 IFC_FTIM1,
846 IFC_FTIM2,
847 IFC_FTIM3,
848};
849
850/*
851 * IFC Controller NAND Machine registers
852 */
853struct fsl_ifc_nand {
854 u32 ncfgr;
855 u32 res1[0x4];
856 u32 nand_fcr0;
857 u32 nand_fcr1;
858 u32 res2[0x8];
859 u32 row0;
860 u32 res3;
861 u32 col0;
862 u32 res4;
863 u32 row1;
864 u32 res5;
865 u32 col1;
866 u32 res6;
867 u32 row2;
868 u32 res7;
869 u32 col2;
870 u32 res8;
871 u32 row3;
872 u32 res9;
873 u32 col3;
874 u32 res10[0x24];
875 u32 nand_fbcr;
876 u32 res11;
877 u32 nand_fir0;
878 u32 nand_fir1;
879 u32 nand_fir2;
880 u32 res12[0x10];
881 u32 nand_csel;
882 u32 res13;
883 u32 nandseq_strt;
884 u32 res14;
885 u32 nand_evter_stat;
886 u32 res15;
887 u32 pgrdcmpl_evt_stat;
888 u32 res16[0x2];
889 u32 nand_evter_en;
890 u32 res17[0x2];
891 u32 nand_evter_intr_en;
Jaiprakash Singhdd888062015-03-20 19:28:27 -0700892 u32 nand_vol_addr_stat;
893 u32 res18;
Dipen Dudhat00c42942011-01-20 16:29:35 +0530894 u32 nand_erattr0;
895 u32 nand_erattr1;
896 u32 res19[0x10];
897 u32 nand_fsr;
Jagdish Gediya83fbe912018-03-24 02:55:51 +0530898 u32 res20[0x1];
899 u32 nand_eccstat[8];
Jaiprakash Singhdd888062015-03-20 19:28:27 -0700900 u32 res21[0x1c];
Dipen Dudhat00c42942011-01-20 16:29:35 +0530901 u32 nanndcr;
902 u32 res22[0x2];
903 u32 nand_autoboot_trgr;
904 u32 res23;
905 u32 nand_mdr;
Jaiprakash Singhdd888062015-03-20 19:28:27 -0700906 u32 res24[0x1c];
907 u32 nand_dll_lowcfg0;
908 u32 nand_dll_lowcfg1;
909 u32 res25;
910 u32 nand_dll_lowstat;
911 u32 res26[0x3C];
Dipen Dudhat00c42942011-01-20 16:29:35 +0530912};
913
914/*
915 * IFC controller NOR Machine registers
916 */
917struct fsl_ifc_nor {
918 u32 nor_evter_stat;
919 u32 res1[0x2];
920 u32 nor_evter_en;
921 u32 res2[0x2];
922 u32 nor_evter_intr_en;
923 u32 res3[0x2];
924 u32 nor_erattr0;
925 u32 nor_erattr1;
926 u32 nor_erattr2;
927 u32 res4[0x4];
928 u32 norcr;
929 u32 res5[0xEF];
930};
931
932/*
933 * IFC controller GPCM Machine registers
934 */
935struct fsl_ifc_gpcm {
936 u32 gpcm_evter_stat;
937 u32 res1[0x2];
938 u32 gpcm_evter_en;
939 u32 res2[0x2];
940 u32 gpcm_evter_intr_en;
941 u32 res3[0x2];
942 u32 gpcm_erattr0;
943 u32 gpcm_erattr1;
944 u32 gpcm_erattr2;
945 u32 gpcm_stat;
Dipen Dudhat00c42942011-01-20 16:29:35 +0530946};
947
Mingkai Hu6f024c92013-05-16 10:18:13 +0800948#ifdef CONFIG_SYS_FSL_IFC_BANK_COUNT
949#if (CONFIG_SYS_FSL_IFC_BANK_COUNT <= 8)
950#define IFC_CSPR_REG_LEN 148
951#define IFC_AMASK_REG_LEN 144
952#define IFC_CSOR_REG_LEN 144
953#define IFC_FTIM_REG_LEN 576
954
955#define IFC_CSPR_USED_LEN sizeof(struct fsl_ifc_cspr) * \
956 CONFIG_SYS_FSL_IFC_BANK_COUNT
957#define IFC_AMASK_USED_LEN sizeof(struct fsl_ifc_amask) * \
958 CONFIG_SYS_FSL_IFC_BANK_COUNT
959#define IFC_CSOR_USED_LEN sizeof(struct fsl_ifc_csor) * \
960 CONFIG_SYS_FSL_IFC_BANK_COUNT
961#define IFC_FTIM_USED_LEN sizeof(struct fsl_ifc_ftim) * \
962 CONFIG_SYS_FSL_IFC_BANK_COUNT
963#else
964#error IFC BANK count not vaild
965#endif
966#else
967#error IFC BANK count not defined
968#endif
969
970struct fsl_ifc_cspr {
971 u32 cspr_ext;
972 u32 cspr;
973 u32 res;
974};
975
976struct fsl_ifc_amask {
977 u32 amask;
978 u32 res[0x2];
979};
980
981struct fsl_ifc_csor {
982 u32 csor;
983 u32 csor_ext;
984 u32 res;
985};
986
987struct fsl_ifc_ftim {
988 u32 ftim[4];
989 u32 res[0x8];
990};
Dipen Dudhat00c42942011-01-20 16:29:35 +0530991
992/*
Jaiprakash Singhdd888062015-03-20 19:28:27 -0700993 * IFC Controller Global Registers
994 * FCM - Flash control machine
Dipen Dudhat00c42942011-01-20 16:29:35 +0530995 */
Jaiprakash Singhdd888062015-03-20 19:28:27 -0700996
997struct fsl_ifc_fcm {
Dipen Dudhat00c42942011-01-20 16:29:35 +0530998 u32 ifc_rev;
Kumar Gala7bc4f622012-08-17 08:20:25 +0000999 u32 res1[0x2];
Mingkai Hu6f024c92013-05-16 10:18:13 +08001000 struct fsl_ifc_cspr cspr_cs[CONFIG_SYS_FSL_IFC_BANK_COUNT];
1001 u8 res2[IFC_CSPR_REG_LEN - IFC_CSPR_USED_LEN];
1002 struct fsl_ifc_amask amask_cs[CONFIG_SYS_FSL_IFC_BANK_COUNT];
1003 u8 res3[IFC_AMASK_REG_LEN - IFC_AMASK_USED_LEN];
1004 struct fsl_ifc_csor csor_cs[CONFIG_SYS_FSL_IFC_BANK_COUNT];
1005 u8 res4[IFC_CSOR_REG_LEN - IFC_CSOR_USED_LEN];
1006 struct fsl_ifc_ftim ftim_cs[CONFIG_SYS_FSL_IFC_BANK_COUNT];
1007 u8 res5[IFC_FTIM_REG_LEN - IFC_FTIM_USED_LEN];
Dipen Dudhat00c42942011-01-20 16:29:35 +05301008 u32 rb_stat;
Jaiprakash Singhdd888062015-03-20 19:28:27 -07001009 u32 rb_map;
1010 u32 wp_map;
Dipen Dudhat00c42942011-01-20 16:29:35 +05301011 u32 ifc_gcr;
Mingkai Hu6f024c92013-05-16 10:18:13 +08001012 u32 res7[0x2];
Dipen Dudhat00c42942011-01-20 16:29:35 +05301013 u32 cm_evter_stat;
Mingkai Hu6f024c92013-05-16 10:18:13 +08001014 u32 res8[0x2];
Dipen Dudhat00c42942011-01-20 16:29:35 +05301015 u32 cm_evter_en;
Mingkai Hu6f024c92013-05-16 10:18:13 +08001016 u32 res9[0x2];
Dipen Dudhat00c42942011-01-20 16:29:35 +05301017 u32 cm_evter_intr_en;
Mingkai Hu6f024c92013-05-16 10:18:13 +08001018 u32 res10[0x2];
Dipen Dudhat00c42942011-01-20 16:29:35 +05301019 u32 cm_erattr0;
1020 u32 cm_erattr1;
Mingkai Hu6f024c92013-05-16 10:18:13 +08001021 u32 res11[0x2];
Dipen Dudhat00c42942011-01-20 16:29:35 +05301022 u32 ifc_ccr;
1023 u32 ifc_csr;
Jaiprakash Singhdd888062015-03-20 19:28:27 -07001024 u32 ddr_ccr_low;
1025};
1026
1027struct fsl_ifc_runtime {
Dipen Dudhat00c42942011-01-20 16:29:35 +05301028 struct fsl_ifc_nand ifc_nand;
1029 struct fsl_ifc_nor ifc_nor;
1030 struct fsl_ifc_gpcm ifc_gpcm;
1031};
1032
Jaiprakash Singhdd888062015-03-20 19:28:27 -07001033struct fsl_ifc {
1034 struct fsl_ifc_fcm *gregs;
1035 struct fsl_ifc_runtime *rregs;
1036};
1037
Pankit Garg92d443b2018-11-05 18:01:33 +00001038struct ifc_regs {
1039 const char *name;
1040 u32 pr;
1041 u32 pr_ext;
1042 u32 amask;
1043 u32 or;
1044 u32 ftim[4];
1045 u32 or_ext;
1046 u32 pr_final;
1047 u32 amask_final;
1048};
1049
1050struct ifc_regs_info {
1051 struct ifc_regs *regs;
1052 u32 cs_size;
1053};
1054
Poonam Aggrwalc7664a42011-06-30 03:00:28 -05001055#ifdef CONFIG_SYS_FSL_ERRATUM_IFC_A002769
1056#undef CSPR_MSEL_NOR
1057#define CSPR_MSEL_NOR CSPR_MSEL_GPCM
1058#endif
Mingkai Hu6f024c92013-05-16 10:18:13 +08001059#endif /* CONFIG_FSL_IFC */
Poonam Aggrwalc7664a42011-06-30 03:00:28 -05001060
Dipen Dudhat00c42942011-01-20 16:29:35 +05301061#endif /* __ASSEMBLY__ */
York Sun37562f62013-10-22 12:39:02 -07001062#endif /* __FSL_IFC_H */