Пример #1
0
void drv_idc_init_gpio(void)
{
	EINT_Mask(TDM_REQ_HI_EINT_NO); // disable TDM_REQ_HI interrupt
	EINT_Mask(TDM_REQ_LO_EINT_NO); // disable TDM_REQ_LO interrupt

	// Level trigger
	EINT_Set_Sensitivity(TDM_REQ_HI_EINT_NO, KAL_FALSE);
	EINT_Set_Sensitivity(TDM_REQ_LO_EINT_NO, KAL_FALSE);

	EINT_Set_HW_Debounce(TDM_REQ_HI_EINT_NO, 0);
	EINT_Set_HW_Debounce(TDM_REQ_LO_EINT_NO, 0);

#if !defined(ATEST_DRV_ENABLE)
	dhl_trace(TRACE_INFO, 0, IDC_TDM_INIT_MSG);
#else
	kal_sprintf(idc_dbg_str, "drv_idc: TDM_REQ Init\n\r");
	DT_IDC_PRINTF(idc_dbg_str);
#endif

	EINT_Registration_and_mask(TDM_REQ_HI_EINT_NO, KAL_TRUE, 1, TDM_REQ_HI_Entry, KAL_FALSE);
	EINT_Registration_and_mask(TDM_REQ_LO_EINT_NO, KAL_TRUE, 0, TDM_REQ_LO_Entry, KAL_FALSE);

	EINT_UnMask(TDM_REQ_HI_EINT_NO); // enable TDM_REQ_HI interrupt
	EINT_UnMask(TDM_REQ_LO_EINT_NO); // enable TDM_REQ_LO interrupt
	
	return;
}
Пример #2
0
/*************************************************************************
* FUNCTION
*  EINT_HISR_Entry
*
* DESCRIPTION
*  This function implements main external interrupt HISR registered in
*  global ISR jump table, eint_hisr_func.
*
* CALLS
*
* PARAMETERS
*
* RETURNS
*  No return
*
* GLOBALS AFFECTED
*
*************************************************************************/
void EINT_HISR_Entry(void)
{
   kal_uint8 index;

   for(index=0;index<EINT_TOTAL_CHANNEL;index++)
   {
      if ( !(eint_is_dedicated & (1 << index)) && (EINT_FUNC.eint_active[index] == KAL_TRUE) 
	  	&& (EINT_FUNC.eint_func[index]) ) 
   	  {

         EINT_FUNC.eint_active[index] = KAL_FALSE;

         eint_trigger_src_log[eint_trigger_src_ptr] = index;
         eint_trigger_src_ptr = (eint_trigger_src_ptr + 1) % EINT_TRIGGER_SRC_LOG_MAX;

         EINT_FUNC.eint_func[index]();

         if (EINT_FUNC.eint_auto_umask[index] == KAL_TRUE) 
         {

            EINT_UnMask(index);
         }
      }
   }
}
Пример #3
0
/*************************************************************************
* FUNCTION
*  EINT_HISR_Entry
*
* DESCRIPTION
*  This function implements main external interrupt HISR registered in
*  global ISR jump table, eint_hisr_func.
*
* CALLS
*
* PARAMETERS
*
* RETURNS
*  No return
*
* GLOBALS AFFECTED
*
*************************************************************************/
void EINT_HISR_Entry(void)
{
   kal_uint8 index;   
   
   for(index  =0; index < EINT_TOTAL_CHANNEL; index++) 
   {
      if ( (EINT_FUNC.eint_active[index] == KAL_TRUE) && (EINT_FUNC.eint_func[index]) ) 
      {

         EINT_FUNC.eint_func[index]();

         EINT_FUNC.eint_active[index] = KAL_FALSE;

         if (EINT_FUNC.eint_auto_umask[index] == KAL_TRUE) 
         {

            EINT_UnMask(index);
         }
      }
   }

#if ( defined(MT6228) || defined(MT6229) || defined(MT6230) || defined(MT6238))

	*IRQ_EOI2 = IRQCode2Line[IRQ_EIT_CODE];

#else

	*IRQ_EOI = (1 << IRQCode2Line[IRQ_EIT_CODE]);

#endif	
}
Пример #4
0
/*************************************************************************
* FUNCTION
*  EINT_TIMER_CALLBACK
*
* DESCRIPTION
*   This function implements main external interrupt LISR registered in
*  global ISR jump table.
*
* CALLS
*
* PARAMETERS
*
* RETURNS
*  No return
*
* GLOBALS AFFECTED
*
*************************************************************************/
void DEINT_TIMER_CALLBACK(void *data)
{
   EINT_SW_DEBOUNCE_STRUCT *sw_debounce = (EINT_SW_DEBOUNCE_STRUCT *)data;

   EINT_Mask(sw_debounce->eint_no);

   if(sw_debounce->eint_sw_debounce_handle != 0x7f)
   {
      DclSGPT_Control(sw_debounce->eint_sw_debounce_handle,SGPT_CMD_STOP,0);
      DclSGPT_Close(&(sw_debounce->eint_sw_debounce_handle));
   }

   sw_debounce->eint_intr_allow = (sw_debounce->eint_intr_allow == KAL_TRUE)? KAL_FALSE: KAL_TRUE;

   /*
    * This timer is to avoid if interrupt status is changed but 
    * sw_debounce->eint_intr_allow is still in KAL_TRUE state
    * because of no interrupt
    */
   if (sw_debounce->eint_intr_allow) 
   {
      SGPT_CTRL_START_T start;

      start.u2Tick= eint_sw_debounce_time_delay[sw_debounce->eint_no];

      start.pfCallback=DEINT_TIMER_CALLBACK;
      start.vPara=data;
      sw_debounce->eint_sw_debounce_handle=DclSGPT_Open(DCL_GPT_CB,0);
      DclSGPT_Control(sw_debounce->eint_sw_debounce_handle,SGPT_CMD_START,(DCL_CTRL_DATA_T*)&start);
   }
   EINT_UnMask(sw_debounce->eint_no);
}
Пример #5
0
/******************************************************************************
* Function:
*	GPSLocateVibSensorStart
*
* Usage:
*	Start vibration sensor monitor
*
* Parameters:
*	None
*
* Return:
*	None
******************************************************************************/
void GPSLocateVibSensorStart(void)
{
	if (gGPSVibSensorStart == KAL_TRUE) return;
	gGPSVibSensorStart = KAL_TRUE;
	/*
	* Enabling the eint to detect the vibration sensor status
	*/
	EINT_UnMask(GPS_VIBSENSOR_EINT_NO);

	if (gGPSVibSensorTimer != NULL)
	{
		GPSAppTimer_Reset(gGPSVibSensorTimer, 
						GPSLocateVibSensorExpireProc,
						GPSLOCATE_VIBSENSOR_SILENCETHRESHOLD_DEFAULT*KAL_TICKS_1_MIN,
						GPSLOCATE_VIBSENSOR_SILENCETHRESHOLD_DEFAULT*KAL_TICKS_1_MIN,
						KAL_TRUE
						);
	}
	else
	{
		gGPSVibSensorTimer = GPSAppTimer_Create(
									GENERAL_GPSAPP_TIMERID,
									GPSLocateVibSensorExpireProc,
									GPSLOCATE_VIBSENSOR_SILENCETHRESHOLD_DEFAULT*KAL_TICKS_1_MIN,
									GPSLOCATE_VIBSENSOR_SILENCETHRESHOLD_DEFAULT*KAL_TICKS_1_MIN,
									KAL_TRUE
									);
	}
}
kal_bool CHR_USB_EINT_UnMask(CHR_DET_EINT_OWNER Owner)
{
	kal_uint32 savedMask;
	kal_uint32 eint;


	#if (!defined(DRV_MISC_CHR_USB_EINT_CENTRAL_UNMASK))
	// If CENTRAL control is NOT enabled, we filter out USB owner control
	// ==> Just ignore USB request, the EINT unmask control is controlled by PMIC only
	if (Owner == CHR_DET_EINT_OWNER_USB){
		return KAL_FALSE;
	}else{
		EINT_UnMask(chr_usb_detect.chr_usb_eint);
		return KAL_TRUE;
	}
	#endif // #if defined(DRV_MISC_CHR_USB_EINT_CENTRAL_UNMASK)

	eint = (kal_uint32)chr_usb_detect.chr_usb_eint;

	// Force to unmask EINT
	// For some cases, our driver may trigger the EINT (Ex: OTG)
	// In this situation, we do NOT need central control
	// Because it is a false alarm trigger
	if (Owner == USB_DET_EINT_OWNER_FORCE_UNMASK){
		savedMask = SaveAndSetIRQMask();
		chr_usb_eint_mask = 0;
		EINT_UnMask((kal_uint8)eint);
		RestoreIRQMask(savedMask);
		return KAL_TRUE;
	}

	savedMask = SaveAndSetIRQMask();
	chr_usb_eint_mask |= (kal_uint8)Owner;


	if (chr_usb_eint_mask == chr_usb_eint_owner_mask){
		EINT_UnMask((kal_uint8)eint);
		// Reset the flag
		chr_usb_eint_mask = 0;
	}
	RestoreIRQMask(savedMask);
	return (chr_usb_eint_mask==0?KAL_TRUE:KAL_FALSE);
}
Пример #7
0
/****************************************************************************
 * FUNCTION
 *  JogBall_RIGHT_HISR
 * DESCRIPTION
 *  Register the call back functions
 *  
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void JogBall_RIGHT_HISR(void)
{		
   EINT_Mask(eint_chans_right);
   if(JBXY == KEY_RIGHT_EVENT)
   {
      kbd_SendKey(DEVICE_KEY_RIGHT);
      JBXY=KEY_DIRECTION_EVENT_NUll;
   }
   else
   {
      JBXY=KEY_RIGHT_EVENT;
   }
   EINT_UnMask(eint_chans_right);	 
}
Пример #8
0
void JogBall_DOWN_HISR(void)
{		
   EINT_Mask(eint_chans_down);		 
   if(JBXY == KEY_DOWN_EVENT)
   {
        kbd_SendKey(DEVICE_KEY_DOWN);
        JBXY=KEY_DIRECTION_EVENT_NUll;
   }
   else
   {
      JBXY=KEY_DOWN_EVENT;
   }
   EINT_UnMask(eint_chans_down);
}
Пример #9
0
void TDM_REQ_HI_Entry(void)
{
	IDC_ILM_MSG_T tmp;
	tmp.type = 3;
	tmp.msg = 100;

	// send msg to EL2 that LTE_TX is not Allowed
#if !defined(ATEST_DRV_ENABLE)
	dhl_trace(TRACE_INFO, 0, IDC_TDM_HI_MSG);
#else
	kal_sprintf(idc_dbg_str, "TDM_REQ_HI_Entry\n\r");
	DT_IDC_PRINTF(idc_dbg_str);
#endif
	msg_send_inline6(DRV_IDC_HISR_ID, idc_port.owner_id, DRIVER_PS_SAP | INLINE_ILM_FLAG_SAP, MSG_ID_IDC_RX_DATA, (void *) &tmp, sizeof(IDC_ILM_MSG_T));
	EINT_UnMask(TDM_REQ_LO_EINT_NO);
}
Пример #10
0
/*************************************************************************
* FUNCTION
*  EINT_TIMER_CALLBACK
*
* DESCRIPTION
*   This function implements main external interrupt LISR registered in
*  global ISR jump table.
*
* CALLS
*
* PARAMETERS
*
* RETURNS
*  No return
*
* GLOBALS AFFECTED
*
*************************************************************************/
void EINT_TIMER_CALLBACK(void *data)
{
   EINT_SW_DEBOUNCE_STRUCT *sw_debounce = (EINT_SW_DEBOUNCE_STRUCT *)data;

   GPTI_StopItem(sw_debounce->eint_sw_debounce_handle);

   sw_debounce->eint_intr_allow = (sw_debounce->eint_intr_allow == KAL_TRUE)? KAL_FALSE: KAL_TRUE;

   /*
    * This timer is to avoid if interrupt status is changed but 
    * sw_debounce->eint_intr_allow is still in KAL_TRUE state
    * because of no interrupt
    */
   if (sw_debounce->eint_intr_allow) 
   {
      GPTI_StartItem(sw_debounce->eint_sw_debounce_handle, eint_sw_debounce_time_delay[sw_debounce->eint_no], /*0.5 second*/ EINT_TIMER_CALLBACK, data);
   }

   EINT_UnMask(sw_debounce->eint_no);
}
Пример #11
0
/*************************************************************************
* FUNCTION
*  EINT_RestoreMask
*
* DESCRIPTION
*  This function restores the MASK of the specified external interrupt
*
* PARAMETERS
*  val   -   value to restore
*
* RETURNS
*  No return
*
*************************************************************************/
void EINT_RestoreMask(kal_uint8 eintno, kal_uint32 val)
{
   kal_uint32 savedMask;


   /* lockout interrupt */   
   savedMask = SaveAndSetIRQMask();

   /*
    * NoteXXX: The external interrup should already be masked here (via the
    *          EINT_SaveAndMask() call). Only need to change the EINT_MASK 
    *          when the external interrupt is originally un-masked.
    */
   if (val == 0)
   {
       EINT_UnMask(eintno);
   }
   
   /* un-lockout interrupt */
   RestoreIRQMask(savedMask);
}
Пример #12
0
/*************************************************************************
* FUNCTION
*  DEINT_HISR_Entry
*
* DESCRIPTION
*  This function implements main dedicated external interrupt HISR registered in
*  global ISR jump table, eint_hisr_func.
*
* CALLS
*
* PARAMETERS
*
* RETURNS
*  No return
*
* GLOBALS AFFECTED
*
*************************************************************************/
void DEINT_HISR_Entry(void)
{
   kal_uint8 index;

   for(index=0;index<EINT_TOTAL_CHANNEL;index++)
   {
	if (eint_is_dedicated & (1 << index))
	{
		if ( (EINT_FUNC.eint_active[index] == KAL_TRUE) && (EINT_FUNC.eint_func[index]) ) 
	   	  {

	         EINT_FUNC.eint_active[index] = KAL_FALSE;

	         EINT_FUNC.eint_func[index]();

	         if (EINT_FUNC.eint_auto_umask[index] == KAL_TRUE) 
	         {
	            EINT_UnMask(index);
	         }
	      }
	}
   }
}
/*************************************************************************
* FUNCTION
*	CHRDET_USB_HISR
*
* DESCRIPTION
*	1. HISR of charger and usb external interrupt
*
* PARAMETERS
*	None
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
static void CHR_USB_EINT_HISR(void)
{
#ifdef __OTG_ENABLE__
	static kal_bool g_usb_host_turn_on_vbus = KAL_FALSE;
#endif // #ifdef __OTG_ENABLE__

//#if defined(PMIC_6305_REG_API) || defined(PMIC_6318_REG_API) || defined(PMIC_6238_REG_API) || defined(PMIC_6326_REG_API) || defined(PMIC_6253_REG_API) || defined(PMIC_6236_REG_API) || defined(PMIC_6276_REG_API) || defined(PMIC_6255_REG_API)

	#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)
	EINT_Set_Polarity(chr_usb_detect.chr_usb_eint, (kal_bool)(chr_usb_detect.chr_usb_state));
	#endif // #if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_HIGH)

	#if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_LOW)
	EINT_Set_Polarity(chr_usb_detect.chr_usb_eint, (kal_bool)(!chr_usb_detect.chr_usb_state));
	#endif // #if defined(PMIC_CHR_USB_DET_EINT_LEVEL_ACTIVE_LOW)

	#if defined(PMIC_6326_REG_API)
	//if (pmic_chrdet_status() == chr_usb_detect.chr_usb_state){
	//	ASSERT(0);	// There is problem!!!! Because whenever the program goes here, we should get invert state
	//					// In => Out => In => Out
	//}
	{
		PMU_CTRL_CHR_GET_CHR_DET_STATUS chrStatus;
		DclPMU_Control(chrDet_PmuHandler, CHR_GET_CHR_DET_STATUS, (DCL_CTRL_DATA_T *)&chrStatus);
	
		if (chrStatus.enable== chr_usb_detect.chr_usb_state)
		{
			// When the detected status is same as the current state, do nothing!
			//kal_prompt_trace(MOD_BMT,"CHRDet status is same as chr_usb_state");
			EINT_UnMask(chr_usb_detect.chr_usb_eint); // unmask eint here, otherwise it never comes interrupt again.
			//CHR_USB_EINT_Owner_SetMask(CHR_DET_EINT_OWNER_BMT); // Set owner mask flag of BMT
			//CHR_USB_EINT_UnMask(CHR_DET_EINT_OWNER_BMT); // EINT_UnMask(chr_usb_detect.chr_usb_eint);
			return;
		}
	}
	#endif // #if defined(PMIC_6326_REG_API)

	

	chr_usb_detect.chr_usb_state = (kal_bool)(!((kal_uint8)chr_usb_detect.chr_usb_state));
	if (chr_usb_detect.chr_usb_state)
	{
		//kal_prompt_trace(MOD_BMT,"CHR_USB IN");
		kal_brief_trace( TRACE_STATE,BMT_CABLE_IN_TRC);

		#ifdef __USB_UART_MULTIPLEXED_WITH_EXT_SWITCH__
		GPIO_WriteIO(1, gpio_usb_uart_switch_pin);	//switch to usb mode
		#endif

		#ifdef __OTG_ENABLE__
		{
			DCL_HANDLE  otg_dcl_handle;
			DCL_BOOL dcl_data;
			kal_bool b_is_host_on_vbus;
			otg_dcl_handle = DclOTG_DRV_Open(DCL_USB, FLAGS_NONE);
			DclOTG_DRV_Control(otg_dcl_handle, OTG_DRV_CMD_IS_HOST_TURN_ON_VBUS, (DCL_CTRL_DATA_T  *)&dcl_data);
			b_is_host_on_vbus = (kal_bool)dcl_data;
			DclOTG_DRV_Close(otg_dcl_handle);
			
			if (b_is_host_on_vbus== KAL_TRUE)
		{
			g_usb_host_turn_on_vbus = KAL_TRUE;
			// Force to unmask EINT for OTG case
			CHR_USB_EINT_UnMask(USB_DET_EINT_OWNER_FORCE_UNMASK); // EINT_UnMask(chr_usb_detect.chr_usb_eint);
			return;
		}
		}
		#endif // #ifdef __OTG_ENABLE__

		// Clear EINT owner bit mask
		CHR_USB_EINT_Owner_ClrMask();

		ASSERT(chr_usb_det_mgr.pw_is_charger_usb_det_eint != NULL);
		chr_usb_det_mgr.pw_is_charger_usb_det_eint();


	}
	else
	{

		#ifdef __USB_UART_MULTIPLEXED_WITH_EXT_SWITCH__
		GPIO_WriteIO(0, gpio_usb_uart_switch_pin);	//switch to uart mode
		#endif

		#ifdef __OTG_ENABLE__
		if (g_usb_host_turn_on_vbus == KAL_TRUE)
		{
			g_usb_host_turn_on_vbus = KAL_FALSE;
			// Force to unmask EINT for OTG case
			CHR_USB_EINT_UnMask(USB_DET_EINT_OWNER_FORCE_UNMASK); // EINT_UnMask(chr_usb_detect.chr_usb_eint);
			return;
		}
		#endif // #ifdef __OTG_ENABLE__

			CHR_USB_PLUG_OUT();
	}


}
/*
* FUNCTION
*	   CHRDET_HISR
*
* DESCRIPTION
*   	This function is the interrupt handler for EINT1
*
* CALLS
*
* PARAMETERS
*	   None
*
* RETURNS
*	   None
*
* GLOBALS AFFECTED
*     None
*/
void CHRDET_HISR(void)
{
	#ifndef __DRV_NO_USB_CHARGER__
	extern void bmt_charger_action(kal_bool in);
	#endif /*__DRV_NO_USB_CHARGER__*/
	kal_uint32 state;
	#if defined(PMIC_6326_REG_API)
	static kal_bool chr_status = KAL_FALSE;
	#endif // #if defined(PMIC_6326_REG_API)

#if defined(PMIC_6326_REG_API)

	{
		PMU_CTRL_CHR_GET_CHR_DET_STATUS chrStatus;
		DclPMU_Control(chrDet_PmuHandler, CHR_GET_CHR_DET_STATUS, (DCL_CTRL_DATA_T *)&chrStatus);
		DclPMU_Close(chrDet_PmuHandler);
	

		if (chr_status == chrStatus.enable){
			#if ( (!defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)) && defined(PMIC_6326_REG_API) )
			#if (!defined(__DRV_EXT_CHARGER_DETECTION__))
			EINT_UnMask(gCHRDET_EINT_NO);
			#endif // #if (!defined(__DRV_EXT_CHARGER_DETECTION__))
			#endif // #if ( (!defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)) && defined(PMIC_6326_REG_API) )
			return;
		}
	}
	
	chr_status =(kal_bool)(!((kal_uint8)chr_status));
	if (chr_status == KAL_TRUE){
		state = DETECTCHRIN;
	}else{
		state = DETECTCHROUT;
	}
	// Should PMIC6326 update the flag?
	BMT.EINT2STATE = !state;

#else // #if defined(PMIC_6326_REG_API)

	BMT.EINT2STATE = !BMT.EINT2STATE;
	#if (!defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__) )
	#if (!defined(__DRV_EXT_CHARGER_DETECTION__))
	chrdet_level_config(BMT.EINT2STATE);
	#endif // #if (!defined(__DRV_EXT_CHARGER_DETECTION__))
	#endif // #if ( (!defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__)) && ( defined(PMIC_6305_REG_API) || defined(PMIC_6223_REG_API)|| defined(PMIC_6238_REG_API) || defined(PMIC_6253_REG_API) || defined(PMIC_6236_REG_API) || defined(PMIC_6251_REG_API)) )
	state = !BMT.EINT2STATE;

#endif // #if defined(PMIC_6326_REG_API)


	if (state == DETECTCHRIN)
	{
		//DclPMU_Control(chrDet_PmuHandler, CHR_SET_CV_DETECTION_VOLTAGE_CALIBRATION, NULL);	
		#ifdef BMT_DEBUG
		dbg_printWithTime("CHARGER_PLUGIN\r\n");
		#endif // #ifdef BMT_DEBUG
		#if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
		BMT_VbatInHISR(); //save current vbat, otherwise turn on LCD backlight may cause VBAT decrease.
		#endif //#if defined(__DRV_BMT_PRECHARGE_TO_FULL_DIRECTLY__)
		bmt_set_chr_status(bmt_chr_in);
		#ifndef __DRV_NO_USB_CHARGER__
		bmt_charger_action(KAL_TRUE);
		#endif // #ifndef __DRV_NO_USB_CHARGER__
	}
	else
	{
		#ifdef BMT_DEBUG
		dbg_printWithTime("CHARGER_PLUGOUT\r\n");
		#endif // #ifdef BMT_DEBUG
		bmt_set_chr_status(bmt_chr_out);
		#ifndef __DRV_NO_USB_CHARGER__
		bmt_charger_action(KAL_FALSE);
		#endif // #ifndef __DRV_NO_USB_CHARGER__
	}

	#if ( (!defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__))  )
	#if (!defined(__DRV_EXT_CHARGER_DETECTION__))
	EINT_UnMask(gCHRDET_EINT_NO);
	#endif // #if (!defined(__DRV_EXT_CHARGER_DETECTION__))
	#endif // #if ( (!defined(__CHARGER_USB_DETECT_WIHT_ONE_EINT__))  )

}
Пример #15
0
/*************************************************************************
* FUNCTION
*  Register_EINT
*
* DESCRIPTION
*   This function implements registration of external interrupts
*
* CALLS
*
* PARAMETERS
*  eintno            -     External interrupt vector number
*  Dbounce_En        -     Debounce control enable
*  ACT_Polarity      -     Interrupt polarity
*  reg_hisr          -     Registered hisr
*  auto_umask        -     A flag instruct the systerm to do unmask after
*                          invoking the registered HISR
*
* RETURNS
*  No return
*
* GLOBALS AFFECTED
*
 *************************************************************************/
void EINT_Registration(kal_uint8 eintno, kal_bool Dbounce_En, kal_bool ACT_Polarity, void (reg_hisr)(void), kal_bool auto_umask)
{
//	PDN_CLR(PDN_GPIO);
	kal_uint32 savedMask;

	/* If EINT Number is out of range, get return address and send it to exception handler */
	if(eintno >= EINT_TOTAL_CHANNEL)
	{
	   kal_uint32 retaddr;
	   
	   GET_RETURN_ADDRESS(retaddr);
	   kal_fatal_error_handler(KAL_ERROR_DRV_EINT_INVALID_INDEX, retaddr);
	}
   
	/*disable eint interrupt*/
	eint_set_irqen(eintno, EINT_DISABLE);

	/*register LISR*/
	/*dispatch for dedicated eint*/
	if (eint_is_dedicated & (1<<eintno))
	{
		switch(eint_is_dedicated_map[eintno])
		{
			case DEDICATED_EINT0:
			{
				eint_set_l1_eint_enable(DEDICATED_EINT0, EINT_DISABLE);
				IRQ_Register_LISR(DEDICATED_EINT_IRQ0, DEINT0_LISR, "DEINT0 handler");
			}
			break;
			case DEDICATED_EINT1:
			{
				eint_set_l1_eint_enable(DEDICATED_EINT1, EINT_DISABLE);
				IRQ_Register_LISR(DEDICATED_EINT_IRQ1, DEINT1_LISR, "DEINT1 handler");
			}
			break;
			case DEDICATED_EINT2:
			{
				eint_set_l1_eint_enable(DEDICATED_EINT2, EINT_DISABLE);
				IRQ_Register_LISR(DEDICATED_EINT_IRQ2, DEINT2_LISR, "DEINT2 handler");
			}
			break;
			case DEDICATED_EINT3:
			{
				eint_set_l1_eint_enable(DEDICATED_EINT3, EINT_DISABLE);
				IRQ_Register_LISR(DEDICATED_EINT_IRQ3, DEINT3_LISR, "DEINT3 handler");
			}
			break;
			default:
			break;
		}
	}
	else
	{
		IRQ_Register_LISR(IRQ_EIT_CODE, EINT_LISR, "EINT handler");
	}

   /* Save and set MCU's I,F bits to disable interrupts */
//   savedMask = LockIRQ();

   /* Set external interrupt polarity */
   EINT_Set_Polarity(eintno,ACT_Polarity);

#if !defined(MT6290)
   gpio_set_eint_src(eintno,eint_src_map[eintno]);
#endif
   if (Dbounce_En)
   {
   	 //eint_set_debounce_duration(eintno,EINT_DB_DUR_DEFAULT);
	 eint_set_debounce_enable(eintno,EINT_ENABLE);
   }
   else
   {
     /*disable debounce */
     eint_set_debounce_enable(eintno,EINT_DISABLE);
   }

   /* Save and set MCU's I,F bits to disable interrupts */
   savedMask = SaveAndSetIRQMask();

   /* Register external interrupt's HISR */
   EINT_FUNC.eint_func[eintno] = reg_hisr;
   EINT_FUNC.eint_active[eintno] = KAL_FALSE;
   EINT_FUNC.eint_auto_umask[eintno] = auto_umask;

	if (eint_is_dedicated & (1<<eintno))
	{
		/* register HISR */
		DRV_Register_HISR(DRV_DEINT_HISR_ID, DEINT_HISR_Entry);
		EINT_L2_ACK(eintno);
		EINT_UnMask(eintno);
		RestoreIRQMask(savedMask);
	}
	else
	{
		/* register HISR */
		DRV_Register_HISR(DRV_EINT_HISR_ID, EINT_HISR_Entry);
		EINT_L2_ACK(eintno);
		EINT_UnMask(eintno);
		IRQSensitivity( IRQ_EIT_CODE, LEVEL_SENSITIVE );
		/* Enable external interrupt */
		IRQUnmask( IRQ_EIT_CODE );
		RestoreIRQMask(savedMask);
	}
}