Exemple #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
}
Exemple #2
0
static void idle_after_wfi(int cpu)
{
#ifdef CONFIG_SMP
		log_idle(cpu,"-");
#endif
#ifdef PROFILE_IDLE
    idle_tick_pos[cpu] = GPT_GetCounter(GPT2);

    if (idle_profile_mask & (0x1 << cpu)) {
#ifdef CONFIG_LOCAL_TIMERS
        dcm_info("[%s:cpu%d]%5d %10u %10u %10u\n", __func__, cpu, 
                idle_profile_idx[cpu], idle_tick_pre[cpu],
                idle_tick_pos[cpu], idle_counter[cpu]);
#else
        dcm_info("[%s:cpu%d]%5d %10u %10u %10u %10u\n", __func__, cpu, 
                idle_profile_idx[cpu], idle_tick_pre[cpu], 
                idle_tick_pos[cpu], idle_counter[cpu], idle_compare[cpu]);
#endif
        idle_profile_idx[cpu]++;
    }
#endif

    idle_count[cpu]++;
    if ((dpidle_debug_mask & DEBUG_TRACING)) {
        idle_single_count[cpu]++;
    }
}
Exemple #3
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;
}
Exemple #4
0
void sc_dpidle_before_wfi(void)
{
#if 0
    /* keep CA9 clock frequency when WFI to sleep */
    topmisc = DRV_Reg32(TOP_MISC);
    DRV_WriteReg32(TOP_MISC, (topmisc & ~(1U << 0)));
#endif
    
    if (unlikely(get_chip_eco_ver() == CHIP_E1)) {        
		DRV_ClrReg32(WPLL_CON0, 0x1);
    } else {
        if (!(clk_mgr.subsys_state & 0x30) && clk_mgr.mmsys_state) {
            mm_clk_pll2sq();
            DRV_SetReg16(MDPLL_CON0, 0x1);
            mmsys_switched_off = 1;
        }
    }

#ifndef CONFIG_LOCAL_TIMERS
    if (mmsys_switched_off) {
        dpidle_compare_update = dpidle_compare - dpidle_counter - 260;
    } else {
        dpidle_compare_update = dpidle_compare - dpidle_counter;
    }

    gpt_set_next_compare(dpidle_compare_update);
#endif

#ifdef CONFIG_LOCAL_WDT
    wdt_counter_pre = mpcore_wdt_get_counter();
    wdt_tick_pre = GPT_GetCounter(GPT2);
#endif

#ifdef PROFILE_DPIDLE
    dpidle_tick_mid = GPT_GetCounter(GPT2);
#endif
}
Exemple #5
0
static ssize_t dpidle_state_store(struct kobject *kobj, struct kobj_attribute *attr,const char *buf, size_t n)
{
    char command[32];
#ifdef PROFILE_IDLE
    char sec_cmd[32];
    int i = 0;
#endif
    int temp;

#ifdef PROFILE_IDLE
    if (sscanf(buf, "%s %s %x", command, sec_cmd, &temp) == 3) {
        if (!strcmp(command, "profile")) {
            if (!strcmp(sec_cmd, "on")) {
                idle_profile_mask |= temp;
                for (i = 0; i < nr_cpu_ids; i++) {
                    //memset(idle_profile_idx, 0, NR_CPUS * sizeof(int));
                    if (temp & (0x1 << i)) { 
                        idle_profile_idx[i] = 0;
                    }
                }
            } else if (!strcmp(sec_cmd, "off")) {
                idle_profile_mask &= ~temp;
            }
        }
        printk("[test]idle_profile_mask=0x%x\n", idle_profile_mask);
    } else
#endif
    if (sscanf(buf, "%s %d", command, &temp) == 2) {
        if (!strcmp(command, "idle")) {
            idle_switch = temp;
        } else if (!strcmp(command, "dpidle")) {
            dpidle_switch = temp;
        } else if (!strcmp(command, "level")) {
			if (unlikely(temp < 0 || temp > 2)) {
				dcm_warn("[%s]invalid dpidle_level %d\n", __func__, temp);
			} else {
	            dpidle_level = (unsigned int)temp;
			}
        } else if (!strcmp(command, "time")) {
            dpidle_time_critera = temp;
        } else if (!strcmp(command, "enable")) {
            enable_dpidle_by_bit(temp);
        } else if (!strcmp(command, "disable")) {
            disable_dpidle_by_bit(temp);
        } else if (!strcmp(command, "enable_hi")) {
            enable_hispeed_by_bit(temp);
        } else if (!strcmp(command, "disable_hi")) {
            disable_hispeed_by_bit(temp);
        } else if (!strcmp(command, "trace")) {
            if (temp == 1) {
                memset(idle_single_count, 0, NR_CPUS * sizeof(unsigned int));
                dpidle_single_count = 0;
                dpidle_cm_block_cnt = 0;
                dpidle_sc_block_cnt = 0;
                dpidle_block_interval = 0;
                memset(dpidle_block_mask, 0, MT65XX_CLOCK_CATEGORY_COUNT * sizeof(unsigned int));
                dpidle_debug_mask |= DEBUG_TRACING;
            } else if (temp == 0) {
                dpidle_debug_mask &= ~DEBUG_TRACING;
            }
        } else if (!strcmp(command, "timer")) {
            timer_delay = temp;
            timer_pre = GPT_GetCounter(GPT2);
            udelay(timer_delay);
            timer_pos = GPT_GetCounter(GPT2);
#ifdef PROFILE_DPIDLE
        } else if (!strcmp(command, "profile")) {
            if (temp == 1) {
                dpidle_debug_mask |= DEBUG_PROFILE;
                dpidle_profile_idx = 0;
            } else if (temp == 0) {
                dpidle_debug_mask &= ~DEBUG_PROFILE;
            }
#endif
        }
        return n;
    } else if (sscanf(buf, "%x", &temp) == 1) {
        dpidle_switch = temp;
        return n;
    }

    return -EINVAL;
}
Exemple #6
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++;
    }
}