Beispiel #1
0
static int primary_cpu_enter_wfi(void *data)
{
#if 0
    int i = 0;
#endif
    unsigned int irqstat = 0;
    int cpu = *(int*)data;

    dcm_info("[%s]: thread idle-%d start\n", __func__, cpu);

#ifdef CONFIG_LOCAL_WDT
    mpcore_wk_wdt_stop();
#endif

    mt6577_irq_mask_all(&cpu_irq_mask[cpu]);
    mt6577_irq_unmask_for_sleep(MT6577_KP_IRQ_ID);

    dcm_info("[%s]: cpu%d waiting all threads done\n", __func__, cpu);
    complete(&each_thread_done[cpu]);
    wait_for_completion(&all_threads_done);
    local_irq_disable();
    dcm_info("[%s]: cpu%d before wfi\n", __func__, cpu);

#if 0
    do {
        go_to_idle();
        irqstat = DRV_Reg32(GIC_CPU_BASE + GIC_CPU_INTACK) & 0x3FF; 
        dcm_info("[%s]: cpu%d after wfi(irqstat:0x%x/%u)\n", __func__, cpu, irqstat, irqstat);
        if (irqstat == MT6577_KP_IRQ_ID) {
            break;
        }
    } while (1);
#else
    go_to_idle();
    irqstat = DRV_Reg32(GIC_CPU_BASE + GIC_CPU_INTACK) & 0x3FF; 
    dcm_info("[%s]: cpu%d after wfi(irqstat:0x%x/%u)\n", __func__, cpu, irqstat, irqstat);
#endif

    local_irq_enable();

    spin_lock(&factory_lock);
    mt6577_irq_mask_restore(&cpu_irq_mask[cpu]);
    spin_unlock(&factory_lock);

#if 0
    for (i = 1; i < nr_cpu_ids; i++) {
        wake_flag[i] = 1;
        smp_send_reschedule(i);
    }
#endif
    
#if defined(CONFIG_MTK_LEDS)
    mt65xx_leds_brightness_set(MT65XX_LED_TYPE_LCD, LED_FULL);
#endif

    dcm_info("[%s]: thread idle-%d end\n", __func__, cpu);
    return 0;
}
int local_wdt_enable(enum wk_wdt_en en)
{
	if(WK_WDT_EN ==en)
	{
		mpcore_wdt_restart(WD_TYPE_NORMAL);
	}
	if(WK_WDT_DIS==en)
	{
		mpcore_wk_wdt_stop();
	}
	return 0;
}
Beispiel #3
0
static int secondary_cpu_enter_wfi(void *data)
{
    int cpu = *(int*)data;
    unsigned int irqstat;

    dcm_info("[%s]: thread idle-%d start\n", __func__, cpu);

#ifdef CONFIG_LOCAL_WDT
    mpcore_wk_wdt_stop();
#endif

    mt6577_irq_mask_all(&cpu_irq_mask[cpu]);

    dcm_info("[%s]: cpu%d waiting all threads done\n", __func__, cpu);
    complete(&each_thread_done[cpu]);
    wait_for_completion(&all_threads_done);
    local_irq_disable();
    dcm_info("[%s]: cpu%d before wfi\n", __func__, cpu);

#if 0
    while (!wake_flag[cpu]) {
        go_to_idle();
        irqstat = DRV_Reg32(GIC_CPU_BASE + GIC_CPU_INTACK) & 0x3FF; 
        dcm_info("[%s]: cpu%d after wfi(irqstat:0x%x/%u)\n", __func__, cpu, irqstat, irqstat);
    }
#else
    go_to_idle();
    irqstat = DRV_Reg32(GIC_CPU_BASE + GIC_CPU_INTACK) & 0x3FF; 
    dcm_info("[%s]: cpu%d after wfi(irqstat:0x%x/%u)\n", __func__, cpu, irqstat, irqstat);
#endif

    local_irq_enable();

    spin_lock(&factory_lock);
    mt6577_irq_mask_restore(&cpu_irq_mask[cpu]);
    spin_unlock(&factory_lock);
    dcm_info("[%s]: thread idle-%d end\n", __func__, cpu);
    return 0;
}
Beispiel #4
0
void factory_cpu0_idle_test(void)
{
    int cpu = 0;
#ifdef CONFIG_SMP
    int i = 0;
    int ret = 0;
    int cpu_pwrdn_flag[nr_cpu_ids];
#endif

    spin_lock(&factory_lock);
    cpu = smp_processor_id();
    spin_unlock(&factory_lock);

    printk("[%s]it's cpu%d\n", __func__, cpu);

#ifdef CONFIG_SMP
    mutex_lock(&ftm_cpu_prepare);
    disable_hotplug_policy(true, nr_cpu_ids);
    memset(cpu_pwrdn_flag, 0, nr_cpu_ids * sizeof(int));
    for (i = 1; i < nr_cpu_ids; i++) {
        if (cpu_online(i)) {
            cpu_pwrdn_flag[i] = 1;
            ret = cpu_down(i);
            dcm_info("[%s]cpu_down(cpu%d) return %d, cpu1_killed=%u\n", __func__, i, ret, cpu1_killed);
        } else {
            dcm_info("[%s]no need to power down cpu%d\n", __func__, i);
        }
    }
    mutex_unlock(&ftm_cpu_prepare);
#endif

#ifdef CONFIG_LOCAL_WDT
    mpcore_wk_wdt_stop();
#endif
    mtk_wdt_disable(); // disable watch dog
    
    //this should be set by low power requirement.
#ifdef IDLE_LOW_POWER_TEST
    enable_low_power_settings();
#endif
    local_irq_disable();
    go_to_idle();
    local_irq_enable();
#ifdef IDLE_LOW_POWER_TEST
    disable_low_power_settings();
#endif

#ifdef CONFIG_SMP
    mutex_lock(&ftm_cpu_prepare);
    for (i = 1; i < nr_cpu_ids; i++) {
        if (cpu_pwrdn_flag[i] == 1) {
            ret = cpu_up(i);
            dcm_info("[%s]cpu_up(cpu%d) return %d, cpu1_killed=%u\n", __func__, i, ret, cpu1_killed);
        } else {
            dcm_info("[%s]no need to power up cpu%d\n", __func__, i);
        }
    }
    disable_hotplug_policy(false, nr_cpu_ids);
    mutex_unlock(&ftm_cpu_prepare);
#endif
}