在把休眠的2440通过外部中断唤醒后,运行其他命令会出现大量类似提示:
**>> yaffs chunk 12352 was not erased
**>> yaffs chunk 12353 was not erased
**>> yaffs chunk 12354 was not erased
**>> yaffs chunk 12355 was not erased
**>> yaffs chunk 12356 was not erased
**>> yaffs chunk 12357 was not erased
**>> yaffs chunk 12358 was not erased
**>> yaffs chunk 12359 was not erased
**>> yaffs chunk 12360 was not erased
**>> yaffs chunk 12361 was not erased
**>> yaffs chunk 12362 was not erased
**>> yaffs chunk 12363 was not erased
**>> yaffs chunk 12364 was not erased
这是由于nandflash驱动程序没有suspend、resume函数,造成休眠、唤醒过程中没有保存NAND FLASH控制器的寄存器状态。
应该在drivers/mtd/nand/s3c2410.c中添加suspend、resume函数 如下:
*add by cefanty 2006-10-26 to support PM*/
*add by cefanty 2006-10-26 to support PM*/
#ifdef CONFIG_PM
static int s3c24xx_nand_suspend(struct platform_device *pdev, pm_message_t pmsg)
{
struct s3c2410_nand_info *info = platform_get_drvdata(pdev);
if (info) {
if (!allow_clk_stop(info))
clk_disable(info->clk);
}
return 0;
}
static int s3c24xx_nand_resume(struct platform_device *pdev)
{
struct s3c2410_nand_info *info = platform_get_drvdata(pdev);
if (info) {
clk_enable(info->clk);
s3c2410_nand_inithw(info, pdev);
if (allow_clk_stop(info))
clk_disable(info->clk);
}
return 0;
}
#else
#define s3c24xx_nand_suspend NULL
#define s3c24xx_nand_resume NULL
#endif
static struct platform_driver s3c2410_nand_driver = {
.probe = s3c2410_nand_probe,
.remove = s3c2410_nand_remove,
.suspend = s3c24xx_nand_suspend,
.resume = s3c24xx_nand_resume,
.driver = {
.name = "s3c2410-nand",
.owner = THIS_MODULE,
},
};
在resume函数中会调用s3c2410_nand_inithw函数重新初始化nandflash寄存器如下:
static int s3c2410_nand_inithw(struct s3c2410_nand_info *info,
struct platform_device *pdev)
{
struct s3c2410_platform_nand *plat = to_nand_plat(pdev);
unsigned long clkrate = clk_get_rate(info->clk);
int tacls_max = (info->cpu_type == TYPE_S3C2412) ? 8 : 4;
int tacls, twrph0, twrph1;
unsigned long cfg = 0;
/* calculate the timing information for the controller */
clkrate /= 1000; /* turn clock into kHz for ease of use */
if (plat != NULL) {
tacls = s3c_nand_calc_rate(plat->tacls, clkrate, tacls_max);
twrph0 = s3c_nand_calc_rate(plat->twrph0, clkrate, 8);
twrph1 = s3c_nand_calc_rate(plat->twrph1, clkrate, 8);
} else {
/* default timings */
tacls = tacls_max;
twrph0 = 8;
twrph1 = 8;
}
if (tacls < 0 || twrph0 < 0 || twrph1 < 0) {
dev_err(info->device, "cannot get suitable timings/n");
return -EINVAL;
}
dev_info(info->device, "Tacls=%d, %dns Twrph0=%d %dns, Twrph1=%d %dns/n",
tacls, to_ns(tacls, clkrate), twrph0, to_ns(twrph0, clkrate), twrph1, to_ns(twrph1, clkrate));
switch (info->cpu_type) {
case TYPE_S3C2410:
cfg = S3C2410_NFCONF_EN;
cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
cfg |= S3C2410_NFCONF_TWRPH0(twrph0 - 1);
cfg |= S3C2410_NFCONF_TWRPH1(twrph1 - 1);
break;
case TYPE_S3C2440:
case TYPE_S3C2412:
cfg = S3C2440_NFCONF_TACLS(tacls - 1);
cfg |= S3C2440_NFCONF_TWRPH0(twrph0 - 1);
cfg |= S3C2440_NFCONF_TWRPH1(twrph1 - 1);
/* enable the controller and de-assert nFCE */
writel(S3C2440_NFCONT_ENABLE, info->regs + S3C2440_NFCONT);
}
dev_dbg(info->device, "NF_CONF is 0x%lx/n", cfg);
writel(cfg, info->regs + S3C2410_NFCONF);
return 0;
}
其中 writel(S3C2440_NFCONT_ENABLE, info->regs + S3C2440_NFCONT);一句很重要
我一开始就因为没发现少了这句代码才一直做不对。
添加上这句代码后 就可以正常休眠/唤醒了。