⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flash_drv_intel.c

📁 MTK手机平台下载工具FLASHTOOL驱动源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************
*  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) 2004
*
*******************************************************************************/

/*******************************************************************************
 *
 * Filename:
 * ---------
 *	  flash_drv_INTEL.c
 *
 * Project:
 * --------
 *    FlashTool Download Agent 
 *
 * Description:
 * ------------
 *    This Module defines the INTEL family flash driver. 
 *
 * Author:
 * -------
 *	  Amos Hsu
 *
 *==============================================================================
 * 				HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *------------------------------------------------------------------------------
 * $Revision:   1.11  $ 
 * $Modtime:   Jan 12 2006 14:18:26  $
 * $Log:   //mtkvs01/vmdata/flash_tool/archives/DA/SRC/flash_drv_INTEL.c-arc  $
 *
 * Mar 8 2006 mtk00539
 * [STP100000625] FlashTool v2.7.1016
 *  1. [DA] Supports new NOR flash device.
 * 		[INTEL] PF48F50xxM0x1xx
 * 		[INTEL] PF48F40xxM0x0xx
 * 		[INTEL] PF48F40xxM0x1xx
 *  2. [DA] Supports new NAND flash device.
 * 		[MICRON] MT29F2G08AAC
 * 		[MICRON] MT29F4G08BAB
 * 		[RENESAS] superAND 512Mb/8bits
 * 		[RENESAS] superAND 512Mb/16bits
 * 		[Infineon] HYF33DS51280
 * 		[Infineon] HYF33DS1G80
 * 		[Infineon] HYF33DS1G16
 * 
 * 
 *    Rev 1.11   Jan 14 2006 00:22:00   mtk00539
 * New features:
 *  1. [DA] Supports INTEL Sibley family flash.
 * Resolution for 159: [FlashTool v2.7.1015]
 * 
 *    Rev 1.10   Dec 29 2005 10:51:18   mtk00539
 *  1. [DA] Supports new NOR flash device.
 * 		[SPANSION] S71PL127N
 * 		[SILICON7] SV6D2832UTA
 * 		[SILICON7] SV6D2832UBA
 * 		[SILICON7] SV6C2832UTA
 * 		[SILICON7] SV6C2832UBA
 * 		[SHARP] LH28F16
 * 		[TOSHIBA] TV00578002DABD
 * 		[TOSHIBA] TV00578003DABD
 *  2. [DA] Supports new NAND flash device.
 * 		[TOSHIBA] TH58NVG1S8BFT
 * 
 * Resolution for 156: [FlashTool v2.7.1013][BUG FIX] Fix BootROM start command failure while manually selecting NMT6226 or MT6227 baseband chip.
 * 
 *    Rev 1.9   Nov 24 2005 16:04:32   mtk00539
 *  1. [DA][BUG FIX] Incorrectly detects S71PL127JXX as S71PL254JXX because da_memcmp() cannot work probably. 
 * Resolution for 149: [BROM_DLL v2.7.1011][New] Add UID Secure Booting feature and Bug Fix.
 * 
 *    Rev 1.8   Nov 19 2005 00:46:10   mtk00539
 *  1. [BROM_DLL&DA][New] Add UID Secure Booting feature.
 *  2. [BROM_DLL&DA][BUG FIX] Fix RTC date-time value could not be initialized problem. 
 *  3. [DA][New] Supports new NOR flash device.
 * 				[INTEL] 38F1010C0ZBL0
 * 				[INTEL] 28F1602C3BD70
 * 				[TOSHIBA] TY0068B012APGG
 * 				[TOSHIBA] TY0068B013APGG
 *  4. [DA][New] Supports new NAND flash device.
 * 				[HYNIX] HY27XG082G2M
 *  5. [DA][BUF FIX] Refill BootLoader header for BootROM to identify NAND flash organization.
 * Resolution for 149: [BROM_DLL v2.7.1011][New] Add UID Secure Booting feature and Bug Fix.
 * 
 *    Rev 1.7   Oct 19 2005 14:45:16   mtk00539
 *  1. [BROM_DLL&DA][New] New H/W devices detection architecture including NOR, NAND, SRAM and DRAM detection. 
 *  2. [BROM_DLL&DA][New] DA partial download technic, that overcomes DA size exceeds MT6205B internal SRAM (32KB).
 *  3. [BROM_DLL&DA][New] Format verification option, each byte should be 0xFF after erasure. 
 *  4. [BROM_DLL&DA][New] DA validation to ensure invalid binary could not be loaded.
 *  5. [BROM_DLL&DA][New] Support NFB download. 
 *  6. [BROM_DLL&DA][New] Support NAND flash format with 3 method, NORMAL, FORCEDLY ERASE and MARK AS BAD BLOCK. 
 *  7. [BROM_DLL&DA][New] Support NAND flash read back with 4 methods, PAGE+ECC, PAGE ONLY, SPARE ONLY and PAGE+SPARE. 
 * Resolution for 140: [BROM_DLL v2.7.1008][New] Support NFB download and many new features.
 * 
 *    Rev 1.6   May 24 2005 19:58:46   mtk00539
 *  1. [DA][New] Support new flash devices S71PL254JXX, S71WS256NXX.
 *  2. [DA][New] Add DA_ENABLE_WATCHDOG_CMD command to enable watchdog. 
 * Resolution for 115: [BROM_DLL v2.4.1012][New] Support new flash devices and bug fix.
 * 
 *    Rev 1.5   Feb 16 2005 17:24:26   mtk00539
 *  1. [DA][BUG FIX] Fix INTEL W18/W30 series flash program fail. this series don't support Buffered-Program method, we can only use WORD program.
 *  2. [DA][BUG FIX] Fix format %x bug in UART_Printf().
 *  3. [DA][BUG FIX] Fix small size EXT_SRAM detection error. Shrink the EXT_SRAM detection unit from 512KB to 128KB in Board_Schematic().
 *  4. [DA][New] Extend max sector region to 4 for SPANSION S71AL016D flash.
 *  5. [DA][New] Add SPANSION S71AL016D T/B and SHARP LRS18C8A flash support. 
 * Resolution for 105: [BROM_DLL v2.4.1009][New] Fix INTEL W18/W30 series bug and add SPANSION S71AL016D and SHARP LRS18C8A flash support.
 * 
 *    Rev 1.4   Nov 29 2004 15:51:06   mtk00539
 * [DA][BUG FIX] For INTEL family flash, if 2nd die ID is zero, skip ID checking.
 * Resolution for 99: [BROM_DLL v2.4.1008][New] Support INTEL family flash Buffered-Program method.
 * 
 *    Rev 1.3   Nov 22 2004 12:25:36   mtk00539
 *  1. [DA][BUG FIX] Add data verification in status polling during erase or program operation.
 *  2. [DA][BUG FIX] Fix two dies flash detection fail in INTEL_CheckDevID(). 
 *  3. [DA][Change Behavior] When RX_BUFFER_FULL occurs, flush data queued in UART ring buffer til data is less than 512KB.
 *  4. [DA][New] Support Buffered-Program method for INTEL family flashes.
 *  5. [DA][New] Support new flashes [SHARP]LRS1828C and [RENESAS]M6MGB64BM34CDG.
 * Resolution for 99: [BROM_DLL v2.4.1008][New] Support INTEL family flash Buffered-Program method.
 * 
 *    Rev 1.2   Oct 29 2004 11:46:46   mtk00539
 *  1. [DA][BUG FIX] Read CFI boot sector flag to determine AM49DL3208GT and S71PL032J, since both flashes have the same id, but different layout.
 *  2. [DA][BUG FIX] Fix INTEL and RENESAS status checking flow.
 *  3. [DA][Enhance] Dump more logs in TEST_ExtSRAM().
 *  4. [DA][New] Support new flashes
 * 				[SAMSUNG] K5J6316CTM
 * 				[TOSHIBA] TH50VPF5682CDSB
 * 				[TOSHIBA] TH50VPF5683CDSB
 * 				[ISSI] IS75V16F128GS32
 * 				[RENESAS] M6MGT64BM34CDG
 * 				[ST] M30L0T7000T0, M36L0T7050T0
 * 				[ST] M30L0T7000B0, M36L0T7050B0
 * 				[SHARP] LRS1862
 * 				[SHARP] LRS1806A
 * 				[AMD] AM49DL3208GT
 * 				[SPANSION] S29PL032J, S71PL032J
 * Resolution for 92: [BROM_DLL v2.4.1006][BUG FIX] Fix AM49DL3208GT & S71PL032J download fail problem and some enhancement.
 * 
 *    Rev 1.1   Aug 03 2004 10:33:06   mtk00539
 *  1. [DA][BUG FIX] Invoke Board_Schematic()(old name is HW_Init()) before FUTL_CheckDevice(). Because FUTL_CheckDevice() must know the absolute address for each bank.
 *  2. [DA][New] Add 12 new flash devices support 
 * 				[SAMSUNG]K5A3280YT,
 * 				[TOSHIBA]TH50VPF6782AASB,
 * 				[TOSHIBA]TH50VPF6783AASB,
 * 				[TOSHIBA]TV00578002AABD,
 * 				[TOSHIBA]TV00578003AABD,
 * 				[Fujitsu]MB84VP24581HK,
 * 				[INTEL]INTEL_28F640W30_B,
 * 				[SPANSION]AM49PDL127BH,
 * 				[SPANSION]AM49PDL129BH,
 * 				[RENESAS]M6MGD13BW66CDG,
 * 				[Winbond]W19B322TM,
 * 				[Winbond]W19B323TM,
 *  3. [DA][New] Readback check after WORD program is done, so that DA won't have to keep the chksum.
 *  4. [DA][New] Auto-detect baseband chip type.
 *  5. [DA][New] Auto-detect external SRAM size.
 *  6. [DA][New] Merge MT6205B, MT6218B and MT6219 to an all-in-one DA.
 *  7. [DA][New] Merge flash stress test module.
 *  8. [DA][New] Modify makefile to build ARM or THUMB code.
 *  9. [DA][New] Construct a customization kit for customers to add new flash or SOC checking algorithm by themselves.
 * 10. [DA][Enhance] Split out AM29PDL128G function to improve the performance of general AMD callback functions.
 * 11. [DA][Enhance] Enhance RX_BUFF_FULL behavior to prevent always retry two times.
 * Resolution for 83: [BROM_DLL v2.4.1002] Merge all the DAs into all-in-one DA and fix many bugs and enhancement.
 * 
 *    Rev 1.0   Jul 19 2004 01:44:28   mtk00539
 * Initial revision.
 * 
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! 
 *==============================================================================
 *******************************************************************************/
#include <string.h>
#include "flash_drv_INTEL.h"
#include "hw_config.h"

//------------------------------------------------------------------------------
// Callback Function Set                                                        
//------------------------------------------------------------------------------
const NOR_CMD_Callback_S	INTEL_CMD_CB_WORD_PGM = {
	INTEL_CheckDevID,
	DUMMY_CheckDevIdle,
	INTEL_Erase_Block_CMD,
	INTEL_Erase_CheckDone,
	DUMMY_Program_PreProcess,
	DUMMY_Program_PostProcess,
	INTEL_Block_Unlock,
	DUMMY_Program_Exit,
	INTEL_Word_Program,
	INTEL_Word_Program_CheckDone,
	NULL,
	NULL
};

const NOR_CMD_Callback_S	INTEL_CMD_CB_32WORD_BUF_PGM = {
	INTEL_CheckDevID,
	DUMMY_CheckDevIdle,
	INTEL_Erase_Block_CMD,
	INTEL_Erase_CheckDone,
	INTEL_PreProcess_32WORD_BUFPGM,
	DUMMY_Program_PostProcess,
	INTEL_Block_Unlock,
	DUMMY_Program_Exit,
	INTEL_Word_Program,
	INTEL_Word_Program_CheckDone,
	INTEL_Buf_Program,
	INTEL_Word_Program_CheckDone
};

const NOR_CMD_Callback_S	INTEL_CMD_CB_SIBLEY_BUF_PGM = {
	INTEL_CheckDevID,
	DUMMY_CheckDevIdle,
	INTEL_Erase_Block_CMD,
	INTEL_Erase_CheckDone,
	INTEL_Sibley_PreProcess_1KB_BUFPGM,
	DUMMY_Program_PostProcess,
	INTEL_Block_Unlock,
	DUMMY_Program_Exit,
	INTEL_Word_Program,
	INTEL_Sibley_Program_CheckDone,
	INTEL_Sibley_Buf_Program,
	INTEL_Sibley_Program_CheckDone
};

//------------------------------------------------------------------------------
// Memory Sector Layout Set                                                     
//------------------------------------------------------------------------------

// L18/L30 series (pure 64KW sectors) 
const NOR_Die_Layout_S		INTEL_L_64 = {
	
	0x00800000,

	{
		 { 0x00000000,	64,		0x20000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

const NOR_Die_Layout_S		INTEL_L_128 = {
	
	0x01000000,

	{
		 { 0x00000000,	128,	0x20000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

const NOR_Die_Layout_S		INTEL_L_256 = {
	
	0x02000000,

	{
		 { 0x00000000,	256,	0x20000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

// L18/L30 series (Top Boot) 
const NOR_Die_Layout_S		INTEL_L_T_64 = {
	
	0x00800000,

	{
		 { 0x00000000,	63,		0x20000 }
		,{ 0x007E0000,	4,		0x8000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

const NOR_Die_Layout_S		INTEL_L_T_128 = {
	
	0x01000000,

	{
		 { 0x00000000,	127,	0x20000 }
		,{ 0x00FE0000,	4,		0x8000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

const NOR_Die_Layout_S		INTEL_L_T_256 = {
	
	0x02000000,

	{
		 { 0x00000000,	255,	0x20000 }
		,{ 0x01FE0000,	4,		0x8000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

// L18/L30 series (Bottom Boot) 
const NOR_Die_Layout_S		INTEL_L_B_64 = {
	
	0x00800000,

	{
		 { 0x00000000,	4,		0x8000 }
		,{ 0x00020000,	63,		0x20000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

const NOR_Die_Layout_S		INTEL_L_B_128 = {
	
	0x01000000,

	{
		 { 0x00000000,	4,		0x8000 }
		,{ 0x00020000,	127,	0x20000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

const NOR_Die_Layout_S		INTEL_L_B_256 = {
	
	0x02000000,

	{
		 { 0x00000000,	4,		0x8000 }
		,{ 0x00020000,	255,	0x20000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

// W18/W30 series (Pure 32KW sectors) 
const NOR_Die_Layout_S		INTEL_W_32 = {
	
	0x00400000,

	{
		 { 0x00000000,	64,		0x10000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

const NOR_Die_Layout_S		INTEL_W_64 = {
	
	0x00800000,

	{
		 { 0x00000000,	127,	0x10000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

const NOR_Die_Layout_S		INTEL_W_128 = {
	
	0x01000000,

	{
		 { 0x00000000,	255,	0x10000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

// W18/W30 series (Top Boot) 
const NOR_Die_Layout_S		INTEL_W_T_32 = {
	
	0x00400000,

	{
		 { 0x00000000,	63,		0x10000 }
		,{ 0x003F0000,	8,		0x2000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

const NOR_Die_Layout_S		INTEL_W_T_64 = {
	
	0x00800000,

	{
		 { 0x00000000,	127,	0x10000 }
		,{ 0x007F0000,	8,		0x2000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

const NOR_Die_Layout_S		INTEL_W_T_128 = {
	
	0x01000000,

	{
		 { 0x00000000,	255,	0x10000 }
		,{ 0x00FF0000,	8,		0x2000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}
};

// W18/W30 series (Bottom Boot) 
const NOR_Die_Layout_S		INTEL_W_B_16 = {
	
	0x00200000,

	{
		 { 0x00000000,	8,		0x2000 }
		,{ 0x00010000,	31,	    0x10000 }
		,{ 0, 0, 0 }
		,{ 0, 0, 0 }
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -