blob: c85430a7b734afa4c8a10bea71e1d3679594acee [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/******************************************************************************
2**
3** INTEL CONFIDENTIAL
4** Copyright 2003-2004 Intel Corporation All Rights Reserved.
5**
6** The source code contained or described herein and all documents
7** related to the source code (Material) are owned by Intel Corporation
8** or its suppliers or licensors. Title to the Material remains with
9** Intel Corporation or its suppliers and licensors. The Material contains
10** trade secrets and proprietary and confidential information of Intel
11** or its suppliers and licensors. The Material is protected by worldwide
12** copyright and trade secret laws and treaty provisions. No part of the
13** Material may be used, copied, reproduced, modified, published, uploaded,
14** posted, transmitted, distributed, or disclosed in any way without Intel's
15** prior express written permission.
16**
17** No license under any patent, copyright, trade secret or other intellectual
18** property right is granted to or conferred upon you by disclosure or
19** delivery of the Materials, either expressly, by implication, inducement,
20** estoppel or otherwise. Any license under such intellectual property rights
21** must be express and approved by Intel in writing.
22**
23** BBM.h
24******************************************************************************//******************************************************************************
25 *
26 * (C)Copyright 2005 - 2011 Marvell. All Rights Reserved.
27 *
28 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF MARVELL.
29 * The copyright notice above does not evidence any actual or intended
30 * publication of such source code.
31 * This Module contains Proprietary Information of Marvell and should be
32 * treated as Confidential.
33 * The information in this file is provided for the exclusive use of the
34 * licensees of Marvell.
35 * Such users have the right to use, modify, and incorporate this code into
36 * products for purposes authorized by the license agreement provided they
37 * include this notice and the associated copyright notice with any such
38 * product.
39 * The information in this file is provided "AS IS" without warranty.
40
41 ******************************************************************************
42**
43** FILENAME: BBM.h
44**
45** PURPOSE: Holds all flash related definitions
46**
47******************************************************************************/
48#ifndef __BBM_H__
49#define __BBM_H__
50
51#include "Typedef.h"
52
53#define MBBT_VERSION_1 0x31303031
54/*
55 * For some nand flash with higher manufacturing process, such as 1xnm,
56 * page program in a block must start from low address to high address.
57 * Do not use this macro if not know what it means.
58 */
59//#define BBT_ORDER_REVERSE
60
61#define READ_DISTURB_LIST_ID 0x52444953 //'RDIS'
62
63#if defined(NEZHA701)
64/* P701 need to reserve larger area for BBM */
65#define LEGACY_BBM_RELOC_PERCENTAGE (7)
66#elif defined(NEZHA702)
67/* P702 need to reserve larger area for BBM */
68#define LEGACY_BBM_RELOC_PERCENTAGE (10)
69#else
70/* 5% of whole device is enough for most FLASH */
71#define LEGACY_BBM_RELOC_PERCENTAGE (5)
72#endif
73
74// Indicates the state of the BBT in volatile memory
75typedef enum
76{
77 BBT_INVALID = 1,
78 BBT_UNCHANGED = 2,
79 BBT_CHANGED = 3,
80 BBT_ERASED = 4,
81 BBT_NEED_SYNC = 5,
82 ABBT_BITFLIP0 = (1<<6),
83 ABBT_BITFLIP1 = (1<<7)
84} ReloState_T;
85
86#define ABBT_STATE_MASK (0xF)
87
88// BBT Types
89typedef enum
90{
91 BBT_TYPE_NA = 0x00000000, //Runtime BBT not being used
92 BBT_TYPE_LEGACY = 0x0000524E, //Legacy version
93 BBT_TYPE_MBBT = 0x4D424254, //"MBBT" Marvell Bad Block Table (NOTE: used as ID for factory AND runtime MBBT)
94 BBT_TYPE_MBBT_FACT = 0x46616374, //"Fact" Factory Bad Block Table (sub type of the MBBT)
95 BBT_TYPE_MBBT_RUN = 0x52756E74, //"Runt" Runtime Bad Block Table (sub type of the MBBT)
96 BBT_TYPE_WNCE = 0x574E4345, //"WNCE" WinCE Bad Block Table
97 BBT_TYPE_LINX = 0x4C695E78, //"Linx" Linux Bad Block Table
98 BBT_TYPE_ASR = 0x41424254 //"ASR" Bad Block Table
99} BBT_TYPE;
100
101//Block state introduced for bitflips
102typedef enum
103{
104 BLOCK_RECYCLED = 0xFFF1,
105 BLOCK_TO_RECYCLE = 0xFFF2,
106 BLOCK_RECYCLE_FAILED = 0xFFF3,
107 BLOCK_RELOCATED = 0xFFF4,
108 BLK_FLIP_COUNT = 0xFFFE,
109 BLOCK_BAD = 0xFFFF
110}Block_State;
111
112//Relocation Pairs - same for MBBT, FBBT, and Legacy BBT
113typedef struct {
114 USHORT From;
115 USHORT To;
116} ReloPair_T, *P_ReloPair_T;
117
118typedef struct {
119 USHORT State;
120 USHORT Index;
121}BlockState_T, *P_BlockState_T;
122
123// Marvell BBT Structure
124typedef struct {
125 UINT_T Identifier;
126 UINT_T Version;
127 UINT_T Type;
128 UINT_T Reserved;
129 UINT_T PartitionID;
130 UINT_T NumRelo;
131 UINT_T BBTLocation;
132 UINT_T Reserved1; //for now, the upper 32bits of 64bit address are reserved
133 UINT_T BackupBBTLoc;
134 UINT_T Reserved2; //for now, the upper 32bits of 64bit address are reserved
135 ReloPair_T Entry[1]; //need to make it an array
136} MBBT_Table_T, *P_MBBT_Table_T;
137
138// Factory BBT Structure
139typedef struct {
140 UINT_T Identifier;
141 UINT_T Version;
142 UINT_T Type;
143 UINT_T Reserved0;
144 UINT_T Reserved1;
145 UINT_T NumRelo;
146 UINT_T BBTLocation;
147 UINT_T Reserved2; //for now, the upper 32bits of 64bit address are reserved
148 UINT_T Reserved3;
149 UINT_T Reserved4;
150 USHORT BadBlocks[1]; //need to make it an array
151} FBBT_Table_T, *P_FBBT_Table_T;
152
153//1.001
154#define ABBT_VERSION 0x31303031
155//1.002
156#define ABBT_VERSION_1002 0x31303032
157//2.001, use complement to distinguish from previous version more clearly
158#define ABBT_VERSION_2001 (~0x32303031)
159
160typedef enum {
161 BBT_NONE = 0,
162 BBT_OBM = 1,
163 BBT_UBOOT = 2,
164 BBT_KERNEL = 3,
165}BBT_Owner;
166
167struct BBT_INFO_Bits {
168 UINT_T Owner : 2;
169 UINT_T Reserved : 14;
170 UINT_T CRC : 16;
171};
172
173typedef union {
174 UINT_T Value;
175 struct BBT_INFO_Bits Bits;
176}BBT_INFO;
177
178//ASR BBT Structure
179typedef struct {
180 UINT_T Identifier;
181 UINT_T Version;
182 union {
183 UINT_T Type;
184 BBT_INFO Info;
185 };
186 UINT_T RefCounter;
187 UINT_T NumReloc;
188 union {
189 UINT_T BackupBBTLoc;
190 UINT_T Reserved0;
191 };
192 UINT_T NumBlockRecyled;
193 UINT_T NumBlockToRecyle;
194 union{
195 ReloPair_T Relo[2]; //need to make it an array
196 BlockState_T BlkInfo[2]; //
197 UINT_T ReloValue[2];
198 };
199} ABBT_Table_T, *P_ABBT_Table_T;
200
201// Legacy BBT Structure
202typedef struct
203{
204 USHORT Header;
205 USHORT NumReloc;
206 ReloPair_T Relo[2];
207} ReloTable_T, *P_ReloTable_T;
208
209/* need to update if ABBT_Table_T changes */
210#define ABBT_HEADER_SIZE (32)
211/* need to update if ReloTable_T changes */
212#define BBT_HEADER_SIZE (4)
213
214#if (RVCT || DS5)
215#pragma anon_unions
216#endif
217//Read Disturb entries
218typedef struct
219{
220 union
221 {
222 unsigned int value;
223 struct
224 {
225 USHORT block;
226 USHORT partition;
227 };
228 };
229} ReadDisturbEntry_T, *P_ReadDisturbEntry_T;
230
231// Read Distrub structure to keep track of read disturbed blocks
232typedef struct
233{
234 UINT_T RDID; //Read Disturb ID
235 UINT_T num_entries;
236 ReadDisturbEntry_T entries[10];
237} ReadDisturbList_T, *P_ReadDisturbList_T;
238
239#endif