[Feature]Upload Modem source code
Change-Id: Id4294f30faced84d3e6fd6d5e61e1111bf287a37
diff --git a/mcu/driver/devdrv/gpt/src/drv_gpt.c b/mcu/driver/devdrv/gpt/src/drv_gpt.c
new file mode 100644
index 0000000..096b404
--- /dev/null
+++ b/mcu/driver/devdrv/gpt/src/drv_gpt.c
@@ -0,0 +1,358 @@
+/*****************************************************************************
+* 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) 2012
+*
+* 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:
+ * ---------
+ * drv_gpt.c
+ *
+ * Project:
+ * --------
+ * TATAKA
+ *
+ * Description:
+ * ------------
+ * Low level GPT driver
+ *
+ * Author:
+ * -------
+ * -------
+ *
+ * ==========================================================================
+ * $Log$
+ *
+ * 07 02 2019 yaoyong.ju
+ * [MOLY00418290] [VMOLY]Remove IRQ_Register_LISR() and IRQSensitivity() From IRQ Initialization Source Code
+ * .Remove IRQ_Restier_LISR and IRQSensitivity API in GPT
+ *
+ * 04 26 2019 yaoyong.ju
+ * [MOLY00399544] [MT6297][Apollo][PreSQC][MP0.5][HQ][MTBF][Lab][Ericsson][ErrorTimes:1][1][core2,vpe1,tc2(vpe7)]Assert fail: drv_gpt.c 287 - (LISR)GPT_DSCC0_Lisr for
+ * .
+ * 1.Remove the debug info
+ * 2.Remove unused code
+ *
+ * 03 25 2019 yaoyong.ju
+ * [MOLY00390408] [MT6297][Apollo][PreSQC][MP0.5][NVIOT][Nokia][Oulu][4G][Overnight]: Assert fail: nicc_ctrl.c 317 - USBCORE
+ * .Add the debug info for the MOLY
+ *
+ * 05 04 2017 way.chen
+ * [MOLY00246761] [UMOLYA] Replace PDN API with OF API, Request by PDN owner(Devin )
+ * Remove 26M on/off API.
+ *
+ * 07 06 2016 way.chen
+ * [MOLY00185478] [UMOLYA] Check in 93 serial GPT driver
+ * Add 26M clock operation.
+ *
+ * 06 20 2016 way.chen
+ * [MOLY00185478] [UMOLYA] Check in 93 serial GPT driver
+ * Check in 93 GPT driver.
+ *
+ * 01 06 2016 way.chen
+ * [MOLY00156138] [UMOLY] Patch GPT driver for U4G FPGA
+ * Patch GPT Driver for U4G FPGA, the FPGA Start Version is 20151231_u4g_ltel2_elbrus_vivado_2015.
+ *
+ * 12 10 2013 chin-chieh.hung
+ * [MOLY00049464] [Driver][GPT] Add debug GPT, request by MS Lin
+ * Add Debug GPT APIs
+ *
+ * 08 26 2013 chin-chieh.hung
+ * [MOLY00011352] [Driver] Update for common devdrv driver
+ * remove compiling warning
+ *
+ * 07 03 2013 chin-chieh.hung
+ * [MOLY00027330] [ARM7toMOLY] ARM7 Build/SYSGEN/Functions Update to TRUNK
+ * .
+ *
+ * 05 13 2013 chin-chieh.hung
+ * [MOLY00013348] [MT6290 Bring-up] Basic Platform Support
+ * MT6290E1_FristCall Branch sync back to MOLY Trunk
+ *
+ * 04 28 2013 chin-chieh.hung
+ * [MOLY00013021] [MT6290 PO admit] Move the LISR context to HISR context
+ * LISR 2 HISR support, driver part
+ *
+ * 04 23 2013 chin-chieh.hung
+ * [MOLY00013021] [MT6290 PO admit] Move the LISR context to HISR context
+ * MOLY LISR2HISR, Driver part
+ ****************************************************************************/
+
+#include "drv_features_gpt.h"
+#include "drv_comm.h"
+
+#include "drv_gpt.h"
+#include "intrCtrl.h"
+
+#include "dcl.h"
+#include "kal_general_types.h"
+#include "kal_public_api.h"
+#include "sync_data.h"
+#if !defined(DRV_GPT_OFF)
+
+/*****************************************************************************
+ * SYMBOL Definition *
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ * Global/External Variable *
+ *****************************************************************************/
+static PFN_DCL_CALLBACK pfHGPTCallback[DRV_GPT_TOTAL_COUNTER];
+static DCL_EVENT eHGPTEvent[DRV_GPT_TOTAL_COUNTER];
+
+/*****************************************************************************
+ * function declaration *
+ *****************************************************************************/
+//function declaration.
+
+
+
+/*****************************************************************************
+ * LISR/HISR/Callback Functions *
+ *****************************************************************************/
+static void drv_default_callback(DCL_EVENT event)
+{
+ kal_uint32 ASSERT_IN_GPT_DEFAULT_CALLBACK = 0;
+ ASSERT(ASSERT_IN_GPT_DEFAULT_CALLBACK);
+ return;
+}
+
+/*****************************************************************************
+ * Basic Driver Implementation *
+ *****************************************************************************/
+
+/*-----------------------------------------------------------------------*
+* FUNCTION
+* drv_gpt_lisr
+*
+* DESCRIPTION
+* GPT interrupt handler (LISR)
+*
+* CALLS
+* It is called when GPT interrupt is coming
+*
+* PARAMETERS
+* None
+*
+* RETURNS
+* None
+*
+* GLOBALS AFFECTED
+* external_global
+*------------------------------------------------------------------------*/
+void drv_gpt_lisr(kal_uint32 v)
+{
+ ASSERT(MDGPT_INTR_ID(DRV_GPT_BASE_COUNTER_NUM) <= v && v <= MDGPT_INTR_ID(DRV_GPT_TOTAL_COUNTER));
+ pfHGPTCallback[MDGPT_INTR_ID2TIMER(v)-1](eHGPTEvent[MDGPT_INTR_ID2TIMER(v)-1]);
+}
+
+/*-----------------------------------------------------------------------*
+* FUNCTION
+* drv_gpt_reset
+*
+* DESCRIPTION
+* This function is to reset the hardware GPT module.
+*
+* PARAMETERS
+* None
+*
+* RETURNS
+* DCL_STATUS_OK
+*
+*------------------------------------------------------------------------*/
+void drv_gpt_reset(void)
+{
+ kal_uint32 i;
+ for(i = DRV_GPT_BASE_COUNTER_NUM; i <= DRV_GPT_TOTAL_COUNTER; i++)
+ {
+ DRV_WriteReg32(MDGPT_CTRL_REG(i), 0);
+ DRV_WriteReg32(MDGPT_CNT_REG(i), 0xFFFFF);
+ DRV_WriteReg32(MDGPT_PSR_REG(i), 0);
+ IRQClearInt(MDGPT_INTR_ID(i));
+
+ pfHGPTCallback[i-1] = drv_default_callback;
+ //IRQUnmask(MDGPT_INTR_ID(i));
+ }
+}
+
+/*-----------------------------------------------------------------------*
+* FUNCTION
+* drv_gpt_set_timer
+*
+* DESCRIPTION
+* This function is to configure the gpt timer.
+*
+* PARAMETERS
+* None
+*
+* RETURNS
+* None
+*
+*------------------------------------------------------------------------*/
+void drv_gpt_set_timer(kal_uint32 num, kal_uint32 time, kal_uint32 mode)
+{
+ ASSERT( (DRV_GPT_BASE_COUNTER_NUM <= num) && (num <= DRV_GPT_TOTAL_COUNTER) && (time <= 0xFFFFFFFUL) );
+ DRV_WriteReg32(MDGPT_CNT_REG(num), time);
+
+ mode &= MDGPT_CTRL_MODE_REPEAT | MDGPT_CTRL_MODE_ONESHOT;
+
+ DRV_WriteReg32_NPW(MDGPT_CTRL_REG(num), mode); //1<<1 enable timer
+}
+
+/*-----------------------------------------------------------------------*
+* FUNCTION
+* drv_gpt_get_data
+*
+* DESCRIPTION
+* This function is to get the current data value.
+*
+* PARAMETERS
+* None
+*
+* RETURNS
+* None
+*
+*------------------------------------------------------------------------*/
+kal_uint32 drv_gpt_get_data(kal_uint32 num)
+{
+ ASSERT( (DRV_GPT_BASE_COUNTER_NUM <= num) && (num <= DRV_GPT_TOTAL_COUNTER));
+ return DRV_Reg32(MDGPT_DATA_REG(num));
+}
+
+void drv_gpt_set_data(kal_uint32 num, kal_uint32 time)
+{
+ ASSERT( (DRV_GPT_BASE_COUNTER_NUM <= num) && (num <= DRV_GPT_TOTAL_COUNTER) && (time <= 0xFFFFFFFUL) );
+ DRV_WriteReg32(MDGPT_CNT_REG(num), time);
+}
+
+/*-----------------------------------------------------------------------*
+* FUNCTION
+* drv_gpt_start_timer
+*
+* DESCRIPTION
+* This function is to start the gpt timer.
+*
+* PARAMETERS
+* None
+*
+* RETURNS
+* None
+*
+*------------------------------------------------------------------------*/
+void drv_gpt_start_timer(kal_uint32 num)
+{
+ unsigned int timer_status;
+
+ ASSERT( (num >= DRV_GPT_BASE_COUNTER_NUM) && (DRV_GPT_TOTAL_COUNTER >= num) );
+
+ timer_status = DRV_Reg32(MDGPT_CTRL_REG(num));
+
+ if( timer_status & MDGPT_CTRL_MODE_ENABLE ){
+ //ASSERT(0);
+ return;
+ }
+ DRV_WriteReg32_NPW(MDGPT_CTRL_REG(num), timer_status | MDGPT_CTRL_MODE_ENABLE);
+ Data_Sync_Barrier();
+}
+
+/*-----------------------------------------------------------------------*
+* FUNCTION
+* drv_gpt_stop_timer
+*
+* DESCRIPTION
+* This function is to start the gpt timer.
+*
+* PARAMETERS
+* None
+*
+* RETURNS
+* None
+*
+*------------------------------------------------------------------------*/
+void drv_gpt_stop_timer(kal_uint32 num)
+{
+ unsigned int timer_status;
+
+ ASSERT( (num >= DRV_GPT_BASE_COUNTER_NUM) && (DRV_GPT_TOTAL_COUNTER >= num) );
+
+ timer_status = DRV_Reg32(MDGPT_CTRL_REG(num));
+
+ DRV_WriteReg32_NPW(MDGPT_CTRL_REG(num), timer_status & (~MDGPT_CTRL_MODE_ENABLE));
+ Data_Sync_Barrier();
+}
+
+kal_uint32 drv_gpt_get_version(void)
+{
+ return DRV_Reg32(MDGPT_BASE);
+}
+
+#if 0
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+/* under construction !*/
+#endif
+
+#else /*!defined(DRV_GPT_OFF)*/
+
+#endif /*!defined(DRV_GPT_OFF)*/
+
+void startSystemTimer(void){
+ IRQUnmask(MDGPT_INTR_ID(DRV_GPT_SYSTEM_TIMER));
+ drv_gpt_start_timer(DRV_GPT_SYSTEM_TIMER);
+}
+