コード例 #1
0
/**
 * syscore_suspend - Execute all the registered system core suspend callbacks.
 *
 * This function is executed with one CPU on-line and disabled interrupts.
 */
int syscore_suspend(void)
{
	struct syscore_ops *ops;
	int ret = 0;

	pr_info("Checking wakeup interrupts\n");

	/* Return error code if there are any wakeup interrupts pending. */
	ret = check_wakeup_irqs();
    /*FIH-SW3-KERNEL-JC-PM_Debug-02+[ */
    #ifdef CONFIG_FIH_SUSPEND_RESUME_LOG
	if (ret)
    {
        pr_info("[PM]check_wakeup_irqs retune 1. \n");
		return ret;
    }
    else
        pr_info("[PM]check_wakeup_irqs retune 0. \n");
    #else
    if (ret)
        return ret;
    #endif
    /*FIH-SW3-KERNEL-JC-PM_Debug-02+] */
    
	WARN_ONCE(!irqs_disabled(),
		"Interrupts enabled before system core suspend.\n");

	list_for_each_entry_reverse(ops, &syscore_ops_list, node)
		if (ops->suspend) {
        /*FIH-SW3-KERNEL-JC-Porting-02+[ */
        #ifndef CONFIG_FIH_SUSPEND_RESUME_LOG
			if (initcall_debug)
        #endif
        /*FIH-SW3-KERNEL-JC-Porting-02+] */
				pr_info("PM: Calling %pF\n", ops->suspend);
			ret = ops->suspend();
			if (ret)
				goto err_out;
			WARN_ONCE(!irqs_disabled(),
				"Interrupts enabled after %pF\n", ops->suspend);
		}

	return 0;

 err_out:
	pr_err("PM: System core suspend callback %pF failed.\n", ops->suspend);

	list_for_each_entry_continue(ops, &syscore_ops_list, node)
		if (ops->resume)
			ops->resume();

	return ret;
}
コード例 #2
0
ファイル: syscore.c プロジェクト: echobrad/bass_kernel
/**
 * syscore_suspend - Execute all the registered system core suspend callbacks.
 *
 * This function is executed with one CPU on-line and disabled interrupts.
 */
int syscore_suspend(void)
{
	struct syscore_ops *ops;
	int ret = 0;

	//trace_suspend_resume(TPS("syscore_suspend"), 0, true);
	pr_debug("Checking wakeup interrupts\n");

	/* Return error code if there are any wakeup interrupts pending. */
	ret = check_wakeup_irqs();
	if (ret)
		return ret;

	WARN_ONCE(!irqs_disabled(),
		"Interrupts enabled before system core suspend.\n");

	list_for_each_entry_reverse(ops, &syscore_ops_list, node)
		if (ops->suspend) {
			if (initcall_debug)
				pr_info("PM: Calling %pF\n", ops->suspend);
			ret = ops->suspend();
			if (ret)
				goto err_out;
			WARN_ONCE(!irqs_disabled(),
				"Interrupts enabled after %pF\n", ops->suspend);
		}

	//trace_suspend_resume(TPS("syscore_suspend"), 0, false);
	return 0;

 err_out:
	pr_err("PM: System core suspend callback %pF failed.\n", ops->suspend);

	list_for_each_entry_continue(ops, &syscore_ops_list, node)
		if (ops->resume)
			ops->resume();

	return ret;
}
コード例 #3
0
ファイル: pm.c プロジェクト: diguokaituozhe/XR871
/* power off whole system, save user data to flash before call this func.
 * BE SUURE: all hardware has been closed and it's prcm config setted to default value.
 * @type:0:shutdown, 1:reboot */
static void pm_power_off(pm_operate_t type)
{
	__record_dbg_status(PM_POWEROFF | 0);

	if (type == PM_REBOOT) {
		PM_REBOOT(); /* never return */
	}

#ifdef __CONFIG_ARCH_APP_CORE
	/* step 1 & 2 has been done when wlan sys poweroff */
	/* step3: writel(0x0f, GPRCM_SYS1_WAKEUP_CTRL) to tell PMU that turn on
	 * SW1, SW2, SRSW1, LDO before release application system reset signal. */
	HAL_PRCM_SetSys1WakeupPowerFlags(0x0f);
	__record_dbg_status(PM_POWEROFF | 5);

	/* step4: writel(0x0f, GPRCM_SYS1_SLEEP_CTRL) to tell PMU that turn off SW1,
	 * SW3 SRSW1, LDO after pull down application system reset signal. */
	HAL_PRCM_SetSys1SleepPowerFlags(0x0f);
	__record_dbg_status(PM_POWEROFF | 7);

	/* step5: switch to HOSC, close SYS1_CLK. */
	PM_SystemDeinit();
	__record_dbg_status(PM_POWEROFF | 9);

	/* step6: set nvic deepsleep flag, and enter wfe. */
	SCB->SCR = 0x14;
	PM_SetCPUBootFlag(0);

	__disable_fault_irq();
	__disable_irq();

	if (check_wakeup_irqs()) {
		PM_REBOOT();
	}

	wfe();
	if (check_wakeup_irqs()) {
		PM_REBOOT();
	}
	wfe();
	/* some irq generated when second wfe */
	PM_REBOOT();
	__record_dbg_status(PM_POWEROFF | 0x0ff);

#else /* net cpu */
	/* check wifi is closed by app? */
	PM_WARN_ON(HAL_PRCM_IsSys3Release());

	/* step1: cpu to switch to HOSC */
	HAL_PRCM_SetCPUNClk(PRCM_CPU_CLK_SRC_HFCLK, PRCM_SYS_CLK_FACTOR_80M);
	__record_dbg_status(PM_POWEROFF | 1);

	/* step2: turn off SYSCLK2. */
	HAL_PRCM_DisableSysClk2(PRCM_SYS_CLK_FACTOR_80M);
	__record_dbg_status(PM_POWEROFF | 3);
	PM_SystemDeinit();

	/* step3: enter WFI state */
	arch_suspend_disable_irqs();
	while (1)
		wfi();
	__record_dbg_status(PM_POWEROFF | 0x0ff);
#endif
}