1 /******************************************************************************
2 ** File Name: nlc_drvapi.h *
5 ** Copyright: 2005 Spreatrum, Incoporated. All Rights Reserved. *
7 ******************************************************************************/
11 /******************************************************************************
13 ******************************************************************************/
16 ERR_NF_SUCCESS = 0, // Success,no error
17 ERR_NF_FAIL, // Oprate nand flash fail
18 ERR_NF_TIMEOUT, // Oprate nand flash timeout;
19 ERR_NF_BUSY, // Current device is busy;
20 ERR_NF_PROTECTED // Current device is protected;
22 /******************************************************************************
24 ******************************************************************************/
28 uint16 acycle; //address cycle, which can be set 3,4,5
29 uint16 pagesize; //page size, which can be set 512 or 2048
30 uint16 sparesize; //spare size, which can be set 16 or 64
31 uint16 buswidth; //bus width, which can be set 0 or 1
32 uint16 advance; //advance property, which can be set 0 or 1
33 uint16 eccpos; //ECC position
39 uint32 nTrTime; //Read wait R/B ready
40 uint32 nTpTime; //Program wait R/B ready
41 uint32 nTeTime; //Erase wait R/B ready
42 uint32 nTwcTime; //Read/Write cycle time
43 } NAND_TIMING_T, *NAND_TIMING_PTR;
52 /******************************************************************************/
53 // Description: Set NF parameter according to AHB_CLK
55 // ahb_clk the frequency of AHB_CLK
57 // ERR_NF_SUCCESS Set NF parameter successfully
58 /******************************************************************************/
59 PUBLIC ERR_NF_E NANDCTL_SetParam (uint32 ahb_clk);
61 /******************************************************************************/
62 // Description: Init nand controller
64 // ahb_clk: the frequency of AHB clock
66 // ERR_NF_SUCCESS Init nand controller successfully
67 /******************************************************************************/
68 PUBLIC ERR_NF_E NANDCTL_Init (uint32 ahb_clk);
70 /******************************************************************************/
71 // Description: Open nand controller
73 // pNandPara the parameter of nandflash
75 // ERR_NF_SUCCESS Open nand controller successfully
76 /******************************************************************************/
77 PUBLIC ERR_NF_E NANDCTL_Open (NAND_PARA_T *pNandPara);
79 /******************************************************************************/
80 // Description: Close nand controller
84 // ERR_NF_SUCCESS Close nand controller successfully
85 /******************************************************************************/
86 PUBLIC ERR_NF_E NANDCTL_Close (void);
88 /******************************************************************************/
89 // Description: Read nandflash ID
91 // pID in the address of nandflash id
93 // ERR_NF_SUCCESS Get the ID successfully
94 /******************************************************************************/
95 PUBLIC ERR_NF_E NANDCTL_Read_ID (uint8 *pID);
97 /******************************************************************************/
98 // Description: Get nand status
102 // ERR_NF_SUCCESS NAND is ready
103 // ERR_NF_BUSY nand is busy
104 // ERR_NF_FAIL Program or erase nand failed
105 /******************************************************************************/
106 PUBLIC ERR_NF_E NANDCTL_Read_Status (void);
108 /******************************************************************************/
109 // Description: Reset NandFlash
113 // ERR_NF_SUCCESS Reset nandflash successfully
114 /******************************************************************************/
115 PUBLIC ERR_NF_E NANDCTL_Reset (void);
117 /******************************************************************************/
118 // Description: Read main part and spare part of nand, ECC value can be get
119 // if necessary. This function is used for small page nandflash.
121 // page_addr: in the nand page address.
122 // pMBuf: in the address of Main part
123 // pSBuf: in the address of Spare part
124 // pEcc: out the address of ECC value
126 // ERR_NF_SUCCESS Read nand successfully
127 /******************************************************************************/
128 PUBLIC ERR_NF_E NANDCTL_MS_Read_S (
134 /******************************************************************************/
135 // Description: Read main part of nand, ECC value can be get
138 // page_addr: in the nand page address.
139 // pMBuf: in the address of Main part
141 // ERR_NF_SUCCESS Read nand successfully
142 /******************************************************************************/
143 PUBLIC ERR_NF_E NANDCTL_M_Read_S (
147 /******************************************************************************/
148 // Description: Read spare part of nand
150 // page_addr: in the nand page address.
151 // pSBuf: in the address of Spare part
153 // ERR_NF_SUCCESS Read nand successfully
154 /******************************************************************************/
155 PUBLIC ERR_NF_E NANDCTL_S_Read_S (
159 /******************************************************************************/
160 // Description: Write main part and spare part of nand
162 // page_addr: in the nand page address.
163 // pMBuf: in the address of main part
164 // pSBuf: in the address of spare part
165 // ecc_en: in the flag to enable ECC
167 // ERR_NF_SUCCESS Control nand successfully
168 // ERR_NF_BUSY nand is busy
169 // ERR_NF_FAIL Program or erase nand failed
170 /******************************************************************************/
171 PUBLIC ERR_NF_E NANDCTL_MS_Write_S (
177 /******************************************************************************/
178 // Description: Write main part of nand
180 // page_addr: in the nand page address.
181 // pMBuf: in the main part address.
183 // ERR_NF_SUCCESS Control nand successfully
184 // ERR_NF_BUSY nand is busy
185 // ERR_NF_FAIL Program or erase nand failed
186 /******************************************************************************/
187 PUBLIC ERR_NF_E NANDCTL_M_Write_S (uint32 page_addr,uint8 *pMBuf);
189 /******************************************************************************/
190 // Description: Write spare part of nand
192 // page_addr: in the nand page address.
193 // pSBuf in the address of spare part
195 // ERR_NF_SUCCESS Control nand successfully
196 // ERR_NF_BUSY nand is busy
197 // ERR_NF_FAIL Program or erase nand failed
198 /******************************************************************************/
199 PUBLIC ERR_NF_E NANDCTL_S_Write_S (uint32 page_addr,uint8 *pSBuf);
201 /******************************************************************************/
202 // Description: Erase a block of nandflash
204 // block_addr: in the nand block address.
206 // ERR_NF_SUCCESS Control nand successfully
207 // ERR_NF_BUSY nand is busy
208 // ERR_NF_FAIL Program or erase nand failed
209 /******************************************************************************/
210 PUBLIC ERR_NF_E NANDCTL_Erase_Block_S (uint32 block_addr);
211 /******************************************************************************/
212 // Description: Read main part and spare part of nand, ECC value can be get
213 // if necessary. This function is used for large page nandflash.
215 // page_addr: in the nand page address.
216 // index in the sector index of one page
217 // nSct in the sector number
218 // pMBuf: in the address of Main part
219 // pSBuf: in the address of Spare part
220 // pEcc: out the address of ECC value
222 // ERR_NF_SUCCESS Read nand successfully
223 /******************************************************************************/
224 PUBLIC ERR_NF_E NANDCTL_MS_Read_L (
232 /******************************************************************************/
233 // Description: Read main part of nand, ECC value can be get
236 // page_addr: in the nand page address.
237 // index in the sector index of one page
238 // nSct in the sector number
239 // pMBuf: in the address of Main part
241 // ERR_NF_SUCCESS Read nand successfully
242 /******************************************************************************/
243 PUBLIC ERR_NF_E NANDCTL_M_Read_L (
249 /******************************************************************************/
250 // Description: Read spare part of nand
252 // page_addr: in the nand page address.
253 // index in the sector index of one page
254 // nSct in the sector number
255 // pSBuf: in the address of Spare part
257 // ERR_NF_SUCCESS Read nand successfully
258 /******************************************************************************/
259 PUBLIC ERR_NF_E NANDCTL_S_Read_L (
265 /******************************************************************************/
266 // Description: Write main part and spare part of nand
268 // page_addr: in the nand page address.
269 // index in the sector index of one page
270 // nSct in the sector number
271 // pMBuf: in the address of Main part
272 // pSBuf: in the address of Spare part
273 // ecc_en: in the flag to enable ECC
275 // ERR_NF_SUCCESS Control nand successfully
276 // ERR_NF_BUSY nand is busy
277 // ERR_NF_FAIL Program or erase nand failed
278 /******************************************************************************/
279 PUBLIC ERR_NF_E NANDCTL_MS_Write_L (
287 /******************************************************************************/
288 // Description: Write main part of nand
290 // page_addr: in the nand page address.
291 // index in the sector index of one page
292 // nSct in the sector number
293 // pMBuf: in the address of Main part
295 // ERR_NF_SUCCESS Control nand successfully
296 // ERR_NF_BUSY nand is busy
297 // ERR_NF_FAIL Program or erase nand failed
298 /******************************************************************************/
299 PUBLIC ERR_NF_E NANDCTL_M_Write_L (uint32 page_addr,uint8 index,uint8 nSct,uint8 *pMBuf);
300 /******************************************************************************/
301 // Description: Write spare part of nand
303 // page_addr: in the nand page address.
304 // index in the sector index of one page
305 // nSct in the sector number
306 // pSBuf: in the address of Spare part
308 // ERR_NF_SUCCESS Control nand successfully
309 // ERR_NF_BUSY nand is busy
310 // ERR_NF_FAIL Program or erase nand failed
311 /******************************************************************************/
312 PUBLIC ERR_NF_E NANDCTL_S_Write_L (uint32 page_addr,uint8 index,uint8 nSct,uint8 *pSBuf);
313 /******************************************************************************/
314 // Description: Erase a block of nandflash
316 // block_addr: in the nand block address.
318 // ERR_NF_SUCCESS Control nand successfully
319 // ERR_NF_BUSY nand is busy
320 // ERR_NF_FAIL Program or erase nand failed
321 /******************************************************************************/
322 PUBLIC ERR_NF_E NANDCTL_Erase_Block_L (uint32 block_addr);
324 /******************************************************************************/
325 // Description: Input the nandflash parameter
327 // pNandTiming the frequency of AHB_CLK
329 // ERR_NF_SUCCESS Set NF parameter successfully
330 /******************************************************************************/
331 PUBLIC ERR_NF_E NANDCTL_InitParam (NAND_TIMING_PTR pNandTiming);
336 #endif // _NLC_DRVAPI_H_