Example #1
0
static void idle_before_wfi(int cpu)
{
#ifdef PROFILE_IDLE
    idle_tick_pre[cpu] = GPT_GetCounter(GPT2);

#ifdef CONFIG_LOCAL_TIMERS
    idle_counter[cpu] = localtimer_get_counter();
#else
    idle_counter[cpu] = GPT_GetCounter(GPT1);
    idle_compare[cpu] = GPT_GetCompare(GPT1);	
#endif
#endif
}
Example #2
0
bool sc_dpidle_can_enter(void)
{
#ifdef PROFILE_IDLE
    dpidle_tick_pre = GPT_GetCounter(GPT2);
#endif

#ifdef CONFIG_LOCAL_TIMERS
    dpidle_counter = localtimer_get_counter();
    if (dpidle_counter >= dpidle_time_critera) { // 13000 => 1ms
        GPT_SetCompare(WAKEUP_GPT, dpidle_counter);
        GPT_Start(WAKEUP_GPT);
        dpidle_state = 1;
        return true; 
    }

    if (dpidle_debug_mask & DEBUG_TRACING) {
        if (dpidle_counter > dpidle_block_interval) {
            dpidle_block_interval = dpidle_counter;
        }
        dpidle_sc_block_cnt++;
    }
#else /* !SMP */
    dpidle_counter = GPT_GetCounter(GPT1);
    dpidle_compare = GPT_GetCompare(GPT1);

    if (dpidle_compare >= dpidle_counter + dpidle_time_critera) { // 13000 => 1ms
        dpidle_state = 1;
        return true; 
    }

    if (dpidle_debug_mask & DEBUG_TRACING) {
        unsigned int delta = dpidle_compare - dpidle_counter;
        if (delta > dpidle_block_interval) {
            dpidle_block_interval = delta;
        }
        dpidle_sc_block_cnt++;
    }
#endif

    dpidle_state = 0;
    return false;
}
Example #3
0
void sc_dpidle_after_wfi(void)
{
#ifdef PROFILE_DPIDLE
    dpidle_tick_pos = GPT_GetCounter(GPT2);
    dpidle_wakeup_src = DRV_Reg32(SC_WAKEUP_SRC);
    if (dpidle_debug_mask & DEBUG_PROFILE) {
#ifdef CONFIG_LOCAL_TIMERS
        dcm_info("[%s]%5d %10u %10u %10u %10u %08x\n", __func__, 
                dpidle_profile_idx, dpidle_tick_pre, dpidle_tick_mid, dpidle_tick_pos,
                dpidle_counter, dpidle_wakeup_src);
#else
        dcm_info("[%s]%5d %10u %10u %10u %10u %10u %10u %08x\n", __func__, 
                dpidle_profile_idx, dpidle_tick_pre, dpidle_tick_mid, dpidle_tick_pos,
                dpidle_counter, dpidle_compare, dpidle_compare_update, dpidle_wakeup_src);

#endif
        dpidle_profile_idx++;
    }
#endif

#ifdef CONFIG_LOCAL_WDT
    wdt_tick_pos = GPT_GetCounter(GPT2);
    if (wdt_counter_pre > (wdt_tick_pos - wdt_tick_pre)) {
        wdt_counter_pos = wdt_counter_pre - (wdt_tick_pos - wdt_tick_pre);
        mpcore_wdt_set_counter(wdt_counter_pos);
    } else {
        dcm_info("[%s]:wdt_counter_pre=%10lu, wdt_tick_pre=%10lu, wdt_tick_pos=%10lu\n", 
                __func__, wdt_counter_pre, wdt_tick_pre, wdt_tick_pos);
        mpcore_wdt_set_counter(1);
    }
#endif

#ifdef CONFIG_LOCAL_TIMERS
    if (GPT_Get_IRQ(WAKEUP_GPT)) {
        /* waked up by WAKEUP_GPT */
        localtimer_set_next_event(1);
    } else {
        /* waked up by other wakeup source */
        unsigned int temp1 = GPT_GetCompare(WAKEUP_GPT);
        unsigned int temp2 = GPT_GetCounter(WAKEUP_GPT);
        if (unlikely(temp1 <= temp2)) {
            dcm_err("[%s]GPT%d: counter = %10u, compare = %10u\n", __func__, temp1, temp2);
            BUG();
        }

        localtimer_set_next_event(temp1-temp2);
        GPT_Stop(WAKEUP_GPT);
        GPT_ClearCount(WAKEUP_GPT);
    }
#endif

    if (get_chip_eco_ver() == CHIP_E1) {
        DRV_SetReg32(WPLL_CON0, 0x1);        
    } else {
        if (mmsys_switched_off) {
            DRV_ClrReg16(MDPLL_CON0, 0x1);
            udelay(20);
            mm_clk_sq2pll();
            mmsys_switched_off = 0;
        }
    }   

#if 0
    /* restore TOP_MISC */
    DRV_WriteReg32(TOP_MISC, topmisc);
#endif

    dpidle_count++;
    if ((dpidle_debug_mask & DEBUG_TRACING)) {
        dpidle_single_count++;
    }
}