blob: daa6ad126b08dd2a6eb15e1f6f4600def8e3b503 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/***********************************************************************
2* Copyright (C) 2001, ZTE Corporation.
3*
4* File Name: drvs_nand.h
5* File Mark:
6* Description: tu hal interface declaration.
7* Others:
8* Version: v1.0
9* Author: wangxia
10* Date: 2008-08-28
11*
12* History 1:
13* Date:
14* Version:
15* Author:
16* Modification:
17
18* History 2:
19**********************************************************************/
20
21#ifndef HAL_NAND_H
22#define HAL_NAND_H
23
24#ifdef _OS_TOS
25#include <cyg/fs/tos_yaffs_nand.h>
26#endif
27#include "drvs_io.h"
28/*************************************************************************
29 * Include files *
30 *************************************************************************/
31
32
33/*************************************************************************
34 * Macro *
35 *************************************************************************/
36#define ZDRV_NAND_PART_NVRO "nvr"
37#define ZDRV_NAND_PART_NVRW "nvrw"
38#define ZDRV_NAND_PART_YAFFS "cpfs"
39/**************************************************************************
40 * Types *
41 **************************************************************************/
42typedef struct{
43 UINT8 pbyManu; /* ÖÆÔìÉÌid */
44 UINT8 pbyDevice; /* оƬid */
45 UINT8 pbyID3; /* ¸½¼Óid */
46 UINT8 pbyID4; /* ¸½¼Óid */
47 UINT8 pbyID5; /* ¸½¼Óid */
48}T_ZDrvNand_DeviceID;
49
50typedef struct{
51 UINT32 nvBase; /* NVÆðʼµØÖ·*/
52 UINT32 nvSize; /* NV´óС */
53}T_ZDrvNand_NVParam;
54
55/**
56 * NAND Flash part information
57*/
58typedef struct _T_Nand_Part_Info
59{
60
61 UINT32 PageSize;
62 UINT32 PageSpareSize;
63 UINT32 BlockSize;
64 UINT32 PartOffset;
65 UINT32 PartSize;
66 UINT32 TotalSize;
67 UINT8 *PartName;
68 T_ZDrvIO_Handle pIoHnd;
69}T_Nand_Part_Info;
70
71typedef enum {
72
73 ZFTL_PART_NVRO_NVRW=0,
74 ZFTL_PART_NVFAC,
75 ZFTL_PART_SMS,
76 ZFTL_PART_SIMNV,
77 ZFTL_PART_SIMNVFAC,
78 ZFTL_PART_MAX
79
80} T_ZFTL_PART_NO;
81
82
83/**************************************************************************
84 * Global Variable *
85 **************************************************************************/
86
87
88/**************************************************************************
89 * Function Prototypes *
90 **************************************************************************/
91/**************************************************************************
92* Function: zDrvNand_Initiate
93* Description:initialize nand for hal_init.c
94* Parameters:
95* Input:None
96* Output: None
97* Returns:None
98**************************************************************************/
99SINT32 zDrvNand_Initiate(VOID);
100
101/**************************************************************************
102* Function: zDrvNand_PartRead
103* Description:read nand base partition.
104* Parameters:
105* Input:None
106* Output: None
107* Returns:None
108**************************************************************************/
109SINT32 zDrvNand_PartRead(char* part_name,UINT32 offset,UINT32 size,UINT8* buffer);
110/**************************************************************************
111* Function: zDrvNand_PartGetSize
112* Description:get nand partition size.
113* Parameters:
114* Input:None
115* Output: None
116* Returns:None
117**************************************************************************/
118UINT32 zDrvNand_PartGetSize(char* part_name);
119
120
121/*******************************************************************************
122 * Function: zDrvNand_ReadBootflag
123 * Description: read the bootflag of zx297510
124 * Parameters:
125 * Input:
126 *
127 * Output:
128 *
129 * Returns: 0: open dl usb
130 * 1: close dl usb
131 *
132 * Others: 0xffffffff_ffffffff: USB DL;
133 * "ZTE7510\0" : NO USB DL
134 ********************************************************************************/
135UINT32 zDrvNand_ReadBootflag( void );
136
137/*******************************************************************************
138 * Function: zDrvNand_WriteBootflag
139 * Description: write the bootflag of zx297510
140 * Parameters:
141 * Input:
142 *
143 * Output:
144 *
145 * Returns:0 success
146 * 1 fail
147 *
148 *
149 * Others: 0xffffffff_ffffffff: USB DL;
150 * "ZTE7510\0" : NO USB DL
151 ********************************************************************************/
152UINT32 zDrvNand_WriteBootflag( UINT32 flag );
153
154/*******************************************************************************
155 * Function: zDrvNand_ReadUsbtimeout
156 * Description: read the usbtimeout flag of zx297510
157 * Parameters:
158 * Input:
159 *
160 * Output:
161 *
162 * Returns: flag:usb time out (1~10)
163 *
164 *
165 * Others:
166 ********************************************************************************/
167UINT32 zDrvNand_ReadUsbtimeout( void );
168
169/*******************************************************************************
170 * Function: zDrvNand_WriteUsbtimeout
171 * Description: write the usbtimeout flag of zx297510
172 * Parameters:
173 * Input:flag (1~10)
174 *
175 * Output:
176 *
177 * Returns:
178 *
179 *
180 * Others:
181 ********************************************************************************/
182UINT32 zDrvNand_WriteUsbtimeout( UINT32 flag );
183
184
185/**************************************************************************
186* º¯ÊýÃû³Æ£º zDrvNand_GetNVParam
187* ¹¦ÄÜÃèÊö£º This function is used to get nv param
188
189* ²ÎÊý˵Ã÷£º (IN)
190 none.
191 (OUT)
192 nvParam: nvÆðʼµØÖ·´óС.
193
194* ·µ »Ø Öµ£º 0: ³É¹¦
195* !=0: ʧ°Ü
196
197* ÆäËü˵Ã÷£º none.
198**************************************************************************/
199extern SINT32 zDrvNand_GetNVParam(T_ZDrvNand_NVParam *nvParam);
200
201/**************************************************************************
202* º¯ÊýÃû³Æ£º zDrvNand_ReadID
203* ¹¦ÄÜÃèÊö£º This function is used to identify the nand chip
204
205* ²ÎÊý˵Ã÷£º (IN)
206 none.
207 (OUT)
208 pbyDevice: ³§ÉÌid,оƬid,¸½¼Óid,¸½¼Óid.
209
210* ·µ »Ø Öµ£º 0: ³É¹¦
211* !=0: ʧ°Ü
212
213* ÆäËü˵Ã÷£º none.
214**************************************************************************/
215extern SINT32 zDrvNand_ReadID(T_ZDrvNand_DeviceID *pbyDevice);
216
217
218/**************************************************************************
219* º¯ÊýÃû³Æ£º zDrvNand_Initialize
220* ¹¦ÄÜÃèÊö£º This function is used to initialize the nand chip
221
222* ²ÎÊý˵Ã÷£º (IN)
223 none.
224 (OUT)
225 none.
226
227* ·µ »Ø Öµ£º none.
228
229* ÆäËü˵Ã÷£º none.
230***************************************************************************/
231extern SINT32 zDrvNand_Initialize(void);
232
233/**************************************************************************
234* º¯ÊýÃû³Æ£º zDrvNand_Erase
235* ¹¦ÄÜÃèÊö£º This function is used to erase the nand blocks spcified by
236 dwStart and dwEnd.
237
238* ²ÎÊý˵Ã÷£º (IN)
239 dwStart: start address to erase
240 dwEnd: end address to erase
241 µØÖ··¶Î§£º( NAND_BASE ~ NAND_BASE + BYTES_IN_NAND )
242 (OUT)
243 none.
244
245* ·µ »Ø Öµ£º 0: ³É¹¦
246* !=0: ʧ°Ü
247
248* ÆäËü˵Ã÷£º ¸Ã¹¦ÄܽöÔÚÕû¿é²Á³ýºÍ¸ñʽ»¯Ê±Ê¹Óá£
249 дµÄʱºòÎÞÐè²Á³ý±»Ð´ÇøÓò.
250 ²Á³ýʱdwStart¡¢dwEndËù¿çµÄ¿é£¨Ã¿¿é16K byte£©½«±»È«²¿²Á³ý¡£
251**************************************************************************/
252extern SINT32 zDrvNand_Erase(UINT32 dwStart, UINT32 dwEnd);
253
254extern SINT32 zDrvNand_Program_1(T_ZFTL_PART_NO partNo, UINT32 offset, UINT32 len, UINT8* from);
255extern SINT32 zDrvNand_Read_1(T_ZFTL_PART_NO partNo, UINT32 offset, UINT32 len, UINT8* to);
256
257#ifdef _OS_TOS
258/**************************************************************************
259* Function: zDrvNand_PartOpen
260* Description:get nand parameters for ecos fs.
261* Parameters:
262* Input: part_name:partition name
263* Output: pNandPartInfo:part information
264* Returns:0: success
265* other: error
266**************************************************************************/
267SINT32 zDrvNand_PartOpen(UINT8* part_name, T_zYaffs_PartInfo *pNandPartInfo);
268
269/*******************************************************************************
270 * Function: zDrvNand_PartReadMain
271 * Description: yaffs read nand main
272 * Parameters:
273 * Input:pNandPartInfo:yaffs information;
274 * dwAddr:start addr;
275 * dwLen:read length;
276 * pbyBuf:read buffer;
277 * Output:
278 *
279 * Returns: 0:success;
280 * others:fail
281 *
282 *
283 * Others:
284 ********************************************************************************/
285
286SINT32 zDrvNand_PartReadMain(T_zYaffs_PartInfo *pNandPartInfo, UINT32 dwAddr, UINT32 dwLen, UINT8 *pbyBuf);
287
288/**************************************************************************
289* Function: zDrvNand_PartReadSpare
290* Description: read data from flash
291* Parameters:
292* Input: pNandPartInfo:yaffs information;
293* dwAddr: address
294* dwLen: length to read
295* Output: None
296* Returns:
297* 0: success
298* other: error
299* Others: Éϲãµ÷ÓÃzDrvNand_PartReadSpare()µÄº¯Êý dwLen ¶ÁÈ¡µÄ³¤¶È¶¼Îª Õû¸öOOB
300 dwAddr ¶ÁÈ¡µØÖ·¶¼Îª Ò³µØÖ·¶ÔÆë
301
302**************************************************************************/
303SINT32 zDrvNand_PartReadSpare(T_zYaffs_PartInfo *pNandPartInfo,UINT32 dwAddr, UINT32 dwLen, UINT8 *pbyBuf);
304
305/**************************************************************************
306* Function: zDrvNand_PartWriteMain
307* Description: write data to flash of main area
308* Parameters:
309* Input: pNandPartInfo:yaffs information;
310* dwAddr: address
311* dwLen: length to read
312* pMBuf: buffer in which data is stored
313* Output: None
314* Returns:
315* 0: success
316* other: error
317* Others: Éϲãµ÷ÓÃzDrvNand_PartWriteMain()µÄº¯Êý dwLen дÈëµÄ³¤¶È1 page,
318 dwAddr дÈëµØÖ·¶¼Îª Ò³µØÖ·¶ÔÆë
319
320**************************************************************************/
321SINT32 zDrvNand_PartWriteMain(T_zYaffs_PartInfo *pNandPartInfo, UINT32 dwAddr, UINT32 dwLen, UINT8 *pbyBuf);
322
323/**************************************************************************
324* Function: zDrvNand_PartWriteSpare
325* Description: write data to flash of spare area
326* Parameters:
327* Input: pNandPartInfo:yaffs information;
328* dwAddr: address
329* dwLen: length to read
330* pbyBuf: buffer in which data is stored
331* Output: None
332* Returns:
333* 0: success
334* other: error
335* Others: Éϲãµ÷ÓÃzDrvNand_PartWriteSpare()µÄº¯Êý dwLen дÈëµÄ³¤¶È¶¼ÎªÕû¸öOOB
336 dwAddr дÈëµØÖ·¶¼Îª Ò³µØÖ·¶ÔÆë
337
338**************************************************************************/
339SINT32 zDrvNand_PartWriteSpare(T_zYaffs_PartInfo *pNandPartInfo, UINT32 dwAddr, UINT32 dwLen, UINT8 *pbyBuf);
340
341/**************************************************************************
342* Function: zDrvNand_PartErase
343* Description: erase a block
344* Parameters:
345* Input: pNandPartInfo:yaffs information;
346* dwAddr: address,block aliagn
347* Output: None
348* Returns:
349* 0: success
350* other: error
351* Others:
352**************************************************************************/
353SINT32 zDrvNand_PartErase(T_zYaffs_PartInfo *pNandPartInfo, UINT32 dwAddr);
354
355/**************************************************************************
356* Function: zDrvNand_PartCheckBadBlock
357* Description:check badblock for ecos fs.
358* Parameters:
359* Input: pNandPartInfo:part information
360* dwAddr:start addrress
361* Output: None
362* Returns:DRV_SUCCESS: good block
363* DRV_ERROR: bad block
364**************************************************************************/
365
366SINT32 zDrvNand_PartCheckBadBlock(T_zYaffs_PartInfo *pNandPartInfo,UINT32 dwAddr);
367
368/**************************************************************************
369* Function: zDrvNand_PartMarkBadBlock
370* Description:mark badblock for ecos fs.
371* Parameters:
372* Input: pNandPartInfo:part information
373* dwAddr:start addrress
374* Output: None
375* Returns:DRV_SUCCESS: mark bad success
376* DRV_ERROR: mark bad fail
377**************************************************************************/
378
379SINT32 zDrvNand_PartMarkBadBlock(T_zYaffs_PartInfo *pNandPartInfo,UINT32 dwAddr);
380#endif
381
382/**************************************************************************
383* Function: zDrvNand_PartMtdOpen
384* Description:get nand parameters for FOTA.
385* Parameters:
386* Input:None
387* Output: None
388* Returns:None
389**************************************************************************/
390SINT32 zDrvNand_PartMtdOpen(UINT8* part_name, T_Nand_Part_Info *pNandPartInfo);
391
392/**************************************************************************
393* Function: zDrvNand_PartMtdRead
394* Description:read data for FOTA.
395* Parameters:
396* Input:None
397* Output: None
398* Returns:None
399**************************************************************************/
400SINT32 zDrvNand_PartMtdRead(T_Nand_Part_Info *pNandPartInfo,UINT32 dwAddr, UINT32 dwLen, UINT8 *pbyBuf);
401/**************************************************************************
402* Function: zDrvNand_PartMtdWrite
403* Description:read data for FOTA.
404* Parameters:
405* Input:None
406* Output: None
407* Returns:None
408**************************************************************************/
409SINT32 zDrvNand_PartMtdWrite(T_Nand_Part_Info *pNandPartInfo,UINT32 dwAddr, UINT32 dwLen, UINT8 *pbyBuf);
410/**************************************************************************
411* Function: zDrvNand_PartMtdErase
412* Description:erase data for FOTA.
413* Parameters:
414* Input:None
415* Output: None
416* Returns:None
417**************************************************************************/
418SINT32 zDrvNand_PartMtdErase(T_Nand_Part_Info *pNandPartInfo,UINT32 dwAddr);
419
420/**************************************************************************
421* Function: zDrvNand_NvRwEccMake
422* Description:
423* Parameters:
424* Input:
425*
426* Output: None
427* Returns: 0: ÕýÈ·
428 ÆäËû: ´íÎó
429*
430*
431* Others:
432**************************************************************************/
433SINT32 zDrvNand_NvRwEccMake(UINT32 dwStart, UINT32 dwLen);
434
435
436
437#endif /* HAL_NAND_H */
438