MTK zephyr平台:系统休眠流程
一、概述:
当内核没有需要调度的东西时,就会进入空闲状态。
CONFIG_PM=y时允许内核调用PM subsys,将空闲系统置于支持的电源状态之一。
Application负责设置唤醒事件,该事件通常是由SoC外围模块触发的中断,例如:
SysTick、RTC、计数器、GPIO
并非所有外设在所有电源模式下都处于活动状态,因此不是所有唤醒源都可以在任何电源模式下对系统进行唤醒
相关代码目录如下,主要关注TFA和Zephyr:
Item | Path |
---|---|
Preloader | mtk\modules\hal\boot\preloader\platform\mt6813\src\drivers\spm |
TFA | mtk\modules\hal\boot\tf-a-2.8\mtk\plat\mediatek\mt6813\drivers\spm mtk\modules\hal\boot\tf-a-2.8\mtk\plat\mediatek\mt6813\include\drivers\spm mtk\modules\hal\boot\tf-a-2.8\mtk\plat\mediatek\drivers\spm mtk\modules\hal\boot\tf-a-2.8\mtk\plat\mediatek\drivers\pm mtk\modules\hal\boot\tf-a-2.8\mtk\plat\mediatek\include\pm |
LK | mtk\modules\hal\boot\Lk\platform\mediatek\common\spm mtk\modules\hal\boot\Lk\platform\mediatek\mt6813\include\platform |
Zephyr | mtk\modules\hal\drivers\lpm mtk\modules\hal\subsys\pm zephyr\subsys\pm zephyr\kernel\idle.c |
二、modem侧
modem在idle状态下会自动进入休眠,且modem支持不进入飞行模式的休眠,比如寻呼休眠等。modem休眠唤醒完全由modem控制,AP不做处理,暂不关注。
三、休眠流程
在MTK文档中有如下图示描述:
Upon entry into Zephyr, if the scheduler selects the idle task, the process of entering sleep mode will be automatically initiated by the MT6813.
- Zephyr ldle Process: The driver is notified to enter sleep processing, and then PSCI (SYSTEM_SUSPEND) is called.
- TFA PSCI Lib: Executes the system suspend process and notifies the SPM driver.
- TFA SPM Driver: Sets the behavior of SPM to suspend.
- T