tizen 2.4 release
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / include / asm / arch-sc9630 / nlc_drvapi.h
1 /******************************************************************************
2  ** File Name:      nlc_drvapi.h                                         *
3  ** Author:         Nick.zhao                                                 *
4  ** DATE:           01/03/2005                                                *
5  ** Copyright:      2005 Spreatrum, Incoporated. All Rights Reserved.         *
6  ** Description:                                                              *
7  ******************************************************************************/
8 #ifndef _NLC_DRVAPI_H_
9 #define _NLC_DRVAPI_H_
10
11 /******************************************************************************
12                           Macro define
13 ******************************************************************************/
14 typedef enum
15 {
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;
21 } ERR_NF_E;
22 /******************************************************************************
23                           Struct define
24 ******************************************************************************/
25
26 typedef struct
27 {
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
34 } NAND_PARA_T;
35
36
37 typedef struct
38 {
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;
44
45
46 #ifdef __cplusplus
47 extern   "C"
48 {
49 #endif
50
51
52 /******************************************************************************/
53 //  Description:   Set NF parameter according to AHB_CLK
54 //  Parameter:
55 //      ahb_clk    the frequency of AHB_CLK
56 //  Return:
57 //      ERR_NF_SUCCESS    Set NF parameter successfully
58 /******************************************************************************/
59 PUBLIC ERR_NF_E NANDCTL_SetParam (uint32 ahb_clk);
60
61 /******************************************************************************/
62 //  Description:   Init nand controller
63 //  Parameter:
64 //      ahb_clk:   the frequency of AHB clock
65 //  Return:
66 //      ERR_NF_SUCCESS    Init nand controller successfully
67 /******************************************************************************/
68 PUBLIC ERR_NF_E NANDCTL_Init (uint32 ahb_clk);
69
70 /******************************************************************************/
71 //  Description:   Open nand controller
72 //  Parameter:
73 //      pNandPara    the parameter of nandflash
74 //  Return:
75 //      ERR_NF_SUCCESS    Open nand controller successfully
76 /******************************************************************************/
77 PUBLIC ERR_NF_E NANDCTL_Open (NAND_PARA_T *pNandPara);
78
79 /******************************************************************************/
80 //  Description:   Close nand controller
81 //  Parameter:
82 //      NULL
83 //  Return:
84 //      ERR_NF_SUCCESS    Close nand controller successfully
85 /******************************************************************************/
86 PUBLIC ERR_NF_E NANDCTL_Close (void);
87
88 /******************************************************************************/
89 //  Description:   Read nandflash ID
90 //  Parameter:
91 //      pID      in  the address of nandflash id
92 //  Return:
93 //      ERR_NF_SUCCESS     Get the ID successfully
94 /******************************************************************************/
95 PUBLIC ERR_NF_E NANDCTL_Read_ID (uint8 *pID);
96
97 /******************************************************************************/
98 //  Description:   Get nand status
99 //  Parameter:
100 //      none
101 //  Return:
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);
107
108 /******************************************************************************/
109 //  Description:   Reset NandFlash
110 //  Parameter:
111 //      None
112 //  Return:
113 //      ERR_NF_SUCCESS     Reset nandflash successfully
114 /******************************************************************************/
115 PUBLIC ERR_NF_E NANDCTL_Reset (void);
116
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.
120 //  Parameter:
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
125 //  Return:
126 //      ERR_NF_SUCCESS    Read nand successfully
127 /******************************************************************************/
128 PUBLIC ERR_NF_E NANDCTL_MS_Read_S (
129     uint32 page_addr,
130     uint8 *pMBuf,
131     uint8 *pSBuf,
132     uint8 *pEcc
133 );
134 /******************************************************************************/
135 //  Description:   Read main part of nand, ECC value can be get
136 //                 if necessary.
137 //  Parameter:
138 //      page_addr:   in   the nand page address.
139 //      pMBuf:       in   the address of Main part
140 //  Return:
141 //      ERR_NF_SUCCESS    Read nand successfully
142 /******************************************************************************/
143 PUBLIC ERR_NF_E NANDCTL_M_Read_S (
144     uint32 page_addr,
145     uint8 *pMBuf
146 );
147 /******************************************************************************/
148 //  Description:   Read spare part of nand
149 //  Parameter:
150 //      page_addr:   in   the nand page address.
151 //      pSBuf:       in   the address of Spare part
152 //  Return:
153 //      ERR_NF_SUCCESS    Read nand successfully
154 /******************************************************************************/
155 PUBLIC ERR_NF_E NANDCTL_S_Read_S (
156     uint32 page_addr,
157     uint8 *pSBuf
158 );
159 /******************************************************************************/
160 //  Description:   Write main part and spare part of nand
161 //  Parameter:
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
166 //  Return:
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 (
172     uint32 page_addr,
173     uint8 *pMBuf,
174     uint8 *pSBuf,
175     uint8 ecc_en
176 );
177 /******************************************************************************/
178 //  Description:   Write main part of nand
179 //  Parameter:
180 //      page_addr: in    the nand page address.
181 //      pMBuf:     in    the main part address.
182 //  Return:
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);
188
189 /******************************************************************************/
190 //  Description:   Write spare part of nand
191 //  Parameter:
192 //      page_addr:  in   the nand page address.
193 //      pSBuf       in   the address of spare part
194 //  Return:
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);
200
201 /******************************************************************************/
202 //  Description:   Erase a block of nandflash
203 //  Parameter:
204 //      block_addr:  in   the nand block address.
205 //  Return:
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.
214 //  Parameter:
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
221 //  Return:
222 //      ERR_NF_SUCCESS    Read nand successfully
223 /******************************************************************************/
224 PUBLIC ERR_NF_E NANDCTL_MS_Read_L (
225     uint32 page_addr,
226     uint8 index,
227     uint8 nSct,
228     uint8 *pMBuf,
229     uint8 *pSBuf,
230     uint8 *pEcc
231 );
232 /******************************************************************************/
233 //  Description:   Read main part of nand, ECC value can be get
234 //                 if necessary.
235 //  Parameter:
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
240 //  Return:
241 //      ERR_NF_SUCCESS    Read nand successfully
242 /******************************************************************************/
243 PUBLIC ERR_NF_E NANDCTL_M_Read_L (
244     uint32 page_addr,
245     uint8 index,
246     uint8 nSct,
247     uint8 *pMBuf
248 );
249 /******************************************************************************/
250 //  Description:   Read spare part of nand
251 //  Parameter:
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
256 //  Return:
257 //      ERR_NF_SUCCESS    Read nand successfully
258 /******************************************************************************/
259 PUBLIC ERR_NF_E NANDCTL_S_Read_L (
260     uint32 page_addr,
261     uint8 index,
262     uint8 nSct,
263     uint8 *pSBuf
264 );
265 /******************************************************************************/
266 //  Description:   Write main part and spare part of nand
267 //  Parameter:
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
274 //  Return:
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 (
280     uint32 page_addr,
281     uint8 index,
282     uint8 nSct,
283     uint8 *pMBuf,
284     uint8 *pSBuf,
285     uint8 ecc_en
286 );
287 /******************************************************************************/
288 //  Description:   Write main part of nand
289 //  Parameter:
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
294 //  Return:
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
302 //  Parameter:
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
307 //  Return:
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
315 //  Parameter:
316 //      block_addr:  in    the nand block address.
317 //  Return:
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);
323
324 /******************************************************************************/
325 //  Description:   Input the nandflash parameter
326 //  Parameter:
327 //      pNandTiming    the frequency of AHB_CLK
328 //  Return:
329 //      ERR_NF_SUCCESS    Set NF parameter successfully
330 /******************************************************************************/
331 PUBLIC ERR_NF_E NANDCTL_InitParam (NAND_TIMING_PTR pNandTiming);
332 #ifdef __cplusplus
333 }
334 #endif
335
336 #endif // _NLC_DRVAPI_H_