blob: 9f18846fc051a8c0b9203c3be9cb2e1b77378036 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2006
8*
9* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
10* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
11* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
12* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
13* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
14* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
15* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
16* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
17* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
18* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
19* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
20* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
21*
22* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
23* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
24* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
25* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
26* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
27*
28* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
29* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
30* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
31* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
32* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
33*
34*****************************************************************************/
35
36/*****************************************************************************
37 *
38 * Filename:
39 * ---------
40 * custom_flash.c
41 *
42 * Project:
43 * --------
44 * Maui_Software
45 *
46 * Description:
47 * ------------
48 * This Module defines flash related settings.
49 *
50 * Author:
51 * -------
52 * -------
53 *
54 * Memory Device database last modified on 2011/7/8
55 *
56 *============================================================================
57 * HISTORY
58 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
59 *------------------------------------------------------------------------------
60 * removed!
61 * removed!
62 * removed!
63 *
64 * removed!
65 * removed!
66 * removed!
67 *
68 * removed!
69 * removed!
70 * removed!
71 *
72 * removed!
73 * removed!
74 * removed!
75 *
76 * removed!
77 * removed!
78 * removed!
79 *
80 * removed!
81 * removed!
82 * removed!
83 *
84 * removed!
85 * removed!
86 * removed!
87 *
88 * removed!
89 * removed!
90 * removed!
91 * removed!
92 * removed!
93 * removed!
94 * removed!
95 *
96 * removed!
97 * removed!
98 * removed!
99 * removed!
100 *
101 * removed!
102 * removed!
103 * removed!
104 *
105 * removed!
106 * removed!
107 * removed!
108 *
109 * removed!
110 * removed!
111 * removed!
112 *
113 * removed!
114 * removed!
115MT6280 SIP_MDSP link fail.
116[Solution]
117Modify EXTSRAM_type_7() to switch $ram_disk_size become 0x40000 if it's MT6280
118[Verification]
119m sys_auto_gen on MT6280_EVB_R7R8_HSPA(SIP_MDSP).W12.17
120and the generated EXTSRAM_FS maxsize becomes 0x40000 and dummy_end base is correct as well.
121[Phase-in Branch]
122MT6280_DVT_DEV
123MODEM_DEV
124[Version]
125scatGenLib.pl m0.03
126[Requester]
127Stanley Chu
128
129 * removed!
130 *
131 * removed!
132 * removed!
133 * removed!
134 *
135 * removed!
136 * removed!
137 * removed!
138 *
139 * removed!
140 * removed!
141 * removed!
142 *
143 * removed!
144 * removed!
145 * removed!
146 *
147 * removed!
148 * removed!
149 * removed!
150 *
151 * removed!
152 * removed!
153 * removed!
154 *
155 * removed!
156 * removed!
157 * removed!
158 *
159 * removed!
160 * removed!
161 * removed!
162 *
163 * removed!
164 * removed!
165 * removed!
166 *
167 * removed!
168 * removed!
169 * removed!
170 *
171 * removed!
172 * removed!
173 * removed!
174 *
175 *------------------------------------------------------------------------------
176 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
177 *============================================================================
178 ****************************************************************************/
179
180#define FLASHCONF_C
181
182#if defined(__SMART_MD_NFI_DRIVER__) // Smart phone start alone driver
183 #ifndef _NAND_FLASH_BOOTING_
184 #define _NAND_FLASH_BOOTING_
185 #endif
186#endif
187
188#include "kal_general_types.h"
189#include "fs_type.h"
190#include "custom_MemoryDevice.h"
191#include "flash_sf.h"
192#include "string.h"
193
194#ifdef FLASH_DISKDRV_DEBUG
195#include <stdlib.h>
196#endif
197
198#include "flash_opt.h"
199#include "DrvFlash.h"
200#include "NAND_FDM.h"
201#include "flash_disk.h"
202#include "flash_disk_internal.h"
203#include "combo_flash_init.h"
204
205#include "custom_flash.h"
206
207#include "flash_mtd_ut.h" //__BASIC_LOAD_FLASH_TEST__
208#include "DrvFlash_UT.h"
209
210#include "custom_nvram_int_config.h" /* To get NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM for MSTABLE_ENTRY_NUM */
211
212
213#if !(defined(__SMART_PHONE_PLATFORM__) && defined(__SMART_PHONE_MODEM__))
214
215
216
217/*-------------------------------------------------------------------
218 * MS table size
219 *
220 * MS table size should be synchronized with user's requirement. The only one user is NVRAM.
221 *
222 * NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM defines the maximum record size in NVRAM
223 * (in custom_nvram_config.h). NVRAM should call NOR_ResumeSectorState (by FS_Commit)
224 * after it writes maximum NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM sectors with protection
225 * mode to ensure the integrity of a record.
226 *
227 * MSTABLE_ENTRY_NUM number is based on the worst senario: All FAT entries of clusters
228 * of logical sectors are located in different physical sectors. In other word, we need
229 * to write additional N sectors to update FAT after we write N data sectors. The other
230 * 1 sector is for directory entry update.
231 *
232 * TODO: Use auto-gen to compute most suitable MS table size. Because the number of
233 * sectors for FAT may be smaller than NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM. For example,
234 * 64KB disk only needs 1 sector to store FAT.
235 *---------------------------------------------------------- W08.50 --*/
236
237#define MS_TABLE_ENTRY_NUM (NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM * 2 + 1)
238
239/*
240 ****************************************************************************
241 PART 1:
242 Rules to Prevent Wrong Configuration
243 ****************************************************************************
244*/
245#ifdef NAND_PARTITION_SECTORS
246
247 #if (NAND_PARTITION_SECTORS > 0 && NAND_PARTITION_SECTORS < NAND_MINIMUM_PARTITION_SIZE)
248 #error "custom\system\{project}\custom_MemoryDevice.h: Error! NAND_FS_FIRST_DRIVE_SECTORS MUST be larger than NAND_MINIMUM_PARTITION_SIZE!"
249 #endif
250
251 #if (defined(_NAND_FLASH_BOOTING_))
252 #if ( (NAND_PARTITION_SECTORS << 9) > NAND_ALLOCATED_FAT_SPACE)
253 #error "custom\system\{project}\custom_MemoryDevice.h: Error! NAND_FS_FIRST_DRIVE_SECTORS MUST be less than NAND_FS_SIZE!"
254 #endif
255 #endif /* _NAND_FLASH_BOOTING_ */
256
257#endif /* NAND_PARTITION_SECTORS */
258
259
260#if defined(__SINGLE_BANK_NOR_DEVICE__)
261
262 #error "custom\system\{project}\custom_MemoryDevice.h: Error! Single Bank device with non Single Bank load! Please modify device or makefile option!"
263
264#endif /* __SINGLE_BANK_NOR_DEVICE__ */
265
266
267#if !defined(_NAND_FLASH_BOOTING_) && !defined(__EMMC_BOOTING__)
268 #ifndef __NOR_FDM5__
269 #if (TOTAL_BLOCKS > 127)
270 #error "TOTAL_BLOCKS > 127 , recommend enable Pseudo Sized Block feature for serial flash project. Enable FDM5.0 feature for NOR flash project."
271 #endif
272 #endif
273#endif
274
275/*
276 ****************************************************************************
277 PART 2:
278 Essential Information of NOR Flash Geometry Layout Information
279 ****************************************************************************
280*/
281/*******************************************************************************
282 NOTICE: Fill the flash region information table, a region is the memory space
283 that contains continuous sectors of equal size. Each region element
284 in the table is the format as below:
285 {S_sector, N_sector},
286 S_sector: the size of sector in the region
287 N_sector: the number of sectors in the region
288 *******************************************************************************/
289
290#if !(defined(__FUE__) || defined(__UBL__) || defined(__EXT_BOOTLOADER__))
291#define __MAUI_LOAD__
292#endif //!__FUE__ && !__UBL__ && !__EXT_BOOTLOADER__
293
294#if !defined(_NAND_FLASH_BOOTING_) && !defined(__EMMC_BOOTING__) && !defined(__RAMDISK__)
295#define _NOR_FLASH_BOOTING_
296#endif // !_NAND_FLASH_BOOTING_ && !__EMMC_BOOTING__
297
298
299#ifdef _NOR_FLASH_BOOTING_
300
301#define FLASH_REGIONINFO_VAR_MODIFIER static const
302
303#if (defined(__MAUI_LOAD__) && defined(_NOR_FLASH_BOOTING_) && !defined(__NOR_FDM5__))
304#define __MAUI_NOR_FDM4__
305#endif
306
307#if defined(__MAUI_NOR_FDM4__)
308FLASH_REGIONINFO_VAR_MODIFIER FlashRegionInfo RegionInfo[]= /* Don't modify this line */
309{
310 REGION_INFO_LAYOUT
311 EndRegionInfo /* Don't modify this line */
312};
313#endif //__MAUI_NOR_FDM4__
314
315#if !defined(__SERIAL_FLASH__)
316#ifdef __NOR_SUPPORT_RAW_DISK__
317
318#ifndef NOR_BOOTING_NOR_DISK_NUM
319#error "custom\system\{project}\custom_MemoryDevice.h: Error! NOR_BOOTING_NOR_DISK_NUM be defined when __NOR_SUPPORT_RAW_DISK__ is defined."
320#endif //NOR_BOOTING_NOR_DISK_NUM
321
322#if (NOR_BOOTING_NOR_DISK_NUM>0)
323FLASH_REGIONINFO_VAR_MODIFIER FlashRegionInfo Disk0RegionInfo[]= /* Don't modify this line */
324{
325 DISK0_REGION_INFO_LAYOUT
326 EndRegionInfo /* Don't modify this line */
327};
328#endif /* NOR_BOOTING_NOR_DISK_NUM>0 */
329
330#if (NOR_BOOTING_NOR_DISK_NUM>1)
331FLASH_REGIONINFO_VAR_MODIFIER FlashRegionInfo Disk1RegionInfo[]= /* Don't modify this line */
332{
333 DISK1_REGION_INFO_LAYOUT
334 EndRegionInfo /* Don't modify this line */
335};
336#endif /* NOR_BOOTING_NOR_DISK_NUM>1 */
337#endif // __NOR_SUPPORT_RAW_DISK__
338
339FLASH_REGIONINFO_VAR_MODIFIER FlashRegionInfo EntireDiskRegionInfo[]= /* Don't modify this line */
340{
341 ENTIRE_DISK_REGION_INFO_LAYOUT
342 EndRegionInfo /* Don't modify this line */
343};
344
345NOR_FLASH_DISK_Data EntireDiskDriveData;
346static NOR_Flash_MTD_Data EntireDiskMtdData;
347
348/*******************************************************************************
349 NOTICE. Modify the value of page buffer size in WORD for page buffer program
350 *******************************************************************************/
351kal_uint32 PAGE_BUFFER_SIZE = BUFFER_PROGRAM_ITERATION_LENGTH;
352
353/*******************************************************************************
354 NOTICE. This is for the Enhanced Signle Bank Support, when this feature is
355 turned on and still use multi-bank device, this table should be filled
356 with correct value.
357
358 This Table define the flash bank information which starts from
359 FLASH_BASE_ADDRESS, please fill the flash bank information table, every
360 entry defines the memory space that contains continuous banks of equal size.
361 Each entry element in the table is the format as below:
362 {S_Bank, N_Bank},
363 S_Bank: the size of bank in the entry
364 N_Bank: the number of banks in the entry
365 *******************************************************************************/
366#endif /* !__COMBO_MEMORY_SUPPORT__ && !__SERIAL_FLASH__ */
367
368#endif // _NOR_FLASH_BOOTING_
369
370/*
371 ****************************************************************************
372 PART 3:
373 Essential Declarations for NOR-Flash Disk
374 ****************************************************************************
375*/
376
377extern NOR_MTD_Driver NORFlashMtd;
378
379#ifdef __MAUI_NOR_FDM4__
380
381static MS_ENTRY MSEntryTable[MS_TABLE_ENTRY_NUM];
382
383
384#if !defined(__SERIAL_FLASH__)
385
386#ifndef __INTEL_SIBLEY__
387
388/* Each FAT sector is 512bytes (0x200) */
389#define TOTAL_SECTORS ((NOR_ALLOCATED_FAT_SPACE -NOR_BLOCK_SIZE * NOR_SYSTEM_DRIVE_RESERVED_BLOCK) / 0x200)
390
391kal_uint8 FDMBuffer[512];
392
393
394FS_Driver NORFlashDriver =
395{
396 NOR_MountDevice_ext,
397 NOR_ShutDown,
398 NOR_ReadSectors_ext,
399 NOR_WriteSectors_ext,
400 NOR_MediaChanged_ext,
401 NOR_DiscardSectors_ext,
402 NOR_GetDiskGeometry_ext,
403 NOR_LowLevelFormat_ext,
404 NOR_NonBlockWriteSectors_ext,
405 NOR_RecoverableWriteSectors_ext,
406 NOR_ResumeSectorStates_ext,
407 NULL, /*high level format*/
408 NULL, /*flush data*/
409 NULL /*message ack*/
410#ifdef __SECURITY_OTP__
411 ,
412 NULL, /*copy sector*/
413 OTPAccess,
414 OTPQueryLength
415#endif
416};
417
418#else /* __INTEL_SIBLEY__ */
419
420/* Each FAT sector is 1024bytes (0x200) */
421#define TOTAL_SECTORS ((NOR_ALLOCATED_FAT_SPACE - NOR_BLOCK_SIZE * NOR_SYSTEM_DRIVE_RESERVED_BLOCK) / 0x400)
422
423kal_uint8 FDMBuffer[1024];
424
425
426FS_Driver NORFlashDriver =
427{
428 SIB_MountDevice,
429 NOR_ShutDown,
430 SIB_ReadSectors,
431 SIB_WriteSectors,
432 NOR_MediaChanged,
433 SIB_DiscardSectors,
434 SIB_GetDiskGeometry,
435 SIB_LowLevelFormat,
436 SIB_NonBlockWriteSectors,
437 SIB_RecoverableWriteSectors,
438 SIB_ResumeSectorStates,
439 NULL, /*high level format*/
440 NULL, /*flush data*/
441 NULL /*message ack*/
442#ifdef __SECURITY_OTP__
443 ,
444 NULL, /*copy sector*/
445 OTPAccess,
446 OTPQueryLength
447#endif
448};
449
450#endif /* __INTEL_SIBLEY__ */
451
452static WORD AVAILSECTORS[TOTAL_BLOCKS];
453static WORD VALIDSECTORS[TOTAL_BLOCKS];
454static BYTE SectorMap[TOTAL_SECTORS];
455NOR_FLASH_DRV_Data FlashDriveData;
456
457
458#ifdef __MTK_TARGET__
459
460static NOR_Flash_MTD_Data mtdflash;
461
462#ifdef __NOR_SUPPORT_RAW_DISK__
463NOR_FLASH_DISK_Data FlashDiskDriveData[NOR_BOOTING_NOR_DISK_NUM];
464static NOR_Flash_MTD_Data mtdFlashDisk[NOR_BOOTING_NOR_DISK_NUM];
465#endif // __NOR_SUPPORT_RAW_DISK__
466
467extern kal_uint32 INT_RetrieveFlashBaseAddr(void);
468
469#else
470
471static NOR_Flash_MTD_Data mtdflash =
472{
473 MakeMtdFlashData((BYTE *)NOR_FLASH_BASE_ADDRESS, RegionInfo)
474};
475
476#endif /* __MTK_TARGET__ */
477
478#endif /* !(__COMBO_MEMORY_SUPPORT__) && !(__SERIAL_FLASH__) */
479
480#endif /* __MAUI_NOR_FDM4__ */
481
482
483
484/*
485 ****************************************************************************
486 PART 4:
487 Public Functions For NOR Flash Information Retrieve, Initial routine, and
488 other misc routines.
489 ****************************************************************************
490*/
491kal_uint32 custom_get_NORFLASH_Base(void);
492
493/*
494 ****************************************************************************
495 PART 5:
496 Essential Declarations for NAND-Flash Disk
497 ****************************************************************************
498*/
499#if (!(defined(__FUE__) && defined(__FOTA_DM__)) && (!defined(__UBL__)||(defined(__UBL__)&&defined(__NAND_SUPPORT_RAW_DISK__))))
500 // 1. NAND FDM variable compile option
501 // a. In general, FOTA and Boot loader don't need to include NAND FDM variable.
502 // b. In TC01 Raw disk case, boot loader need to call FDM function, it will need raw disk configuration
503 // 2. Declare NAND variable structue
504 // a. In general, NFBxxx is only used for NAND_BOOTING
505 // b. UP_PKG_ON_NAND will also need NFBxxx.
506
507#if defined(__EMMC_BOOTING__)
508
509
510#elif defined(_NAND_FLASH_BOOTING_)
511 /* System Drive on NAND-flash */
512 #if ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
513 kal_uint32 NFB_BASE_ADDRESS[NAND_DISK_NUM];
514 kal_uint32 NFB_ALLOCATED_FAT_SPACE[NAND_DISK_NUM];
515 kal_uint16 FS_DISK_REPLACE_RATIO[NAND_DISK_NUM];
516 const kal_uint8 NANDDiskNum = NAND_DISK_NUM;
517 #if ( defined(__NANDFDM_TOTAL_BBM__))
518 kal_uint32 FS_DISK_START_SECTION[NAND_DISK_NUM];
519 kal_uint32 NFB_REPLACE_BASE_ADDRESS;
520 kal_uint32 NFB_REPLACE_SPACE;
521 BBM_BRMT_INFO NAND_BRMT_Info;
522 #endif
523 #else // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
524 const kal_uint32 NFB_BASE_ADDRESS = NAND_FLASH_BASE_ADDRESS;
525 const kal_uint32 NFB_ALLOCATED_FAT_SPACE = NAND_ALLOCATED_FAT_SPACE;
526 #endif // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
527
528#else /* !_NAND_FLASH_BOOTING_ || __EMMC_BOOTING__ */
529 #if (defined(__UP_PKG_ON_NAND__) && defined(NAND_SUPPORT)) || (defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__))
530 /* update package storage on NAND flash */
531 #if ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
532 kal_uint32 NFB_BASE_ADDRESS[NAND_DISK_NUM];
533 kal_uint32 NFB_ALLOCATED_FAT_SPACE[NAND_DISK_NUM];
534 kal_uint16 FS_DISK_REPLACE_RATIO[NAND_DISK_NUM];
535 const kal_uint8 NANDDiskNum = NAND_DISK_NUM;
536 #else // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
537 const kal_uint32 NFB_BASE_ADDRESS = NAND_FLASH_BASE_ADDRESS;
538 const kal_uint32 NFB_ALLOCATED_FAT_SPACE = NAND_ALLOCATED_FAT_SPACE;
539 #endif // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
540 #endif
541#endif /* _NAND_FLASH_BOOTING_ || __EMMC_BOOTING__ */
542
543#if defined(__NAND_FDM_50__)
544 #ifdef NAND_BOOTING_NAND_MAX_REPLACE_COUNT
545 kal_uint16 wNandMaxReplaceCount = NAND_BOOTING_NAND_MAX_REPLACE_COUNT;
546 #else
547 kal_uint16 wNandMaxReplaceCount = 28;
548 #endif
549#endif //defined(__NAND_FDM_50__)
550
551#ifdef __EMMC_BOOTING__
552kal_uint32 custom_part_secs = 0;
553#else
554kal_uint32 custom_part_secs = NAND_PARTITION_SECTORS;
555#endif
556
557#if ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
558 #if (defined(__UBL__)&&defined(__NAND_SUPPORT_RAW_DISK__))
559 NAND_FLASH_DRV_DATA NANDFlashDriveData[1]; // To save ZI Space
560 #else
561 NAND_FLASH_DRV_DATA NANDFlashDriveData[NAND_DISK_NUM];
562 #endif
563#else // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
564NAND_FLASH_DRV_DATA NANDFlashDriveData;
565#endif // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
566
567#endif /* (!(__FOTA_DM__ && __FUE__) || !__UBL__)) || (UBL&&RAW) */
568/*************************************************************************
569* FUNCTION
570* custom_get_NORFLASH_ROMSpace()
571*
572* DESCRIPTION
573* Query the of space configured for NORFLASH ROM
574*
575* PARAMETERS
576*
577* RETURNS
578* BASE ADDRESS
579*
580* GLOBALS AFFECTED
581*
582*************************************************************************/
583kal_uint32
584custom_get_NORFLASH_ROMSpace(void)
585{
586#if defined(_NAND_FLASH_BOOTING_) || defined(__EMMC_BOOTING__) || defined(__RAMDISK__)
587 return 0;
588#elif defined(__FS_SYSDRV_ON_NAND__) || (defined(__UP_PKG_ON_NAND__) && defined(NAND_SUPPORT))
589 return NOR_FLASH_BASE_ADDRESS + NOR_ALLOCATED_FAT_SPACE;
590#else
591 return NOR_FLASH_BASE_ADDRESS;
592#endif
593}
594
595
596/*************************************************************************
597* FUNCTION
598* custom_get_NORFLASH_Size()
599*
600* DESCRIPTION
601* Query the size of NORFLASH ROM
602*
603* PARAMETERS
604*
605* RETURNS
606* SIZE
607*
608* GLOBALS AFFECTED
609*
610*************************************************************************/
611kal_uint32
612custom_get_NORFLASH_Size(void)
613{
614#if defined(_NAND_FLASH_BOOTING_) || defined(__EMMC_BOOTING__) || defined(__RAMDISK__)
615 return 0;
616#else
617 return NOR_FLASH_SIZE;
618#endif
619}
620
621/*************************************************************************
622* FUNCTION
623* Initialize_FDD_tables
624*
625* DESCRIPTION
626* Initialize important information for NOR-flash disk
627*
628* PARAMETERS
629*
630* RETURNS
631* None
632*
633* GLOBALS AFFECTED
634*
635*************************************************************************/
636#if defined(__MAUI_LOAD__)
637
638#if defined(__RAMDISK__)
639extern kal_uint8 ram_disk[];
640void Initialize_FDD_tables(void)
641{
642 return;
643}
644#elif defined(__SERIAL_FLASH__) && defined(_NOR_FLASH_BOOTING_)
645void Initialize_FDD_tables(void)
646{
647#if !defined(ATEST_DRV_ENABLE) && !defined(ATEST_DRV_ENVIRON)
648 ComboMem_Initialize();
649#endif /* end of ATEST_DRV_ENABLE */
650 return;
651}
652
653#else /* (!(__COMBO_MEMORY_SUPPORT__) && !(__SERIAL_FLASH__)) && !(_NOR_FLASH_BOOTING_) */
654
655#ifndef __NOR_FDM5__
656
657#ifdef __NONE_FLASH_EXIST__
658
659NOR_MTD_Driver NORFlashMtd;
660
661#endif
662
663void Initialize_FDD_tables(void)
664{
665#if ( !defined(__FS_SYSDRV_ON_NAND__) && defined(_NOR_FLASH_BOOTING_))
666
667 /* Initialize MTD data table */
668 mtdflash.Signature = ~((kal_uint32)RegionInfo);
669
670#ifdef __MTK_TARGET__
671#if (defined(__SMART_PHONE_PLATFORM__) && !defined(__SMART_PHONE_MODEM__)) && defined(__RAMDISK__)
672 mtdflash.BaseAddr = (kal_uint8 *)ram_disk;
673#else
674 mtdflash.BaseAddr = (BYTE *)(INT_RetrieveFlashBaseAddr() + NOR_FLASH_BASE_ADDRESS);
675#endif
676
677#endif /* __MTK_TARGET__ */
678
679 mtdflash.RegionInfo = (FlashRegionInfo *)RegionInfo;
680
681 /* Initialize FDD data table */
682 FlashDriveData.MTDDriver = &NORFlashMtd;
683 FlashDriveData.MTDData = &mtdflash;
684 FlashDriveData.AvailSectorsInBlock = AVAILSECTORS;
685 FlashDriveData.ValidSectorsInBlock = VALIDSECTORS;
686 FlashDriveData.SectorMap = (BYTE*)SectorMap;
687 FlashDriveData.PartitionSectors = NOR_PARTITION_SECTORS;
688 FlashDriveData.Buffer = FDMBuffer;
689 FlashDriveData.MSTABLE_ENTRY_NUM = MS_TABLE_ENTRY_NUM;
690 FlashDriveData.MSEntryTable = MSEntryTable;
691
692 /* The reserved unit is 0.5 block.*/
693 FlashDriveData.SystemDriveReservedUnits = (kal_uint32)(NOR_SYSTEM_DRIVE_RESERVED_BLOCK * 2);
694
695
696#ifdef __NOR_SUPPORT_RAW_DISK__
697 mtdFlashDisk[0].Signature = ~((kal_uint32)Disk0RegionInfo);
698 mtdFlashDisk[0].BaseAddr = (BYTE *)(INT_RetrieveFlashBaseAddr() + NOR_BOOTING_NOR_DISK0_BASE_ADDRESS);
699 mtdFlashDisk[0].RegionInfo = (FlashRegionInfo *)Disk0RegionInfo;
700 FlashDiskDriveData[0].DiskSize = NOR_BOOTING_NOR_DISK0_SIZE;
701 FlashDiskDriveData[0].MTDDriver = &NORFlashMtd;
702 FlashDiskDriveData[0].MTDData = &mtdFlashDisk[0];
703#if (NOR_BOOTING_NOR_DISK_NUM > 1)
704 mtdFlashDisk[1].Signature = ~((kal_uint32)Disk1RegionInfo);
705 mtdFlashDisk[1].BaseAddr = (BYTE *)(INT_RetrieveFlashBaseAddr() + NOR_BOOTING_NOR_DISK1_BASE_ADDRESS);
706 mtdFlashDisk[1].RegionInfo = (FlashRegionInfo *)Disk1RegionInfo;
707 FlashDiskDriveData[1].DiskSize = NOR_BOOTING_NOR_DISK1_SIZE;
708 FlashDiskDriveData[1].MTDDriver = &NORFlashMtd;
709 FlashDiskDriveData[1].MTDData = &mtdFlashDisk[1];
710#endif // NOR_BOOTING_NOR_DISK_NUM > 1
711#endif // __NOR_SUPPORT_RAW_DISK__
712
713#ifdef __FOTA_DM__
714 FlashDriveData.FlashInfo.baseUnlockBlock = INVALID_BLOCK_INDEX;
715 FlashDriveData.FlashInfo.endUnlockBlock = INVALID_BLOCK_INDEX;
716#endif
717
718
719#ifdef __BASIC_LOAD_FLASH_TEST__
720#ifdef __INTEL_SIBLEY__
721 LocateSector_ext = SIB_LocateSector;
722#else
723 LocateSector_ext = LocateSector;
724#endif //__INTEL_SIBLEY__
725#endif //__BASIC_LOAD_FLASH_TEST__
726
727
728#endif /* !__FS_SYSDRV_ON_NAND__ && _NOR_FLASH_BOOTING_ */
729
730 #if ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
731 {
732 kal_uint32 DiskIndex;
733
734 for (DiskIndex=0; DiskIndex<NAND_DISK_NUM; DiskIndex++)
735 {
736 #if (defined(__UBL__)&&defined(__NAND_SUPPORT_RAW_DISK__))
737 if(DiskIndex==RAW_DISK_INDEX){
738 NANDFlashDriveData[0].NAND_FDMData.DiskIndex = RAW_DISK_INDEX;
739 }
740 #else
741 NANDFlashDriveData[DiskIndex].NAND_FDMData.DiskIndex = DiskIndex;
742 #endif
743 switch (DiskIndex)
744 {
745 case 0:
746 NFB_BASE_ADDRESS[0] = NAND_BOOTING_NAND_FS_DISK0_BASE_ADDRESS;
747 NFB_ALLOCATED_FAT_SPACE[0] = NAND_BOOTING_NAND_FS_DISK0_SIZE;
748 FS_DISK_REPLACE_RATIO[0] = NAND_BOOTING_NAND_FS_DISK0_REPLACE_RATIO;
749 break;
750 #if (NAND_DISK_NUM > 1)
751 case 1:
752 NFB_BASE_ADDRESS[1] = NAND_BOOTING_NAND_FS_DISK1_BASE_ADDRESS;
753 NFB_ALLOCATED_FAT_SPACE[1] = NAND_BOOTING_NAND_FS_DISK1_SIZE;
754 FS_DISK_REPLACE_RATIO[1] = NAND_BOOTING_NAND_FS_DISK1_REPLACE_RATIO;
755 break;
756 #endif /* NAND_DISK_NUM > 1 */
757 #if (NAND_DISK_NUM > 2)
758 case 2:
759 NFB_BASE_ADDRESS[2] = NAND_BOOTING_NAND_FS_DISK2_BASE_ADDRESS;
760 NFB_ALLOCATED_FAT_SPACE[2] = NAND_BOOTING_NAND_FS_DISK2_SIZE;
761 FS_DISK_REPLACE_RATIO[2] = NAND_BOOTING_NAND_FS_DISK2_REPLACE_RATIO;
762 break;
763 #endif /* NAND_DISK_NUM > 2 */
764 #if (NAND_DISK_NUM > 3)
765 case 3:
766 NFB_BASE_ADDRESS[3] = NAND_BOOTING_NAND_FS_DISK3_BASE_ADDRESS;
767 NFB_ALLOCATED_FAT_SPACE[3] = NAND_BOOTING_NAND_FS_DISK3_SIZE;
768 FS_DISK_REPLACE_RATIO[3] = NAND_BOOTING_NAND_FS_DISK3_REPLACE_RATIO;
769 break;
770 #endif /* NAND_DISK_NUM > 3 */
771 #if (NAND_DISK_NUM > 4)
772 case 4:
773 NFB_BASE_ADDRESS[4] = NAND_BOOTING_NAND_FS_DISK4_BASE_ADDRESS;
774 NFB_ALLOCATED_FAT_SPACE[4] = NAND_BOOTING_NAND_FS_DISK4_SIZE;
775 FS_DISK_REPLACE_RATIO[4] = NAND_BOOTING_NAND_FS_DISK4_REPLACE_RATIO;
776 break;
777 #endif /* NAND_DISK_NUM > 4 */
778 #if (NAND_DISK_NUM > 5)
779 case 5:
780 NFB_BASE_ADDRESS[5] = NAND_BOOTING_NAND_FS_DISK5_BASE_ADDRESS;
781 NFB_ALLOCATED_FAT_SPACE[5] = NAND_BOOTING_NAND_FS_DISK5_SIZE;
782 FS_DISK_REPLACE_RATIO[5] = NAND_BOOTING_NAND_FS_DISK5_REPLACE_RATIO;
783 break;
784 #endif /* NAND_DISK_NUM > 5 */
785 #if (NAND_DISK_NUM > 6)
786 case 6:
787 NFB_BASE_ADDRESS[6] = NAND_BOOTING_NAND_FS_DISK6_BASE_ADDRESS;
788 NFB_ALLOCATED_FAT_SPACE[6] = NAND_BOOTING_NAND_FS_DISK6_SIZE;
789 FS_DISK_REPLACE_RATIO[6] = NAND_BOOTING_NAND_FS_DISK6_REPLACE_RATIO;
790 break;
791 #endif /* NAND_DISK_NUM > 6 */
792 #if (NAND_DISK_NUM > 7)
793 case 7:
794 NFB_BASE_ADDRESS[7] = NAND_BOOTING_NAND_FS_DISK7_BASE_ADDRESS;
795 NFB_ALLOCATED_FAT_SPACE[7] = NAND_BOOTING_NAND_FS_DISK7_SIZE;
796 FS_DISK_REPLACE_RATIO[7] = NAND_BOOTING_NAND_FS_DISK7_REPLACE_RATIO;
797 break;
798 #endif /* NAND_DISK_NUM > 7 */
799 }
800 }
801 }
802 #if ( defined(__NANDFDM_TOTAL_BBM__))
803 NFB_REPLACE_BASE_ADDRESS = NAND_BOOTING_NAND_FS_REPLACE_BASE_ADDRESS;
804 NFB_REPLACE_SPACE = NAND_BOOTING_NAND_FS_REPLACE_SIZE;
805 NAND_BRMT_Info.ParameterReady = KAL_FALSE;
806 NAND_BRMT_Info.NoReplace = KAL_FALSE;
807 NAND_BRMT_Info.BRMT_Addr = 0;
808 NAND_BRMT_Info.CurSectorInRAM = 0xff;
809 #endif
810
811 #endif // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
812}
813#endif /*__NOR_FDM5__*/
814#endif /* !(__COMBO_MEMORY_SUPPORT__) && !(__SERIAL_FLASH__) */
815
816void nor_sweep_device(void)
817{
818#ifdef __NOR_FDM5__
819 kal_set_eg_events(nor_egid, NOR_DMAN_EVENT, KAL_OR);
820#endif
821 return;
822}
823
824void nor_manual_reclaim(void)
825{
826#ifdef __NOR_FDM5__
827 kal_set_eg_events(nor_egid, NOR_BRECL_EVENT, KAL_OR);
828#endif
829 return;
830}
831
832/*************************************************************************
833* FUNCTION
834* custom_get_fat_addr()
835*
836* DESCRIPTION
837* This function gets the start address of FAT.
838*
839* PARAMETERS
840* none
841*
842* RETURNS
843* FAT start address
844*
845*************************************************************************/
846kal_uint32 custom_get_fat_addr()
847{
848 #if defined(__RAMDISK__)
849 return (kal_uint32)(&ram_disk);
850 #elif defined(__EMMC_BOOTING__)
851 return EMMC_CODE_PARTITION_SIZE;
852 #elif defined(_NAND_FLASH_BOOTING_)
853 return NAND_FLASH_BASE_ADDRESS;
854 #else
855 return NOR_FLASH_BASE_ADDRESS;
856 #endif /* _NAND_FLASH_BOOTING_ */
857}
858
859/*************************************************************************
860* FUNCTION
861* custom_get_fat_len()
862*
863* DESCRIPTION
864* This function gets the len of FAT.
865*
866* PARAMETERS
867* none
868*
869* RETURNS
870* FAT length
871*
872*************************************************************************/
873kal_uint32 custom_get_fat_len()
874{
875 #if defined(__RAMDISK__)
876 return RAM_FS_SIZE_INT;
877 #elif defined(__EMMC_BOOTING__)
878 return 0;
879 #elif defined(_NAND_FLASH_BOOTING_)
880 return NAND_ALLOCATED_FAT_SPACE;
881 #else
882 return NOR_ALLOCATED_FAT_SPACE;
883 #endif /* _NAND_FLASH_BOOTING_ */
884}
885#endif // __MAUI_LOAD__
886
887/*************************************************************************
888* FUNCTION
889* Custom_NAND_Init
890*
891* DESCRIPTION
892* Initialize important information for NAND-flash disk
893*
894* PARAMETERS
895*
896* RETURNS
897* None
898*
899* GLOBALS AFFECTED
900*
901*************************************************************************/
902#if ((defined(__UBL__)&&defined(__NAND_SUPPORT_RAW_DISK__))||(!defined(__UBL__))) && !defined(__FUE__)
903kal_bool NANDParameterInitialized = KAL_FALSE;
904void Custom_NAND_Init(void)
905{
906 #if ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
907 {
908 kal_uint32 DiskIndex;
909 if(NANDParameterInitialized==KAL_TRUE){
910 return;
911 }
912 NANDParameterInitialized = KAL_TRUE;
913
914 for (DiskIndex=0; DiskIndex<NAND_DISK_NUM; DiskIndex++)
915 {
916 #if (defined(__UBL__)&&defined(__NAND_SUPPORT_RAW_DISK__))
917 if(DiskIndex==RAW_DISK_INDEX){
918 NANDFlashDriveData[0].NAND_FDMData.DiskIndex = RAW_DISK_INDEX;
919 }
920 #else
921 NANDFlashDriveData[DiskIndex].NAND_FDMData.DiskIndex = DiskIndex;
922 #endif
923 switch (DiskIndex)
924 {
925 case 0:
926 NFB_BASE_ADDRESS[0] = NAND_BOOTING_NAND_FS_DISK0_BASE_ADDRESS;
927 NFB_ALLOCATED_FAT_SPACE[0] = NAND_BOOTING_NAND_FS_DISK0_SIZE;
928 FS_DISK_REPLACE_RATIO[0] = NAND_BOOTING_NAND_FS_DISK0_REPLACE_RATIO;
929 break;
930 #if (NAND_DISK_NUM > 1)
931 case 1:
932 NFB_BASE_ADDRESS[1] = NAND_BOOTING_NAND_FS_DISK1_BASE_ADDRESS;
933 NFB_ALLOCATED_FAT_SPACE[1] = NAND_BOOTING_NAND_FS_DISK1_SIZE;
934 FS_DISK_REPLACE_RATIO[1] = NAND_BOOTING_NAND_FS_DISK1_REPLACE_RATIO;
935 break;
936 #endif /* NAND_DISK_NUM > 1 */
937 #if (NAND_DISK_NUM > 2)
938 case 2:
939 NFB_BASE_ADDRESS[2] = NAND_BOOTING_NAND_FS_DISK2_BASE_ADDRESS;
940 NFB_ALLOCATED_FAT_SPACE[2] = NAND_BOOTING_NAND_FS_DISK2_SIZE;
941 FS_DISK_REPLACE_RATIO[2] = NAND_BOOTING_NAND_FS_DISK2_REPLACE_RATIO;
942 break;
943 #endif /* NAND_DISK_NUM > 2 */
944 #if (NAND_DISK_NUM > 3)
945 case 3:
946 NFB_BASE_ADDRESS[3] = NAND_BOOTING_NAND_FS_DISK3_BASE_ADDRESS;
947 NFB_ALLOCATED_FAT_SPACE[3] = NAND_BOOTING_NAND_FS_DISK3_SIZE;
948 FS_DISK_REPLACE_RATIO[3] = NAND_BOOTING_NAND_FS_DISK3_REPLACE_RATIO;
949 break;
950 #endif /* NAND_DISK_NUM > 3 */
951 #if (NAND_DISK_NUM > 4)
952 case 4:
953 NFB_BASE_ADDRESS[4] = NAND_BOOTING_NAND_FS_DISK4_BASE_ADDRESS;
954 NFB_ALLOCATED_FAT_SPACE[4] = NAND_BOOTING_NAND_FS_DISK4_SIZE;
955 FS_DISK_REPLACE_RATIO[4] = NAND_BOOTING_NAND_FS_DISK4_REPLACE_RATIO;
956 break;
957 #endif /* NAND_DISK_NUM > 4 */
958 #if (NAND_DISK_NUM > 5)
959 case 5:
960 NFB_BASE_ADDRESS[5] = NAND_BOOTING_NAND_FS_DISK5_BASE_ADDRESS;
961 NFB_ALLOCATED_FAT_SPACE[5] = NAND_BOOTING_NAND_FS_DISK5_SIZE;
962 FS_DISK_REPLACE_RATIO[5] = NAND_BOOTING_NAND_FS_DISK5_REPLACE_RATIO;
963 break;
964 #endif /* NAND_DISK_NUM > 5 */
965 #if (NAND_DISK_NUM > 6)
966 case 6:
967 NFB_BASE_ADDRESS[6] = NAND_BOOTING_NAND_FS_DISK6_BASE_ADDRESS;
968 NFB_ALLOCATED_FAT_SPACE[6] = NAND_BOOTING_NAND_FS_DISK6_SIZE;
969 FS_DISK_REPLACE_RATIO[6] = NAND_BOOTING_NAND_FS_DISK6_REPLACE_RATIO;
970 break;
971 #endif /* NAND_DISK_NUM > 6 */
972 #if (NAND_DISK_NUM > 7)
973 case 7:
974 NFB_BASE_ADDRESS[7] = NAND_BOOTING_NAND_FS_DISK7_BASE_ADDRESS;
975 NFB_ALLOCATED_FAT_SPACE[7] = NAND_BOOTING_NAND_FS_DISK7_SIZE;
976 FS_DISK_REPLACE_RATIO[7] = NAND_BOOTING_NAND_FS_DISK7_REPLACE_RATIO;
977 break;
978 #endif /* NAND_DISK_NUM > 7 */
979 }
980 }
981 }
982 #if ( defined(__NANDFDM_TOTAL_BBM__))
983 NFB_REPLACE_BASE_ADDRESS = NAND_BOOTING_NAND_FS_REPLACE_BASE_ADDRESS;
984 NFB_REPLACE_SPACE = NAND_BOOTING_NAND_FS_REPLACE_SIZE;
985 NAND_BRMT_Info.ParameterReady = KAL_FALSE;
986 NAND_BRMT_Info.NoReplace = KAL_FALSE;
987 NAND_BRMT_Info.BRMT_Addr = 0;
988 NAND_BRMT_Info.CurSectorInRAM = 0xff;
989 #endif
990
991 #endif // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
992}
993#endif /* (!__UBL__ && !__FUE__)|| (UBL&&RAW) */
994
995extern kal_int32 EMI_QueryIsRemapped(void);
996
997void Custom_NOR_Init(void)
998{
999#if (!(defined(__FS_SYSDRV_ON_NAND__) || defined( _NAND_FLASH_BOOTING_) || defined(__EMMC_BOOTING__))) && !defined(__RAMDISK__)
1000 #if defined(__SERIAL_FLASH__)
1001 CMEM_Init_FullDriver();
1002 #else // (defined(__COMBO_MEMORY_SUPPORT__) || defined(__SERIAL_FLASH__))
1003 EntireDiskMtdData.Signature = ~((kal_uint32)EntireDiskRegionInfo);
1004 #if defined(__UBL__)
1005 if(EMI_QueryIsRemapped())
1006 EntireDiskMtdData.BaseAddr = (BYTE *)0x10000000;
1007 else
1008 EntireDiskMtdData.BaseAddr = (BYTE *)0;
1009 #else
1010 EntireDiskMtdData.BaseAddr = (BYTE *)INT_RetrieveFlashBaseAddr();
1011 #endif
1012 EntireDiskMtdData.RegionInfo = (FlashRegionInfo *)EntireDiskRegionInfo;
1013 EntireDiskDriveData.DiskSize = NOR_FLASH_SIZE;
1014 EntireDiskDriveData.MTDDriver = &NORFlashMtd;
1015 EntireDiskDriveData.MTDData = &EntireDiskMtdData;
1016 EntireDiskDriveData.is_mount = KAL_FALSE;
1017 #endif // (defined(__COMBO_MEMORY_SUPPORT__) || defined(__SERIAL_FLASH__))
1018#endif /* !__FS_SYSDRV_ON_NAND__ && !_NAND_FLASH_BOOTING_ */
1019}
1020
1021#if (defined(__FUE__) || defined(__EXT_BOOTLOADER__)) && defined(__FOTA_DM__)
1022#if defined(__SERIAL_FLASH__)
1023
1024void Initialize_NOR_Info(void)
1025{
1026 CMEM_Init_FUE();
1027}
1028
1029
1030#else //!__COMBO_MEMORY_SUPPORT__ && !__SERIAL_FLASH__
1031
1032#include "custom_fota.h"
1033
1034NOR_Flash_MTD_Data fue_nor_mtdflash;
1035
1036extern NOR_MTD_Driver NORFlashMtd;
1037
1038NOR_FLASH_DRV_Data FlashDriveData;
1039
1040void Initialize_NOR_Info(void)
1041{
1042#if defined(_NOR_FLASH_BOOTING_)
1043 kal_uint32 blk_addr = 0;
1044
1045 /* Initialize MTD data table */
1046 fue_nor_mtdflash.Signature = ~((kal_uint32)NORRegionInfo);
1047
1048 #if !defined(__UBL__)
1049 FlashDriveData.MTDDriver = &NORFlashMtd;
1050 #endif /* __UBL__ */
1051 FlashDriveData.MTDData = &fue_nor_mtdflash;
1052
1053#ifdef __MTK_TARGET__
1054 #if defined(MT6238) || defined(MT6239) || defined(MT6235B)
1055 fue_nor_mtdflash.BaseAddr = (BYTE *)(custom_get_NORFLASH_Base()|0x08000000);
1056 #elif defined(MT6228) || defined(MT6229) || defined(MT6230) || defined(MT6225) || defined(MT6268T)
1057 fue_nor_mtdflash.BaseAddr = (BYTE *)(custom_get_NORFLASH_Base()|0x04000000);
1058 #else
1059 fue_nor_mtdflash.BaseAddr = (BYTE *)custom_get_NORFLASH_Base();
1060 #endif
1061#endif /* __MTK_TARGET__ */
1062
1063 fue_nor_mtdflash.RegionInfo = (FlashRegionInfo *)NORRegionInfo;
1064
1065#ifdef __FOTA_DM__
1066 blk_addr = SSF_GetUAImageLoadAddress()|custom_get_NORFLASH_Base();
1067 #if defined(MT6238) || defined(MT6239) || defined(MT6235B)
1068 blk_addr |= 0x08000000;
1069 #elif defined(MT6228) || defined(MT6229) || defined(MT6230) || defined(MT6225) || defined(MT6268T)
1070 blk_addr |= 0x04000000;
1071 #else
1072 blk_addr |= 0x0;
1073 #endif
1074 blk_addr -= (kal_uint32)fue_nor_mtdflash.BaseAddr;
1075 FlashDriveData.FlashInfo.baseUnlockBlock = BlockIndex(&fue_nor_mtdflash, blk_addr);
1076
1077 #if (defined(__UP_PKG_ON_NAND__) && defined(NAND_SUPPORT))
1078 blk_addr = (custom_get_NORFLASH_ROMSpace() - 1) | custom_get_NORFLASH_Base();
1079 #else
1080 blk_addr = FOTA_GetPackageStorageBase()+FOTA_GetPackageStorageSize();
1081 #endif /* __UP_PKG_ON_NAND__ && NAND_SUPPORT */
1082
1083 #if defined(MT6238) || defined(MT6239) || defined(MT6235B)
1084 blk_addr |= 0x08000000;
1085 #elif defined(MT6228) || defined(MT6229) || defined(MT6230) || defined(MT6225) || defined(MT6268T)
1086 blk_addr |= 0x04000000;
1087 #else
1088 blk_addr |= 0x0;
1089 #endif
1090
1091 blk_addr -= (kal_uint32)fue_nor_mtdflash.BaseAddr;
1092 FlashDriveData.FlashInfo.endUnlockBlock = BlockIndex(&fue_nor_mtdflash, blk_addr);
1093#endif
1094
1095#endif // _NOR_FLASH_BOOTING_
1096}
1097
1098#endif //__COMBO_MEMORY_SUPPORT__ || __SERIAL_FLASH__
1099#endif /* (__FUE__ || __EXT_BOOTLOADER__) && __FOTA_DM__ */
1100
1101
1102
1103
1104
1105/*************************************************************************
1106* FUNCTION
1107* custom_get_FLASH_Size()
1108*
1109* DESCRIPTION
1110* Query the of space configured for ROM
1111*
1112* PARAMETERS
1113*
1114* RETURNS
1115* BASE ADDRESS
1116*
1117* GLOBALS AFFECTED
1118*
1119*************************************************************************/
1120kal_uint32 custom_get_FLASH_Size(void)
1121{
1122#if defined(__RAMDISK__)
1123 return RAM_FS_SIZE_INT;
1124#elif defined(__EMMC_BOOTING__)
1125 return 0;
1126#elif defined(_NAND_FLASH_BOOTING_)
1127 return NAND_TOTAL_SIZE << 20;
1128#else
1129 return NOR_FLASH_SIZE;
1130#endif
1131}
1132
1133#if defined(__RAMDISK__)
1134#include "ramdisk_gprot.h" // for RAM Disk FDM APIs
1135kal_uint32 RAMDiskDriveData;
1136FS_Driver RAMDiskDriver =
1137{
1138 ramdisk_fdm_mount_device,
1139 ramdisk_fdm_shutdown,
1140 ramdisk_fdm_read_sectors,
1141 ramdisk_fdm_write_sectors,
1142 ramdisk_fdm_media_changed,
1143 NULL,
1144 ramdisk_fdm_get_disk_geometry,
1145 NULL,
1146 NULL,
1147 ramdisk_fdm_recoverable_write_sectors,
1148 ramdisk_fdm_resume_sector_states,
1149 NULL,
1150 NULL, /*flush data*/
1151 NULL, /*message ack*/
1152 NULL, /*copy sector*/
1153 NULL,
1154 NULL
1155};
1156#endif // __RAMDISK__
1157#else // __SMART_PHONE_PLATFORM__ && __SMART_PHONE_MODEM__
1158void Initialize_FDD_tables(void)
1159{
1160 return;
1161}
1162
1163kal_uint32 custom_get_fat_addr()
1164{
1165 return 0;
1166}
1167
1168kal_uint32 custom_get_fat_len()
1169{
1170 return 0;
1171}
1172
1173
1174/*************************************************************************
1175* FUNCTION
1176* custom_get_NORFLASH_Base()
1177*
1178* DESCRIPTION
1179* Query the of space configured for NORFLASH ROM
1180*
1181* PARAMETERS
1182*
1183* RETURNS
1184* BASE ADDRESS
1185*
1186* GLOBALS AFFECTED
1187*
1188*************************************************************************/
1189kal_uint32 custom_get_NORFLASH_Base(void)
1190{
1191#if defined(_NAND_FLASH_BOOTING_) || defined(__EMMC_BOOTING__)
1192 return 0;
1193#else
1194 return NOR_FLASH_BASE_ADDR;
1195#endif
1196}
1197
1198
1199#endif //!__SMART_PHONE_PLATFORM__ || !__SMART_PHONE_MODEM__
1200
1201
1202
1203/*************************************************************************
1204* FUNCTION
1205* INT_QueryIsROMSpace()
1206*
1207* DESCRIPTION
1208* Query the address in Flash address space or not
1209*
1210* PARAMETERS
1211* address to check
1212*
1213* RETURNS
1214* KAL_TRUE if address is in Flash address space
1215* KAL_FALSE if not
1216*
1217* Only apply to ADMUX MT6255 for DMA to check whether the address to be copied in flash or not.
1218* To avoid DMA accessing Single bank flash when it is busy.
1219*
1220*************************************************************************/
1221
1222kal_bool INT_QueryIsROMSpace(kal_uint32 addr)
1223{
1224 return KAL_FALSE;
1225}
1226