📄 custom_emi.c
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2006
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* custom_EMI.c
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
* This Module defines the EMI (external memory interface) related setting.
*
* Author:
* -------
* EMI auto generator V4.07
*
* Memory Device database last modified on 2007/10/22
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* $Revision$
* $Modtime$
* $Log$
*
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
#define FLASHCONF_C
#ifndef FLASH_DISKDRV_DEBUG
#include "kal_release.h"
#else
#include <stdlib.h>
#endif
#include "flash_opt.h"
#include "reg_base.h"
#include "MemoryDevice_TypeDef.h"
#include "custom_MemoryDevice.h"
#include "fat_fs.h"
#include "DrvFlash.h"
#include "NAND_FDM.h"
#include "custom_emi.h"
/*
****************************************************************************
Essential Declarations for NOR-Flash Disk
****************************************************************************
*/
extern void drvier_config(kal_uint8 ,kal_uint32);
#define MANUFACTURE_ID_ADDR 0x80030100
#define DEV_ID_ADDR 0x80030200
#define EXT_DEV1_ID_ADDR 0x80030104
#define EXT_DEV2_ID_ADDR 0x80030204
#define MCP_NUMBERS 6//for flash table
#define EMI_LOCATION_ADDR 0x80030300
#define TEST_MEMORY 0X1234ABCD
#ifdef REMAPPING
#define EXTRAM_32MADDR 0x00400400
#define EXTRAM_0MADDR 0X00000400
#else
#define EXTRAM_32MADDR 0x08400400
#define EXTRAM_0MADDR 0x08000400
#endif
kal_uint16 gManufacture_code;
kal_uint16 gDev_code;
kal_uint16 gExt_dev_code1;
kal_uint16 gExt_dev_code2;
kal_uint32 gFatsize;
kal_uint32 gfat_base_addr;
kal_uint8 drv_dbg;
const Flash_setting_info flash_info_table[MCP_NUMBERS]=
{
{{0x0001,0x227e,0x223c,0x2200},32,0x01c00000,0x00400000,0x00800000,SPANSION_PL_N,
{{0x40000, 15},
{0x10000, 4},
EndRegionInfo}
#if defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__) && defined( __MULTI_BANK_NOR_DEVICE__)
,{{ 0x400000, 1 },
EndBankInfo}
#endif
},//s71PL256NC0HFW5B
{{0x00ec,0x227e,0x2263,0x2260},0,0x01c00000,0x00400000,0x00800000,SPANSION_PL_J,
{{0x40000, 15},
{0x10000, 4},
EndRegionInfo}
#if defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__) && defined( __MULTI_BANK_NOR_DEVICE__)
,{{ 0x400000, 1 },
EndBankInfo}
#endif
},//K5L5563CAM-D770
{{0x0001,0x227e,0x2220,0x2200},32,0x00e00000,0x00200000,0x00800000,SPANSION_PL_N,
{{0x40000, 7},
{0x10000, 4},
EndRegionInfo}
#if defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__) && defined( __MULTI_BANK_NOR_DEVICE__)
,{{ 0x200000, 1 },
EndBankInfo}
#endif
},//71PL127NCOHFW4B
{{0x00ec,0x257e,0x2508,0x2501},0,0x00e00000,0x00200000,0x00800000,SPANSION_PL_J,
{{0x10000, 31},
{0x2000, 8},
EndRegionInfo}
#if defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__) && defined( __MULTI_BANK_NOR_DEVICE__)
,{{ 0x200000, 1 },
EndBankInfo}
#endif
},//K5L2763CAM
{{0x0001,0x227e,0x2220,0x2200},32,0X00E00000,0X00200000,0X00400000,SPANSION_PL_N,
{{0x40000, 7},
{0x10000, 4},
EndRegionInfo}
#if defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__) && defined( __MULTI_BANK_NOR_DEVICE__)
,{{ 0x200000, 1 },
EndBankInfo}
#endif
},//71PL127NBOHFW4U
{{0x00ec,0x257e,0x2508,0x2501},0,0X00E00000,0X00200000,0X00400000,SPANSION_PL_J,
{{0x10000, 31},
{0x2000, 8},
EndRegionInfo}
#if defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__) && defined( __MULTI_BANK_NOR_DEVICE__)
,{{ 0x200000, 1 },
EndBankInfo}
#endif
}//K5L2731CAA
} ;
#ifndef __FUE__
/* __FUE__ compile option is used for FOTA build
* add this compile option to avoid compiling functions other than custom_setEMI()
*/
#if ( defined(__FS_SYSDRV_ON_NAND__) || defined( _NAND_FLASH_BOOTING_) )
/* System Drive on NAND-flash */
kal_uint32 NFB_BASE_ADDRESS;
kal_uint32 NFB_ALLOCATED_FAT_SPACE;
#else/* __FS_SYSDRV_ON_NAND__ || _NAND_FLASH_BOOTING_ */
#ifndef __NOR_FDM5__
/* System Drive on NOR-flash */
#ifndef __INTEL_SIBLEY__
/* Each FAT sector is 512bytes (0x200) */
#define TOTAL_SECTORS (ALLOCATED_FAT_SPACE/0x200)
kal_uint8 FDMBuffer[512];
FS_Driver NORFlashDriver =
{
NOR_MountDevice,
NOR_ShutDown,
NOR_ReadSectors,
NOR_WriteSectors,
NOR_MediaChanged,
NULL,
NOR_GetDiskGeometry,
NOR_LowLevelFormat,
#if defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__)
NULL,
#else
NOR_NonBlockWriteSectors,
#endif /* __SINGLE_BANK_NOR_FLASH_SUPPORT__ */
NOR_RecoverableWriteSectors,
NOR_ResumeSectorStates,
NULL, /*high level format*/
NULL, /*flush data*/
NULL /*message ack*/
#ifdef __SECURITY_OTP__
,
NULL, /*copy sector*/
OTPAccess,
OTPQueryLength
#endif
};
#else
/* Each FAT sector is 1024bytes (0x200) */
#define TOTAL_SECTORS (ALLOCATED_FAT_SPACE/0x400)
kal_uint8 FDMBuffer[1024];
FS_Driver NORFlashDriver =
{
SIB_MountDevice,
NOR_ShutDown,
SIB_ReadSectors,
SIB_WriteSectors,
NOR_MediaChanged,
NULL,
SIB_GetDiskGeometry,
SIB_LowLevelFormat,
SIB_NonBlockWriteSectors,
SIB_RecoverableWriteSectors,
SIB_ResumeSectorStates,
NULL, /*high level format*/
NULL, /*flush data*/
NULL /*message ack*/
#ifdef __SECURITY_OTP__
,
NULL, /*copy sector*/
OTPAccess,
OTPQueryLength
#endif
};
#endif /* __INTEL_SIBLEY__ */
static WORD AVAILSECTORS[TOTAL_BLOCKS];
static WORD VALIDSECTORS[TOTAL_BLOCKS];
static BYTE SectorMap[TOTAL_SECTORS];
NOR_FLASH_DRV_Data FlashDriveData;
#if defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__)
//static kal_uint32 EraseQueue[TOTAL_BLOCKS];
static NOR_EraseInfo EraseBlockQueue[SNOR_ERASE_QUEUE_SIZE];
#endif /* __SINGLE_BANK_NOR_FLASH_SUPPORT__ */
extern NOR_MTD_Driver NORFlashMtd;
#ifdef __MTK_TARGET__
static NOR_Flash_MTD_Data mtdflash;
extern kal_uint32 INT_RetrieveFlashBaseAddr(void);
#else
static NOR_Flash_MTD_Data mtdflash =
{
MakeMtdFlashData((BYTE *)FLASH_BASE_ADDRESS, RegionInfo)
};
#endif /* __MTK_TARGET__ */
#endif /*__NOR_FDM5__*/
#endif /* __FS_SYSDRV_ON_NAND__ || _NAND_FLASH_BOOTING_ */
#ifdef PARTITION_SIZE
#if (PARTITION_SIZE > 0 && PARTITION_SIZE < NAND_MINIMUM_PARTITION_SIZE)
#error " PARTITION_SIZE MUST be larger than NAND_MINIMUM_PARTITION_SIZE !!"
#endif
#if (defined(_NAND_FLASH_BOOTING_))
#if ( (PARTITION_SIZE << 9) > ALLOCATED_FAT_SPACE)
#error " PARTITION_SIZE MUST be less than ALLOCATED_FAT_SPACE !!"
#endif
#endif /* _NAND_FLASH_BOOTING_ */
#endif /* PARTITION_SIZE */
kal_uint32 custom_part_secs = PARTITION_SIZE;
NAND_FLASH_DRV_DATA NANDFlashDriveData;
#endif /*__FUE__*/
/*************************************************************************
* FUNCTION
* custom_setEMI()
*
* DESCRIPTION
* This routine aims to set EMI
*
* PARAMETERS
*
* RETURNS
* None
*
* GLOBALS AFFECTED
*
*************************************************************************/
kal_int8 custom_setEMI(void)
{
kal_uint8 i;
kal_bool flash_found=KAL_FALSE;
kal_uint16 Manufacture_code,Dev_code,Ext_dev_code1,Ext_dev_code2;
kal_uint32 EXTSRAM_SIZE,tmp0,tmp1;
const Flash_timing timing_table[MCP_NUMBERS]=// can not use global varibles at this time
{
{{0x0001,0x227e,0x223c,0x2200},0x00800000,0x40514648, 0x40514808},//s71PL256NC0HFW5B checked
{{0x00ec,0x227e,0x2263,0x2260},0x00800000,0x20514649, 0x204d4809},//K5L5563CAM-D770
{{0x0001,0x227e,0x2220,0x2200},0x00800000,0x2051494a, 0x2051490a},//71PL127NCOHFW4B checked
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -