Platform/ECM3532/M3/hw/power/ecm3532/src/eta_pwr_gov.c
/**
 *  set next policy
 *
 *  if load is computed decide next policy based on load
 *
 *  else restart timer and continue on current policy
 *
 *  @return int   actual sleep ticks programmed
 */
set next policy
if load is computed decide next policy based on load

else restart timer and continue on current policy

@return int   actual sleep ticks programmed
set next policy if load is computed decide next policy based on load else restart timer and continue on current policy @return int actual sleep ticks programmed
static void
ecm3531_set_next_policy(void)
{
    uint32_t tout;
    int lc;
    static uint8_t high_deb, low_deb;
    lc = ecm3531_compute_load();
    if (lc >= 0) {
       if (lc >= load_crit_high_threshold)
        {
            ecm3531_stepup_policy(CONFIG_DELTA_STEP_UP * 2);
        }
        else if (lc > load_high_threshold)
        {
            high_deb++;
            if (high_deb >= high_threshold_deb)
            {
                ecm3531_stepup_policy(CONFIG_DELTA_STEP_UP);
                high_deb = 0;
            }
        }
        else if (lc < load_very_low_threshold)
        {
            ecm3531_stepdown_policy((CONFIG_DELTA_STEP_DOWN * 2));
            low_deb = 0;
        }
        else if (lc < load_low_threshold)
        {
            low_deb++;
            if (low_deb >= low_threshold_deb)
            {
                ecm3531_stepdown_policy(CONFIG_DELTA_STEP_DOWN);
                low_deb = 0;
            }
        }
         else {
             low_deb = 0;
             high_deb = 0;
        }
        ecm3531_start_gov_timer(ecm3531_pg.tmr_period);
#ifdef CONFIG_PM_MON
	    send_mon_event(CPU_LOAD, lc);
#endif
    }
    else {
        tout = HalTmrRead(ecm3531_pg.ti);
        tout = (ecm3531_pg.stop_cnt - tout);
        ecm3531_pg.tmr_state = TIMER_RUN;
        HalTmrChangePeriod(ecm3531_pg.sPmTmr, tout);
        HalTmrStart(ecm3531_pg.sPmTmr);
    }
}
static void ecm3531_set_next_policy ( void ) { uint32_t tout ; int lc ; static uint8_t high_deb , low_deb ; lc = ecm3531_compute_load ( ) ; if ( lc >= 0 ) { if ( lc >= load_crit_high_threshold ) { ecm3531_stepup_policy ( CONFIG_DELTA_STEP_UP * 2 ) ; } else if ( lc > load_high_threshold ) { high_deb ++ ; if ( high_deb >= high_threshold_deb ) { ecm3531_stepup_policy ( CONFIG_DELTA_STEP_UP ) ; high_deb = 0 ; } } else if ( lc < load_very_low_threshold ) { ecm3531_stepdown_policy ( ( CONFIG_DELTA_STEP_DOWN * 2 ) ) ; low_deb = 0 ; } else if ( lc < load_low_threshold ) { low_deb ++ ; if ( low_deb >= low_threshold_deb ) { ecm3531_stepdown_policy ( CONFIG_DELTA_STEP_DOWN ) ; low_deb = 0 ; } } else { low_deb = 0 ; high_deb = 0 ; } ecm3531_start_gov_timer ( ecm3531_pg . tmr_period ) ; #ifdef CONFIG_PM_MON send_mon_event ( CPU_LOAD , lc ) ; #endif } else { tout = HalTmrRead ( ecm3531_pg . ti ) ; tout = ( ecm3531_pg . stop_cnt - tout ) ; ecm3531_pg . tmr_state = TIMER_RUN ; HalTmrChangePeriod ( ecm3531_pg . sPmTmr , tout ) ; HalTmrStart ( ecm3531_pg . sPmTmr ) ; } }
set next policy
  if load is computed decide next policy based on load
set next policy if load is computed decide next policy based on load
/*
     * this will return -ve value when time elaspe is
     * less then  DEF_TMR_PERIOD, minimum time for
     * load meaurement
     */ /*
         * measure load is greater then crit high threshold
         * bump up freq
         */ /*
         * measure load is greater then threshold
         * after debounce count, we need to bump up freq
         */ /*
         * load is very less step down with debounce
         */ /*
             * measure load is less then threshold
             * after debounce count, we need to reduce freq
             */ /* re start counter */ /*
     * time elaspe is  less then  DEF_TMR_PERIOD
     * we will reprogram timer with DEF_TMR_PERIOD - elapse
     * time and continue on last policy
     */ /* continue last cycle timer */ //ecm3531_set_policy(ecm3531_pg.curr_freq);