[Feature]Upload Modem source code
Change-Id: Id4294f30faced84d3e6fd6d5e61e1111bf287a37
diff --git a/mcu/custom/driver/common/MemoryDevice_TypeDef.h b/mcu/custom/driver/common/MemoryDevice_TypeDef.h
new file mode 100644
index 0000000..3e2ac31
--- /dev/null
+++ b/mcu/custom/driver/common/MemoryDevice_TypeDef.h
@@ -0,0 +1,116 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * MemoryDevice_TypeDef.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This file defines the enum and data structure necessary for memory
+ * device configuration.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#ifndef __MEMDEV_TYPEDEF__
+#define __MEMDEV_TYPEDEF__
+
+
+/*****************************************************************/
+
+/**
+ * Define this if we want to include those header that RHR suggested to add.
+ */
+#define RHR_SUGGEST_ADD
+
+/**
+ * Define this if we want to exclude those header that RHR suggested to add.
+ */
+//#define RHR_SUGGEST_REMOVE
+
+/*****************************************************************/
+
+
+typedef enum
+{
+ NOR_RAM_MCP = 0,
+ NOR_FLASH,
+ RAM,
+ LPSDRAM,
+ UNUSED = 0xFF
+} ExtMemoryType_T;
+
+typedef enum
+{
+ ASYNC_ACCESS = 0,
+ SYNC_ACCESS,
+ UNDEF_ACCESS = 0xFF
+} ExtMemoryAccessType_T;
+
+#endif /* __MEMDEV_TYPEDEF__ */
+
diff --git a/mcu/custom/driver/common/adc_nvram_def.c b/mcu/custom/driver/common/adc_nvram_def.c
new file mode 100644
index 0000000..b1cce8e
--- /dev/null
+++ b/mcu/custom/driver/common/adc_nvram_def.c
@@ -0,0 +1,255 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * adc_nvram_def.c
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * This file contains `vendor' defined logical data items stored in NVRAM.
+ * These logical data items are used in object code of Protocol Stack software.
+ *
+ * As for customizable logical data items, they are defined in nvram_user_config.c
+ *
+ * Author:
+ * -------
+ *
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+#ifndef NVRAM_NOT_PRESENT
+
+
+/*
+ * Include Headers
+ */
+
+#include "kal_general_types.h"
+
+/*
+ * NVRAM Basic Headers
+ */
+#ifdef NVRAM_AUTO_GEN
+#include "nvram_auto_gen.h"
+#endif
+
+#include "nvram_enums.h"
+
+#define NVRAM_LID_SPLIT
+#include "nvram_defs.h"
+
+#include "nvram_data_items.h"
+
+/*
+ * User Headers & Default value
+ */
+#include "adc_nvram_def.h"
+#include "drv_features_adc.h"
+
+#if !defined(DRV_ADC_OFF)
+static kal_int32 const NVRAM_EF_ADC_DEFAULT[] = {
+#if defined(DRV_ADC_MAX_CH_1)
+ ADC_CALIBRATION_SLOPE_CH0,
+ ADC_CALIBRATION_OFFSET_CH0
+#elif defined(DRV_ADC_MAX_CH_5)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4
+#elif defined(DRV_ADC_MAX_CH_6)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5
+#elif defined(DRV_ADC_MAX_CH_7)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6
+#elif defined(DRV_ADC_MAX_CH_8)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7
+#elif defined(DRV_ADC_MAX_CH_9)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7, ADC_CALIBRATION_SLOPE_CH8,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7, ADC_CALIBRATION_OFFSET_CH8
+#elif defined(DRV_ADC_MAX_CH_10)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7, ADC_CALIBRATION_SLOPE_CH8,ADC_CALIBRATION_SLOPE_CH9,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7, ADC_CALIBRATION_OFFSET_CH8,ADC_CALIBRATION_OFFSET_CH9
+#elif defined(DRV_ADC_MAX_CH_11)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7, ADC_CALIBRATION_SLOPE_CH8,ADC_CALIBRATION_SLOPE_CH9,
+ ADC_CALIBRATION_SLOPE_CH10,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7, ADC_CALIBRATION_OFFSET_CH8,ADC_CALIBRATION_OFFSET_CH9,
+ ADC_CALIBRATION_OFFSET_CH10
+#elif defined(DRV_ADC_MAX_CH_12)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7, ADC_CALIBRATION_SLOPE_CH8,ADC_CALIBRATION_SLOPE_CH9,
+ ADC_CALIBRATION_SLOPE_CH10, ADC_CALIBRATION_SLOPE_CH11,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7, ADC_CALIBRATION_OFFSET_CH8,ADC_CALIBRATION_OFFSET_CH9,
+ ADC_CALIBRATION_OFFSET_CH10,ADC_CALIBRATION_OFFSET_CH11
+#elif defined(DRV_ADC_MAX_CH_13) //12 bits use small slope
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7, ADC_CALIBRATION_SLOPE_CH8,ADC_CALIBRATION_SLOPE_CH9,
+ ADC_CALIBRATION_SLOPE_CH10, ADC_CALIBRATION_SLOPE_CH11, ADC_CALIBRATION_SLOPE_CH12,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7, ADC_CALIBRATION_OFFSET_CH8,ADC_CALIBRATION_OFFSET_CH9,
+ ADC_CALIBRATION_OFFSET_CH10,ADC_CALIBRATION_OFFSET_CH11, ADC_CALIBRATION_OFFSET_CH12
+#elif defined(DRV_ADC_MAX_CH_14)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7, ADC_CALIBRATION_SLOPE_CH8,ADC_CALIBRATION_SLOPE_CH9,
+ ADC_CALIBRATION_SLOPE_CH10, ADC_CALIBRATION_SLOPE_CH11, ADC_CALIBRATION_SLOPE_CH12, ADC_CALIBRATION_SLOPE_CH13,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7, ADC_CALIBRATION_OFFSET_CH8,ADC_CALIBRATION_OFFSET_CH9,
+ ADC_CALIBRATION_OFFSET_CH10,ADC_CALIBRATION_OFFSET_CH11, ADC_CALIBRATION_OFFSET_CH12, ADC_CALIBRATION_OFFSET_CH13
+#elif defined(DRV_ADC_MAX_CH_15)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7, ADC_CALIBRATION_SLOPE_CH8,ADC_CALIBRATION_SLOPE_CH9,
+ ADC_CALIBRATION_SLOPE_CH10, ADC_CALIBRATION_SLOPE_CH11, ADC_CALIBRATION_SLOPE_CH12, ADC_CALIBRATION_SLOPE_CH13, ADC_CALIBRATION_SLOPE_CH14,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7, ADC_CALIBRATION_OFFSET_CH8,ADC_CALIBRATION_OFFSET_CH9,
+ ADC_CALIBRATION_OFFSET_CH10,ADC_CALIBRATION_OFFSET_CH11, ADC_CALIBRATION_OFFSET_CH12, ADC_CALIBRATION_OFFSET_CH13, ADC_CALIBRATION_OFFSET_CH14
+#elif defined(DRV_ADC_MAX_CH_16)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7, ADC_CALIBRATION_SLOPE_CH8,ADC_CALIBRATION_SLOPE_CH9,
+ ADC_CALIBRATION_SLOPE_CH10, ADC_CALIBRATION_SLOPE_CH11, ADC_CALIBRATION_SLOPE_CH12, ADC_CALIBRATION_SLOPE_CH13, ADC_CALIBRATION_SLOPE_CH14,
+ ADC_CALIBRATION_SLOPE_CH15,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7, ADC_CALIBRATION_OFFSET_CH8,ADC_CALIBRATION_OFFSET_CH9,
+ ADC_CALIBRATION_OFFSET_CH10,ADC_CALIBRATION_OFFSET_CH11, ADC_CALIBRATION_OFFSET_CH12, ADC_CALIBRATION_OFFSET_CH13, ADC_CALIBRATION_OFFSET_CH14,
+ ADC_CALIBRATION_OFFSET_CH15
+#elif defined(DRV_ADC_MAX_CH_17)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7, ADC_CALIBRATION_SLOPE_CH8,ADC_CALIBRATION_SLOPE_CH9,
+ ADC_CALIBRATION_SLOPE_CH10, ADC_CALIBRATION_SLOPE_CH11, ADC_CALIBRATION_SLOPE_CH12, ADC_CALIBRATION_SLOPE_CH13, ADC_CALIBRATION_SLOPE_CH14,
+ ADC_CALIBRATION_SLOPE_CH15, ADC_CALIBRATION_SLOPE_CH16,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7, ADC_CALIBRATION_OFFSET_CH8,ADC_CALIBRATION_OFFSET_CH9,
+ ADC_CALIBRATION_OFFSET_CH10,ADC_CALIBRATION_OFFSET_CH11, ADC_CALIBRATION_OFFSET_CH12, ADC_CALIBRATION_OFFSET_CH13, ADC_CALIBRATION_OFFSET_CH14,
+ ADC_CALIBRATION_OFFSET_CH15,ADC_CALIBRATION_OFFSET_CH16
+#elif defined(DRV_ADC_MAX_CH_18)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7, ADC_CALIBRATION_SLOPE_CH8,ADC_CALIBRATION_SLOPE_CH9,
+ ADC_CALIBRATION_SLOPE_CH10, ADC_CALIBRATION_SLOPE_CH11, ADC_CALIBRATION_SLOPE_CH12, ADC_CALIBRATION_SLOPE_CH13, ADC_CALIBRATION_SLOPE_CH14,
+ ADC_CALIBRATION_SLOPE_CH15, ADC_CALIBRATION_SLOPE_CH16, ADC_CALIBRATION_SLOPE_CH17,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7, ADC_CALIBRATION_OFFSET_CH8,ADC_CALIBRATION_OFFSET_CH9,
+ ADC_CALIBRATION_OFFSET_CH10,ADC_CALIBRATION_OFFSET_CH11, ADC_CALIBRATION_OFFSET_CH12, ADC_CALIBRATION_OFFSET_CH13, ADC_CALIBRATION_OFFSET_CH14,
+ ADC_CALIBRATION_OFFSET_CH15,ADC_CALIBRATION_OFFSET_CH16, ADC_CALIBRATION_OFFSET_CH17
+#elif defined(DRV_ADC_MAX_CH_19)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7, ADC_CALIBRATION_SLOPE_CH8,ADC_CALIBRATION_SLOPE_CH9,
+ ADC_CALIBRATION_SLOPE_CH10, ADC_CALIBRATION_SLOPE_CH11, ADC_CALIBRATION_SLOPE_CH12, ADC_CALIBRATION_SLOPE_CH13, ADC_CALIBRATION_SLOPE_CH14,
+ ADC_CALIBRATION_SLOPE_CH15, ADC_CALIBRATION_SLOPE_CH16, ADC_CALIBRATION_SLOPE_CH17, ADC_CALIBRATION_SLOPE_CH18,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7, ADC_CALIBRATION_OFFSET_CH8,ADC_CALIBRATION_OFFSET_CH9,
+ ADC_CALIBRATION_OFFSET_CH10,ADC_CALIBRATION_OFFSET_CH11, ADC_CALIBRATION_OFFSET_CH12, ADC_CALIBRATION_OFFSET_CH13, ADC_CALIBRATION_OFFSET_CH14,
+ ADC_CALIBRATION_OFFSET_CH15,ADC_CALIBRATION_OFFSET_CH16, ADC_CALIBRATION_OFFSET_CH17, ADC_CALIBRATION_OFFSET_CH18
+#elif defined(DRV_ADC_MAX_CH_20)
+ ADC_CALIBRATION_SLOPE_CH0, ADC_CALIBRATION_SLOPE_CH1, ADC_CALIBRATION_SLOPE_CH2, ADC_CALIBRATION_SLOPE_CH3, ADC_CALIBRATION_SLOPE_CH4,
+ ADC_CALIBRATION_SLOPE_CH5, ADC_CALIBRATION_SLOPE_CH6, ADC_CALIBRATION_SLOPE_CH7, ADC_CALIBRATION_SLOPE_CH8,ADC_CALIBRATION_SLOPE_CH9,
+ ADC_CALIBRATION_SLOPE_CH10, ADC_CALIBRATION_SLOPE_CH11, ADC_CALIBRATION_SLOPE_CH12, ADC_CALIBRATION_SLOPE_CH13, ADC_CALIBRATION_SLOPE_CH14,
+ ADC_CALIBRATION_SLOPE_CH15, ADC_CALIBRATION_SLOPE_CH16, ADC_CALIBRATION_SLOPE_CH17, ADC_CALIBRATION_SLOPE_CH18, ADC_CALIBRATION_SLOPE_CH19,
+ ADC_CALIBRATION_OFFSET_CH0, ADC_CALIBRATION_OFFSET_CH1, ADC_CALIBRATION_OFFSET_CH2, ADC_CALIBRATION_OFFSET_CH3, ADC_CALIBRATION_OFFSET_CH4,
+ ADC_CALIBRATION_OFFSET_CH5, ADC_CALIBRATION_OFFSET_CH6, ADC_CALIBRATION_OFFSET_CH7, ADC_CALIBRATION_OFFSET_CH8,ADC_CALIBRATION_OFFSET_CH9,
+ ADC_CALIBRATION_OFFSET_CH10,ADC_CALIBRATION_OFFSET_CH11, ADC_CALIBRATION_OFFSET_CH12, ADC_CALIBRATION_OFFSET_CH13, ADC_CALIBRATION_OFFSET_CH14,
+ ADC_CALIBRATION_OFFSET_CH15,ADC_CALIBRATION_OFFSET_CH16, ADC_CALIBRATION_OFFSET_CH17, ADC_CALIBRATION_OFFSET_CH18, ADC_CALIBRATION_OFFSET_CH19
+#endif // #if defined(DRV_ADC_MAX_CH_5)
+
+};
+
+
+
+/*
+ * LID table
+ */
+ltable_entry_struct logical_data_item_table_adc[] =
+{
+ {
+ NVRAM_EF_ADC_LID,
+ NVRAM_EF_ADC_TOTAL,
+ NVRAM_EF_ADC_SIZE,
+ NVRAM_NORMAL((kal_uint8 const *)NVRAM_EF_ADC_DEFAULT),
+ NVRAM_CATEGORY_CALIBRAT,
+ NVRAM_ATTR_AVERAGE,
+ "AD1F",
+ VER(NVRAM_EF_ADC_LID)
+ }
+};
+
+#endif //#if !defined(DRV_ADC_OFF)
+
+#endif /* NVRAM_NOT_PRESENT */
diff --git a/mcu/custom/driver/common/adc_nvram_def.h b/mcu/custom/driver/common/adc_nvram_def.h
new file mode 100644
index 0000000..48c574c
--- /dev/null
+++ b/mcu/custom/driver/common/adc_nvram_def.h
@@ -0,0 +1,127 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * adc_nvram_def.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * This file contains `vendor' defined logical data items stored in NVRAM.
+ * These logical data items are used in object code of Protocol Stack software.
+ *
+ * As for customizable logical data items, they are defined in nvram_user_config.c
+ *
+ * Author:
+ * -------
+ *
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+#ifndef __ADC_NVRAM_DEF_H__
+#define __ADC_NVRAM_DEF_H__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+/*
+ * Include Headers
+ */
+
+
+/*
+ * NVRAM Basic Headers
+ */
+#include "nvram_data_items.h"
+#include "nvram_defs.h"
+
+
+/*
+ * User Headers
+ */
+#include "drv_features.h"
+#include "adc_channel.h"
+
+
+/*
+ * LID Enums
+ */
+
+typedef enum
+{
+ NVRAM_EF_ADC_LID = NVRAM_LID_GRP_ADC(0),
+}nvram_lid_adc_enum;
+
+
+/*
+ * Record Size/Total Records
+ */
+#define NVRAM_EF_ADC_TOTAL 1
+#define NVRAM_EF_ADC_SIZE (ADC_MAX_CHANNEL * 8)
+
+#define NVRAM_EF_ADC_LID_VERNO "000"
+#define NVRAM_EF_ADC_LID_HASH 0xAA9E7153
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ADC_NVRAM_DEF_H__ */
diff --git a/mcu/custom/driver/common/adc_nvram_editor.h b/mcu/custom/driver/common/adc_nvram_editor.h
new file mode 100644
index 0000000..dfec598
--- /dev/null
+++ b/mcu/custom/driver/common/adc_nvram_editor.h
@@ -0,0 +1,163 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * adc_nvram_editor.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * This file contains `vendor' defined logical data items stored in NVRAM.
+ * These logical data items are used in object code of Protocol Stack software.
+ *
+ * As for customizable logical data items, they are defined in nvram_user_config.c
+ *
+ * Author:
+ * -------
+ *
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+#ifndef __ADC_NVRAM_EDITOR_H__
+#define __ADC_NVRAM_EDITOR_H__
+#ifndef NVRAM_NOT_PRESENT
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+/*
+ * Include Headers
+ */
+
+
+/*
+ * NVRAM Basic Headers
+ */
+#include "nvram_data_items.h"
+
+/*
+ * User Headers
+ */
+
+#include "adc_nvram_def.h"
+
+/*
+ * Bit Level Description Language
+ */
+#ifdef GEN_FOR_PC
+
+#include "drv_features_adc.h"
+
+typedef struct
+{
+//Because of Android may update modem version on user side.
+//Do not change this structure !!
+ kal_int32 ADCSlope[ADC_MAX_CHANNEL];
+ kal_int32 ADCOffset[ADC_MAX_CHANNEL];
+}ADC_CALIDATA;
+
+#if !defined(DRV_ADC_OFF)
+BEGIN_NVRAM_DATA
+/******************************************************
+* LID_NAME
+* NVRAM_EF_ADC_LID
+* DESCRIPTION
+* NVRAM LID for saving calibration data of external AUXADC
+* INFORMATION
+* Can OTA Reset: Yes
+* Update Scenario: This LID is only updated in production line
+*******************************************************/
+LID_BIT MULTIPLE_LID VER_LID(NVRAM_EF_ADC_LID)
+ADC_CALIDATA *NVRAM_EF_ADC_TOTAL
+{
+ ADCSlope:"Slop for Each ADC Channel";
+ ADCOffset:"Offset for Each ADC Channel";
+};
+
+END_NVRAM_DATA
+#endif
+
+#endif /* GEN_FOR_PC */
+#endif /* !NVRAM_NOT_PRESENT */
+#endif /* __ADC_NVRAM_EDITOR_H__ */
diff --git a/mcu/custom/driver/common/aud_I2S_config.c b/mcu/custom/driver/common/aud_I2S_config.c
new file mode 100644
index 0000000..6c9518a
--- /dev/null
+++ b/mcu/custom/driver/common/aud_I2S_config.c
@@ -0,0 +1,77 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * aud_I2S_config.c
+ *
+ * Project:
+ * --------
+ * MAUI Project
+ *
+ * Description:
+ * ------------
+ * Audio I2S config
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+
diff --git a/mcu/custom/driver/common/aud_common.c b/mcu/custom/driver/common/aud_common.c
new file mode 100644
index 0000000..0194fcf
--- /dev/null
+++ b/mcu/custom/driver/common/aud_common.c
@@ -0,0 +1,81 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * aud_common.c
+ *
+ * Project:
+ * --------
+ * MAUI Project
+ *
+ * Description:
+ * ------------
+ * Common Audio Customization Parameters
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+
+
diff --git a/mcu/custom/driver/common/aud_common_config.h b/mcu/custom/driver/common/aud_common_config.h
new file mode 100644
index 0000000..966b494
--- /dev/null
+++ b/mcu/custom/driver/common/aud_common_config.h
@@ -0,0 +1,86 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * audio_common_config.h
+ *
+ * Project:
+ * --------
+ * MAUI
+ *
+ * Description:
+ * ------------
+ * This file is for customers to config/customize their audio parameters to NVRAM Layer and
+ * Driver Layer.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+#ifndef __AUDIO_COMMON_CONFIG_H__
+#define __AUDIO_COMMON_CONFIG_H__
+
+
+#endif /* __AUDIO_COMMON_CONFIG_H__ */
+
diff --git a/mcu/custom/driver/common/audcoeff_default.h b/mcu/custom/driver/common/audcoeff_default.h
new file mode 100644
index 0000000..08f9224
--- /dev/null
+++ b/mcu/custom/driver/common/audcoeff_default.h
@@ -0,0 +1,303 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * audcoeff_default.h
+ *
+ * Project:
+ * --------
+ * MAUI Project
+ *
+ * Description:
+ * ------------
+ * The default value of audio coefficients
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *==============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *==============================================================================
+ *******************************************************************************/
+
+#ifndef AUDCOEFF_COMMON_DOT_H
+#define AUDCOEFF_COMMON_DOT_H
+
+#include "l1audio.h"
+
+
+/*
+ * The Bluetooth DAI Hardware COnfiguration Parameter
+ */
+#define DEFAULT_BLUETOOTH_SYNC_TYPE 0
+#define DEFAULT_BLUETOOTH_SYNC_LENGTH 1
+
+#define DEFAULT_DIGITAL_MIC_CHANNEL1_PHASE 3
+#define DEFAULT_DIGITAL_MIC_CHANNEL2_PHASE 3
+/*
+phase: 0~7
+*/
+#define DEFAULT_DIGITAL_MIC_CLOCK_SELECTION 0
+/* clock selection
+0: 3P25M
+1: 1P625M
+*/
+
+#define BT_COMP_FILTER (0 << 15)
+#define BT_SYNC_DELAY 86
+
+
+/*
+ * Speech enhancement parameter
+ * BT_CARKIT (from W0643; AfterW0809, BT_CARKIT replace AUX1)
+ * AUX1 : undefined
+ * AUX2 : undefined
+ */
+
+
+#if defined(__SMART_PHONE_MODEM__)
+
+#define DEFAULT_WB_DMNR_PARAM \
+{ \
+ 460, 470, 480, 490, 500, \
+ 510, 520, 530, 540, 550, \
+ 560, 570, 580, 590, 600, \
+ 610, 620, 630, 640, 650, \
+ 660, 670, 680, 690, 700, \
+ 710, 720, 730, 740, 750, \
+ 760, 770, 780, 790, 800, \
+ 810, 820, 830, 840, 850, \
+ 860, 870, 880, 890, 900, \
+ 910, 920, 930, 940, 950, \
+ 960, 970, 980, 990, 1000, \
+ 1010, 1020, 1030, 1040, 1050, \
+ 1060, 1070, 1080, 1090, 1200, \
+ 1210, 1220, 1230, 1240, 1250, \
+ 1260, 1270, 1280, 1290, 1300, \
+ 1310 \
+}
+
+#define DEFAULT_LSPK_WB_DMNR_PARAM \
+{ \
+ 460, 470, 480, 490, 500, \
+ 510, 520, 530, 540, 550, \
+ 560, 570, 580, 590, 600, \
+ 610, 620, 630, 640, 650, \
+ 660, 670, 680, 690, 700, \
+ 710, 720, 730, 740, 750, \
+ 760, 770, 780, 790, 800, \
+ 810, 820, 830, 840, 850, \
+ 860, 870, 880, 890, 900, \
+ 910, 920, 930, 940, 950, \
+ 960, 970, 980, 990, 1000, \
+ 1010, 1020, 1030, 1040, 1050, \
+ 1060, 1070, 1080, 1090, 1200, \
+ 1210, 1220, 1230, 1240, 1250, \
+ 1260, 1270, 1280, 1290, 1300, \
+ 1310 \
+}
+
+#define DEFAULT_DMNR_PARAM \
+{ \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 68, 0, 0, 0 \
+}
+
+#define DEFAULT_LSPK_DMNR_PARAM \
+{ \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 0, 0, 0, 0, 0, \
+ 68, 0, 0, 0 \
+}
+
+#endif
+
+#endif // ... AUDCOEFF_COMMON_DOT_H
diff --git a/mcu/custom/driver/common/combo_flash_defs.h b/mcu/custom/driver/common/combo_flash_defs.h
new file mode 100644
index 0000000..e59d7a4
--- /dev/null
+++ b/mcu/custom/driver/common/combo_flash_defs.h
@@ -0,0 +1,238 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * combo_flash_defs.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This Module defines the data structures used in ComboMCP
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+#ifndef _COMBO_FLASH_DEFS_H_
+#define _COMBO_FLASH_DEFS_H_
+
+#include "kal_public_api.h" //MSBB change #include "kal_release.h"
+#include "custom_MemoryDevice.h"
+#include "DrvFlash.h"
+#include "flash_opt.h"
+
+#if defined(__SERIAL_FLASH__) || (defined(_NAND_FLASH_BOOTING_) && defined(__NAND_MDL_APPEND__))
+
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+#include "br_sw_types.h"
+#include "br_GFH.h"
+#endif
+
+#define CMEM_FLASH_ID_LEN_NOR 4
+#define CMEM_FLASH_ID_LEN_NAND 8
+#define CMEM_REGION_INFO_LEN 8
+#define CMEM_BLOCK_INFO_LEN 8
+#define CMEM_BANK_INFO_LEN 8
+#define CMEM_BLOCK_INFO_LEN 8
+#if defined(_NAND_FLASH_BOOTING_) && defined(__NAND_MDL_APPEND__)
+#define COMBO_MEM_ID_VER 2 // identify block/page/spare size MDL format
+#else
+#define COMBO_MEM_ID_VER 1
+#endif
+#define COMBO_MEM_NOR_VER 2
+#define COMBO_MEM_IDENTITY_ID "COMBOMEM_ID"
+#define COMBO_MEM_IDENTITY_NOR "COMBOMEM_NOR"
+#define COMBO_MEM_ID_GFH_HEADER GFH_HEADER(GFH_CMEM_ID_INFO, 1)
+#define COMBO_MEM_NOR_GFH_HEADER GFH_HEADER(GFH_CMEM_NOR_INFO, 1)
+
+#ifdef __SERIAL_FLASH__
+#include "combo_sfi_defs.h"
+#endif
+
+ #define COMBO_MEM_DEVICE_COUNT 1
+
+//-----------------------------------------------------------------------------
+// Combo MCP ID list
+//-----------------------------------------------------------------------------
+
+// Union: CMEMFlashID
+typedef union {
+ kal_uint8 NAND[CMEM_FLASH_ID_LEN_NAND];
+ kal_uint16 NOR[CMEM_FLASH_ID_LEN_NOR];
+} CMEMFlashID;
+
+#if defined(_NAND_FLASH_BOOTING_) && defined(__NAND_MDL_APPEND__)
+typedef struct {
+ kal_uint16 page_size;
+ kal_uint16 spare_size;
+ kal_uint16 block_size;
+} CMEMFlashInfo;
+#endif
+// Type: CMEMEntryID
+typedef struct {
+ kal_uint8 DeviceType; // rename to Flash Type: NOR / NAND /EMMC
+ kal_uint8 IDLength;
+#if defined(_NAND_FLASH_BOOTING_) && defined(__NAND_MDL_APPEND__)
+ CMEMFlashInfo FlashDevice_Info; //include block, page and spare size
+#endif
+ #if defined(_NAND_FLASH_BOOTING_)|| defined(__SERIAL_FLASH__)
+ kal_uint8 ID[CMEM_FLASH_ID_LEN_NAND];
+ #else
+ kal_uint16 ID[CMEM_FLASH_ID_LEN_NOR];
+ #endif
+} CMEMEntryID;
+
+// Type: CMEMEntryIDList
+typedef struct {
+ #if !defined(__SV5_ENABLED__) && !defined(__SV5X_ENABLED__)
+ char m_identifier[16]; // MTK_CMB_ID_INFO
+ #endif
+ unsigned int m_ver;
+ unsigned int Count;
+ CMEMEntryID List[COMBO_MEM_DEVICE_COUNT];
+} CMEMEntryIDList;
+
+//-----------------------------------------------------------------------------
+// Combo MCP SW Settings
+//-----------------------------------------------------------------------------
+// Type: FlashBlockLayout
+typedef struct {
+ kal_uint32 Offset;
+ kal_uint32 Size;
+} FlashBlockLayout;
+
+// Type: CMEMEntryNOR
+typedef struct {
+ kal_uint16 FDMType; // rename to Device Type: DEFAULT / SIB
+ kal_uint16 PageBufferSize; // Autogen from MDL
+ kal_uint32 UniformBlocks; // Uniform Block Layout
+ FlashBlockLayout BlockLayout[CMEM_REGION_INFO_LEN];
+ FlashBankInfo BankInfo[CMEM_BANK_INFO_LEN];
+} CMEMEntryNOR;
+
+// Type: CMEMEntryNORList
+typedef struct {
+ #if !defined(__SV5_ENABLED__) && !defined(__SV5X_ENABLED__)
+ char m_identifier[16]; // MTK_CMB_ID_INFO
+ #endif
+ unsigned int m_ver;
+ unsigned int Count;
+ CMEMEntryNOR List[COMBO_MEM_DEVICE_COUNT];
+} CMEMEntryNORList;
+
+
+#endif // defined(__COMBO_MEMORY_SUPPORT__) || defined(__SERIAL_FLASH__)
+
+#endif // ifndef _COMBO_FLASH_DEFS_H_
+
diff --git a/mcu/custom/driver/common/combo_flash_init.c b/mcu/custom/driver/common/combo_flash_init.c
new file mode 100644
index 0000000..6641097
--- /dev/null
+++ b/mcu/custom/driver/common/combo_flash_init.c
@@ -0,0 +1,460 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * combo_flash_init.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This Module defines the ComboMCP Init function
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+#include "custom_MemoryDevice.h"
+#include "flash_opt.h"
+
+#if defined(__SERIAL_FLASH__) || (defined(_NAND_FLASH_BOOTING_) && defined(__NAND_MDL_APPEND__))
+#include "combo_flash_init.h"
+#include "combo_flash_defs.h"
+ #if (!defined(_NAND_FLASH_BOOTING_))
+ #include "flash_cfi.h"
+ #include "flash_cfi_internal.h"
+ #include "flash_mtd.h"
+ #endif
+ #if defined(NAND_SUPPORT)
+ #ifdef __UBL__
+ extern void NFI_ReadID(kal_uint32 id_num, kal_uint8* id_data);
+ #else
+ extern kal_bool DAL_is_initialized;
+ extern kal_int32 DAL_init (void);
+ extern void MTD_ReadID(kal_uint32 id_num,kal_uint8* id_data);
+ #endif
+ #endif
+#if defined(__SERIAL_FLASH__)
+#include "flash_sf.h"
+#endif
+
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+#include "br_GFH_cmem_id_info.h"
+#endif /* __SV5_ENABLED__ */
+
+//-----------------------------------------------------------------------------
+// MCP ID Table
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+// [Section] RVCT and GCC
+//-----------------------------------------------------------------------------
+#if defined(__MTK_TARGET__)
+#if defined(__SV5_ENABLED__)|| defined(__SV5X_ENABLED__)
+ #if defined(__UBL__)
+ #if defined (__MINI_BOOTLOADER__)
+ #define __sf_section_RODATA_GFH __attribute__ ((section ("BOOTLOADER_GFH_EXT")))
+ #elif defined ( __EXT_BOOTLOADER__)
+ #define __sf_section_RODATA_GFH __attribute__ ((section ("EXT_BOOTLOADER_GFH_EXT")))
+ #endif
+ #else
+ #define __sf_section_RODATA_GFH __attribute__ ((section ("MAUI_GFH_EXT")))
+ #endif
+#else // SV3
+ // Method1
+ // #define __sf_section_RODATA_GFH __attribute__ ((section ("SECOND_PART_RODATA")))
+ // Method2
+ #define __sf_section_RODATA_GFH
+#endif
+#else //defined(__MTK_TARGET__)
+ /* Reserve for MoDIS */
+ #define __sf_section_RODATA_GFH
+#endif // defined(__MTK_TARGET__)
+
+#if defined(__MTK_TARGET__)
+ #define __sf_section_RWDATA_EMI __attribute__ ((section ("EMIINITRW")))
+ #define __sf_section_SECOND_PART /* Second part region is removed */
+ #define __sf_section_EMI __attribute__ ((section ("EMIINITCODE")))
+#else
+/* Reserve for MoDIS */
+ #define __sf_section_RWDATA_EMI
+ #define __sf_section_SECOND_PART
+ #define __sf_section_EMI
+#endif // __MTK_TARGET__
+
+
+
+#define COMBO_MEM_TYPE_MODIFIER __sf_section_RODATA_GFH const
+#define COMBO_MEM_INST_NAME combo_mem_id_list
+
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+ #define COMBO_MEM_TYPE_NAME GFH_CMEM_ID_INFO_v1
+#else
+ #define COMBO_MEM_TYPE_NAME CMEMEntryIDList
+#endif
+
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+#define COMBO_MEM_STRUCT_HEAD COMBO_MEM_ID_GFH_HEADER, { COMBO_MEM_ID_VER, COMBO_MEM_DEVICE_COUNT, {
+#define COMBO_MEM_STRUCT_FOOT } }
+#else
+#define COMBO_MEM_STRUCT_HEAD COMBO_MEM_IDENTITY_ID, COMBO_MEM_ID_VER, COMBO_MEM_DEVICE_COUNT, {
+#define COMBO_MEM_STRUCT_FOOT }
+#endif
+
+
+#include "combo_flash_id.h" // ==== Instantiate ID table
+
+
+
+//-----------------------------------------------------------------------------
+// External Functions
+//-----------------------------------------------------------------------------
+extern kal_uint32 custom_get_fat_addr(void);
+
+//-----------------------------------------------------------------------------
+// Internal Functions
+//-----------------------------------------------------------------------------
+// ===[EMI/SFI Initialization]===
+kal_int32 CMEM_EMIINIT_Index(void);
+void CMEM_EMIINIT_ReadID(void *BaseAddr, kal_uint16 *flashid);
+
+//-----------------------------------------------------------------------------
+// Internal Variables
+//-----------------------------------------------------------------------------
+#define CMEM_INVALID_INDEX -1
+
+
+
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Determine whether SF ID is valid.
+ Apply for MT6250 because after command issue(ex: Read ID), Data pins are in floating, may read trasient value instead of 0x00 or 0xFF.
+ @retval
+ KAL_TRUE: the device ID0 is valid.
+ KAL_FALSE: the device ID0 is not valid.
+*/
+__sf_section_SECOND_PART kal_bool CMEM_CheckValidDeviceID(kal_uint8 *id)
+{
+ // Serial Flash
+#if defined(__SERIAL_FLASH__)
+ kal_int32 i, j;
+ const CMEMEntryID *id_list=NULL;
+
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+ id_list=combo_mem_id_list.m_data.List;
+#else
+ id_list=combo_mem_id_list.List;
+#endif
+ // seach CMEM list for specific Flash ID
+ for (i=0; i<COMBO_MEM_DEVICE_COUNT; i++) {
+ // Check 1: Compare ID
+ for (j=0; j<id_list[i].IDLength; j++) {
+ if (id_list[i].ID[j]!=id[j]) break;
+ }
+ // Check 2: Compare RegionInfo
+ if (j==id_list[i].IDLength) {
+ // TBD: Compare RegionInfo
+ return KAL_TRUE;
+ }
+ }
+#endif //defined(__SERIAL_FLASH__)
+ return KAL_FALSE;
+}
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Seach device in the combo MCP list by Flash ID.
+ 1. Read NOR/NAND flash ID
+ 2. Lookup ID table and return the index to the found entry.
+
+ @retval
+ The index to the found entry.
+ -1 : ID not found
+ @remars
+ If combo MCP was not turned on, the returned index is always 0.
+*/
+
+__sf_section_SECOND_PART kal_int32 CMEM_Index(void)
+{
+ return 0;
+}
+
+
+__sf_section_SECOND_PART const CMEMEntryID *CMEM_GetIDEntry(kal_uint32 index)
+{
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+ return &combo_mem_id_list.m_data.List[index];
+#else
+ return &combo_mem_id_list.List[index];
+#endif
+}
+
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Read Flash ID
+ @param[in] BaseAddr Base address to the Flash
+ @param[out] flashid Flash ID
+ @remarks
+ This function is only allowed in EMI/SFI init stage.
+*/
+__sf_section_EMI void CMEM_EMIINIT_ReadID(void *BaseAddr, kal_uint16 *flashid)
+{
+ // Serial Flash
+ return;
+}
+
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Determine whether SF ID is valid.
+ Apply for MT6250 because after command issue(ex: Read ID), Data pins are in floating, may read trasient value instead of 0x00 or 0xFF.
+ @retval
+ KAL_TRUE: the device ID0 is valid.
+ KAL_FALSE: the device ID0 is not valid.
+*/
+__sf_section_EMI kal_bool CMEM_EMIINIT_CheckValidDeviceID(kal_uint8 *id)
+{
+ // Serial Flash
+#if defined(__SERIAL_FLASH__)
+ kal_int32 i, j;
+ const CMEMEntryID *id_list=NULL;
+ // seach CMEM list for specific Flash ID
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+ id_list=combo_mem_id_list.m_data.List;
+#else
+ id_list=combo_mem_id_list.List;
+#endif
+
+ for (i=0; i<COMBO_MEM_DEVICE_COUNT; i++) {
+ // Check 1: Compare ID
+ for (j=0; j<id_list[i].IDLength; j++) {
+ if (id_list[i].ID[j]!=id[j]) break;
+ }
+ // Check 2: Compare RegionInfo
+ if (j==id_list[i].IDLength) {
+ // TBD: Compare RegionInfo
+ return KAL_TRUE;
+ }
+ }
+
+#endif //defined(__SERIAL_FLASH__)
+ return KAL_FALSE;
+}
+
+
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Search device ID list
+ @retval
+ The index to the found device ID.
+ -1: device not found
+ @remarks
+ This function is only allowed in EMI/SFI init stage.
+*/
+
+__sf_section_EMI kal_int32 CMEM_EMIINIT_Index(void)
+{
+ return 0;
+}
+
+
+
+#if defined(_NAND_FLASH_BOOTING_) && defined(__NAND_MDL_APPEND__)
+kal_bool CMEM_GetflashInfo(kal_uint8* id, CMEMFlashInfo* st)
+{
+ const CMEMEntryID *flash_id_list=NULL;
+ kal_uint32 icount, l_index;
+
+ if((id == NULL) || (st == NULL))
+ return KAL_FALSE;
+
+ #if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+ flash_id_list = combo_mem_id_list.m_data.List;
+ #else
+ flash_id_list = combo_mem_id_list.List;
+ #endif
+
+ for(l_index = 0; l_index < COMBO_MEM_DEVICE_COUNT; l_index++)
+ {
+ for(icount = 0; icount < flash_id_list[l_index].IDLength; icount++)
+ {
+ if (flash_id_list[l_index].ID[icount] != id[icount])
+ break;
+ }
+
+ if (icount == flash_id_list[l_index].IDLength)
+ {
+ break;
+ }
+ }
+
+ if(l_index == COMBO_MEM_DEVICE_COUNT)
+ return KAL_FALSE;
+
+ st->block_size = flash_id_list[l_index].FlashDevice_Info.block_size;
+ st->page_size = flash_id_list[l_index].FlashDevice_Info.page_size;
+ st->spare_size = flash_id_list[l_index].FlashDevice_Info.spare_size;
+
+ return KAL_TRUE;
+}
+#endif
+
+
+#endif // defined(__COMBO_MEMORY_SUPPORT__) || defined(__SERIAL_FLASH__) || defined(__NAND_MDL_APPEND__)
diff --git a/mcu/custom/driver/common/combo_flash_init.h b/mcu/custom/driver/common/combo_flash_init.h
new file mode 100644
index 0000000..79f91bd
--- /dev/null
+++ b/mcu/custom/driver/common/combo_flash_init.h
@@ -0,0 +1,183 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * combo_flash_init.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This Module defines the ComboMCP Init function
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+#ifndef __COMBO_FLASH_INIT_H__
+#define __COMBO_FLASH_INIT_H__
+
+#include "flash_opt.h"
+#include "kal_public_api.h" //MSBB change #include "kal_release.h"
+#include "combo_flash_defs.h"
+
+#if defined(__SERIAL_FLASH__) || (defined(_NAND_FLASH_BOOTING_) && defined(__NAND_MDL_APPEND__))
+
+#include "custom_MemoryDevice.h"
+#include "fat_fs.h"
+#include "DrvFlash.h"
+
+// Naming Rule: Camo
+typedef enum {
+ CMEM_NO_ERROR=0,
+ CMEM_ERR_ID_NOT_FOUND,
+ CMEM_ERR_FDM_MISMATCH,
+ CMEM_ERR_MTD_MISMATCH,
+ CMEM_ERR_FDM_INIT_FAIL,
+ CMEM_ERR_MTD_INIT_FAIL,
+ CMEM_ERR_FDM_REGION_INFO_OVERFLOW
+} Enum_CMEM_StatusCode;
+
+typedef enum {
+ CMEM_TYPE_END_OF_LIST=0,
+ CMEM_TYPE_NAND,
+ CMEM_TYPE_NOR,
+ CMEM_TYPE_SERIAL_NOR_FLASH
+} Enum_CMEM_Type;
+
+
+//Sync with original flash_opt.h and MemoryDeviceList
+//Ransense series is phase out
+typedef enum {
+ CMEM_FDM_NOR_DEFAULT=0, //for serial flash
+ CMEM_NOR_CS_INTEL_SERIES,
+ CMEM_NOR_CS_INTEL_SIBLEY,
+ CMEM_NOR_CS_RAM_DISK,
+ CMEM_NOR_CS_SST,
+ CMEM_NOR_CS_AMD_SERIES,
+ CMEM_NOR_CS_SPANSION_PL_J,
+ CMEM_NOR_CS_SPANSION_PL_N,
+ CMEM_NOR_CS_SPANSION_WS_N,
+ CMEM_NOR_CS_SPANSION_WS_P,
+ CMEM_NOR_CS_SPANSION_GL_A,
+ CMEM_NOR_CS_SPANSION_GL_N,
+ CMEM_NOR_CS_SPANSION_NS_N,
+ CMEM_NOR_CS_SPANSION_NS_P,
+ CMEM_NOR_CS_SPANSION_NS_J,
+ CMEM_NOR_CS_TOSHIBA,
+ CMEM_NOR_CS_TOSHIBA_TV,
+ CMEM_NOR_CS_TOSHIBA_TY,
+ CMEM_NOR_CS_SILICON7,
+ CMEM_NOR_CS_SAMSUNG_SPANSION_NS_J_LIKE,
+ CMEM_NOR_CS_SPANSION_VS_R,
+ CMEM_NOR_CS_SPANSION_VS_R64,
+ CMEM_NOR_CS_SPANSION_WS_R
+
+} Enum_CMEM_CommSeries;
+
+// Functions Exported to MAUI
+extern kal_int32 ComboMem_Initialize(void);
+extern kal_int32 CMEM_Init_FullDriver(void);
+extern kal_uint32 CMEM_BlockSize(kal_uint32 address);
+
+kal_int32 CMEM_Index(void);
+const CMEMEntryID *CMEM_GetIDEntry(kal_uint32 index);
+
+#endif // (defined(__COMBO_MEMORY_SUPPORT__) || defined(__SERIAL_FLASH__))
+
+// Function exported to EMI/SFI
+kal_int32 CMEM_EMIINIT_Index(void);
+kal_bool CMEM_CheckValidDeviceID(kal_uint8 *id);
+kal_bool CMEM_EMIINIT_CheckValidDeviceID(kal_uint8 *id);
+
+#if defined(_NAND_FLASH_BOOTING_) && defined(__NAND_MDL_APPEND__)
+kal_bool CMEM_GetflashInfo(kal_uint8* id, CMEMFlashInfo* st);
+#endif
+
+#endif // __COMBO_FLASH_INIT_H__
diff --git a/mcu/custom/driver/common/combo_flash_nor.c b/mcu/custom/driver/common/combo_flash_nor.c
new file mode 100644
index 0000000..3db20ef
--- /dev/null
+++ b/mcu/custom/driver/common/combo_flash_nor.c
@@ -0,0 +1,1434 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * combo_flash_nor.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This Module defines the ComboMCP Init function for NAND/NOR FDM
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+#include "custom_MemoryDevice.h"
+#include "flash_opt.h"
+
+#include "kal_public_api.h" //MSBB change #include "kal_release.h"
+#include "combo_flash_init.h"
+#include "fat_fs.h"
+#include "combo_flash_defs.h"
+
+#include "flash_mtd_sf_dal.h"
+#include "flash_mtd_pf_dal.h"
+
+#if defined(__SERIAL_FLASH__)
+#if ( !defined(__FS_SYSDRV_ON_NAND__) && !defined( _NAND_FLASH_BOOTING_) && !defined(__EMMC_BOOTING__))
+
+#include "flash_sf.h"
+#include "DrvFlash.h"
+#include "flash_disk_internal.h"
+
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+#include "br_GFH_cmem_nor_info.h"
+#endif /* __SV5_ENABLED__ || __SV5X_ENABLED__ */
+
+#include "DrvFlash_UT.h" //locateSector_ext for basic load
+#include "flash_mtd_ut.h" //__BASIC_LOAD_FLASH_TEST__
+
+#include "custom_nvram_int_config.h" /* To get NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM for MSTABLE_ENTRY_NUM */
+
+
+
+
+/*-------------------------------------------------------------------
+ * MS table size
+ *
+ * MS table size should be synchronized with user's requirement. The only one user is NVRAM.
+ *
+ * NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM defines the maximum record size in NVRAM
+ * (in custom_nvram_config.h). NVRAM should call NOR_ResumeSectorState (by FS_Commit)
+ * after it writes maximum NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM sectors with protection
+ * mode to ensure the integrity of a record.
+ *
+ * MSTABLE_ENTRY_NUM number is based on the worst senario: All FAT entries of clusters
+ * of logical sectors are located in different physical sectors. In other word, we need
+ * to write additional N sectors to update FAT after we write N data sectors. The other
+ * 1 sector is for directory entry update.
+ *
+ * TODO: Use auto-gen to compute most suitable MS table size. Because the number of
+ * sectors for FAT may be smaller than NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM. For example,
+ * 64KB disk only needs 1 sector to store FAT.
+ *---------------------------------------------------------- W08.50 --*/
+
+#define MS_TABLE_ENTRY_NUM (NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM * 2 + 1)
+
+
+//-----------------------------------------------------------------------------
+// Combo MCP related
+//-----------------------------------------------------------------------------
+static kal_int32 cmem_nor_index; // Do not use this variabe during EMI init stage
+const CMEMEntryID *cmem_id;
+
+//-----------------------------------------------------------------------------
+// MCP Serial/NOR Flash Driver settings
+//-----------------------------------------------------------------------------
+
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+#if defined(__UBL__)
+#define __sf_section_RODATA_GFH __attribute__ ((section ("BOOTLOADER_GFH_EXT")))
+#define __sf_section_RAM __attribute__ ((section ("SECOND_PART")))
+#else
+#define __sf_section_RODATA_GFH __attribute__ ((section ("MAUI_GFH_EXT")))
+#define __sf_section_RAM __attribute__ ((section ("SECOND_PART")))
+#endif
+#else //__SV5_ENABLED__ || __SV5X_ENABLED__
+/* SV3 */
+
+// Method1
+// #define __sf_section_RODATA_GFH __attribute__ ((section ("SECOND_PART_RODATA")))
+// Method2
+#define __sf_section_RODATA_GFH
+
+#define __sf_section_RAM __attribute__ ((section ("SECOND_PART")))
+#endif //__SV5_ENABLED__ || __SV5X_ENABLED__
+
+
+
+
+
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+ #define COMBO_MEM_TYPE_NAME GFH_CMEM_NOR_INFO_v1
+#else
+ #define COMBO_MEM_TYPE_NAME CMEMEntryNORList
+#endif
+
+#define COMBO_MEM_INST_NAME combo_mem_sw_list
+#define COMBO_MEM_TYPE_MODIFIER __sf_section_RODATA_GFH static const
+
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+#define COMBO_MEM_STRUCT_HEAD COMBO_MEM_NOR_GFH_HEADER, { COMBO_MEM_NOR_VER, COMBO_MEM_DEVICE_COUNT, {
+#define COMBO_MEM_STRUCT_FOOT } }
+#else
+#define COMBO_MEM_STRUCT_HEAD COMBO_MEM_IDENTITY_NOR, COMBO_MEM_NOR_VER, COMBO_MEM_DEVICE_COUNT, {
+#define COMBO_MEM_STRUCT_FOOT }
+#endif
+
+
+#include "combo_flash_config.h" // ==== Instantiate NOR flash table
+
+static const CMEMEntryNOR *nor_list=NULL;
+
+
+//-----------------------------------------------------------------------------
+// Driver Interface and Driver Data
+//-----------------------------------------------------------------------------
+// System Info
+#if !((defined(__FUE__) && defined(__FOTA_DM__)) || defined(__UBL__))
+//---------------------------------------
+// Part 1: NOR FDM Driver
+//---------------------------------------
+FS_Driver NORFlashDriver; // FDM driver interface
+NOR_FLASH_DRV_Data FlashDriveData; // FDM driver data
+kal_uint32 TOTAL_BLOCKS; // Local define
+kal_uint32 TOTAL_SECTORS; // Local define
+kal_uint32 NOR_LARGEST_BLOCK_SIZE; // Local define (to replace NOR_BLOCK_SIZE)
+static kal_uint16 PAGE_SIZE; // Local define (CMEM only)
+#ifdef __INTEL_SIBLEY__
+kal_uint8 FDMBuffer[1024]; // FDM buffer
+#else
+kal_uint8 FDMBuffer[512]; // FDM buffer
+#endif
+static kal_uint16 AVAILSECTORS[CMEM_MAX_BLOCKS]; // Number of avail sectors in each block
+static kal_uint16 VALIDSECTORS[CMEM_MAX_BLOCKS]; // Number of valid sectors in each block
+static kal_uint8 SectorMap[CMEM_MAX_SECTORS]; // Address translation map
+
+#if defined(__ERASE_QUEUE_ENABLE__)
+static NOR_EraseInfo EraseBlockQueue[SNOR_ERASE_QUEUE_SIZE]; // Erase queue
+#endif
+
+static FlashRegionInfo RegionInfo[CMEM_REGION_INFO_LEN]; // RegionInfo[] assigned to FDM data
+
+#elif (defined(__FUE__) || defined(__EXT_BOOTLOADER__)) && defined(__FOTA_DM__)
+NOR_FLASH_DRV_Data FlashDriveData;
+#endif // !((defined(__FUE__) && defined(__FOTA_DM__)) || defined(__UBL__))
+
+static const FlashBlockLayout *BlockLayout; // BlockLayout read from MCP list
+const static FlashBankInfo *BankInfo;
+
+static MS_ENTRY MSEntryTable[MS_TABLE_ENTRY_NUM];
+
+//---------------------------------------
+// Part 2: NOR MTD driver
+//---------------------------------------
+kal_uint32 PAGE_BUFFER_SIZE; // Global Var. used by mtd driver
+
+#ifdef __SERIAL_FLASH__
+ NOR_MTD_Driver NORFlashMtd; // SF driver interface
+ SF_MTD_Data mtdflash; // SF driver data
+ SF_Status StatusMap[SF_SR_COUNT]; // status map assigned to SF data (shall be read only after initialziation, it's shareable)
+ SF_MTD_CMD sf_dal_data_cmd; // command set assiged to SF data (shall be read only after initialziation, it's shareable)
+#else
+ NOR_MTD_Driver NORFlashMtd; // ADM driver interface
+ PF_MTD_Data mtdflash; // ADM driver data was instantiated in flash_mtd.amd.c or flash_mtd.intel.c.
+ PF_Status StatusMap[PF_SR_COUNT];
+ PF_MTD_CMD pf_dal_data_cmd; // command set assiged to PF data (shall be read only after initialziation, it's shareable)
+#endif
+
+//---------------------------------------
+// Part 3: NOR RAW Disk FDM/MTD driver
+//---------------------------------------
+#ifdef __NOR_SUPPORT_RAW_DISK__
+PF_MTD_Data FlashDiskDriveData[NOR_BOOTING_NOR_DISK_NUM];
+#ifdef __SERIAL_FLASH__
+static SF_MTD_Data mtdFlashDisk[NOR_BOOTING_NOR_DISK_NUM];
+#else // __SERIAL_FLASH__
+static NOR_Flash_MTD_Data mtdFlashDisk[NOR_BOOTING_NOR_DISK_NUM];
+#endif // __SERIAL_FLASH__
+#endif // __NOR_SUPPORT_RAW_DISK__
+
+#if defined(__NOR_SUPPORT_RAW_DISK__) && defined(NOR_BOOTING_NOR_DISK_NUM)
+#if (NOR_BOOTING_NOR_DISK_NUM>0)
+FlashRegionInfo Disk0RegionInfo[CMEM_REGION_INFO_LEN];
+#endif /* NOR_BOOTING_NOR_DISK_NUM>0 */
+#if (NOR_BOOTING_NOR_DISK_NUM>1)
+FlashRegionInfo Disk1RegionInfo[CMEM_REGION_INFO_LEN];
+#endif // NOR_BOOTING_NOR_DISK_NUM
+#endif // __NOR_SUPPORT_RAW_DISK__
+
+//---------------------------------------
+// Part 4: FOTA
+//---------------------------------------
+
+//---------------------------------------
+// Part 5: NOR Full Driver
+//---------------------------------------
+// FDM driver data
+static FlashRegionInfo EntireDiskRegionInfo[CMEM_REGION_INFO_LEN];
+NOR_FLASH_DISK_Data EntireDiskDriveData;
+
+#ifdef __SERIAL_FLASH__
+ SF_MTD_Data EntireDiskMtdData; // SF MTD driver data
+#else
+ PF_MTD_Data EntireDiskMtdData; // ADM MTD driver data
+#endif
+
+//-----------------------------------------------------------------------------
+// Internal Functions
+//-----------------------------------------------------------------------------
+// NOR Flash Driver Initialization
+
+// 1. Entry Function
+kal_int32 CMEM_Init_NOR(void); // MAUI
+kal_int32 CMEM_Init_FullDriver(void); // MAUI or BOOTLOADER (for Card Download and RAW disk)
+kal_int32 CMEM_Init_FOTA(void); // FOTA with MAUI
+void CMEM_Init_FUE(void); // FOTA update engine
+
+// 1.1 Common initilaization of the entry function
+void CMEM_Init_nor_list(void);
+
+// ---<NOR>---
+// 2. NOR FDM Initialization
+kal_int32 CMEM_Init_NOR_FDM_Common(void);
+kal_int32 CMEM_Init_NOR_FDM_NonSIB(void);
+kal_int32 CMEM_Init_NOR_FDM_SIB(void);
+
+// 3. NOR MTD Initialization
+kal_int32 CMEM_Init_NOR_MTD_Common(void);
+kal_int32 CMEM_Init_NOR_MTD_SF(void);
+kal_int32 CMEM_Init_NOR_MTD_ADMUX(void);
+
+// 4. NOR RAW Disk Initialization
+kal_int32 CMEM_Init_NOR_RAWDisk_Common(void);
+kal_int32 CMEM_Init_NOR_RAWDisk_SF(void);
+kal_int32 CMEM_Init_NOR_RAWDisk_ADMUX(void);
+
+// 5. EMI-INIT-NOR-driver
+kal_uint32 EMIINIT_CMEM_BlockSize(kal_uint32 address);
+kal_uint32 CMEM_NOR_Construct_RegionInfo_Internal(
+ kal_uint32 baseaddr,
+ kal_uint32 length,
+ FlashRegionInfo *regioninfo,
+ const FlashBlockLayout* blocklayout);
+kal_int32 NOR_Construct_RegionInfo(kal_uint32 baseaddr, kal_uint32 length, FlashRegionInfo *regioninfo);
+kal_int32 EMIINIT_CMEM_NOR_Construct_RegionInfo(kal_uint32 baseaddr, kal_uint32 length, FlashRegionInfo *regioninfo);
+
+//-----------------------------------------------------------------------------
+// External Function
+//-----------------------------------------------------------------------------
+extern kal_uint32 custom_get_fat_addr(void);
+extern kal_uint32 INT_RetrieveFlashBaseAddr(void);
+extern kal_uint32 custom_get_fat_len(void);
+extern kal_uint32 custom_get_fat_addr(void);
+
+#if !((defined(__FUE__) && defined(__FOTA_DM__)) || defined(__UBL__))
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ NOR Flash MTD interface/data common initialization
+ @retval
+ CMEM_NO_ERROR: Success
+*/
+kal_int32 CMEM_Init_NOR_MTD_Common(void)
+{
+ // 1. <DATA> Signature
+ mtdflash.Signature = ~((kal_uint32)RegionInfo);
+
+ // 2. <DATA> Page Buffer and Base Address
+#if defined(__MTK_TARGET__)
+ PAGE_BUFFER_SIZE = nor_list[cmem_nor_index].PageBufferSize;
+
+ mtdflash.BaseAddr = (BYTE *)(INT_RetrieveFlashBaseAddr() + NOR_FLASH_BASE_ADDRESS);
+#endif // __MTK_TARGET__
+
+ // 3. <DATA> RegionInfo and BankInfo
+ mtdflash.RegionInfo = (FlashRegionInfo *)RegionInfo;
+
+ return CMEM_NO_ERROR;
+}
+
+#if defined(__SERIAL_FLASH__)
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Serial NOR Flash MTD interface/data initialization
+ @retval
+ CMEM_NO_ERROR: Success
+ CMEM_ERR_MTD_INIT_FAIL: Fail
+*/
+kal_int32 CMEM_Init_NOR_MTD_SF(void)
+{
+ kal_int32 result;
+
+ // Assign MTD driver to FDM data
+ FlashDriveData.MTDDriver = &NORFlashMtd;
+
+ // Allocate status map and command for MTD data
+ mtdflash.StatusMap = &StatusMap[0];
+ mtdflash.CMD = &sf_dal_data_cmd;
+
+ // serial Flash driver will initialize the interface/data by its own.
+ result=SF_DAL_Init_Driver(
+ &NORFlashMtd, // Driver Interface (to FDM)
+ &mtdflash, // Driver Data
+ (INT_RetrieveFlashBaseAddr() + NOR_FLASH_BASE_ADDRESS), // Base Address
+ nor_list[cmem_nor_index].UniformBlocks); // Uniform Block
+
+ if (result==FS_FLASH_MOUNT_ERROR) {
+ return CMEM_ERR_MTD_INIT_FAIL;
+ }
+ return CMEM_NO_ERROR;
+}
+
+#else // __SERIAL_FLASH__
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ AMDUX NOR Flash MTD interface/data initialization
+*/
+kal_int32 CMEM_Init_NOR_MTD_ADMUX(void)
+{
+
+ kal_int32 result;
+
+ // Assign MTD driver to FDM data
+ FlashDriveData.MTDDriver = &NORFlashMtd;
+
+ // Allocate status map and command for MTD data
+ mtdflash.StatusMap = StatusMap;
+ mtdflash.CMD = &pf_dal_data_cmd;
+
+ // Admux NOR Flash driver will initialize the interface/data by its own.
+ result=ADMUX_DAL_Init_Driver(
+ &NORFlashMtd, // Driver Interface (to FDM)
+ &mtdflash, // Driver Data
+ (INT_RetrieveFlashBaseAddr() + NOR_FLASH_BASE_ADDRESS), // Base Address
+ nor_list[cmem_nor_index].FDMType);
+ if (result==FS_FLASH_MOUNT_ERROR)
+ {
+ return CMEM_ERR_MTD_INIT_FAIL;
+ }
+
+ return CMEM_NO_ERROR;
+
+}
+#endif // __SERIAL_FLASH__
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ NOR Flash FDM 4.0 interface/data common initialization
+*/
+kal_int32 CMEM_Init_NOR_FDM_Common(void)
+{
+ // 1. <DATA> Assign MTD data to FDM
+ FlashDriveData.MTDData = &mtdflash;
+
+ // 2. <DATA> Common Data
+ FlashDriveData.AvailSectorsInBlock = AVAILSECTORS;
+ FlashDriveData.ValidSectorsInBlock = VALIDSECTORS;
+ FlashDriveData.SectorMap = (kal_uint8*)SectorMap;
+ FlashDriveData.PartitionSectors = NOR_PARTITION_SECTORS;
+ FlashDriveData.Buffer = FDMBuffer;
+ FlashDriveData.MSTABLE_ENTRY_NUM = MS_TABLE_ENTRY_NUM;
+ FlashDriveData.MSEntryTable = MSEntryTable;
+
+ FlashDriveData.SystemDriveReservedUnits = (kal_uint32)(NOR_SYSTEM_DRIVE_RESERVED_BLOCK * 2); // The reserved unit is 0.5 block
+
+ // 3. <INTERFACE> Common Interface
+ NORFlashDriver.DiscardSectors=NULL;
+#ifdef __SECURITY_OTP__
+ NORFlashDriver.CopySectors=NULL; // copy sector
+ NORFlashDriver.OTPAccess=OTPAccess;
+ NORFlashDriver.OTPQueryLength=OTPQueryLength;
+#endif
+ NORFlashDriver.HighLevelFormat=NULL; // high level format
+ NORFlashDriver.RecoverDisk=NULL; // flush data
+ NORFlashDriver.MessageAck=NULL; // message ack
+ NORFlashDriver.IOCtrl=NULL;
+
+ return CMEM_NO_ERROR;
+}
+
+#if defined(__NON_INTEL_SIBLEY__)
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ NOR Flash FDM 4.0 interface/data initialization
+*/
+kal_int32 CMEM_Init_NOR_FDM_NonSIB(void)
+{
+ // FDM driver interface
+ NORFlashDriver.MountDevice=NOR_MountDevice_ext;
+ NORFlashDriver.ShutDown=NOR_ShutDown_ext;
+ NORFlashDriver.ReadSectors=NOR_ReadSectors_ext;
+ NORFlashDriver.WriteSectors=NOR_WriteSectors_ext;
+ NORFlashDriver.MediaChanged=NOR_MediaChanged_ext;
+ NORFlashDriver.DiscardSectors=NOR_DiscardSectors_ext;
+ NORFlashDriver.GetDiskGeometry=NOR_GetDiskGeometry_ext;
+ NORFlashDriver.LowLevelFormat=NOR_LowLevelFormat_ext;
+ NORFlashDriver.NonBlockWriteSectors=NOR_NonBlockWriteSectors_ext;
+ NORFlashDriver.RecoverableWriteSectors=NOR_RecoverableWriteSectors_ext;
+ NORFlashDriver.ResumeSectorStates=NOR_ResumeSectorStates_ext;
+
+ // Sibley FDM driver data
+
+#ifdef __BASIC_LOAD_FLASH_TEST__
+ extern kal_uint32 LocateSector(NOR_FLASH_DRV_Data * D, kal_uint32 LogicalSector);
+ LocateSector_ext = LocateSector;
+#endif //__BASIC_LOAD_FLASH_TEST__
+
+ return CMEM_NO_ERROR;
+}
+#endif
+
+#if defined(__INTEL_SIBLEY__)
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ NOR Flash Sibley FDM 4.0 interface/data initialization
+*/
+kal_int32 CMEM_Init_NOR_FDM_SIB(void)
+{
+ // FDM driver interface
+ NORFlashDriver.MountDevice=SIB_MountDevice;
+ NORFlashDriver.ShutDown=NOR_ShutDown;
+ NORFlashDriver.ReadSectors=SIB_ReadSectors;
+ NORFlashDriver.WriteSectors=SIB_WriteSectors;
+ NORFlashDriver.MediaChanged=NOR_MediaChanged;
+ NORFlashDriver.DiscardSectors=SIB_DiscardSectors;
+ NORFlashDriver.GetDiskGeometry=SIB_GetDiskGeometry;
+ NORFlashDriver.LowLevelFormat=SIB_LowLevelFormat;
+ NORFlashDriver.NonBlockWriteSectors=SIB_NonBlockWriteSectors;
+ NORFlashDriver.RecoverableWriteSectors=SIB_RecoverableWriteSectors;
+ NORFlashDriver.ResumeSectorStates=SIB_ResumeSectorStates;
+
+ // FDM driver data
+
+#ifdef __BASIC_LOAD_FLASH_TEST__
+ LocateSector_ext = SIB_LocateSector;
+#endif //__BASIC_LOAD_FLASH_TEST__
+
+
+ return CMEM_NO_ERROR;
+}
+#endif
+
+#endif // !((defined(__FUE__) && defined(__FOTA_DM__)) || defined(__UBL__))
+
+
+//-----------------------------------------------------------------------------
+// Begin of SECOND_PART
+//
+// Put those functions in second part to avoid leakage near to the FS
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Returns the size of the block located at given address.
+ @remarks
+ This is a internal function placed in SECOND part, which can be called by FOTA, MAUI, and Bootloader
+*/
+__sf_section_RAM kal_uint32 CMEM_BlockSize_Internal(kal_uint32 address, const FlashBlockLayout* blocklayout)
+{
+ kal_uint16 i;
+
+ address = address & (0x08000000-1);
+
+ for (i=0; blocklayout[i+1].Size!=0; i++) {
+ if (address >= blocklayout[i].Offset &&
+ address < blocklayout[i+1].Offset) {
+ break;
+ }
+ }
+ return blocklayout[i].Size;
+}
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Returns the size of the block located at given address.
+*/
+__sf_section_RAM kal_uint32 CMEM_BlockSize(kal_uint32 address)
+{
+ return CMEM_BlockSize_Internal(address, BlockLayout);
+}
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Returns the size of the block located at given address.
+ @remarks
+ For EMI init stage only, it will compare ID and match the correct settings.
+*/
+__sf_section_RAM kal_uint32 EMIINIT_CMEM_BlockSize(kal_uint32 address)
+{
+ kal_uint32 index=CMEM_EMIINIT_Index();
+ const CMEMEntryNOR *list=NULL;
+
+ #if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+ list=combo_mem_sw_list.m_data.List;
+ #else
+ list=combo_mem_sw_list.List;
+ #endif //__SV5_ENABLED__ || __SV5X_ENABLED__
+
+ return CMEM_BlockSize_Internal(address, list[index].BlockLayout);
+}
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Construct region info by combo MCP block info
+*/
+__sf_section_RAM kal_int32 NOR_Get_FlashSizeFromBankInfo(const FlashBankInfo *bankinfo)
+{
+ kal_uint32 result=0, i;
+
+ // For all entries in the geometry info
+ for (i=0; bankinfo[i].BankSize!=0; i++) {
+ result += bankinfo[i].Banks * bankinfo[i].BankSize;
+ }
+ return result;
+}
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Construct region info by combo MCP block info
+ @remarks
+ This is a internal function placed in SECOND part, which can be called by FOTA, MAUI, and Bootloader
+*/
+__sf_section_RAM kal_uint32 CMEM_NOR_Construct_RegionInfo_Internal(
+ kal_uint32 baseaddr,
+ kal_uint32 length,
+ FlashRegionInfo *regioninfo,
+ const FlashBlockLayout *blocklayout)
+{
+ kal_uint32 addr, ptr, blksize, total_blocks;
+ kal_uint32 endaddr = baseaddr + length;
+
+ // iterates all blocks
+ for (addr=baseaddr, ptr=0, total_blocks=0; addr<endaddr; ) {
+ blksize=CMEM_BlockSize_Internal(addr, blocklayout);
+ // the block is the first entry of the first region
+ if (total_blocks==0) {
+ regioninfo[ptr].BlockSize=blksize;
+ regioninfo[ptr].RegionBlocks=1;
+ }
+ // the block belongs to the same region
+ else if (blksize==regioninfo[ptr].BlockSize) {
+ regioninfo[ptr].RegionBlocks++;
+ }
+ // the block belongs to a new region
+ else {
+ ptr++;
+ if (ptr==(CMEM_REGION_INFO_LEN+1)) {
+ return CMEM_ERR_FDM_REGION_INFO_OVERFLOW;
+ }
+ regioninfo[ptr].BlockSize=blksize;
+ regioninfo[ptr].RegionBlocks=1;
+ }
+ addr+=blksize;
+ total_blocks++;
+ }
+
+ // TODO: Add bank boundary check and block boundary check
+
+ return CMEM_NO_ERROR;
+}
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Construct region info by combo MCP block info
+*/
+__sf_section_RAM kal_int32 NOR_Construct_RegionInfo(kal_uint32 baseaddr, kal_uint32 length, FlashRegionInfo *regioninfo)
+{
+ kal_mem_set(regioninfo, 0, sizeof(FlashRegionInfo)*CMEM_REGION_INFO_LEN);
+
+ return CMEM_NOR_Construct_RegionInfo_Internal(baseaddr, length, regioninfo, BlockLayout);
+}
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Construct region info by combo MCP block info
+ @remarks
+ For EMI init stage only, it will compare ID and match the correct settings.
+*/
+__sf_section_RAM kal_int32 EMIINIT_CMEM_NOR_Construct_RegionInfo(kal_uint32 baseaddr, kal_uint32 length, FlashRegionInfo *regioninfo)
+{
+ kal_uint32 index=CMEM_EMIINIT_Index();
+ const CMEMEntryNOR *list=NULL;
+
+ #if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+ list=combo_mem_sw_list.m_data.List;
+ #else
+ list=combo_mem_sw_list.List;
+ #endif //__SV5_ENABLED__ || __SV5X_ENABLED__
+
+ return CMEM_NOR_Construct_RegionInfo_Internal(baseaddr, length, regioninfo, list[index].BlockLayout);
+}
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Retrieve Uniform block size
+ @remarks
+ For EMI init stage only, it will compare ID and match the correct settings.
+*/
+__sf_section_RAM kal_uint32 EMIINIT_CMEM_NOR_GetUniformBlock(void)
+{
+ kal_uint32 index=CMEM_EMIINIT_Index();
+ const CMEMEntryNOR *list=NULL;
+
+ #if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+ list=combo_mem_sw_list.m_data.List;
+ #else
+ list=combo_mem_sw_list.List;
+ #endif //__SV5_ENABLED__ || __SV5X_ENABLED__
+
+ return list[index].UniformBlocks;
+}
+
+//-----------------------------------------------------------------------------
+// End of SECOND_PART
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ This function is used to construct bank info, and the caller is
+ CMEM_NOR_Construct_BankInfo()
+*/
+void CMEM_NOR_AddBankInfo(FlashBankInfo *bankInfo, kal_uint32 *index, kal_uint32 bankSize)
+{
+ if(bankInfo[*index].BankSize == bankSize)
+ {
+ bankInfo[*index].Banks ++;
+ }
+ else
+ {
+ *index ++;
+ bankInfo[*index].Banks = 1;
+ bankInfo[*index].BankSize= bankSize;
+ }
+
+}
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Construct bank info of the given address/lenth according to the
+ combo MCP bank info
+*/
+kal_uint32 CMEM_NOR_Construct_BankInfo(
+ kal_uint32 baseaddr,
+ kal_uint32 length,
+ FlashBankInfo *bankInfo,
+ const FlashBankInfo *cmemBankInfo)
+{
+ kal_uint32 Partition = 0;
+ kal_int32 Index = 0;
+ kal_uint32 bankSize;
+ kal_uint32 NextBankAddr,srcBankIdx;
+
+ kal_mem_set(bankInfo, 0, sizeof(FlashBankInfo)*CMEM_BANK_INFO_LEN);
+
+ for(srcBankIdx = 0, NextBankAddr=0; length>0; srcBankIdx++)
+ {
+ if(srcBankIdx >= cmemBankInfo[Partition].Banks)
+ {
+ srcBankIdx = 0; //BankIndex in current partition
+ Partition++;
+ }
+
+ NextBankAddr += cmemBankInfo[Partition].BankSize;
+
+ if(baseaddr <= NextBankAddr) {
+ bankSize = NextBankAddr - baseaddr;
+ if(length < bankSize)
+ bankSize = length;
+
+ //Add One Bank Info
+ if(bankInfo[Index].BankSize == bankSize)
+ {
+ bankInfo[Index].Banks ++;
+ }
+ else
+ {
+ if(bankInfo[Index].BankSize != 0) Index++;
+ bankInfo[Index].Banks = 1;
+ bankInfo[Index].BankSize= bankSize;
+ }
+
+ baseaddr += bankSize;
+ length -= bankSize;
+ }
+
+ }
+
+
+ return CMEM_NO_ERROR;
+}
+
+
+
+#if !((defined(__FUE__) && defined(__FOTA_DM__)) || defined(__UBL__))
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ NOR Flash initialization of MAUI
+*/
+kal_int32 CMEM_Init_NOR(void)
+{
+ kal_int32 result;
+ kal_int32 i;
+
+ // Total Blocks := Blocks in Region Info
+ // Block Size := MAX(RegionInfo[i].BlockSize)
+ BlockLayout=nor_list[cmem_nor_index].BlockLayout;
+ BankInfo=nor_list[cmem_nor_index].BankInfo;
+
+ // construct RegionInfo from block info and bank info
+ result=NOR_Construct_RegionInfo(custom_get_fat_addr(), custom_get_fat_len(), RegionInfo);
+
+ if (result!=CMEM_NO_ERROR) {
+ return result;
+ }
+
+ for (i=0, TOTAL_BLOCKS=0, NOR_LARGEST_BLOCK_SIZE=0 ;RegionInfo[i].BlockSize!=0;i++) {
+ TOTAL_BLOCKS += RegionInfo[i].RegionBlocks;
+ if (RegionInfo[i].BlockSize > NOR_LARGEST_BLOCK_SIZE)
+ NOR_LARGEST_BLOCK_SIZE = RegionInfo[i].BlockSize;
+ }
+
+ // 1. FDM data/interface initialization
+ result=CMEM_Init_NOR_FDM_Common();
+ if (result!=CMEM_NO_ERROR) return result;
+
+ switch (nor_list[cmem_nor_index].FDMType) {
+ #if defined(__INTEL_SIBLEY__)
+ case CMEM_NOR_CS_INTEL_SIBLEY:
+ PAGE_SIZE=0x400;
+ result=CMEM_Init_NOR_FDM_SIB();
+ break;
+ #endif
+ #if defined(__NON_INTEL_SIBLEY__)
+ default:
+ PAGE_SIZE=0x200;
+ result=CMEM_Init_NOR_FDM_NonSIB();
+ break;
+ #endif
+#if !(defined(__INTEL_SIBLEY__) || defined(__NON_INTEL_SIBLEY__))
+ default:
+ result=CMEM_ERR_FDM_MISMATCH;
+ break;
+#endif
+ }
+
+ // Total Sectors := Flash Area / Page Size
+ TOTAL_SECTORS = (NOR_ALLOCATED_FAT_SPACE / PAGE_SIZE);
+
+ if (result!=CMEM_NO_ERROR) return result;
+
+ // 2. MTD data/interface initialization
+
+ result=CMEM_Init_NOR_MTD_Common();
+ if (result!=CMEM_NO_ERROR) return result;
+
+ switch (cmem_id->DeviceType) {
+ #if !defined(__SERIAL_FLASH__)
+ case CMEM_TYPE_NOR:
+ result=CMEM_Init_NOR_MTD_ADMUX();
+ break;
+ #else // __SERIAL_FLASH__
+ case CMEM_TYPE_SERIAL_NOR_FLASH:
+ result=CMEM_Init_NOR_MTD_SF();
+ break;
+ #endif // __SERIAL_FLASH__
+ default:
+ result=CMEM_ERR_MTD_MISMATCH;
+ break;
+ }
+
+ if (result!=CMEM_NO_ERROR) return result;
+
+ // 3. RAW disk initialization
+ #ifdef __NOR_SUPPORT_RAW_DISK__
+ result=CMEM_Init_NOR_RAWDisk_Common();
+ switch (cmem_id->DeviceType) {
+ #if !defined(__SERIAL_FLASH__)
+ case CMEM_TYPE_NOR:
+ result=CMEM_Init_NOR_RAWDisk_ADMUX();
+ break;
+ #else // __SERIAL_FLASH__
+ case CMEM_TYPE_SERIAL_NOR_FLASH:
+ result=CMEM_Init_NOR_RAWDisk_SF();
+ break;
+ #endif // __SERIAL_FLASH__
+ default:
+ result=CMEM_ERR_MTD_MISMATCH;
+ break;
+ }
+ #endif
+
+ return result;
+}
+
+#endif // !((defined(__FUE__) && defined(__FOTA_DM__)) || defined(__UBL__))
+
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Compare device ID and retrieve the correspond NOR flash settings
+*/
+void CMEM_Init_nor_list(void)
+{
+#if ((!defined __FS_SYSDRV_ON_NAND__) && (!defined(_NAND_FLASH_BOOTING_)))
+ cmem_nor_index=CMEM_Index();
+ if (cmem_nor_index<0) ASSERT(0);//return CMEM_ERR_ID_NOT_FOUND;
+ cmem_id=CMEM_GetIDEntry(cmem_nor_index);
+#if defined(__SV5_ENABLED__) || defined(__SV5X_ENABLED__)
+ nor_list=combo_mem_sw_list.m_data.List; // SV5
+#else
+ nor_list=combo_mem_sw_list.List; // SV3
+#endif //__SV5_ENABLED__ || __SV5X_ENABLED__
+
+#endif //! __FS_SYSDRV_ON_NAND__ && !_NAND_FLASH_BOOTING_
+}
+
+
+//-----------------------------------------------------------------------------
+// MCP Initialization Function
+//-----------------------------------------------------------------------------
+#if !((defined(__FUE__) && defined(__FOTA_DM__)) || defined(__UBL__))
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Combo MCP intialization function for MAUI
+ @param[in] type The type of initialization (reserved)
+ @retval
+ CMEM_NO_ERROR: Success
+ otherwise: Fail
+*/
+kal_int32 ComboMem_Initialize(void)
+{
+#if ((!defined __FS_SYSDRV_ON_NAND__) && (!defined(_NAND_FLASH_BOOTING_)))
+ CMEM_Init_nor_list();
+ return CMEM_Init_NOR();
+#else
+ // NAND Flash driver has its own init functions
+ return CMEM_NO_ERROR;
+#endif
+}
+#endif // !((defined(__FUE__) && defined(__FOTA_DM__)) || defined(__UBL__))
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ NOR Flash RAW Disk initialization
+*/
+#ifdef __NOR_SUPPORT_RAW_DISK__
+kal_int32 CMEM_Init_NOR_RAWDisk_Common(void)
+{
+ mtdFlashDisk[0].Signature = ~((kal_uint32)Disk0RegionInfo);
+ mtdFlashDisk[0].BaseAddr = (BYTE *)(INT_RetrieveFlashBaseAddr() + NOR_BOOTING_NOR_DISK0_BASE_ADDRESS);
+ mtdFlashDisk[0].RegionInfo = (FlashRegionInfo *)Disk0RegionInfo;
+ FlashDiskDriveData[0].DiskSize = NOR_BOOTING_NOR_DISK0_SIZE;
+
+ FlashDiskDriveData[0].MTDData = &mtdFlashDisk[0];
+#if (NOR_BOOTING_NOR_DISK_NUM > 1)
+ mtdFlashDisk[1].Signature = ~((kal_uint32)Disk1RegionInfo);
+ mtdFlashDisk[1].BaseAddr = (BYTE *)(INT_RetrieveFlashBaseAddr() + NOR_BOOTING_NOR_DISK1_BASE_ADDRESS);
+ mtdFlashDisk[1].RegionInfo = (FlashRegionInfo *)Disk1RegionInfo;
+ FlashDiskDriveData[1].DiskSize = NOR_BOOTING_NOR_DISK1_SIZE;
+ FlashDiskDriveData[1].MTDDriver = &NORFlashMtd;
+ FlashDiskDriveData[1].MTDData = &mtdFlashDisk[1];
+#endif // NOR_BOOTING_NOR_DISK_NUM > 1
+ return CMEM_NO_ERROR;
+}
+
+
+
+#if !defined(__SERIAL_FLASH__)
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ ADMUX NOR Flash RAW Disk initialization
+*/
+kal_int32 CMEM_Init_NOR_RAWDisk_ADMUX(void)
+{
+
+ kal_int32 result;
+
+ NOR_Construct_RegionInfo(NOR_BOOTING_NOR_DISK0_BASE_ADDRESS, NOR_BOOTING_NOR_DISK0_SIZE, Disk0RegionInfo);
+ NOR_Construct_RegionInfo(NOR_BOOTING_NOR_DISK1_BASE_ADDRESS, NOR_BOOTING_NOR_DISK1_SIZE, Disk1RegionInfo);
+
+ // Assign RAW Disk 0 interface
+ FlashDiskDriveData[0].MTDDriver = &NORFlashMtd;
+ mtdFlashDisk[0].CMD=&sf_dal_data_cmd;
+ mtdFlashDisk[0].StatusMap=&StatusMap[0];
+
+ // RAW Disk 0 MTD
+ result=ADMUX_DAL_Init_Driver(
+ &NORFlashMtd, // Driver Interface
+ &mtdFlashDisk[0], // Driver Data
+ (INT_RetrieveFlashBaseAddr() + NOR_BOOTING_NOR_DISK0_BASE_ADDRESS), // Base Address
+ 0); // Reserved: Driver Type
+
+ if (result==FS_FLASH_MOUNT_ERROR)
+ {
+ return CMEM_ERR_MTD_INIT_FAIL;
+ }
+
+#if (NOR_BOOTING_NOR_DISK_NUM > 1)
+ // Assign RAW Disk 1 interface
+ FlashDiskDriveData[1].MTDDriver = &NORFlashMtd;
+ mtdFlashDisk[1].CMD=&sf_dal_data_cmd;
+ mtdFlashDisk[1].StatusMap=&StatusMap[0];
+
+
+ // RAW Disk 0 MTD
+ result=ADMUX_DAL_Init_Driver(
+ &NORFlashMtd, // Driver Interface
+ &mtdFlashDisk[1], // Driver Data
+ (INT_RetrieveFlashBaseAddr() + NOR_BOOTING_NOR_DISK1_BASE_ADDRESS), // Base Address
+ 0); // Reserved: Driver Type
+#endif
+ return CMEM_NO_ERROR;
+}
+
+#else // __SERIAL_FLASH__
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Serial NOR Flash RAW Disk initialization
+*/
+kal_int32 CMEM_Init_NOR_RAWDisk_SF(void)
+{
+ kal_int32 result;
+
+ NOR_Construct_RegionInfo(NOR_BOOTING_NOR_DISK0_BASE_ADDRESS, NOR_BOOTING_NOR_DISK0_SIZE, Disk0RegionInfo);
+ NOR_Construct_RegionInfo(NOR_BOOTING_NOR_DISK1_BASE_ADDRESS, NOR_BOOTING_NOR_DISK1_SIZE, Disk1RegionInfo);
+
+ // Assign RAW Disk 0 interface
+ FlashDiskDriveData[0].MTDDriver = &NORFlashMtd;
+
+ mtdFlashDisk[0].CMD=&sf_dal_data_cmd;
+ mtdFlashDisk[0].StatusMap=&StatusMap[0];
+
+ // RAW Disk 0 MTD
+ result=SF_DAL_Init_Driver(
+ &NORFlashMtd, // Driver Interface
+ &mtdFlashDisk[0], // Driver Data
+ (INT_RetrieveFlashBaseAddr() + NOR_BOOTING_NOR_DISK0_BASE_ADDRESS), // Base Address
+ nor_list[cmem_nor_index].UniformBlocks); // Uniform Block
+
+ if (result==FS_FLASH_MOUNT_ERROR) {
+ return CMEM_ERR_MTD_INIT_FAIL;
+ }
+
+#if (NOR_BOOTING_NOR_DISK_NUM > 1)
+ // Assign RAW Disk 1 interface
+ FlashDiskDriveData[1].MTDDriver = &NORFlashMtd;
+
+ mtdFlashDisk[1].CMD=&sf_dal_data_cmd;
+ mtdFlashDisk[1].StatusMap=&StatusMap[0];
+
+ // RAW Disk 0 MTD
+ result=SF_DAL_Init_Driver(
+ &NORFlashMtd, // Driver Interface
+ &mtdFlashDisk[1], // Driver Data
+ (INT_RetrieveFlashBaseAddr() + NOR_BOOTING_NOR_DISK1_BASE_ADDRESS), // Base Address
+ nor_list[cmem_nor_index].UniformBlocks); // Uniform Block
+#endif
+ return CMEM_NO_ERROR;
+
+}
+#endif // __SERIAL_FLASH__
+#endif // __NOR_SUPPORT_RAW_DISK__
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ NOR Flash FOTA initialization
+*/
+#ifdef __FOTA_DM__
+#if (!defined(__UBL__) && !defined(__FUE__))
+
+extern NOR_FLASH_DRV_Data NORFlashDriveData; //fota_partial.c
+
+#if defined(__SERIAL_FLASH__)
+SF_MTD_Data CMEM_FOTA_nor_mtdflash;
+#else
+PF_MTD_Data CMEM_FOTA_nor_mtdflash;
+#endif
+
+FlashRegionInfo CMEM_FOTA_NORRegionInfo[CMEM_REGION_INFO_LEN];
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ FOTA initialization Entry Function
+*/
+kal_int32 CMEM_Init_FOTA(void)
+{
+
+ kal_int32 result;
+
+ CMEM_Init_nor_list();
+
+ /* Initialize MTD data table */
+ CMEM_FOTA_nor_mtdflash.Signature = ~((kal_uint32)CMEM_FOTA_NORRegionInfo);
+
+ NORFlashDriveData.MTDDriver = &NORFlashMtd;
+ NORFlashDriveData.MTDData = &CMEM_FOTA_nor_mtdflash;
+
+ PAGE_BUFFER_SIZE = nor_list[cmem_nor_index].PageBufferSize;
+
+ BlockLayout=nor_list[cmem_nor_index].BlockLayout;
+ BankInfo=nor_list[cmem_nor_index].BankInfo;
+
+
+#ifdef __MTK_TARGET__
+ CMEM_FOTA_nor_mtdflash.BaseAddr = (BYTE *)INT_RetrieveFlashBaseAddr();
+#endif /* __MTK_TARGET__ */
+
+
+ CMEM_FOTA_nor_mtdflash.RegionInfo = (FlashRegionInfo *)CMEM_FOTA_NORRegionInfo;
+ NOR_Construct_RegionInfo(0, custom_get_NORFLASH_Size(), CMEM_FOTA_NORRegionInfo);
+
+
+ // Allocate status map and command for MTD data
+ CMEM_FOTA_nor_mtdflash.StatusMap = StatusMap;
+
+#if defined(__SERIAL_FLASH__)
+
+ // serial Flash driver will initialize the interface/data by its own.
+
+ CMEM_FOTA_nor_mtdflash.CMD = &sf_dal_data_cmd;
+
+ result=SF_DAL_Init_Driver(
+ &NORFlashMtd, // Driver Interface (to FDM)
+ &CMEM_FOTA_nor_mtdflash, // Driver Data
+ (kal_uint32)CMEM_FOTA_nor_mtdflash.BaseAddr, // Base Address
+ nor_list[cmem_nor_index].UniformBlocks); // Uniform Block
+#else //ADMUX flash
+ CMEM_FOTA_nor_mtdflash.CMD = &pf_dal_data_cmd;
+
+ result=ADMUX_DAL_Init_Driver(
+ &NORFlashMtd, // Driver Interface (to FDM)
+ &CMEM_FOTA_nor_mtdflash, // Driver Data
+ (kal_uint32)CMEM_FOTA_nor_mtdflash.BaseAddr, // Base Address
+ nor_list[cmem_nor_index].FDMType); // Reserved: Driver Type
+
+#endif // __SERIAL_FLASH__
+
+ return CMEM_NO_ERROR;
+}
+#endif // !(__UBL__) && !(__FUE__)
+#endif // __FOTA_DM__
+
+extern kal_int32 EMI_QueryIsRemapped(void);
+
+//-----------------------------------------------------------------------------
+/*!
+ @brief
+ Full driver initialization Entry Function
+ @remarks
+ EntireFlashDisk (SecurDisk, Card Download)
+*/
+kal_int32 CMEM_Init_FullDriver(void)
+{
+ kal_int32 result;
+
+ CMEM_Init_nor_list();
+
+ PAGE_BUFFER_SIZE = nor_list[cmem_nor_index].PageBufferSize;
+
+ BlockLayout=nor_list[cmem_nor_index].BlockLayout;
+ BankInfo=nor_list[cmem_nor_index].BankInfo;
+
+ // Allocate status map and command for MTD data
+ EntireDiskMtdData.StatusMap = &StatusMap[0];
+#ifdef __SERIAL_FLASH__
+ EntireDiskMtdData.CMD = &sf_dal_data_cmd;
+#else
+ EntireDiskMtdData.CMD = &pf_dal_data_cmd;
+#endif
+
+ EntireDiskMtdData.Signature = ~((kal_uint32)EntireDiskRegionInfo);
+ #ifdef __UBL__
+ //begin from MT6255, remapping is done before NOR_ReadID
+ if(EMI_QueryIsRemapped())
+ EntireDiskMtdData.BaseAddr = (BYTE *)0x10000000;
+ else
+ EntireDiskMtdData.BaseAddr = (BYTE *)0;
+
+ #else
+ EntireDiskMtdData.BaseAddr = (BYTE *)INT_RetrieveFlashBaseAddr();
+ #endif
+
+#if defined(__SERIAL_FLASH__)
+ // serial Flash driver will initialize the interface/data by its own.
+ result=SF_DAL_Init_Driver(
+ &NORFlashMtd, // Driver Interface (to FDM)
+ &EntireDiskMtdData, // Driver Data
+ (kal_uint32)EntireDiskMtdData.BaseAddr, // Base Address
+ nor_list[cmem_nor_index].UniformBlocks); // Uniform Block
+#else //ADMUX flash
+
+ result=ADMUX_DAL_Init_Driver(
+ &NORFlashMtd, // Driver Interface (to FDM)
+ &EntireDiskMtdData, // Driver Data
+ (kal_uint32)EntireDiskMtdData.BaseAddr, // Base Address
+ nor_list[cmem_nor_index].FDMType); // Reserved: Driver Type
+
+#endif // __SERIAL_FLASH__
+
+ ASSERT(result!=FS_FLASH_MOUNT_ERROR);
+
+ EntireDiskDriveData.DiskSize = NOR_Get_FlashSizeFromBankInfo(BankInfo);
+ NOR_Construct_RegionInfo(0, EntireDiskDriveData.DiskSize, EntireDiskRegionInfo);
+ EntireDiskMtdData.RegionInfo = (FlashRegionInfo *)EntireDiskRegionInfo;
+
+ EntireDiskDriveData.MTDDriver = &NORFlashMtd;
+ EntireDiskDriveData.MTDData = &EntireDiskMtdData;
+ EntireDiskDriveData.is_mount = KAL_FALSE;
+
+ return CMEM_NO_ERROR;
+}
+
+#if (defined(__FUE__) || defined(__EXT_BOOTLOADER__)) && defined(__FOTA_DM__)
+#include "custom_fota.h"
+
+extern kal_uint32 SSF_GetUAImageLoadAddress(void);
+
+#ifdef __SERIAL_FLASH__
+SF_MTD_Data fue_nor_mtdflash;
+SF_Status fue_sf_srmap[SF_SR_COUNT];
+SF_MTD_CMD fue_sf_cmd;
+#else
+PF_MTD_Data fue_nor_mtdflash;
+PF_Status fue_pf_srmap[SF_SR_COUNT];
+PF_MTD_CMD fue_pf_cmd;
+#endif // __SERIAL_FLASH__
+
+extern NOR_MTD_Driver NORFlashMtd;
+
+void CMEM_Init_FUE(void)
+{
+ kal_int32 result;
+ kal_uint32 blk_addr = 0;
+
+ CMEM_Init_nor_list();
+
+ PAGE_BUFFER_SIZE = nor_list[cmem_nor_index].PageBufferSize;
+
+ BlockLayout=nor_list[cmem_nor_index].BlockLayout;
+ BankInfo=nor_list[cmem_nor_index].BankInfo;
+
+ // construct NORRegionInfo from block info and bank info
+ // ***Note: NORRegionInfo[] body is instantiated in custom_fota.c
+ result=NOR_Construct_RegionInfo(0, custom_get_NORFLASH_Size(), NORRegionInfo);
+
+ ASSERT(result==CMEM_NO_ERROR);
+
+ /* Initialize MTD data table */
+ fue_nor_mtdflash.Signature = ~((kal_uint32)NORRegionInfo);
+
+ FlashDriveData.MTDDriver = &NORFlashMtd;
+ FlashDriveData.MTDData = &fue_nor_mtdflash;
+
+#ifdef __MTK_TARGET__
+
+ #if defined(MT6238) || defined(MT6239) || defined(MT6235B)
+ fue_nor_mtdflash.BaseAddr = (BYTE *)(custom_get_NORFLASH_Base()|0x08000000);
+ #elif defined(MT6228) || defined(MT6229) || defined(MT6230) || defined(MT6225) || defined(MT6268T)
+ fue_nor_mtdflash.BaseAddr = (BYTE *)(custom_get_NORFLASH_Base()|0x04000000);
+ #else
+ fue_nor_mtdflash.BaseAddr = (BYTE *)custom_get_NORFLASH_Base();
+ #endif
+
+ #ifdef __SERIAL_FLASH__
+ fue_nor_mtdflash.CMD = &fue_sf_cmd;
+ fue_nor_mtdflash.StatusMap = fue_sf_srmap;
+ SF_DAL_Init_Driver(&NORFlashMtd, &fue_nor_mtdflash, (kal_uint32)fue_nor_mtdflash.BaseAddr, nor_list[cmem_nor_index].UniformBlocks);
+ #else //ADMUX with combo memory support on
+ fue_nor_mtdflash.CMD = &fue_pf_cmd;
+ fue_nor_mtdflash.StatusMap = fue_pf_srmap;
+ ADMUX_DAL_Init_Driver(&NORFlashMtd, &fue_nor_mtdflash, (kal_uint32)fue_nor_mtdflash.BaseAddr, nor_list[cmem_nor_index].FDMType);
+ #endif // __SERIAL_FLASH__
+
+#endif /* __MTK_TARGET__ */
+
+ fue_nor_mtdflash.RegionInfo = (FlashRegionInfo *)NORRegionInfo;
+
+ blk_addr = SSF_GetUAImageLoadAddress()|custom_get_NORFLASH_Base();
+ #if defined(MT6238) || defined(MT6239) || defined(MT6235B)
+ blk_addr |= 0x08000000;
+ #elif defined(MT6228) || defined(MT6229) || defined(MT6230) || defined(MT6225) || defined(MT6268T)
+ blk_addr |= 0x04000000;
+ #else
+ blk_addr |= 0x0;
+ #endif
+ blk_addr -= (kal_uint32)fue_nor_mtdflash.BaseAddr;
+ FlashDriveData.FlashInfo.baseUnlockBlock = BlockIndex(&fue_nor_mtdflash, blk_addr);
+
+ #if (defined(__UP_PKG_ON_NAND__) && defined(NAND_SUPPORT))
+ blk_addr = (custom_get_NORFLASH_ROMSpace() - 1) | custom_get_NORFLASH_Base();
+ #else
+ blk_addr = FOTA_GetPackageStorageBase()+FOTA_GetPackageStorageSize();
+ #endif /* __UP_PKG_ON_NAND__ && NAND_SUPPORT */
+
+ #if defined(MT6238) || defined(MT6239) || defined(MT6235B)
+ blk_addr |= 0x08000000;
+ #elif defined(MT6228) || defined(MT6229) || defined(MT6230) || defined(MT6225) || defined(MT6268T)
+ blk_addr |= 0x04000000;
+ #else
+ blk_addr |= 0x0;
+ #endif
+
+ blk_addr -= (kal_uint32)fue_nor_mtdflash.BaseAddr;
+ FlashDriveData.FlashInfo.endUnlockBlock = BlockIndex(&fue_nor_mtdflash, blk_addr);
+
+}
+
+#endif // (__FUE__ || __EXT_BOOTLOADER__) && __FOTA_DM__
+
+
+#endif // ( !defined(__FS_SYSDRV_ON_NAND__) && !defined( _NAND_FLASH_BOOTING_) )
+
+#endif // (__COMBO_MEMORY_SUPPORT__) || defined(__SERIAL_FLASH__)
+
diff --git a/mcu/custom/driver/common/custom_EMI_MT6280.c b/mcu/custom/driver/common/custom_EMI_MT6280.c
new file mode 100644
index 0000000..b322916
--- /dev/null
+++ b/mcu/custom/driver/common/custom_EMI_MT6280.c
@@ -0,0 +1,185 @@
+/*****************************************************************************
+* 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_MT6280.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This Module defines the EMI (external memory interface) related setting.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ * Memory Device database last modified on 2011/3/18
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
diff --git a/mcu/custom/driver/common/custom_EMI_MT6290.c b/mcu/custom/driver/common/custom_EMI_MT6290.c
new file mode 100644
index 0000000..0e5a105
--- /dev/null
+++ b/mcu/custom/driver/common/custom_EMI_MT6290.c
@@ -0,0 +1,70 @@
+/*****************************************************************************
+* 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_MT6290.c
+ *
+ * Project:
+ * --------
+ * MOLY
+ *
+ * Description:
+ * ------------
+ * This Module defines the EMI (external memory interface) related setting.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
diff --git a/mcu/custom/driver/common/custom_EMI_SP.c b/mcu/custom/driver/common/custom_EMI_SP.c
new file mode 100644
index 0000000..cab55f1
--- /dev/null
+++ b/mcu/custom/driver/common/custom_EMI_SP.c
@@ -0,0 +1,316 @@
+/*****************************************************************************
+* 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:
+ * -------
+ * -------
+ *
+ * Memory Device database last modified on 2011/6/29
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#include "custom_EMI_release.h"
+
+#if defined(__EMI_DEVICE_NONE__)
+#if defined(__MTK_TARGET__)
+
+#include "kal_public_api.h" //MSBB change #include "kal_release.h"
+#include "pll.h"
+
+
+/*************************************
+ *
+ * Imported APIs.
+ *
+ *************************************/
+
+
+/*************************************
+ *
+ * Global Variables.
+ *
+ *************************************/
+
+
+/*************************************************************************
+* FUNCTION
+* custom_setEMI()
+*
+* DESCRIPTION
+* This routine aims to set EMI
+*
+* PARAMETERS
+*
+* RETURNS
+* None
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+kal_int8 custom_setEMI(void)
+{
+
+/**
+ * MT6573 EMI will be init at CMM when bring-up.
+ */
+
+ return 1;
+
+}
+
+/*************************************************************************
+* FUNCTION
+* custom_InitDRAM()
+*
+* DESCRIPTION
+* This routine aims to set EMI and initialize LPSDRAM
+*
+* PARAMETERS
+*
+* RETURNS
+* None
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+kal_int8 custom_InitDRAM(void)
+{
+ return -1;
+
+}
+
+#if ( !defined(__UBL__) && !defined(__FUE__) )
+ /* __FUE__ , __UBL__ compile option is used for FOTA or USB Bootloader build
+ * add this compile option to avoid compiling functions other than custom_setEMI()
+ */
+
+/*************************************************************************
+* FUNCTION
+* custom_setAdvEMI()
+*
+* DESCRIPTION
+* This routine aims to set additional EMI
+* This is special for device which needs to set device configuration
+* register to turn-on special mode.
+*
+* PARAMETERS
+*
+* RETURNS
+* 1:
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+
+#ifdef __MTK_TARGET__
+#endif /* __MTK_TARGET__ */
+
+
+kal_int8 custom_setAdvEMI(void)
+{
+ kal_int8 status = 0;
+
+ return status;
+}
+
+#ifdef __MTK_TARGET__
+#endif /* __MTK_TARGET__ */
+
+
+/*************************************************************************
+* FUNCTION
+* custom_get_EXTSRAM_size()
+*
+* DESCRIPTION
+* Return predefined external SRAM size.
+*
+* PARAMETERS
+*
+* RETURNS
+* None
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+void
+custom_get_EXTSRAM_size(kal_uint32 *size)
+{
+ *size = (kal_uint32)EMI_EXTSRAM_SIZE;
+}
+
+/*************************************************************************
+* FUNCTION
+* custom_ifLPSDRAM()
+*
+* DESCRIPTION
+* Query if the memory device is LPSDRAM
+*
+* PARAMETERS
+*
+* RETURNS
+* KAL_TRUE: The memory device is LPSDRAM
+* KAL_FALSE: The memory device is not LPSDRAM
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+kal_bool
+custom_ifLPSDRAM(void)
+{
+#if defined(DRAM_CS) && defined(DRAM_SIZE)
+ return KAL_TRUE;
+#else
+ return KAL_FALSE;
+#endif
+}
+
+
+/*************************************************************************
+* FUNCTION
+* custom_DynamicClockSwitch
+*
+* DESCRIPTION
+* This function dedicates to switch the system clock and adjust the EMI
+* according to the working system clock.
+*
+* PARAMETERS
+* clock - clock to switch
+*
+* RETURNS
+* 0 for success; -1 for failure
+*
+*************************************************************************/
+#if 0 //#ifdef DCM_ENABLE
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif /* DCM_ENABLE */
+
+
+/*************************************************************************
+* FUNCTION
+* custom_EMIDynamicClockSwitch_Init
+*
+* DESCRIPTION
+* This function is used to Init setting for DCM
+*
+* PARAMETERS
+*
+*
+* RETURNS
+* 0 for success; -1 for failure
+*
+*************************************************************************/
+
+int custom_EMIDynamicClockSwitch_Init(void)
+{
+
+ return 0;
+}
+
+
+
+#endif /* !__UBL__ && !__FUE__ */
+
+#endif // #if defined(__MTK_TARGET__)
+#endif // #if defined(MT6573) || defined(MT6575)
diff --git a/mcu/custom/driver/common/custom_SFI.c b/mcu/custom/driver/common/custom_SFI.c
new file mode 100644
index 0000000..8260616
--- /dev/null
+++ b/mcu/custom/driver/common/custom_SFI.c
@@ -0,0 +1,232 @@
+/*****************************************************************************
+* 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_SFI.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This Module defines the SFI (serial flash interface) related setting.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ * Memory Device database last modified on 2011/7/8
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#if defined(__MTK_TARGET__)
+#define __sf_section_RAM __attribute__ ((section ("SNORCODE")))
+#define __sf_section_SECOND_PART __attribute__ ((section ("SECOND_PART")))
+#define __sf_section_EMIINITCODE __attribute__ ((section ("EMIINITCODE")))
+#define __sf_section_RODATA_EMI __attribute__ ((section ("EMIINITCONST")))
+#define __sf_section_ZIDATA_EMI __attribute__ ((zero_init, section ("EMIINITZI")))
+#define __sf_section_RWDATA_INTSRAM __attribute__ ((section ("INTSRAM_RW")))
+#define __sf_section_RODATA_INTSRAM __attribute__ ((section ("INTSRAM_RODATA")))
+#define __sf_section_ZIDATA_INTSRAM __attribute__ ((zero_init, section ("INTSRAM_ZI")))
+#define __sf_section_INTSRAM __attribute__ ((section ("INTSRAM_ROCODE")))
+#else //defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__) && defined(__MTK_TARGET__)
+ /* Reserve for MoDIS */
+#define __sf_section_RAM
+#define __sf_section_SECOND_PART
+#define __sf_section_EMIINITCODE
+#define __sf_section_RODATA_EMI
+#define __sf_section_ZIDATA_EMI
+#define __sf_section_RWDATA_INTSRAM
+#define __sf_section_RODATA_INTSRAM
+#define __sf_section_ZIDATA_INTSRAM
+#define __sf_section_INTSRAM
+#endif //defined(__SINGLE_BANK_NOR_FLASH_SUPPORT__) && defined(__MTK_TARGET__)
+
+
+
+#include "kal_public_api.h" //MSBB change #include "kal_release.h"
+#include "pll.h"
+
+__sf_section_EMIINITCODE kal_int8 custom_setSFI(void)
+{
+ return 0;
+}
+
+__sf_section_EMIINITCODE kal_int8 custom_setAdvSFI(void)
+{
+ return 0;
+}
+
+__sf_section_RAM int custom_SFIDynamicClockSwitch_Init()
+{
+ return 0;
+}
+
+__sf_section_INTSRAM int custom_SFIDynamicClockSwitch()
+{
+ return 0;
+}
+
diff --git a/mcu/custom/driver/common/custom_flash.c b/mcu/custom/driver/common/custom_flash.c
new file mode 100644
index 0000000..9f18846
--- /dev/null
+++ b/mcu/custom/driver/common/custom_flash.c
@@ -0,0 +1,1226 @@
+/*****************************************************************************
+* 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_flash.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * This Module defines flash related settings.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ * Memory Device database last modified on 2011/7/8
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+MT6280 SIP_MDSP link fail.
+[Solution]
+Modify EXTSRAM_type_7() to switch $ram_disk_size become 0x40000 if it's MT6280
+[Verification]
+m sys_auto_gen on MT6280_EVB_R7R8_HSPA(SIP_MDSP).W12.17
+and the generated EXTSRAM_FS maxsize becomes 0x40000 and dummy_end base is correct as well.
+[Phase-in Branch]
+MT6280_DVT_DEV
+MODEM_DEV
+[Version]
+scatGenLib.pl m0.03
+[Requester]
+Stanley Chu
+
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#define FLASHCONF_C
+
+#if defined(__SMART_MD_NFI_DRIVER__) // Smart phone start alone driver
+ #ifndef _NAND_FLASH_BOOTING_
+ #define _NAND_FLASH_BOOTING_
+ #endif
+#endif
+
+#include "kal_general_types.h"
+#include "fs_type.h"
+#include "custom_MemoryDevice.h"
+#include "flash_sf.h"
+#include "string.h"
+
+#ifdef FLASH_DISKDRV_DEBUG
+#include <stdlib.h>
+#endif
+
+#include "flash_opt.h"
+#include "DrvFlash.h"
+#include "NAND_FDM.h"
+#include "flash_disk.h"
+#include "flash_disk_internal.h"
+#include "combo_flash_init.h"
+
+#include "custom_flash.h"
+
+#include "flash_mtd_ut.h" //__BASIC_LOAD_FLASH_TEST__
+#include "DrvFlash_UT.h"
+
+#include "custom_nvram_int_config.h" /* To get NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM for MSTABLE_ENTRY_NUM */
+
+
+#if !(defined(__SMART_PHONE_PLATFORM__) && defined(__SMART_PHONE_MODEM__))
+
+
+
+/*-------------------------------------------------------------------
+ * MS table size
+ *
+ * MS table size should be synchronized with user's requirement. The only one user is NVRAM.
+ *
+ * NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM defines the maximum record size in NVRAM
+ * (in custom_nvram_config.h). NVRAM should call NOR_ResumeSectorState (by FS_Commit)
+ * after it writes maximum NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM sectors with protection
+ * mode to ensure the integrity of a record.
+ *
+ * MSTABLE_ENTRY_NUM number is based on the worst senario: All FAT entries of clusters
+ * of logical sectors are located in different physical sectors. In other word, we need
+ * to write additional N sectors to update FAT after we write N data sectors. The other
+ * 1 sector is for directory entry update.
+ *
+ * TODO: Use auto-gen to compute most suitable MS table size. Because the number of
+ * sectors for FAT may be smaller than NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM. For example,
+ * 64KB disk only needs 1 sector to store FAT.
+ *---------------------------------------------------------- W08.50 --*/
+
+#define MS_TABLE_ENTRY_NUM (NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM * 2 + 1)
+
+/*
+ ****************************************************************************
+ PART 1:
+ Rules to Prevent Wrong Configuration
+ ****************************************************************************
+*/
+#ifdef NAND_PARTITION_SECTORS
+
+ #if (NAND_PARTITION_SECTORS > 0 && NAND_PARTITION_SECTORS < NAND_MINIMUM_PARTITION_SIZE)
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! NAND_FS_FIRST_DRIVE_SECTORS MUST be larger than NAND_MINIMUM_PARTITION_SIZE!"
+ #endif
+
+ #if (defined(_NAND_FLASH_BOOTING_))
+ #if ( (NAND_PARTITION_SECTORS << 9) > NAND_ALLOCATED_FAT_SPACE)
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! NAND_FS_FIRST_DRIVE_SECTORS MUST be less than NAND_FS_SIZE!"
+ #endif
+ #endif /* _NAND_FLASH_BOOTING_ */
+
+#endif /* NAND_PARTITION_SECTORS */
+
+
+#if defined(__SINGLE_BANK_NOR_DEVICE__)
+
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Single Bank device with non Single Bank load! Please modify device or makefile option!"
+
+#endif /* __SINGLE_BANK_NOR_DEVICE__ */
+
+
+#if !defined(_NAND_FLASH_BOOTING_) && !defined(__EMMC_BOOTING__)
+ #ifndef __NOR_FDM5__
+ #if (TOTAL_BLOCKS > 127)
+ #error "TOTAL_BLOCKS > 127 , recommend enable Pseudo Sized Block feature for serial flash project. Enable FDM5.0 feature for NOR flash project."
+ #endif
+ #endif
+#endif
+
+/*
+ ****************************************************************************
+ PART 2:
+ Essential Information of NOR Flash Geometry Layout Information
+ ****************************************************************************
+*/
+/*******************************************************************************
+ NOTICE: Fill the flash region information table, a region is the memory space
+ that contains continuous sectors of equal size. Each region element
+ in the table is the format as below:
+ {S_sector, N_sector},
+ S_sector: the size of sector in the region
+ N_sector: the number of sectors in the region
+ *******************************************************************************/
+
+#if !(defined(__FUE__) || defined(__UBL__) || defined(__EXT_BOOTLOADER__))
+#define __MAUI_LOAD__
+#endif //!__FUE__ && !__UBL__ && !__EXT_BOOTLOADER__
+
+#if !defined(_NAND_FLASH_BOOTING_) && !defined(__EMMC_BOOTING__) && !defined(__RAMDISK__)
+#define _NOR_FLASH_BOOTING_
+#endif // !_NAND_FLASH_BOOTING_ && !__EMMC_BOOTING__
+
+
+#ifdef _NOR_FLASH_BOOTING_
+
+#define FLASH_REGIONINFO_VAR_MODIFIER static const
+
+#if (defined(__MAUI_LOAD__) && defined(_NOR_FLASH_BOOTING_) && !defined(__NOR_FDM5__))
+#define __MAUI_NOR_FDM4__
+#endif
+
+#if defined(__MAUI_NOR_FDM4__)
+FLASH_REGIONINFO_VAR_MODIFIER FlashRegionInfo RegionInfo[]= /* Don't modify this line */
+{
+ REGION_INFO_LAYOUT
+ EndRegionInfo /* Don't modify this line */
+};
+#endif //__MAUI_NOR_FDM4__
+
+#if !defined(__SERIAL_FLASH__)
+#ifdef __NOR_SUPPORT_RAW_DISK__
+
+#ifndef NOR_BOOTING_NOR_DISK_NUM
+#error "custom\system\{project}\custom_MemoryDevice.h: Error! NOR_BOOTING_NOR_DISK_NUM be defined when __NOR_SUPPORT_RAW_DISK__ is defined."
+#endif //NOR_BOOTING_NOR_DISK_NUM
+
+#if (NOR_BOOTING_NOR_DISK_NUM>0)
+FLASH_REGIONINFO_VAR_MODIFIER FlashRegionInfo Disk0RegionInfo[]= /* Don't modify this line */
+{
+ DISK0_REGION_INFO_LAYOUT
+ EndRegionInfo /* Don't modify this line */
+};
+#endif /* NOR_BOOTING_NOR_DISK_NUM>0 */
+
+#if (NOR_BOOTING_NOR_DISK_NUM>1)
+FLASH_REGIONINFO_VAR_MODIFIER FlashRegionInfo Disk1RegionInfo[]= /* Don't modify this line */
+{
+ DISK1_REGION_INFO_LAYOUT
+ EndRegionInfo /* Don't modify this line */
+};
+#endif /* NOR_BOOTING_NOR_DISK_NUM>1 */
+#endif // __NOR_SUPPORT_RAW_DISK__
+
+FLASH_REGIONINFO_VAR_MODIFIER FlashRegionInfo EntireDiskRegionInfo[]= /* Don't modify this line */
+{
+ ENTIRE_DISK_REGION_INFO_LAYOUT
+ EndRegionInfo /* Don't modify this line */
+};
+
+NOR_FLASH_DISK_Data EntireDiskDriveData;
+static NOR_Flash_MTD_Data EntireDiskMtdData;
+
+/*******************************************************************************
+ NOTICE. Modify the value of page buffer size in WORD for page buffer program
+ *******************************************************************************/
+kal_uint32 PAGE_BUFFER_SIZE = BUFFER_PROGRAM_ITERATION_LENGTH;
+
+/*******************************************************************************
+ NOTICE. This is for the Enhanced Signle Bank Support, when this feature is
+ turned on and still use multi-bank device, this table should be filled
+ with correct value.
+
+ This Table define the flash bank information which starts from
+ FLASH_BASE_ADDRESS, please fill the flash bank information table, every
+ entry defines the memory space that contains continuous banks of equal size.
+ Each entry element in the table is the format as below:
+ {S_Bank, N_Bank},
+ S_Bank: the size of bank in the entry
+ N_Bank: the number of banks in the entry
+ *******************************************************************************/
+#endif /* !__COMBO_MEMORY_SUPPORT__ && !__SERIAL_FLASH__ */
+
+#endif // _NOR_FLASH_BOOTING_
+
+/*
+ ****************************************************************************
+ PART 3:
+ Essential Declarations for NOR-Flash Disk
+ ****************************************************************************
+*/
+
+extern NOR_MTD_Driver NORFlashMtd;
+
+#ifdef __MAUI_NOR_FDM4__
+
+static MS_ENTRY MSEntryTable[MS_TABLE_ENTRY_NUM];
+
+
+#if !defined(__SERIAL_FLASH__)
+
+#ifndef __INTEL_SIBLEY__
+
+/* Each FAT sector is 512bytes (0x200) */
+#define TOTAL_SECTORS ((NOR_ALLOCATED_FAT_SPACE -NOR_BLOCK_SIZE * NOR_SYSTEM_DRIVE_RESERVED_BLOCK) / 0x200)
+
+kal_uint8 FDMBuffer[512];
+
+
+FS_Driver NORFlashDriver =
+{
+ NOR_MountDevice_ext,
+ NOR_ShutDown,
+ NOR_ReadSectors_ext,
+ NOR_WriteSectors_ext,
+ NOR_MediaChanged_ext,
+ NOR_DiscardSectors_ext,
+ NOR_GetDiskGeometry_ext,
+ NOR_LowLevelFormat_ext,
+ NOR_NonBlockWriteSectors_ext,
+ NOR_RecoverableWriteSectors_ext,
+ NOR_ResumeSectorStates_ext,
+ NULL, /*high level format*/
+ NULL, /*flush data*/
+ NULL /*message ack*/
+#ifdef __SECURITY_OTP__
+ ,
+ NULL, /*copy sector*/
+ OTPAccess,
+ OTPQueryLength
+#endif
+};
+
+#else /* __INTEL_SIBLEY__ */
+
+/* Each FAT sector is 1024bytes (0x200) */
+#define TOTAL_SECTORS ((NOR_ALLOCATED_FAT_SPACE - NOR_BLOCK_SIZE * NOR_SYSTEM_DRIVE_RESERVED_BLOCK) / 0x400)
+
+kal_uint8 FDMBuffer[1024];
+
+
+FS_Driver NORFlashDriver =
+{
+ SIB_MountDevice,
+ NOR_ShutDown,
+ SIB_ReadSectors,
+ SIB_WriteSectors,
+ NOR_MediaChanged,
+ SIB_DiscardSectors,
+ 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;
+
+
+#ifdef __MTK_TARGET__
+
+static NOR_Flash_MTD_Data mtdflash;
+
+#ifdef __NOR_SUPPORT_RAW_DISK__
+NOR_FLASH_DISK_Data FlashDiskDriveData[NOR_BOOTING_NOR_DISK_NUM];
+static NOR_Flash_MTD_Data mtdFlashDisk[NOR_BOOTING_NOR_DISK_NUM];
+#endif // __NOR_SUPPORT_RAW_DISK__
+
+extern kal_uint32 INT_RetrieveFlashBaseAddr(void);
+
+#else
+
+static NOR_Flash_MTD_Data mtdflash =
+{
+ MakeMtdFlashData((BYTE *)NOR_FLASH_BASE_ADDRESS, RegionInfo)
+};
+
+#endif /* __MTK_TARGET__ */
+
+#endif /* !(__COMBO_MEMORY_SUPPORT__) && !(__SERIAL_FLASH__) */
+
+#endif /* __MAUI_NOR_FDM4__ */
+
+
+
+/*
+ ****************************************************************************
+ PART 4:
+ Public Functions For NOR Flash Information Retrieve, Initial routine, and
+ other misc routines.
+ ****************************************************************************
+*/
+kal_uint32 custom_get_NORFLASH_Base(void);
+
+/*
+ ****************************************************************************
+ PART 5:
+ Essential Declarations for NAND-Flash Disk
+ ****************************************************************************
+*/
+#if (!(defined(__FUE__) && defined(__FOTA_DM__)) && (!defined(__UBL__)||(defined(__UBL__)&&defined(__NAND_SUPPORT_RAW_DISK__))))
+ // 1. NAND FDM variable compile option
+ // a. In general, FOTA and Boot loader don't need to include NAND FDM variable.
+ // b. In TC01 Raw disk case, boot loader need to call FDM function, it will need raw disk configuration
+ // 2. Declare NAND variable structue
+ // a. In general, NFBxxx is only used for NAND_BOOTING
+ // b. UP_PKG_ON_NAND will also need NFBxxx.
+
+#if defined(__EMMC_BOOTING__)
+
+
+#elif defined(_NAND_FLASH_BOOTING_)
+ /* System Drive on NAND-flash */
+ #if ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+ kal_uint32 NFB_BASE_ADDRESS[NAND_DISK_NUM];
+ kal_uint32 NFB_ALLOCATED_FAT_SPACE[NAND_DISK_NUM];
+ kal_uint16 FS_DISK_REPLACE_RATIO[NAND_DISK_NUM];
+ const kal_uint8 NANDDiskNum = NAND_DISK_NUM;
+ #if ( defined(__NANDFDM_TOTAL_BBM__))
+ kal_uint32 FS_DISK_START_SECTION[NAND_DISK_NUM];
+ kal_uint32 NFB_REPLACE_BASE_ADDRESS;
+ kal_uint32 NFB_REPLACE_SPACE;
+ BBM_BRMT_INFO NAND_BRMT_Info;
+ #endif
+ #else // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+ const kal_uint32 NFB_BASE_ADDRESS = NAND_FLASH_BASE_ADDRESS;
+ const kal_uint32 NFB_ALLOCATED_FAT_SPACE = NAND_ALLOCATED_FAT_SPACE;
+ #endif // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+
+#else /* !_NAND_FLASH_BOOTING_ || __EMMC_BOOTING__ */
+ #if (defined(__UP_PKG_ON_NAND__) && defined(NAND_SUPPORT)) || (defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__))
+ /* update package storage on NAND flash */
+ #if ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+ kal_uint32 NFB_BASE_ADDRESS[NAND_DISK_NUM];
+ kal_uint32 NFB_ALLOCATED_FAT_SPACE[NAND_DISK_NUM];
+ kal_uint16 FS_DISK_REPLACE_RATIO[NAND_DISK_NUM];
+ const kal_uint8 NANDDiskNum = NAND_DISK_NUM;
+ #else // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+ const kal_uint32 NFB_BASE_ADDRESS = NAND_FLASH_BASE_ADDRESS;
+ const kal_uint32 NFB_ALLOCATED_FAT_SPACE = NAND_ALLOCATED_FAT_SPACE;
+ #endif // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+ #endif
+#endif /* _NAND_FLASH_BOOTING_ || __EMMC_BOOTING__ */
+
+#if defined(__NAND_FDM_50__)
+ #ifdef NAND_BOOTING_NAND_MAX_REPLACE_COUNT
+ kal_uint16 wNandMaxReplaceCount = NAND_BOOTING_NAND_MAX_REPLACE_COUNT;
+ #else
+ kal_uint16 wNandMaxReplaceCount = 28;
+ #endif
+#endif //defined(__NAND_FDM_50__)
+
+#ifdef __EMMC_BOOTING__
+kal_uint32 custom_part_secs = 0;
+#else
+kal_uint32 custom_part_secs = NAND_PARTITION_SECTORS;
+#endif
+
+#if ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+ #if (defined(__UBL__)&&defined(__NAND_SUPPORT_RAW_DISK__))
+ NAND_FLASH_DRV_DATA NANDFlashDriveData[1]; // To save ZI Space
+ #else
+ NAND_FLASH_DRV_DATA NANDFlashDriveData[NAND_DISK_NUM];
+ #endif
+#else // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+NAND_FLASH_DRV_DATA NANDFlashDriveData;
+#endif // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+
+#endif /* (!(__FOTA_DM__ && __FUE__) || !__UBL__)) || (UBL&&RAW) */
+/*************************************************************************
+* FUNCTION
+* custom_get_NORFLASH_ROMSpace()
+*
+* DESCRIPTION
+* Query the of space configured for NORFLASH ROM
+*
+* PARAMETERS
+*
+* RETURNS
+* BASE ADDRESS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+kal_uint32
+custom_get_NORFLASH_ROMSpace(void)
+{
+#if defined(_NAND_FLASH_BOOTING_) || defined(__EMMC_BOOTING__) || defined(__RAMDISK__)
+ return 0;
+#elif defined(__FS_SYSDRV_ON_NAND__) || (defined(__UP_PKG_ON_NAND__) && defined(NAND_SUPPORT))
+ return NOR_FLASH_BASE_ADDRESS + NOR_ALLOCATED_FAT_SPACE;
+#else
+ return NOR_FLASH_BASE_ADDRESS;
+#endif
+}
+
+
+/*************************************************************************
+* FUNCTION
+* custom_get_NORFLASH_Size()
+*
+* DESCRIPTION
+* Query the size of NORFLASH ROM
+*
+* PARAMETERS
+*
+* RETURNS
+* SIZE
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+kal_uint32
+custom_get_NORFLASH_Size(void)
+{
+#if defined(_NAND_FLASH_BOOTING_) || defined(__EMMC_BOOTING__) || defined(__RAMDISK__)
+ return 0;
+#else
+ return NOR_FLASH_SIZE;
+#endif
+}
+
+/*************************************************************************
+* FUNCTION
+* Initialize_FDD_tables
+*
+* DESCRIPTION
+* Initialize important information for NOR-flash disk
+*
+* PARAMETERS
+*
+* RETURNS
+* None
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+#if defined(__MAUI_LOAD__)
+
+#if defined(__RAMDISK__)
+extern kal_uint8 ram_disk[];
+void Initialize_FDD_tables(void)
+{
+ return;
+}
+#elif defined(__SERIAL_FLASH__) && defined(_NOR_FLASH_BOOTING_)
+void Initialize_FDD_tables(void)
+{
+#if !defined(ATEST_DRV_ENABLE) && !defined(ATEST_DRV_ENVIRON)
+ ComboMem_Initialize();
+#endif /* end of ATEST_DRV_ENABLE */
+ return;
+}
+
+#else /* (!(__COMBO_MEMORY_SUPPORT__) && !(__SERIAL_FLASH__)) && !(_NOR_FLASH_BOOTING_) */
+
+#ifndef __NOR_FDM5__
+
+#ifdef __NONE_FLASH_EXIST__
+
+NOR_MTD_Driver NORFlashMtd;
+
+#endif
+
+void Initialize_FDD_tables(void)
+{
+#if ( !defined(__FS_SYSDRV_ON_NAND__) && defined(_NOR_FLASH_BOOTING_))
+
+ /* Initialize MTD data table */
+ mtdflash.Signature = ~((kal_uint32)RegionInfo);
+
+#ifdef __MTK_TARGET__
+#if (defined(__SMART_PHONE_PLATFORM__) && !defined(__SMART_PHONE_MODEM__)) && defined(__RAMDISK__)
+ mtdflash.BaseAddr = (kal_uint8 *)ram_disk;
+#else
+ mtdflash.BaseAddr = (BYTE *)(INT_RetrieveFlashBaseAddr() + NOR_FLASH_BASE_ADDRESS);
+#endif
+
+#endif /* __MTK_TARGET__ */
+
+ mtdflash.RegionInfo = (FlashRegionInfo *)RegionInfo;
+
+ /* Initialize FDD data table */
+ FlashDriveData.MTDDriver = &NORFlashMtd;
+ FlashDriveData.MTDData = &mtdflash;
+ FlashDriveData.AvailSectorsInBlock = AVAILSECTORS;
+ FlashDriveData.ValidSectorsInBlock = VALIDSECTORS;
+ FlashDriveData.SectorMap = (BYTE*)SectorMap;
+ FlashDriveData.PartitionSectors = NOR_PARTITION_SECTORS;
+ FlashDriveData.Buffer = FDMBuffer;
+ FlashDriveData.MSTABLE_ENTRY_NUM = MS_TABLE_ENTRY_NUM;
+ FlashDriveData.MSEntryTable = MSEntryTable;
+
+ /* The reserved unit is 0.5 block.*/
+ FlashDriveData.SystemDriveReservedUnits = (kal_uint32)(NOR_SYSTEM_DRIVE_RESERVED_BLOCK * 2);
+
+
+#ifdef __NOR_SUPPORT_RAW_DISK__
+ mtdFlashDisk[0].Signature = ~((kal_uint32)Disk0RegionInfo);
+ mtdFlashDisk[0].BaseAddr = (BYTE *)(INT_RetrieveFlashBaseAddr() + NOR_BOOTING_NOR_DISK0_BASE_ADDRESS);
+ mtdFlashDisk[0].RegionInfo = (FlashRegionInfo *)Disk0RegionInfo;
+ FlashDiskDriveData[0].DiskSize = NOR_BOOTING_NOR_DISK0_SIZE;
+ FlashDiskDriveData[0].MTDDriver = &NORFlashMtd;
+ FlashDiskDriveData[0].MTDData = &mtdFlashDisk[0];
+#if (NOR_BOOTING_NOR_DISK_NUM > 1)
+ mtdFlashDisk[1].Signature = ~((kal_uint32)Disk1RegionInfo);
+ mtdFlashDisk[1].BaseAddr = (BYTE *)(INT_RetrieveFlashBaseAddr() + NOR_BOOTING_NOR_DISK1_BASE_ADDRESS);
+ mtdFlashDisk[1].RegionInfo = (FlashRegionInfo *)Disk1RegionInfo;
+ FlashDiskDriveData[1].DiskSize = NOR_BOOTING_NOR_DISK1_SIZE;
+ FlashDiskDriveData[1].MTDDriver = &NORFlashMtd;
+ FlashDiskDriveData[1].MTDData = &mtdFlashDisk[1];
+#endif // NOR_BOOTING_NOR_DISK_NUM > 1
+#endif // __NOR_SUPPORT_RAW_DISK__
+
+#ifdef __FOTA_DM__
+ FlashDriveData.FlashInfo.baseUnlockBlock = INVALID_BLOCK_INDEX;
+ FlashDriveData.FlashInfo.endUnlockBlock = INVALID_BLOCK_INDEX;
+#endif
+
+
+#ifdef __BASIC_LOAD_FLASH_TEST__
+#ifdef __INTEL_SIBLEY__
+ LocateSector_ext = SIB_LocateSector;
+#else
+ LocateSector_ext = LocateSector;
+#endif //__INTEL_SIBLEY__
+#endif //__BASIC_LOAD_FLASH_TEST__
+
+
+#endif /* !__FS_SYSDRV_ON_NAND__ && _NOR_FLASH_BOOTING_ */
+
+ #if ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+ {
+ kal_uint32 DiskIndex;
+
+ for (DiskIndex=0; DiskIndex<NAND_DISK_NUM; DiskIndex++)
+ {
+ #if (defined(__UBL__)&&defined(__NAND_SUPPORT_RAW_DISK__))
+ if(DiskIndex==RAW_DISK_INDEX){
+ NANDFlashDriveData[0].NAND_FDMData.DiskIndex = RAW_DISK_INDEX;
+ }
+ #else
+ NANDFlashDriveData[DiskIndex].NAND_FDMData.DiskIndex = DiskIndex;
+ #endif
+ switch (DiskIndex)
+ {
+ case 0:
+ NFB_BASE_ADDRESS[0] = NAND_BOOTING_NAND_FS_DISK0_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[0] = NAND_BOOTING_NAND_FS_DISK0_SIZE;
+ FS_DISK_REPLACE_RATIO[0] = NAND_BOOTING_NAND_FS_DISK0_REPLACE_RATIO;
+ break;
+ #if (NAND_DISK_NUM > 1)
+ case 1:
+ NFB_BASE_ADDRESS[1] = NAND_BOOTING_NAND_FS_DISK1_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[1] = NAND_BOOTING_NAND_FS_DISK1_SIZE;
+ FS_DISK_REPLACE_RATIO[1] = NAND_BOOTING_NAND_FS_DISK1_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 1 */
+ #if (NAND_DISK_NUM > 2)
+ case 2:
+ NFB_BASE_ADDRESS[2] = NAND_BOOTING_NAND_FS_DISK2_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[2] = NAND_BOOTING_NAND_FS_DISK2_SIZE;
+ FS_DISK_REPLACE_RATIO[2] = NAND_BOOTING_NAND_FS_DISK2_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 2 */
+ #if (NAND_DISK_NUM > 3)
+ case 3:
+ NFB_BASE_ADDRESS[3] = NAND_BOOTING_NAND_FS_DISK3_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[3] = NAND_BOOTING_NAND_FS_DISK3_SIZE;
+ FS_DISK_REPLACE_RATIO[3] = NAND_BOOTING_NAND_FS_DISK3_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 3 */
+ #if (NAND_DISK_NUM > 4)
+ case 4:
+ NFB_BASE_ADDRESS[4] = NAND_BOOTING_NAND_FS_DISK4_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[4] = NAND_BOOTING_NAND_FS_DISK4_SIZE;
+ FS_DISK_REPLACE_RATIO[4] = NAND_BOOTING_NAND_FS_DISK4_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 4 */
+ #if (NAND_DISK_NUM > 5)
+ case 5:
+ NFB_BASE_ADDRESS[5] = NAND_BOOTING_NAND_FS_DISK5_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[5] = NAND_BOOTING_NAND_FS_DISK5_SIZE;
+ FS_DISK_REPLACE_RATIO[5] = NAND_BOOTING_NAND_FS_DISK5_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 5 */
+ #if (NAND_DISK_NUM > 6)
+ case 6:
+ NFB_BASE_ADDRESS[6] = NAND_BOOTING_NAND_FS_DISK6_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[6] = NAND_BOOTING_NAND_FS_DISK6_SIZE;
+ FS_DISK_REPLACE_RATIO[6] = NAND_BOOTING_NAND_FS_DISK6_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 6 */
+ #if (NAND_DISK_NUM > 7)
+ case 7:
+ NFB_BASE_ADDRESS[7] = NAND_BOOTING_NAND_FS_DISK7_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[7] = NAND_BOOTING_NAND_FS_DISK7_SIZE;
+ FS_DISK_REPLACE_RATIO[7] = NAND_BOOTING_NAND_FS_DISK7_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 7 */
+ }
+ }
+ }
+ #if ( defined(__NANDFDM_TOTAL_BBM__))
+ NFB_REPLACE_BASE_ADDRESS = NAND_BOOTING_NAND_FS_REPLACE_BASE_ADDRESS;
+ NFB_REPLACE_SPACE = NAND_BOOTING_NAND_FS_REPLACE_SIZE;
+ NAND_BRMT_Info.ParameterReady = KAL_FALSE;
+ NAND_BRMT_Info.NoReplace = KAL_FALSE;
+ NAND_BRMT_Info.BRMT_Addr = 0;
+ NAND_BRMT_Info.CurSectorInRAM = 0xff;
+ #endif
+
+ #endif // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+}
+#endif /*__NOR_FDM5__*/
+#endif /* !(__COMBO_MEMORY_SUPPORT__) && !(__SERIAL_FLASH__) */
+
+void nor_sweep_device(void)
+{
+#ifdef __NOR_FDM5__
+ kal_set_eg_events(nor_egid, NOR_DMAN_EVENT, KAL_OR);
+#endif
+ return;
+}
+
+void nor_manual_reclaim(void)
+{
+#ifdef __NOR_FDM5__
+ kal_set_eg_events(nor_egid, NOR_BRECL_EVENT, KAL_OR);
+#endif
+ return;
+}
+
+/*************************************************************************
+* FUNCTION
+* custom_get_fat_addr()
+*
+* DESCRIPTION
+* This function gets the start address of FAT.
+*
+* PARAMETERS
+* none
+*
+* RETURNS
+* FAT start address
+*
+*************************************************************************/
+kal_uint32 custom_get_fat_addr()
+{
+ #if defined(__RAMDISK__)
+ return (kal_uint32)(&ram_disk);
+ #elif defined(__EMMC_BOOTING__)
+ return EMMC_CODE_PARTITION_SIZE;
+ #elif defined(_NAND_FLASH_BOOTING_)
+ return NAND_FLASH_BASE_ADDRESS;
+ #else
+ return NOR_FLASH_BASE_ADDRESS;
+ #endif /* _NAND_FLASH_BOOTING_ */
+}
+
+/*************************************************************************
+* FUNCTION
+* custom_get_fat_len()
+*
+* DESCRIPTION
+* This function gets the len of FAT.
+*
+* PARAMETERS
+* none
+*
+* RETURNS
+* FAT length
+*
+*************************************************************************/
+kal_uint32 custom_get_fat_len()
+{
+ #if defined(__RAMDISK__)
+ return RAM_FS_SIZE_INT;
+ #elif defined(__EMMC_BOOTING__)
+ return 0;
+ #elif defined(_NAND_FLASH_BOOTING_)
+ return NAND_ALLOCATED_FAT_SPACE;
+ #else
+ return NOR_ALLOCATED_FAT_SPACE;
+ #endif /* _NAND_FLASH_BOOTING_ */
+}
+#endif // __MAUI_LOAD__
+
+/*************************************************************************
+* FUNCTION
+* Custom_NAND_Init
+*
+* DESCRIPTION
+* Initialize important information for NAND-flash disk
+*
+* PARAMETERS
+*
+* RETURNS
+* None
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+#if ((defined(__UBL__)&&defined(__NAND_SUPPORT_RAW_DISK__))||(!defined(__UBL__))) && !defined(__FUE__)
+kal_bool NANDParameterInitialized = KAL_FALSE;
+void Custom_NAND_Init(void)
+{
+ #if ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+ {
+ kal_uint32 DiskIndex;
+ if(NANDParameterInitialized==KAL_TRUE){
+ return;
+ }
+ NANDParameterInitialized = KAL_TRUE;
+
+ for (DiskIndex=0; DiskIndex<NAND_DISK_NUM; DiskIndex++)
+ {
+ #if (defined(__UBL__)&&defined(__NAND_SUPPORT_RAW_DISK__))
+ if(DiskIndex==RAW_DISK_INDEX){
+ NANDFlashDriveData[0].NAND_FDMData.DiskIndex = RAW_DISK_INDEX;
+ }
+ #else
+ NANDFlashDriveData[DiskIndex].NAND_FDMData.DiskIndex = DiskIndex;
+ #endif
+ switch (DiskIndex)
+ {
+ case 0:
+ NFB_BASE_ADDRESS[0] = NAND_BOOTING_NAND_FS_DISK0_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[0] = NAND_BOOTING_NAND_FS_DISK0_SIZE;
+ FS_DISK_REPLACE_RATIO[0] = NAND_BOOTING_NAND_FS_DISK0_REPLACE_RATIO;
+ break;
+ #if (NAND_DISK_NUM > 1)
+ case 1:
+ NFB_BASE_ADDRESS[1] = NAND_BOOTING_NAND_FS_DISK1_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[1] = NAND_BOOTING_NAND_FS_DISK1_SIZE;
+ FS_DISK_REPLACE_RATIO[1] = NAND_BOOTING_NAND_FS_DISK1_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 1 */
+ #if (NAND_DISK_NUM > 2)
+ case 2:
+ NFB_BASE_ADDRESS[2] = NAND_BOOTING_NAND_FS_DISK2_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[2] = NAND_BOOTING_NAND_FS_DISK2_SIZE;
+ FS_DISK_REPLACE_RATIO[2] = NAND_BOOTING_NAND_FS_DISK2_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 2 */
+ #if (NAND_DISK_NUM > 3)
+ case 3:
+ NFB_BASE_ADDRESS[3] = NAND_BOOTING_NAND_FS_DISK3_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[3] = NAND_BOOTING_NAND_FS_DISK3_SIZE;
+ FS_DISK_REPLACE_RATIO[3] = NAND_BOOTING_NAND_FS_DISK3_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 3 */
+ #if (NAND_DISK_NUM > 4)
+ case 4:
+ NFB_BASE_ADDRESS[4] = NAND_BOOTING_NAND_FS_DISK4_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[4] = NAND_BOOTING_NAND_FS_DISK4_SIZE;
+ FS_DISK_REPLACE_RATIO[4] = NAND_BOOTING_NAND_FS_DISK4_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 4 */
+ #if (NAND_DISK_NUM > 5)
+ case 5:
+ NFB_BASE_ADDRESS[5] = NAND_BOOTING_NAND_FS_DISK5_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[5] = NAND_BOOTING_NAND_FS_DISK5_SIZE;
+ FS_DISK_REPLACE_RATIO[5] = NAND_BOOTING_NAND_FS_DISK5_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 5 */
+ #if (NAND_DISK_NUM > 6)
+ case 6:
+ NFB_BASE_ADDRESS[6] = NAND_BOOTING_NAND_FS_DISK6_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[6] = NAND_BOOTING_NAND_FS_DISK6_SIZE;
+ FS_DISK_REPLACE_RATIO[6] = NAND_BOOTING_NAND_FS_DISK6_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 6 */
+ #if (NAND_DISK_NUM > 7)
+ case 7:
+ NFB_BASE_ADDRESS[7] = NAND_BOOTING_NAND_FS_DISK7_BASE_ADDRESS;
+ NFB_ALLOCATED_FAT_SPACE[7] = NAND_BOOTING_NAND_FS_DISK7_SIZE;
+ FS_DISK_REPLACE_RATIO[7] = NAND_BOOTING_NAND_FS_DISK7_REPLACE_RATIO;
+ break;
+ #endif /* NAND_DISK_NUM > 7 */
+ }
+ }
+ }
+ #if ( defined(__NANDFDM_TOTAL_BBM__))
+ NFB_REPLACE_BASE_ADDRESS = NAND_BOOTING_NAND_FS_REPLACE_BASE_ADDRESS;
+ NFB_REPLACE_SPACE = NAND_BOOTING_NAND_FS_REPLACE_SIZE;
+ NAND_BRMT_Info.ParameterReady = KAL_FALSE;
+ NAND_BRMT_Info.NoReplace = KAL_FALSE;
+ NAND_BRMT_Info.BRMT_Addr = 0;
+ NAND_BRMT_Info.CurSectorInRAM = 0xff;
+ #endif
+
+ #endif // ( defined(__NANDFDM_MULTI_INSTANCE__) && defined(__NAND_FDM_50__) )
+}
+#endif /* (!__UBL__ && !__FUE__)|| (UBL&&RAW) */
+
+extern kal_int32 EMI_QueryIsRemapped(void);
+
+void Custom_NOR_Init(void)
+{
+#if (!(defined(__FS_SYSDRV_ON_NAND__) || defined( _NAND_FLASH_BOOTING_) || defined(__EMMC_BOOTING__))) && !defined(__RAMDISK__)
+ #if defined(__SERIAL_FLASH__)
+ CMEM_Init_FullDriver();
+ #else // (defined(__COMBO_MEMORY_SUPPORT__) || defined(__SERIAL_FLASH__))
+ EntireDiskMtdData.Signature = ~((kal_uint32)EntireDiskRegionInfo);
+ #if defined(__UBL__)
+ if(EMI_QueryIsRemapped())
+ EntireDiskMtdData.BaseAddr = (BYTE *)0x10000000;
+ else
+ EntireDiskMtdData.BaseAddr = (BYTE *)0;
+ #else
+ EntireDiskMtdData.BaseAddr = (BYTE *)INT_RetrieveFlashBaseAddr();
+ #endif
+ EntireDiskMtdData.RegionInfo = (FlashRegionInfo *)EntireDiskRegionInfo;
+ EntireDiskDriveData.DiskSize = NOR_FLASH_SIZE;
+ EntireDiskDriveData.MTDDriver = &NORFlashMtd;
+ EntireDiskDriveData.MTDData = &EntireDiskMtdData;
+ EntireDiskDriveData.is_mount = KAL_FALSE;
+ #endif // (defined(__COMBO_MEMORY_SUPPORT__) || defined(__SERIAL_FLASH__))
+#endif /* !__FS_SYSDRV_ON_NAND__ && !_NAND_FLASH_BOOTING_ */
+}
+
+#if (defined(__FUE__) || defined(__EXT_BOOTLOADER__)) && defined(__FOTA_DM__)
+#if defined(__SERIAL_FLASH__)
+
+void Initialize_NOR_Info(void)
+{
+ CMEM_Init_FUE();
+}
+
+
+#else //!__COMBO_MEMORY_SUPPORT__ && !__SERIAL_FLASH__
+
+#include "custom_fota.h"
+
+NOR_Flash_MTD_Data fue_nor_mtdflash;
+
+extern NOR_MTD_Driver NORFlashMtd;
+
+NOR_FLASH_DRV_Data FlashDriveData;
+
+void Initialize_NOR_Info(void)
+{
+#if defined(_NOR_FLASH_BOOTING_)
+ kal_uint32 blk_addr = 0;
+
+ /* Initialize MTD data table */
+ fue_nor_mtdflash.Signature = ~((kal_uint32)NORRegionInfo);
+
+ #if !defined(__UBL__)
+ FlashDriveData.MTDDriver = &NORFlashMtd;
+ #endif /* __UBL__ */
+ FlashDriveData.MTDData = &fue_nor_mtdflash;
+
+#ifdef __MTK_TARGET__
+ #if defined(MT6238) || defined(MT6239) || defined(MT6235B)
+ fue_nor_mtdflash.BaseAddr = (BYTE *)(custom_get_NORFLASH_Base()|0x08000000);
+ #elif defined(MT6228) || defined(MT6229) || defined(MT6230) || defined(MT6225) || defined(MT6268T)
+ fue_nor_mtdflash.BaseAddr = (BYTE *)(custom_get_NORFLASH_Base()|0x04000000);
+ #else
+ fue_nor_mtdflash.BaseAddr = (BYTE *)custom_get_NORFLASH_Base();
+ #endif
+#endif /* __MTK_TARGET__ */
+
+ fue_nor_mtdflash.RegionInfo = (FlashRegionInfo *)NORRegionInfo;
+
+#ifdef __FOTA_DM__
+ blk_addr = SSF_GetUAImageLoadAddress()|custom_get_NORFLASH_Base();
+ #if defined(MT6238) || defined(MT6239) || defined(MT6235B)
+ blk_addr |= 0x08000000;
+ #elif defined(MT6228) || defined(MT6229) || defined(MT6230) || defined(MT6225) || defined(MT6268T)
+ blk_addr |= 0x04000000;
+ #else
+ blk_addr |= 0x0;
+ #endif
+ blk_addr -= (kal_uint32)fue_nor_mtdflash.BaseAddr;
+ FlashDriveData.FlashInfo.baseUnlockBlock = BlockIndex(&fue_nor_mtdflash, blk_addr);
+
+ #if (defined(__UP_PKG_ON_NAND__) && defined(NAND_SUPPORT))
+ blk_addr = (custom_get_NORFLASH_ROMSpace() - 1) | custom_get_NORFLASH_Base();
+ #else
+ blk_addr = FOTA_GetPackageStorageBase()+FOTA_GetPackageStorageSize();
+ #endif /* __UP_PKG_ON_NAND__ && NAND_SUPPORT */
+
+ #if defined(MT6238) || defined(MT6239) || defined(MT6235B)
+ blk_addr |= 0x08000000;
+ #elif defined(MT6228) || defined(MT6229) || defined(MT6230) || defined(MT6225) || defined(MT6268T)
+ blk_addr |= 0x04000000;
+ #else
+ blk_addr |= 0x0;
+ #endif
+
+ blk_addr -= (kal_uint32)fue_nor_mtdflash.BaseAddr;
+ FlashDriveData.FlashInfo.endUnlockBlock = BlockIndex(&fue_nor_mtdflash, blk_addr);
+#endif
+
+#endif // _NOR_FLASH_BOOTING_
+}
+
+#endif //__COMBO_MEMORY_SUPPORT__ || __SERIAL_FLASH__
+#endif /* (__FUE__ || __EXT_BOOTLOADER__) && __FOTA_DM__ */
+
+
+
+
+
+/*************************************************************************
+* FUNCTION
+* custom_get_FLASH_Size()
+*
+* DESCRIPTION
+* Query the of space configured for ROM
+*
+* PARAMETERS
+*
+* RETURNS
+* BASE ADDRESS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+kal_uint32 custom_get_FLASH_Size(void)
+{
+#if defined(__RAMDISK__)
+ return RAM_FS_SIZE_INT;
+#elif defined(__EMMC_BOOTING__)
+ return 0;
+#elif defined(_NAND_FLASH_BOOTING_)
+ return NAND_TOTAL_SIZE << 20;
+#else
+ return NOR_FLASH_SIZE;
+#endif
+}
+
+#if defined(__RAMDISK__)
+#include "ramdisk_gprot.h" // for RAM Disk FDM APIs
+kal_uint32 RAMDiskDriveData;
+FS_Driver RAMDiskDriver =
+{
+ ramdisk_fdm_mount_device,
+ ramdisk_fdm_shutdown,
+ ramdisk_fdm_read_sectors,
+ ramdisk_fdm_write_sectors,
+ ramdisk_fdm_media_changed,
+ NULL,
+ ramdisk_fdm_get_disk_geometry,
+ NULL,
+ NULL,
+ ramdisk_fdm_recoverable_write_sectors,
+ ramdisk_fdm_resume_sector_states,
+ NULL,
+ NULL, /*flush data*/
+ NULL, /*message ack*/
+ NULL, /*copy sector*/
+ NULL,
+ NULL
+};
+#endif // __RAMDISK__
+#else // __SMART_PHONE_PLATFORM__ && __SMART_PHONE_MODEM__
+void Initialize_FDD_tables(void)
+{
+ return;
+}
+
+kal_uint32 custom_get_fat_addr()
+{
+ return 0;
+}
+
+kal_uint32 custom_get_fat_len()
+{
+ return 0;
+}
+
+
+/*************************************************************************
+* FUNCTION
+* custom_get_NORFLASH_Base()
+*
+* DESCRIPTION
+* Query the of space configured for NORFLASH ROM
+*
+* PARAMETERS
+*
+* RETURNS
+* BASE ADDRESS
+*
+* GLOBALS AFFECTED
+*
+*************************************************************************/
+kal_uint32 custom_get_NORFLASH_Base(void)
+{
+#if defined(_NAND_FLASH_BOOTING_) || defined(__EMMC_BOOTING__)
+ return 0;
+#else
+ return NOR_FLASH_BASE_ADDR;
+#endif
+}
+
+
+#endif //!__SMART_PHONE_PLATFORM__ || !__SMART_PHONE_MODEM__
+
+
+
+/*************************************************************************
+* FUNCTION
+* INT_QueryIsROMSpace()
+*
+* DESCRIPTION
+* Query the address in Flash address space or not
+*
+* PARAMETERS
+* address to check
+*
+* RETURNS
+* KAL_TRUE if address is in Flash address space
+* KAL_FALSE if not
+*
+* Only apply to ADMUX MT6255 for DMA to check whether the address to be copied in flash or not.
+* To avoid DMA accessing Single bank flash when it is busy.
+*
+*************************************************************************/
+
+kal_bool INT_QueryIsROMSpace(kal_uint32 addr)
+{
+ return KAL_FALSE;
+}
+
diff --git a/mcu/custom/driver/common/custom_flash_norfdm5.c b/mcu/custom/driver/common/custom_flash_norfdm5.c
new file mode 100644
index 0000000..1abc9e0
--- /dev/null
+++ b/mcu/custom/driver/common/custom_flash_norfdm5.c
@@ -0,0 +1,297 @@
+/*****************************************************************************
+* 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_flash_norfdm5.c
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * defines prototypes and data structure which will be used in NOR FDM 5.0
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ * Memory Device database last modified on 2011/7/8
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#include "kal_public_api.h" //MSBB change #include "kal_release.h"
+#include "fat_fs.h"
+#include "DrvFlash.h"
+#include "flash_opt.h"
+#include "custom_MemoryDevice.h"
+
+#include "custom_nvram_int_config.h" /* To get NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM for MSTABLE_ENTRY_NUM */
+
+
+#ifdef __NOR_FDM5__
+#include "custom_flash_norfdm5.h"
+
+#define STORAGE_NO_PARTITION 0xFFFFFFFF
+
+
+/*-------------------------------------------------------------------
+ * MS table size
+ *
+ * MS table size should be synchronized with user's requirement. The only one user is NVRAM.
+ *
+ * NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM defines the maximum record size in NVRAM
+ * (in custom_nvram_config.h). NVRAM should call NOR_ResumeSectorState (by FS_Commit)
+ * after it writes maximum NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM sectors with protection
+ * mode to ensure the integrity of a record.
+ *
+ * MSTABLE_ENTRY_NUM number is based on the worst senario: All FAT entries of clusters
+ * of logical sectors are located in different physical sectors. In other word, we need
+ * to write additional N sectors to update FAT after we write N data sectors. The other
+ * 1 sector is for directory entry update.
+ *
+ * TODO: Use auto-gen to compute most suitable MS table size. Because the number of
+ * sectors for FAT may be smaller than NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM. For example,
+ * 64KB disk only needs 1 sector to store FAT.
+ *---------------------------------------------------------- W08.50 --*/
+
+#define MS_TABLE_ENTRY_NUM (NVRAM_CUSTOM_CFG_MAX_RECORD_SECTOR_NUM * 2 + 1)
+
+
+/*****************************************
+ * Don't modify any code above this line *
+ *****************************************/
+
+/*******************************************************************************
+ Follow the 4 steps below to configure flash memory
+
+ Step 1. Fill the flash bank (partition) information table,
+ flash device features flexible, multi-bank read-while-program and
+ read-while-erase capability, enabling background programming or erasing in
+ one bank simultaneously with code execution or data reads in another bank.
+ Each element in the table is the format as below:
+ {bank size, bank number},
+
+ Step 2. Modify the value of LSMT, you can see MemoryDevice_FlashDisk_FAQ for
+ detail information
+
+ Step 2. Define the toal sectors (512bytes) of system drive
+ the remainder is the size of public drive
+ If there is no partiton (just one drive, system drive)
+ set this value to STORAGE_NO_PARTITION (0xFFFFFFFF)
+
+
+ Note : Code region and FAT region can not share the same bank (partition)
+*******************************************************************************/
+
+
+/***********
+ * Step 1. *
+ ***********/
+static NORBankInfo BankInfo[] =
+{
+ NOR_FDM5_BANK_INFO_LAYOUT
+ EndBankInfo /* Don't modify this line */
+};
+
+
+/*****************************************
+ * Don't modify any code below this line *
+ *****************************************/
+
+#define NOR_TOTAL_BLOCKS (NOR_ALLOCATED_FAT_SPACE/NOR_BLOCK_SIZE)
+#define NOR_TOTAL_TABLE_BLOCKS 32
+NOR_FTL_DATA FlashDriveData;
+static NORLayoutInfo LayoutInfo;
+
+static kal_uint32 LogPageID[MS_TABLE_ENTRY_NUM];
+static WORD NewEntryID[MS_TABLE_ENTRY_NUM];
+static WORD OldEntryID[MS_TABLE_ENTRY_NUM];
+
+#ifndef __INTEL_SIBLEY__
+
+#define NOR_PAGE_SIZE 512
+
+FS_Driver NORFlashDriver = {
+ nNOR_MountDevice,
+ nShutDown,
+ nNOR_ReadSectors,
+ nNOR_WriteSectors,
+ NOR_MediaChanged,
+ nNOR_DiscardSectors,
+ nGetDiskGeometry,
+ nNOR_LowLevelFormat,
+ nNOR_NonBlockWriteSectors,
+ nNOR_RecoverableWriteSectors,
+ nNOR_ResumeSectorStates,
+ NULL, /*high level format*/
+ NULL, /*flush data*/
+ NULL /*message ack*/
+#ifdef __SECURITY_OTP__
+ ,
+ NULL, /*copy sector*/
+ OTPAccess,
+ OTPQueryLength
+#endif
+};
+
+#else
+
+#define NOR_PAGE_SIZE 1024
+
+FS_Driver NORFlashDriver = {
+ nSIB_MountDevice,
+ nShutDown,
+ nSIB_ReadSectors,
+ nSIB_WriteSectors,
+ NOR_MediaChanged,
+ nSIB_DiscardSectors,
+ nGetDiskGeometry,
+ nSIB_LowLevelFormat,
+ nSIB_NonBlockWriteSectors,
+ nSIB_RecoverableWriteSectors,
+ nSIB_ResumeSectorStates,
+ NULL, /*high level format*/
+ NULL, /*flush data*/
+ NULL /*message ack*/
+#ifdef __SECURITY_OTP__
+ ,
+ NULL, /*copy sector*/
+ OTPAccess,
+ OTPQueryLength
+#endif
+};
+#endif /*__INTEL_SIBLEY__*/
+
+
+static kal_uint16 NOR_LBM[NOR_TOTAL_BLOCKS];
+static LSMGEntry NOR_LSMG[NOR_TOTAL_LSMT]; // need to check in the program
+static kal_uint16 NOR_AvailInBlk[NOR_TOTAL_BLOCKS];
+static kal_uint16 NOR_InvaildInBlk[NOR_TOTAL_BLOCKS];
+static kal_uint32 NOR_InvalidEntryInTblBlk[NOR_TOTAL_TABLE_BLOCKS];
+static kal_uint8 FDMBuffer[NOR_PAGE_SIZE];
+static kal_uint8 CopyBuffer[NOR_PAGE_SIZE];
+static NOR_MTD_DATA mtdflash;
+kal_eventgrpid nor_egid = NULL;
+
+extern NOR_MTD_Driver NORFlashMtd;
+extern kal_uint32 INT_RetrieveFlashBaseAddr(void);
+
+void Initialize_FDD_tables(void)
+{
+#if ( !defined(__FS_SYSDRV_ON_NAND__) && !defined( _NAND_FLASH_BOOTING_) )
+ /* Initialize MTD data table */
+ mtdflash.Signature = ~((kal_uint32)&LayoutInfo);
+
+#ifdef __MTK_TARGET__
+ mtdflash.BaseAddr = (BYTE *)(INT_RetrieveFlashBaseAddr() + NOR_FLASH_BASE_ADDRESS);
+#endif
+ LayoutInfo.BankInfo = BankInfo;
+ LayoutInfo.TotalBlks = NOR_TOTAL_BLOCKS;
+ LayoutInfo.BlkSize = NOR_BLOCK_SIZE;
+ LayoutInfo.PageSize = NOR_PAGE_SIZE;
+ LayoutInfo.TotalLSMT= NOR_TOTAL_LSMT;
+ mtdflash.LayoutInfo = (NORLayoutInfo *)&LayoutInfo;
+
+ /* Initialize FDD data table */
+ FlashDriveData.MTDDriver = &NORFlashMtd;
+ FlashDriveData.MTDData = &mtdflash;
+ FlashDriveData.LBM = NOR_LBM;
+ FlashDriveData.LSMG = NOR_LSMG;
+ FlashDriveData.AvailInBlk = NOR_AvailInBlk;
+ FlashDriveData.InvalidInBlk = NOR_InvaildInBlk;
+ FlashDriveData.InvalidEntryInTblBlk = NOR_InvalidEntryInTblBlk;
+
+ FlashDriveData.MSTABLE_ENTRY_NUM = MS_TABLE_ENTRY_NUM;
+ FlashDriveData.MSTable.LogPageID = LogPageID;
+ FlashDriveData.MSTable.NewEntryID = NewEntryID;
+ FlashDriveData.MSTable.OldEntryID = OldEntryID;
+
+#if (NOR_SYSDRV_SECTORS==0)
+ #if (NOR_PARTITION_SECTORS==0)
+ FlashDriveData.SecondPartitionSectors = 0xffffffff;
+ #else // (NOR_PARTITION_SECTORS==0)
+ FlashDriveData.SecondPartitionSectors = 0xfe000000 | NOR_PARTITION_SECTORS;
+ #endif // (NOR_PARTITION_SECTORS==0)
+#else // (NOR_SYSDRV_SECTORS==0)
+ FlashDriveData.SecondPartitionSectors = NOR_SYSDRV_SECTORS;
+#endif // (NOR_SYSDRV_SECTORS==0)
+
+ FlashDriveData.SetTblBlks = NOR_TOTAL_TABLE_BLOCKS;
+ FlashDriveData.Buffer = FDMBuffer;
+ FlashDriveData.CopyBuffer = CopyBuffer;
+#ifndef __INTEL_SIBLEY__
+ FlashDriveData.ReclaimBlock = nNOR_ReclaimBlock;
+#else
+ FlashDriveData.ReclaimBlock = nSIB_ReclaimBlock;
+#endif /* __INTEL_SIBLEY__ */
+#endif /* !__FS_SYSDRV_ON_NAND__ && !_NAND_FLASH_BOOTING_ */
+}
+
+#endif /*__NOR_FDM5__*/
diff --git a/mcu/custom/driver/common/custom_ostd_utility.c b/mcu/custom/driver/common/custom_ostd_utility.c
new file mode 100644
index 0000000..73a38dc
--- /dev/null
+++ b/mcu/custom/driver/common/custom_ostd_utility.c
@@ -0,0 +1,136 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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_ostd_utility.h
+ *
+ * Project:
+ * --------
+ * MT6885
+ *
+ * Description:
+ * ------------
+ * This file contains ostd customized configuration.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *******************************************************************************/
+#include "kal_general_types.h"
+#include "ostd_public.h"
+#ifdef __NVRAM_LID_CACHE__
+#include "nvram_cache_interface.h"
+#endif
+#include "string.h"
+
+/*
+void example_callback(kal_uint32 ap_status)
+{
+ //use ap_status to determine your code flow;
+ return;
+}
+*/
+#ifdef __NVRAM_LID_CACHE__
+/*****************************************************************************
+ * FUNCTION
+ * send_event_to_nvcache_callback
+ * DESCRIPTION
+ * ostd send event to NVRAM cache for update AP status
+ * PARAMETERS
+ * ap_status [IN]
+ * RETURNS
+ * void
+ *****************************************************************************/
+void send_event_to_nvcache_callback(kal_uint32 ap_status)
+{
+ send_event_to_nvram_cache();
+}
+#endif
+ostd_urc_src_module_info_struct src_module_info[] =
+{
+ /*
+ {"Name", "module_id expecting receive ilm"(if no need to receive, fill MOD_NIL), "callback funtion"(if no need, fill NULL), "pending data flag"(default = KAL_FALSE)}
+ example:
+ {"OSTD", MOD_NIL, example_callback, KAL_FALE}
+ */
+ {"L4C", MOD_L4C, NULL, KAL_FALSE},
+ {"L4", MOD_L4BPWR, NULL, KAL_FALSE},
+ #ifdef __NVRAM_LID_CACHE__
+ {"NVRAM", MOD_NIL, send_event_to_nvcache_callback, KAL_FALSE},
+ #endif
+};
+
+ostd_urc_src_module_info_struct *custom_get_urc_src_mod()
+{
+ return src_module_info;
+}
+
+kal_uint8 custom_get_num_of_urc_src_mod()
+{
+ return sizeof(src_module_info)/sizeof(src_module_info[0]);
+}
+
+void set_pending_data_flag(char* module_name, kal_bool flag)
+{
+ kal_uint8 i, total_mod;
+ total_mod = sizeof(src_module_info)/sizeof(src_module_info[0]);
+ for(i=0; i<total_mod; i++)
+ {
+ if(strcmp(src_module_info[i].module_name, module_name) == 0)
+ {
+ src_module_info[i].pending_urc = flag;
+ break;
+ }
+ }
+}
+
+kal_bool unmask_ap2md_apmcu_active_wkup_event()
+{
+ kal_uint8 i, total_mod;
+ total_mod = sizeof(src_module_info)/sizeof(src_module_info[0]);
+ for(i=0; i<total_mod; i++)
+ {
+ if(src_module_info[i].pending_urc == KAL_TRUE)
+ {
+ return KAL_TRUE;
+ }
+ }
+ return KAL_FALSE;
+}
+
diff --git a/mcu/custom/driver/common/flash_opt.h b/mcu/custom/driver/common/flash_opt.h
new file mode 100644
index 0000000..f9253b9
--- /dev/null
+++ b/mcu/custom/driver/common/flash_opt.h
@@ -0,0 +1,603 @@
+/*****************************************************************************
+* 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:
+ * ---------
+ * flash_opt.h
+ *
+ * Project:
+ * --------
+ * Maui_Software
+ *
+ * Description:
+ * ------------
+ * NOR flash related options
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ * Memory Device database last modified on 2011/7/8
+ *
+ *============================================================================
+ * HISTORY
+ * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *------------------------------------------------------------------------------
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ * removed!
+ *
+ * removed!
+ * removed!
+ * removed!
+ *
+ *------------------------------------------------------------------------------
+ * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
+ *============================================================================
+ ****************************************************************************/
+
+#include "custom_MemoryDevice.h"
+#include "custom_FeatureConfig.h"
+#include "flash_opt_gen.h"
+#if defined(__SECURE_DATA_STORAGE__)
+#include "custom_secure_config.h"
+#endif
+
+/*
+ *******************************************************************************
+ PART 1:
+ FLASH CONFIG Options Definition here
+ *******************************************************************************
+*/
+
+/*
+ * RAM Disk is enabled and replaces any other flash-type (e.g., NOR or NAND) disk on smartphone moden-only load
+ * NOTE. __SMART_PHONE_PLATFORM__ should be defined before (e.g., defined in flash_opt_gen.h)
+ */
+#if !(defined(__FUE__) || defined(__UBL__) || defined(__EXT_BOOTLOADER__)) // RAM Disk module is not necessary in Bootloader and FUE environment
+ #if defined(__FS_RAMDISK__)
+ #if !defined(__SMART_PHONE_PLATFORM__)
+ #error "RAM Disk is allowed in SP modem-only project only! Please make sure __SMART_PHONE_PLATFORM__ is defined before!"
+ #endif
+ #define __RAMDISK__
+ #endif
+#endif
+
+/*
+ *******************************************************************************
+ PART 2:
+ FLASH FDM FEATURE CONFIG PARAMETERS translated from Manual custom_Memorydevice.h
+ *******************************************************************************
+*/
+ #ifndef NOR_PARAMETER_SYSTEM_DRIVE_RESERVED_BLOCK
+ #define NOR_SYSTEM_DRIVE_RESERVED_BLOCK (3)
+ #else
+ #define NOR_SYSTEM_DRIVE_RESERVED_BLOCK (NOR_PARAMETER_SYSTEM_DRIVE_RESERVED_BLOCK)
+ #endif
+
+
+
+/*
+ *******************************************************************************
+ PART 3:
+ FLASH GEOMETRY translated from MEMORY DEVICE DATABASE
+ *******************************************************************************
+*/
+
+
+/*
+ *******************************************************************************
+ PART 4:
+ FLASH FAT CONFIG translated from Manual custom_Memorydevice.h
+ *******************************************************************************
+*/
+#if defined(__NANDFDM_MULTI_INSTANCE__)
+#define NAND_DISK_NUM (NAND_BOOTING_NAND_FS_DISK_NUMBER)
+#else // defined(__NANDFDM_MULTI_INSTANCE__)
+#define NAND_DISK_NUM (0)
+#endif // defined(__NANDFDM_MULTI_INSTANCE__)
+#if defined(__RAMDISK__)
+ #include "ramdisk_gprot.h"
+ #ifndef RAM_FS_SIZE
+ #error "Error! Please assign RAM_FS_SIZE in ramdisk_gprot.h for RAM Disk!"
+ #else
+ #define RAM_FS_SIZE_INT (RAM_FS_SIZE)
+ #endif
+ #ifdef RAM_FS_FIRST_DRIVE_SECTORS
+ #define RAM_FS_FIRST_DRIVE_SECTORS_INT (RAM_FS_FIRST_DRIVE_SECTORS)
+ #else
+ #define RAM_FS_FIRST_DRIVE_SECTORS_INT (0)
+ #endif
+#endif // defined(__NANDFDM_MULTI_INSTANCE__)
+
+#if defined(__EMMC_BOOTING__)
+
+ #ifndef EMMC_BOOTING_GP1_PARTITION_SIZE
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Please Manually Assign EMMC_BOOTING_GP1_PARTITION_SIZE in custom_Memorydevice.h for EMMC Booting!"
+ #else
+ #define EMMC_CODE_PARTITION_SIZE (EMMC_BOOTING_GP1_PARTITION_SIZE)
+ #endif /* !EMMC_BOOTING_GP1_PARTITION_SIZE */
+
+ #ifndef EMMC_BOOTING_UP_FS_BASE_ADDRESS
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Please Manually Assign EMMC_BOOTING_UP_FS_BASE_ADDRESS in custom_Memorydevice.h for EMMC Booting!"
+ #else
+ #define EMMC_FS_BASE_ADDRESS (EMMC_BOOTING_UP_FS_BASE_ADDRESS)
+ #endif /* !EMMC_BOOTING_UP_FS_BASE_ADDRESS */
+
+ #ifndef EMMC_BOOTING_UP_FS_SIZE
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Please Manually Assign EMMC_BOOTING_UP_FS_SIZE in custom_Memorydevice.h for EMMC Booting!"
+ #else
+ #define EMMC_FS_SIZE (EMMC_BOOTING_UP_FS_SIZE)
+ #endif /* !EMMC_BOOTING_UP_FS_SIZE */
+
+ #ifndef EMMC_BOOTING_UP_FS_SYSTEM_DRIVE_SIZE
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Please Manually Assign EMMC_BOOTING_UP_FS_SYSTEM_DRIVE_SIZE in custom_Memorydevice.h for EMMC Booting!"
+ #else
+ #define EMMC_FS_SYSTEM_DRIVE_SIZE (EMMC_BOOTING_UP_FS_SYSTEM_DRIVE_SIZE)
+ #endif /* !EMMC_BOOTING_UP_FS_SYSTEM_DRIVE_SIZE */
+
+#elif defined(_NAND_FLASH_BOOTING_)
+
+
+ /*-----------------------------------------------------------------------------------------
+ * FS base address is automatically adjusted with update package storage size as
+ * NAND_BOOTING_NAND_FS_BASE_ADDRESS + FOTA_PACKAGE_STORAGE_SIZE (defined in custom_img_config.h)
+ *-----------------------------------------------------------------------------------------*/
+
+ #ifndef NAND_BOOTING_NAND_FS_BASE_ADDRESS
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Please Manually Assign NAND_BOOTING_NAND_FS_BASE_ADDRESS in custom_Memorydevice.h for NAND-Flash Booting!"
+ #else
+ #define NAND_FLASH_BASE_ADDRESS (NAND_BOOTING_NAND_FS_BASE_ADDRESS + FOTA_DM_FS_OFFSET)
+ #endif /* !NAND_BOOTING_FLASH_BASE_ADDRESS */
+
+ /*-----------------------------------------------------------------------------------------
+ * FS size is automatically decreased by update package storage size as
+ * NAND_BOOTING_NAND_FS_SIZE - FOTA_PACKAGE_STORAGE_SIZE (defined in custom_img_config.h)
+ *-----------------------------------------------------------------------------------------*/
+
+ #ifndef NAND_BOOTING_NAND_FS_SIZE
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Please Manually Assign NAND_BOOTING_NAND_FS_SIZE in custom_Memorydevice.h for NAND-Flash Booting!"
+ #else
+ #if defined(__SECURE_DATA_STORAGE__)
+ #define NAND_ALLOCATED_FAT_SPACE (NAND_BOOTING_NAND_FS_SIZE - FOTA_DM_FS_OFFSET - SDS_TOTAL_SIZE)
+ #else
+ #define NAND_ALLOCATED_FAT_SPACE (NAND_BOOTING_NAND_FS_SIZE - FOTA_DM_FS_OFFSET)
+ #endif
+ #endif /* !NAND_BOOTING_ALLOCATED_FAT_SPACE */
+
+ /*-----------------------------------------------------------------------------------------
+ * FS first drive size is automatically decreased by update package storage size as
+ * NAND_BOOTING_NAND_FS_FIRST_DRIVE_SECTORS - FOTA_PACKAGE_STORAGE_SIZE / 512 (defined in custom_img_config.h)
+ *-----------------------------------------------------------------------------------------*/
+
+ #ifndef NAND_BOOTING_NAND_FS_FIRST_DRIVE_SECTORS
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Please Manually Assign NAND_BOOTING_NAND_FS_FIRST_DRIVE_SECTORS in custom_Memorydevice.h for NAND-Flash Booting!"
+ #else
+ #if defined(__NANDFDM_MULTI_INSTANCE__)
+ #define NAND_PARTITION_SECTORS (0)
+ #else /* __NANDFDM_MULTI_INSTANCE__ */
+ #define NAND_PARTITION_SECTORS (NAND_BOOTING_NAND_FS_FIRST_DRIVE_SECTORS - FOTA_DM_FS_SECTOR_OFFSET)
+ #endif /* __NANDFDM_MULTI_INSTANCE__ */
+ #endif /* !NAND_FAT_PARTITION_SECTORS */
+
+
+#elif defined(__FS_SYSDRV_ON_NAND__ )
+
+ #define NOR_FLASH_BASE_ADDRESS (NOR_FLASH_BASE_ADDRESS_DEFAULT)
+ #define NOR_ALLOCATED_FAT_SPACE (NOR_ALLOCATED_FAT_SPACE_DEFAULT)
+
+ /*-----------------------------------------------------------------------------------------
+ * FS base address is automatically adjusted with update package storage size as
+ * NOR_BOOTING_NAND_FS_BASE_ADDRESS + FOTA_PACKAGE_STORAGE_SIZE (defined in custom_img_config.h)
+ *-----------------------------------------------------------------------------------------*/
+
+ #ifndef NOR_BOOTING_NAND_FS_BASE_ADDRESS
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Please Manually Assign NOR_BOOTING_NAND_FS_BASE_ADDRESS in custom_Memorydevice.h for System Drive on NAND!"
+ #else
+ #define NAND_FLASH_BASE_ADDRESS (NOR_BOOTING_NAND_FS_BASE_ADDRESS + FOTA_DM_FS_OFFSET)
+ #endif /* !NAND_BOOTING_FLASH_BASE_ADDRESS */
+
+ /*-----------------------------------------------------------------------------------------
+ * FS size is automatically decreased by update package storage size as
+ * NOR_BOOTING_NAND_FS_SIZE - FOTA_PACKAGE_STORAGE_SIZE (defined in custom_img_config.h)
+ *-----------------------------------------------------------------------------------------*/
+
+ #ifndef NOR_BOOTING_NAND_FS_SIZE
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Please Manually Assign NOR_BOOTING_NAND_FS_SIZE in custom_Memorydevice.h for System Drive on NAND!"
+ #else
+ #define NAND_ALLOCATED_FAT_SPACE (NOR_BOOTING_NAND_FS_SIZE - FOTA_DM_FS_OFFSET)
+ #endif /* !NAND_BOOTING_ALLOCATED_FAT_SPACE */
+
+ /*-----------------------------------------------------------------------------------------
+ * FS first drive size is automatically decreased by update package storage size as
+ * NOR_BOOTING_NAND_FS_FIRST_DRIVE_SECTORS - FOTA_PACKAGE_STORAGE_SIZE / 512 (defined in custom_img_config.h)
+ *-----------------------------------------------------------------------------------------*/
+
+ #ifndef NOR_BOOTING_NAND_FS_FIRST_DRIVE_SECTORS
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Please Manually Assign NOR_BOOTING_NAND_FS_FIRST_DRIVE_SECTORS in custom_Memorydevice.h for System Drive on NAND!"
+ #else
+ #if defined(__NANDFDM_MULTI_INSTANCE__)
+ #define NAND_PARTITION_SECTORS (0)
+ #else /* __NANDFDM_MULTI_INSTANCE__ */
+ #define NAND_PARTITION_SECTORS (NOR_BOOTING_NAND_FS_FIRST_DRIVE_SECTORS - FOTA_DM_FS_SECTOR_OFFSET)
+ #endif /* __NANDFDM_MULTI_INSTANCE__ */
+ #endif /* !NAND_FAT_PARTITION_SECTORS */
+
+#else /* Generic NOR-XIP Case */
+
+ #if defined(__UP_PKG_ON_NAND__) && defined(NAND_SUPPORT)
+
+ #ifndef NOR_BOOTING_NOR_FS_BASE_ADDRESS
+ #define NOR_FLASH_BASE_ADDRESS (NOR_FLASH_BASE_ADDRESS_DEFAULT)
+ #else
+ #define NOR_FLASH_BASE_ADDRESS (NOR_BOOTING_NOR_FS_BASE_ADDRESS)
+ #endif /* !NOR_FLASH_BASE_ADDRESS */
+
+ #ifndef NOR_BOOTING_NOR_FS_SIZE
+ #if defined(__SECURE_DATA_STORAGE__)
+ #define NOR_ALLOCATED_FAT_SPACE (NOR_ALLOCATED_FAT_SPACE_DEFAULT - SDS_TOTAL_SIZE)
+ #else
+ #define NOR_ALLOCATED_FAT_SPACE (NOR_ALLOCATED_FAT_SPACE_DEFAULT)
+ #endif
+ #else
+ #if defined(__SECURE_DATA_STORAGE__)
+ #define NOR_ALLOCATED_FAT_SPACE (NOR_BOOTING_NOR_FS_SIZE - SDS_TOTAL_SIZE)
+ #else
+ #define NOR_ALLOCATED_FAT_SPACE (NOR_BOOTING_NOR_FS_SIZE)
+ #endif
+ #endif /* !NOR_ALLOCATED_FAT_SPACE */
+
+ #ifndef NOR_BOOTING_NOR_FS_FIRST_DRIVE_SECTORS
+ #define NOR_PARTITION_SECTORS (0)
+ #else
+ #define NOR_PARTITION_SECTORS (NOR_BOOTING_NOR_FS_FIRST_DRIVE_SECTORS)
+ #endif /* !NOR_FAT_PARTITION_SECTORS */
+
+ /*-----------------------------------------------------------------------------------------
+ * FS base address is automatically adjusted with update package storage size as
+ * NOR_BOOTING_NAND_FS_BASE_ADDRESS + FOTA_PACKAGE_STORAGE_SIZE (defined in custom_img_config.h)
+ *-----------------------------------------------------------------------------------------*/
+
+ #ifndef NOR_BOOTING_NAND_FS_BASE_ADDRESS
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Please Manually Assign NOR_BOOTING_NAND_FS_BASE_ADDRESS in custom_Memorydevice.h for FOTA Update Package on NAND!"
+ #else
+ #define NAND_FLASH_BASE_ADDRESS (NOR_BOOTING_NAND_FS_BASE_ADDRESS + FOTA_DM_FS_OFFSET)
+ #endif /* !NAND_BOOTING_FLASH_BASE_ADDRESS */
+
+ /*-----------------------------------------------------------------------------------------
+ * FS size is automatically decreased by update package storage size as
+ * NOR_BOOTING_NAND_FS_SIZE - FOTA_PACKAGE_STORAGE_SIZE (defined in custom_img_config.h)
+ *-----------------------------------------------------------------------------------------*/
+
+ #ifndef NOR_BOOTING_NAND_FS_SIZE
+ #error "custom\system\{project}\custom_MemoryDevice.h: Error! Please Manually Assign NOR_BOOTING_NAND_FS_SIZE in custom_Memorydevice.h for FOTA Update Package on NAND!"
+ #else
+ #define NAND_ALLOCATED_FAT_SPACE (NOR_BOOTING_NAND_FS_SIZE - FOTA_DM_FS_OFFSET)
+ #endif /* !NAND_BOOTING_ALLOCATED_FAT_SPACE */
+
+ /* All NAND flash space is treated as one public drive */
+ #define NAND_PARTITION_SECTORS (0)
+
+ #else /* !__UP_PKG_ON_NAND__ || !NAND_SUPPORT */
+
+ /*-----------------------------------------------------------------------------------------
+ * FS base address is automatically adjusted with update package storage size as
+ * NOR_BOOTING_NOR_FS_BASE_ADDRESS + FOTA_PACKAGE_STORAGE_SIZE (defined in custom_img_config.h)
+ *-----------------------------------------------------------------------------------------*/
+
+ #ifndef NOR_BOOTING_NOR_FS_BASE_ADDRESS
+ #define NOR_FLASH_BASE_ADDRESS (NOR_FLASH_BASE_ADDRESS_DEFAULT + FOTA_DM_FS_OFFSET)
+ #else
+ #define NOR_FLASH_BASE_ADDRESS (NOR_BOOTING_NOR_FS_BASE_ADDRESS + FOTA_DM_FS_OFFSET)
+ #endif /* !NOR_FLASH_BASE_ADDRESS */
+
+ /*-----------------------------------------------------------------------------------------
+ * FS size is automatically decreased by update package storage size as
+ * NOR_BOOTING_NOR_FS_SIZE - FOTA_PACKAGE_STORAGE_SIZE (defined in custom_img_config.h)
+ *-----------------------------------------------------------------------------------------*/
+
+ #ifndef NOR_BOOTING_NOR_FS_SIZE
+ #if defined(__SECURE_DATA_STORAGE__)
+ #define NOR_ALLOCATED_FAT_SPACE (NOR_ALLOCATED_FAT_SPACE_DEFAULT - FOTA_DM_FS_OFFSET - SDS_TOTAL_SIZE)
+ #else
+ #define NOR_ALLOCATED_FAT_SPACE (NOR_ALLOCATED_FAT_SPACE_DEFAULT - FOTA_DM_FS_OFFSET)
+ #endif
+ #else
+ #if defined(__SECURE_DATA_STORAGE__)
+ #define NOR_ALLOCATED_FAT_SPACE (NOR_BOOTING_NOR_FS_SIZE - FOTA_DM_FS_OFFSET - SDS_TOTAL_SIZE)
+ #else
+ #define NOR_ALLOCATED_FAT_SPACE (NOR_BOOTING_NOR_FS_SIZE - FOTA_DM_FS_OFFSET)
+ #endif
+ #endif /* !NOR_ALLOCATED_FAT_SPACE */
+
+ /*-----------------------------------------------------------------------------------------
+ * FS first drive size is automatically decreased by update package storage size as
+ * NOR_BOOTING_NOR_FS_FIRST_DRIVE_SECTORS - FOTA_PACKAGE_STORAGE_SIZE / 512 (defined in custom_img_config.h)
+ *-----------------------------------------------------------------------------------------*/
+
+ #ifndef NOR_BOOTING_NOR_FS_FIRST_DRIVE_SECTORS
+ #define NOR_PARTITION_SECTORS (0)
+ #else
+ #define NOR_PARTITION_SECTORS (NOR_BOOTING_NOR_FS_FIRST_DRIVE_SECTORS - FOTA_DM_FS_SECTOR_OFFSET)
+ #endif /* !NOR_FAT_PARTITION_SECTORS */
+
+ /* If NAND_SUPPORT is enabled, all NAND flash space is treated as one public drive */
+ #define NAND_PARTITION_SECTORS (0)
+
+ #endif /* __UP_PKG_ON_NAND__ && NAND_SUPPORT */
+
+
+#endif /* _NAND_FLASH_BOOTING_ || __EMMC_BOOTING__ */
+
+/*
+ * Define __PUBLIC_DRIVE_AVAILABLE__ if public drive is available.
+ * This definition will be referenced by File System. Please inform FS owner if any changes.
+ */
+#if defined(__NANDFDM_MULTI_INSTANCE__)
+ #ifndef __PUBLIC_DRIVE_AVAILABLE__
+ #define __PUBLIC_DRIVE_AVAILABLE__ // NAND FDM Multi-Instance always has public drive
+ #endif
+#endif
+
+#if defined(NOR_PARTITION_SECTORS) // NOR flash has public drive
+ #if (NOR_PARTITION_SECTORS > 0)
+ #if ((NOR_BOOTING_NOR_FS_FIRST_DRIVE_SECTORS - 0) < 21)
+ #error "custom\system\{project}\custom_MemoryDevice.h: NOR_BOOTING_NOR_FS_FIRST_DRIVE_SECTORS should be zero Or (NOR_BOOTING_NOR_FS_FIRST_DRIVE_SECTORS - 0) should be more than 20 sectors."
+ #endif
+
+ #ifndef __PUBLIC_DRIVE_AVAILABLE__
+ #define __PUBLIC_DRIVE_AVAILABLE__
+ #endif
+ #endif
+#endif
+
+#if defined(NAND_PARTITION_SECTORS) // NAND flash has public drive (including __FS_SYSDRV_ON_NAND__)
+ #if (NAND_PARTITION_SECTORS > 0)
+ #ifndef __PUBLIC_DRIVE_AVAILABLE__
+ #define __PUBLIC_DRIVE_AVAILABLE__
+ #endif
+ #endif
+#endif
+
+#if defined(__EMMC_BOOTING__) // EMMC has public drive
+ #ifndef __PUBLIC_DRIVE_AVAILABLE__
+ #define __PUBLIC_DRIVE_AVAILABLE__
+ #endif
+#endif
+
+#if !defined(_NAND_FLASH_BOOTING_) && !defined(__EMMC_BOOTING__) && !defined(__FS_SYSDRV_ON_NAND__) && defined(NAND_SUPPORT)
+ /*
+ * NOR booting / System drive on NOR / NAND flash is existed
+ * NAND_PARTITION_SECTORS is 0 but all NAND flash space is treated as one public drive
+ *
+ * Note. Please ensure NAND_SUPPORT is correctly DISABLED if NAND flash is NOT existed,
+ * otherwise __PUBLIC_DRIVE_AVAILABLE__ will be incorrectly defined but public drive is not existed!
+ */
+ #ifndef __PUBLIC_DRIVE_AVAILABLE__
+ #define __PUBLIC_DRIVE_AVAILABLE__
+ #endif
+
+ #ifndef __PUBLIC_DRIVE_2_AVAILABLE__
+ #define __PUBLIC_DRIVE_2_AVAILABLE__
+ #endif
+#endif
+
+/*
+ *******************************************************************************
+ PART 5:
+ FLASH TYPE CATEGORY below to configure flash memory command
+ *******************************************************************************
+*/
+#ifdef NOR_FLASH_TYPE_INTEL_SERIES
+#define __INTEL_SERIES_NOR__
+#endif
+
+#ifdef NOR_FLASH_TYPE_INTEL
+#define __INTEL_SERIES_NOR__
+#endif
+
+#ifdef NOR_FLASH_TYPE_RENESAS_SERIES
+#define __RENESAS_SERIES_NOR__
+#endif
+
+#ifdef NOR_FLASH_TYPE_RENESAS
+#define __RENESAS_SERIES_NOR__
+#endif
+
+#ifdef NOR_FLASH_TYPE_INTEL_SIBLEY
+#define __INTEL_SERIES_NOR__
+#define __INTEL_SIBLEY__
+
+#endif
+
+#ifdef NOR_FLASH_TYPE_SST
+#define __AMD_SERIES_NOR__
+#define __SST_NOR__
+#endif
+
+#ifdef NOR_FLASH_TYPE_ST_AMD_LIKE
+#define __AMD_SERIES_NOR__
+#endif
+
+#ifdef NOR_FLASH_TYPE_ST_INTEL_LIKE
+#define __INTEL_SERIES_NOR__
+#endif
+
+#ifdef NOR_FLASH_TYPE_AMD_SERIES
+#define __AMD_SERIES_NOR__
+#endif
+
+#ifdef NOR_FLASH_TYPE_SPANSION_PL_J
+#define __AMD_SERIES_NOR__
+#define NOR_SUSPEND_LATENCY (35)
+#endif
+
+#ifdef NOR_FLASH_TYPE_SPANSION_PL_N
+#define __AMD_SERIES_NOR__
+#define __SPANSION_PL_N__
+#define NOR_SUSPEND_LATENCY (20)
+#endif
+
+#ifdef NOR_FLASH_TYPE_SPANSION_WS_N
+#define __AMD_SERIES_NOR__
+#define __SPANSION_WS_N__
+#define __SPANSION_PL_N__
+#define NOR_SUSPEND_LATENCY (20)
+#endif
+
+#ifdef NOR_FLASH_TYPE_SPANSION_WS_P
+#define __AMD_SERIES_NOR__
+#define __SPANSION_WS_P__
+#define NOR_SUSPEND_LATENCY (40)
+#define NOR_RESUME_SUSPEND_INTERVAL (40)
+#endif
+
+#ifdef NOR_FLASH_TYPE_SPANSION_GL_A
+#define __AMD_SERIES_NOR__
+#define __SPANSION_GL_A__
+#endif
+
+#ifdef NOR_FLASH_TYPE_SPANSION_GL_N
+#define __AMD_SERIES_NOR__
+#define __SPANSION_GL_N__
+#define NOR_SUSPEND_LATENCY (20)
+#endif
+
+#ifdef NOR_FLASH_TYPE_SPANSION_NS_N
+#define __AMD_SERIES_NOR__
+#define __SPANSION_NS_N__
+#define NOR_SUSPEND_LATENCY (35)
+#define NOR_RESUME_SUSPEND_INTERVAL (30)
+#endif
+
+#ifdef NOR_FLASH_TYPE_SPANSION_NS_P
+#define __AMD_SERIES_NOR__
+#define __SPANSION_NS_N__
+#define NOR_SUSPEND_LATENCY (20)
+#define NOR_RESUME_SUSPEND_INTERVAL (30)
+#endif
+
+#ifdef NOR_FLASH_TYPE_SPANSION_NS_J
+#define __AMD_SERIES_NOR__
+#define __SPANSION_NS_J__
+#define NOR_SUSPEND_LATENCY (35)
+#endif
+
+#ifdef NOR_FLASH_TYPE_TOSHIBA
+#define __AMD_SERIES_NOR__
+#endif
+
+#ifdef NOR_FLASH_TYPE_TOSHIBA_TV
+#define __AMD_SERIES_NOR__
+#define __TOSHIBA_TV__
+#endif
+
+#ifdef NOR_FLASH_TYPE_TOSHIBA_TY
+#define __AMD_SERIES_NOR__
+#define __TOSHIBA_TY__
+#endif
+
+#ifdef NOR_FLASH_TYPE_SILICON7
+#define __RENESAS_SERIES_NOR__
+#endif
+
+#ifdef NOR_FLASH_TYPE_SAMSUNG_SPANSION_NS_J_LIKE
+#define __AMD_SERIES_NOR__
+#define __SAMSUNG_SPANSION_NS_J_LIKE__
+#define NOR_SUSPEND_LATENCY (20)
+#define NOR_RESUME_SUSPEND_INTERVAL (30)
+#endif
+
+#ifdef NOR_FLASH_TYPE_SPANSION_VS_R
+#define __AMD_SERIES_NOR__
+#define __SPANSION_VS_R__
+#define NOR_SUSPEND_LATENCY (30)
+#define NOR_RESUME_SUSPEND_INTERVAL (30)
+#define __NOR_FDM_4_FLIPPING_TOLERABLE__
+#endif
+
+#ifdef NOR_FLASH_TYPE_SPANSION_VS_R64
+#define __AMD_SERIES_NOR__
+#define __SPANSION_VS_R64__
+#define __SPANSION_NS_N__
+#define NOR_SUSPEND_LATENCY (30)
+#define __NOR_FDM_4_FLIPPING_TOLERABLE__
+#endif
+
+#ifdef NOR_FLASH_TYPE_SPANSION_WS_R
+#define __AMD_SERIES_NOR__
+#define __SPANSION_WS_R__
+#define NOR_SUSPEND_LATENCY (30)
+#define NOR_RESUME_SUSPEND_INTERVAL (30)
+#define __NOR_FDM_4_FLIPPING_TOLERABLE__
+#endif
+
+/*
+ *******************************************************************************
+ PART 6:
+ FOTA UPDATABLE FLASH AREA
+ *******************************************************************************
+*/
+#ifdef __FOTA_DM__
+ #ifndef CONFIG_FOTA_UE_FLASH_SPACE
+ #error "custom\system\{project}\custom_FeatureConfig.h: Error! Please define CONFIG_FOTA_UE_FLASH_SPACE in custom_FeatureConfig.h!"
+ #endif /* CONFIG_FOTA_UE_FLASH_SPACE */
+
+ #ifndef CONFIG_FOTA_PACKAGE_BLOCK_NUMBER
+ #error "custom\system\{project}\custom_FeatureConfig.h: Error! Please define CONFIG_FOTA_PACKAGE_BLOCK_NUMBER in custom_FeatureConfig.h!"
+ #endif /* CONFIG_FOTA_PACKAGE_BLOCK_NUMBER */
+#endif /* __FOTA_DM__ */
+
+
diff --git a/mcu/custom/driver/common/fmr_config_customize.c b/mcu/custom/driver/common/fmr_config_customize.c
new file mode 100644
index 0000000..84b9097
--- /dev/null
+++ b/mcu/custom/driver/common/fmr_config_customize.c
@@ -0,0 +1,81 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * fmr_config_customize.c
+ *
+ * Project:
+ * --------
+ * Maui
+ *
+ * Description:
+ * ------------
+ * This file contains fm radio customized configuration.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *******************************************************************************/
+#if defined(FM_RADIO_ENABLE)
+#include "kal_general_types.h"
+
+/*RSSI threshold*/
+#if (defined(MT6251FM))
+kal_uint16 FMR_RSSI_THRESHOLD_LANT = 0x301;
+kal_uint16 FMR_RSSI_THRESHOLD_SANT = 0x2E0;
+kal_uint16 FMR_CQI_TH = 0xE9;
+#elif (defined(MT6276FM))
+kal_uint16 FMR_RSSI_THRESHOLD_LANT = 0x301;
+kal_uint16 FMR_RSSI_THRESHOLD_SANT = 0x2E0;
+kal_uint16 FMR_CQI_TH = 0xE9;
+#elif (defined(MT6256FM)||defined(MT6255FM))
+kal_uint16 FMR_RSSI_THRESHOLD_LANT = 0x301;
+kal_uint16 FMR_RSSI_THRESHOLD_SANT = 0x2E0;
+kal_uint16 FMR_CQI_TH = 0xE9;
+#elif (defined(MT6626))
+kal_uint16 FMR_RSSI_THRESHOLD_LANT = 0xFF01;
+kal_uint16 FMR_RSSI_THRESHOLD_SANT = 0xFEE0;
+kal_bool FMR_DEEMPHASIS_50us = KAL_FALSE;
+kal_uint16 FMR_CQI_TH = 0xFFE9;
+#endif
+
+kal_uint16 FMR_SCAN_BAND_UP = 1080; //108MHz
+kal_uint16 FMR_SCAN_BAND_DN = 875; //87.5MHz
+
+#endif
diff --git a/mcu/custom/driver/common/fmr_config_customize.h b/mcu/custom/driver/common/fmr_config_customize.h
new file mode 100644
index 0000000..15e3142
--- /dev/null
+++ b/mcu/custom/driver/common/fmr_config_customize.h
@@ -0,0 +1,62 @@
+/*****************************************************************************
+* 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) 2005
+*
+* 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:
+ * ---------
+ * fmr_config_customize.h
+ *
+ * Project:
+ * --------
+ * Maui
+ *
+ * Description:
+ * ------------
+ * This file contains fm radio customized configuration.
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ *******************************************************************************/
+#if defined(FM_RADIO_ENABLE)
+/*
+*FM radio MMI, MED/MDI, driver should refer to this definition.
+*FM drvier search range should be less than 256 khz:(FM_RADIO_MAX_FREQ-FM_RADIO_MIN_FREQ)<256
+*/
+#define FM_RADIO_MIN_FREQ 875 //87.5MHz
+#define FM_RADIO_MAX_FREQ 1080 //108MHz
+#endif