2 * NAND Flash Controller Device Driver
3 * Copyright (c) 2009, Intel Corporation and its suppliers.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "spectraswconfig.h"
26 /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
27 #if FLASH_EMU /* vector all the LLD calls to the LLD_EMU code */
31 /* common functions: */
32 u16
GLOB_LLD_Flash_Reset(void)
34 return emu_Flash_Reset();
37 u16
GLOB_LLD_Read_Device_ID(void)
39 return emu_Read_Device_ID();
42 int GLOB_LLD_Flash_Release(void)
44 return emu_Flash_Release();
47 u16
GLOB_LLD_Flash_Init(void)
49 return emu_Flash_Init();
52 u16
GLOB_LLD_Erase_Block(u32 block_add
)
54 return emu_Erase_Block(block_add
);
57 u16
GLOB_LLD_Write_Page_Main(u8
*write_data
, u32 block
, u16 Page
,
60 return emu_Write_Page_Main(write_data
, block
, Page
, PageCount
);
63 u16
GLOB_LLD_Read_Page_Main(u8
*read_data
, u32 block
, u16 Page
,
66 return emu_Read_Page_Main(read_data
, block
, Page
, PageCount
);
69 u16
GLOB_LLD_Read_Page_Main_Polling(u8
*read_data
,
70 u32 block
, u16 page
, u16 page_count
)
72 return emu_Read_Page_Main(read_data
, block
, page
, page_count
);
75 u16
GLOB_LLD_Write_Page_Main_Spare(u8
*write_data
, u32 block
,
76 u16 Page
, u16 PageCount
)
78 return emu_Write_Page_Main_Spare(write_data
, block
, Page
, PageCount
);
81 u16
GLOB_LLD_Read_Page_Main_Spare(u8
*read_data
, u32 block
,
82 u16 Page
, u16 PageCount
)
84 return emu_Read_Page_Main_Spare(read_data
, block
, Page
, PageCount
);
87 u16
GLOB_LLD_Write_Page_Spare(u8
*write_data
, u32 block
, u16 Page
,
90 return emu_Write_Page_Spare(write_data
, block
, Page
, PageCount
);
93 u16
GLOB_LLD_Read_Page_Spare(u8
*read_data
, u32 block
, u16 Page
,
96 return emu_Read_Page_Spare(read_data
, block
, Page
, PageCount
);
99 u16
GLOB_LLD_Get_Bad_Block(u32 block
)
101 return emu_Get_Bad_Block(block
);
104 #endif /* FLASH_EMU */
106 /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
107 #if FLASH_MTD /* vector all the LLD calls to the LLD_MTD code */
109 #include "lld_cdma.h"
111 /* common functions: */
112 u16
GLOB_LLD_Flash_Reset(void)
114 return mtd_Flash_Reset();
117 u16
GLOB_LLD_Read_Device_ID(void)
119 return mtd_Read_Device_ID();
122 int GLOB_LLD_Flash_Release(void)
124 return mtd_Flash_Release();
127 u16
GLOB_LLD_Flash_Init(void)
129 return mtd_Flash_Init();
132 u16
GLOB_LLD_Erase_Block(u32 block_add
)
134 return mtd_Erase_Block(block_add
);
137 u16
GLOB_LLD_Write_Page_Main(u8
*write_data
, u32 block
, u16 Page
,
140 return mtd_Write_Page_Main(write_data
, block
, Page
, PageCount
);
143 u16
GLOB_LLD_Read_Page_Main(u8
*read_data
, u32 block
, u16 Page
,
146 return mtd_Read_Page_Main(read_data
, block
, Page
, PageCount
);
149 u16
GLOB_LLD_Read_Page_Main_Polling(u8
*read_data
,
150 u32 block
, u16 page
, u16 page_count
)
152 return mtd_Read_Page_Main(read_data
, block
, page
, page_count
);
155 u16
GLOB_LLD_Write_Page_Main_Spare(u8
*write_data
, u32 block
,
156 u16 Page
, u16 PageCount
)
158 return mtd_Write_Page_Main_Spare(write_data
, block
, Page
, PageCount
);
161 u16
GLOB_LLD_Read_Page_Main_Spare(u8
*read_data
, u32 block
,
162 u16 Page
, u16 PageCount
)
164 return mtd_Read_Page_Main_Spare(read_data
, block
, Page
, PageCount
);
167 u16
GLOB_LLD_Write_Page_Spare(u8
*write_data
, u32 block
, u16 Page
,
170 return mtd_Write_Page_Spare(write_data
, block
, Page
, PageCount
);
173 u16
GLOB_LLD_Read_Page_Spare(u8
*read_data
, u32 block
, u16 Page
,
176 return mtd_Read_Page_Spare(read_data
, block
, Page
, PageCount
);
179 u16
GLOB_LLD_Get_Bad_Block(u32 block
)
181 return mtd_Get_Bad_Block(block
);
184 #endif /* FLASH_MTD */
186 /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
187 #if FLASH_NAND /* vector all the LLD calls to the NAND controller code */
188 #include "lld_nand.h"
189 #include "lld_cdma.h"
192 /* common functions for LLD_NAND */
193 void GLOB_LLD_ECC_Control(int enable
)
195 NAND_ECC_Ctrl(enable
);
198 /* common functions for LLD_NAND */
199 u16
GLOB_LLD_Flash_Reset(void)
201 return NAND_Flash_Reset();
204 u16
GLOB_LLD_Read_Device_ID(void)
206 return NAND_Read_Device_ID();
209 u16
GLOB_LLD_UnlockArrayAll(void)
211 return NAND_UnlockArrayAll();
214 u16
GLOB_LLD_Flash_Init(void)
216 return NAND_Flash_Init();
219 int GLOB_LLD_Flash_Release(void)
221 return nand_release_spectra();
224 u16
GLOB_LLD_Erase_Block(u32 block_add
)
226 return NAND_Erase_Block(block_add
);
230 u16
GLOB_LLD_Write_Page_Main(u8
*write_data
, u32 block
, u16 Page
,
233 return NAND_Write_Page_Main(write_data
, block
, Page
, PageCount
);
236 u16
GLOB_LLD_Read_Page_Main(u8
*read_data
, u32 block
, u16 page
,
239 if (page_count
== 1) /* Using polling to improve read speed */
240 return NAND_Read_Page_Main_Polling(read_data
, block
, page
, 1);
242 return NAND_Read_Page_Main(read_data
, block
, page
, page_count
);
245 u16
GLOB_LLD_Read_Page_Main_Polling(u8
*read_data
,
246 u32 block
, u16 page
, u16 page_count
)
248 return NAND_Read_Page_Main_Polling(read_data
,
249 block
, page
, page_count
);
252 u16
GLOB_LLD_Write_Page_Main_Spare(u8
*write_data
, u32 block
,
253 u16 Page
, u16 PageCount
)
255 return NAND_Write_Page_Main_Spare(write_data
, block
, Page
, PageCount
);
258 u16
GLOB_LLD_Write_Page_Spare(u8
*write_data
, u32 block
, u16 Page
,
261 return NAND_Write_Page_Spare(write_data
, block
, Page
, PageCount
);
264 u16
GLOB_LLD_Read_Page_Main_Spare(u8
*read_data
, u32 block
,
265 u16 page
, u16 page_count
)
267 return NAND_Read_Page_Main_Spare(read_data
, block
, page
, page_count
);
270 u16
GLOB_LLD_Read_Page_Spare(u8
*read_data
, u32 block
, u16 Page
,
273 return NAND_Read_Page_Spare(read_data
, block
, Page
, PageCount
);
276 u16
GLOB_LLD_Get_Bad_Block(u32 block
)
278 return NAND_Get_Bad_Block(block
);
282 u16
GLOB_LLD_Event_Status(void)
284 return CDMA_Event_Status();
287 u16
glob_lld_execute_cmds(void)
289 return CDMA_Execute_CMDs();
292 u16
GLOB_LLD_MemCopy_CMD(u8
*dest
, u8
*src
,
293 u32 ByteCount
, u16 flag
)
295 /* Replace the hardware memcopy with software memcpy function */
296 if (CDMA_Execute_CMDs())
298 memcpy(dest
, src
, ByteCount
);
301 /* return CDMA_MemCopy_CMD(dest, src, ByteCount, flag); */
304 u16
GLOB_LLD_Erase_Block_cdma(u32 block
, u16 flags
)
306 return CDMA_Data_CMD(ERASE_CMD
, 0, block
, 0, 0, flags
);
309 u16
GLOB_LLD_Write_Page_Main_cdma(u8
*data
, u32 block
, u16 page
, u16 count
)
311 return CDMA_Data_CMD(WRITE_MAIN_CMD
, data
, block
, page
, count
, 0);
314 u16
GLOB_LLD_Read_Page_Main_cdma(u8
*data
, u32 block
, u16 page
,
315 u16 count
, u16 flags
)
317 return CDMA_Data_CMD(READ_MAIN_CMD
, data
, block
, page
, count
, flags
);
320 u16
GLOB_LLD_Write_Page_Main_Spare_cdma(u8
*data
, u32 block
, u16 page
,
321 u16 count
, u16 flags
)
323 return CDMA_Data_CMD(WRITE_MAIN_SPARE_CMD
,
324 data
, block
, page
, count
, flags
);
327 u16
GLOB_LLD_Read_Page_Main_Spare_cdma(u8
*data
,
328 u32 block
, u16 page
, u16 count
)
330 return CDMA_Data_CMD(READ_MAIN_SPARE_CMD
, data
, block
, page
, count
,
331 LLD_CMD_FLAG_MODE_CDMA
);
335 #endif /* FLASH_NAND */
337 /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/