tizen 2.4 release
[kernel/u-boot-tm1.git] / nand_fdl / fdl-2 / inc / fdl_nand_operate.h
1 #ifndef FDL_NAND_OPERATE_H
2 #define FDL_NAND_OPERATE_H
3
4 #include <asm/arch/cmd_def.h>
5
6 #define NAND_SUCCESS                0
7 #define NAND_SYSTEM_ERROR           1
8 #define NAND_UNKNOWN_DEVICE         2
9 #define NAND_INVALID_DEVICE_SIZE    3
10 #define NAND_INCOMPATIBLE_PART      4
11 #define NAND_INVALID_ADDR           5
12 #define NAND_INVALID_SIZE           6
13
14 static __inline DLSTATUS convert_err (int err)
15 {
16     switch (err)
17     {
18         case NAND_SUCCESS:
19             return BSL_REP_ACK;
20         case NAND_INVALID_ADDR:
21             return BSL_REP_DOWN_DEST_ERROR;
22         case NAND_INVALID_SIZE:
23             return BSL_REP_DOWN_SIZE_ERROR;
24         case NAND_UNKNOWN_DEVICE:
25             return BSL_UNKNOWN_DEVICE;
26         case NAND_INVALID_DEVICE_SIZE:
27             return BSL_INVALID_DEVICE_SIZE;
28         case NAND_INCOMPATIBLE_PART:
29             return BSL_INCOMPATIBLE_PARTITION;
30         default:
31             return BSL_REP_OPERATION_FAILED;
32     }
33 }
34 /**
35  * fdl2_download_start
36  *
37  * Get download info from download start command which  
38  * will used in next step
39  *
40  * @param part partition/volume name
41  * @param size total download size
42  * @param nv_checksum NA
43  * @return 0 failed
44  *             1 success
45  */
46 int fdl2_download_start(char* name, unsigned long size, unsigned long nv_checksum);
47
48 /**
49  * fdl2_download_midst
50  *
51  * Save data to fdl buf and finally write it to nand flash
52  *
53  * @param size total download size
54  * @param buf data recvd
55  * @return 0 failed
56  *             1 success
57  */
58 int fdl2_download_midst(unsigned short size, char *buf);
59
60 /**
61  * fdl2_download_end
62  *
63  * Set download end
64  *
65  * @param void
66  * @return 0 failed
67  *             1 success
68  */
69 int fdl2_download_end(void);
70
71 /**
72  * fdl2_nand_read_start
73  *
74  * Get partition/volume info from read start command which  
75  * will used in next step
76  *
77  * @param part partition/volume name
78  * @param size total size
79  * @return 0 failed
80  *             1 success
81  */
82 int fdl2_read_start(char* part, unsigned long size);
83
84 /**
85  * fdl2_nand_read_midst
86  *
87  * Read partition/volume data
88  *
89  * @param size size to be read
90  * @param off offset of begin of part/vol
91  * @param buf data saved
92  * @return 0 failed
93  *             1 success
94  */
95 int fdl2_read_midst(unsigned long size, unsigned long off, unsigned char *buf);
96
97 /**
98  * fdl2_read_end
99  *
100  * Set read flash end
101  *
102  * @param void
103  * @return 0 failed
104  *             1 success
105  */
106 int fdl2_read_end(void);
107
108 /**
109  * fdl2_erase
110  *
111  * Erase partition/volume
112  *
113  * @param part partition/volume name
114  * @param size size to be erased(no use now)
115  * @return 0 failed
116  *             1 success
117  */
118 int fdl2_erase(char* part, unsigned long size);
119
120 /**
121  * fdl2_repartition
122  *
123  * Resize/Add/Delete volumes
124  *
125  * @param vol_cfg volume cfg
126  * @param total_vol_num
127  * @return 0 failed
128  *             1 success
129  */
130 int fdl2_repartition(void* vol_cfg, unsigned short total_vol_num);
131
132 #endif  /*FDL_NAND_OPERATE_H*/
133