view src/cs/drivers/drv_app/power/board/power.c @ 304:58c7961bd0b0 default tip

TCH tap: extend DL sniffing feature to support CSD modes Our debug feature for TCH DL sniffing reads the content of the DSP's a_dd_0 buffer (or a_dd_1 for TCH/H subchannel 1) at appropriate times and forwards captured bits to the host. This feature was originally implemented for TCH/FS, TCH/EFS and TCH/HS - now extend it to cover TCH/F data modes too.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 25 Nov 2024 23:33:27 +0000
parents a75eefbf8be4
children
line wrap: on
line source

/*******************************************************************************
*
* power.c
*
* Purpose: This file contains the functions used for power on and off
*          management of the board.
*          In case of RVM_PWR_SWE, this file contains also the
*          functions used for charger plug and unplug management.
*          They are all called after the occurence of the ABB interrupt.
*
* Author:  Candice Bazanegue (c-brille@ti.com)
*
* The present FreeCalypso version is heavily modified from TI's original,
* for the new FreeCalypso way of managing handset on/off state.
*
******************************************************************************/

#ifndef _WINDOWS
  #include "rv.cfg"
#endif

#include "abb/abb.h"
#include "rvm/rvm_use_id_list.h"
#include "spi/spi_env.h"
#include "power/power.h"
#include "rv/rv_general.h"
#include "rvf/rvf_api.h"
#include "rv/rv_defined_swe.h"	   // for RVM_PWR_SWE

#ifndef _WINDOWS
  #include "kpd/kpd_power_api.h"
  #include "ffs/ffs.h"
#endif  // _WINDOWS

#ifndef _WINDOWS
  /* Declare the variable containing pressed and released callback.  */
  extern T_KPD_KEYPAD Kp;

  extern effs_t ffs_exit(void);
#endif  // _WINDOWS

#if (MMI != 0)
  #include "fcbm/fcbm_send_msg.h"
#endif

/// The ABB status used to know the cause of the Switch ON event.
static SYS_UWORD16 Power_abb_status = 0;


/*******************************************************************************
**
** Function      Power_ON_Button
**
** Description:  Informs the Protocol Stack that the Power ON key has been
**		 pressed, and thus allows it to start.
**
*******************************************************************************/
void Power_ON_Button(void)
{
#if (MMI != 0)
    extern void fchs_pwon_button_boot(void);
    extern int r2d_is_running, mmi_task_init_done;
    extern UINT16 fchg_first_vbat;

    while (!fchg_first_vbat || !r2d_is_running || !mmi_task_init_done)
	rvf_delay(8);

    /*
     * Is PWON button still held down?  If it isn't, we power off.
     * We use a raw VRPCDEV write instead of ABB_Power_Off()
     * in order to skip the PWON release wait and BZ_KeyBeep_OFF():
     * the off-beep would be very confusing to users in this scenario,
     * and we need to skip the PWON release wait so that if the user's
     * finger slips but the user really does wish to turn the phone on,
     * we won't get stuck in that PWON release wait.
     */
    if (ABB_Read_Status() & ONREFLT) {
	rvf_send_trace("PWON short press, not accepting", 31, NULL_PARAM,
			RV_TRACE_LEVEL_DEBUG_HIGH, LCC_USE_ID);
	/*
	 * Delay so that all trace output up to the last line above
	 * will be visible in rvtdump or rvinterf for debugging.
	 */
	rvf_delay(RVF_MS_TO_TICKS(600));
	ABB_Write_Register_on_page(PAGE0, VRPCDEV, 0x0001);
    }

    /* proceed with phone boot */
    fchs_pwon_button_boot();
#endif
}


/*******************************************************************************
**
** Function      Power_OFF_Button
**
** Description:  Informs the Protocol Stack that the Power OFF key has been
**		 pressed, and thus allows it to stop.
**
*******************************************************************************/
void Power_OFF_Button(void)
{
    rvf_send_trace("Power off button", 16, NULL_PARAM, RV_TRACE_LEVEL_WARNING,
		   LCC_USE_ID);
    if (Kp.pressed && Kp.released) {
	(Kp.pressed)(KPD_PWR);  /* tell key is pressed */
	rvf_delay(5);
	(Kp.released)();        /* tell key is released */
    } else
	ABB_Power_Off();
}


/**
 * @brief Sets the cause of the switch ON event.
 *
 * This function get the ABB status register and stores it into the
 * global variable Power_abb_status.
 *
 * @noparam
 *
 * @noreturn
 */
void Set_Switch_ON_Cause(void)
{
   Power_abb_status = ABB_Read_Status();
}


/*******************************************************************************
**
** Function      Switch_ON
**
** Description   This function is called by the spi task after the board is
**               switched ON. It calls the appropriate function according
**               to the ABB status register.
**
** Warning       The Set_Switch_ON_Cause() function has to be called prior.
**
*******************************************************************************/
void Switch_ON(void)
{
   if (Power_abb_status & (CHGSTS|CHGPRES))
   {
      /* Switch on Condition on CHARGER IC PLUG */
      rvf_send_trace("Boot: Charger Plug",18, NULL_PARAM,
		     RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
      #if (MMI != 0)
	fcbm_message_to_task(FCBM_START_CHG_MODE);
      #endif
   }

   else if (Power_abb_status & ONBSTS)
   {
      /* Switch on Condition on ON BUTTON Push */
      rvf_send_trace("Push Button from OFF to ON",26, NULL_PARAM,
		     RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
      Power_ON_Button();
   }

   else
   {
      /* In FreeCalypso start from reset is NOT the same as PWON! */
      rvf_send_trace("Start from reset",16, NULL_PARAM,
		     RV_TRACE_LEVEL_DEBUG_LOW, LCC_USE_ID);
      #if (MMI != 0)
	fcbm_message_to_task(FCBM_START_RESET_MODE);
      #endif
   }
}


/*******************************************************************************
**
** Function         Power_ON_Remote
**
** Description
**
**
*******************************************************************************/
void Power_ON_Remote(void)
{
}


/*******************************************************************************
**
** Function         Power_OFF_Remote
**
** Description
**
**
*******************************************************************************/
void Power_OFF_Remote(void)
{
}


/*******************************************************************************
**
** Function         Power_IT_WakeUp
**
** Description
**
**
*******************************************************************************/
void Power_IT_WakeUp(void)
{
}