环境:
ARM CPU: S3C2416
Linux-Kernel: 3.6.0
针对S3C2416睡眠和唤醒的实现方法,参见上一篇:
从sys/power/state分析并实现S3C2416的睡眠和唤醒
本文分析S3C2416睡眠的底层实现,分两个部分:
1、CPU相关的实现过程
2、内核怎么把睡眠唤醒的功能加入
一、CPU相关的实现过程
S3C2416睡眠的寄存器设置在pm-s3c2416.c中(同色为调用关系)
arch/arm/mach-s3c24xx/pm-s3c2416.c
static int
s3c2416_cpu_suspend(unsigned long arg):使能睡眠功能,让CPU进入睡眠
{
/* enable wakeup sources regardless of battery state */
/* #define S3C2443_PWRCFG_SLEEP (1<<15) */
__raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG);
/* set the mode as sleep, 2BED represents "Go to BED" */
__raw_writel(0x2BED, S3C2443_PWRMODE);
s3c2412_sleep_enter();
panic("sleep resumed to originator?");
}
__raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG)函数将寄存器PWRCFG[15]位置1,开启睡眠唤醒源,如手册:
那么我们拓展一下,如果实现的不是睡眠模式,而是Deep-Stop模式,那就可以依样操作
寄存器PWRCFG
[16]位
至于第2个寄存器操作,对照datasheet,就可以明白;同样的,换个Power模式就操作相应的寄存器。
这里有一个
问题:Datasheet上说(位于
STOP mode (Normal and Deep-stop)小节)
To enter the Deep-STOP mode, PWRMODE[18] register should be configured before entering STOP mode.但是上图PWRMODE寄存器明显标明,PWRMODE[18]是“RESERVED”,尚未使用的。哪里来的BUG?
以上只是配置寄存器,进入睡眠在s3c2412_sleep_enter()函数中实现,该函数由汇编代码实现,在