關于2440的電源管理調試出現(xiàn)過的問題以及解決方法:
1、系統(tǒng)睡眠與喚醒,拿到普通的代碼,出現(xiàn)的問題經常是進入睡眠后,GPIO喚醒總是導致系統(tǒng)重新啟動,其實這是因為沒有設置CPU的運行模式,而這運行模式是通過設置GPG13,GPG14,GPG15來進行的。所以就要想喚醒后恢復到睡眠之前的狀態(tài),則要在進入睡眠前設置這三個GPIO的模式,可以在arch/arm/plat-s3c24xx/pm.c文件中的s3c2410_pm_enter()中在進入誰面前,也就是執(zhí)行__raw_writel(0x00, S3C2410_CLKCON)前加入如下三條語句:
__raw_writel(__raw_readl(S3C2410_EINTPEND), S3C2410_EINTPEND);
__raw_writel(__raw_readl(S3C2410_INTPND), S3C2410_INTPND);
__raw_writel(__raw_readl(S3C2410_SRCPND), S3C2410_SRCPND);
即可使系統(tǒng)恢復正常。
附:
我修改的s3c2410_pm_enter函數(shù)如下:
static int s3c2410_pm_enter(suspend_state_t state)
{
unsigned long regs_save[16];
int tmp;
/* ensure the debug is initialised (if enabled) */
s3c2410_pm_debug_init();
DBG("s3c2410_pm_enter(%d)n", state);
/* our board doesn't support hard disk.*/
if (state != PM_SUSPEND_MEM) {
printk(KERN_ERR PFX "error: only PM_SUSPEND_MEM supportedn");
return -EINVAL;
}
if (pm_cpu_prep == NULL || pm_cpu_sleep == NULL) {
printk(KERN_ERR PFX "error: no cpu sleep functions setn");
return -EINVAL;
}
/* configure pin GPF4 for wake-up */
//enable_irq_wake(IRQ_EINT4);
//s3c2410_gpio_cfgpin(S3C2410_GPF4,S3C2410_GPF4_EINT4);
//set_irq_type(IRQ_EINT4, IRQT_BOTHEDGE);
tmp = __raw_readl(S3C2410_EINTMASK);
tmp &= ~(1UL<<4);
__raw_writel(tmp,S3C2410_EINTMASK);
s3c2410_gpio_cfgpin(S3C2410_GPG13,S3C2410_GPG13_INP);//tfirst
s3c2410_gpio_cfgpin(S3C2410_GPG14,S3C2410_GPG14_INP);//tfirst
s3c2410_gpio_cfgpin(S3C2410_GPG15,S3C2410_GPG15_INP);//tfirst
/* check if we have anything to wake-up with... bad things seem
* to happen if you suspend with no wakeup (system will often
* require a full power-cycle)
*/
if (!any_allowed(s3c_irqwake_intmask, s3c_irqwake_intallow) &&
!any_allowed(s3c_irqwake_eintmask, s3c_irqwake_eintallow)) {
printk(KERN_ERR PFX "No sources enabled for wake-up!n");
printk(KERN_ERR PFX "Aborting sleepn");
return -EINVAL;
}
/* prepare check area if configured */
s3c2410_pm_check_prepare();
/* set USB pad as suspend mode ,tfirst add ,2009-05-27 */
__raw_writel(__raw_readl(S3C2410_MISCCR) | (3<<12),S3C2410_MISCCR);
/* store the physical address of the register recovery block */
s3c2410_sleep_save_phys = virt_to_phys(regs_save);
DBG("s3c2410_sleep_save_phys=0x%08lxn", s3c2410_sleep_save_phys);
/* save resume address */
__raw_writel(virt_to_phys(s3c2410_cpu_resume), S3C2410_GSTATUS3);
/*clear the General Status Registers reg 2*/
__raw_writel(0xff,S3C2410_GSTATUS2);
/* save all necessary core registers not covered by the drivers */
s3c2410_pm_do_save(misc_save, ARRAY_SIZE(misc_save));
s3c2410_pm_do_save(gpio_save, ARRAY_SIZE(gpio_save));
s3c2410_pm_do_save(core_save, ARRAY_SIZE(core_save));
s3c2410_pm_do_save(uart_save, ARRAY_SIZE(uart_save));
/* set the irq configuration for wake */
s3c2410_pm_configure_extint();
DBG("sleep: irq wakeup masks: %08lx,%08lxn",
s3c_irqwake_intmask, s3c_irqwake_eintmask);
__raw_writel(s3c_irqwake_intmask, S3C2410_INTMSK);
__raw_writel(s3c_irqwake_eintmask, S3C2410_EINTMASK);
/* ack any outstanding external interrupts before we go to sleep */
__raw_writel(__raw_readl(S3C2410_EINTPEND), S3C2410_EINTPEND);
__raw_writel(__raw_readl(S3C2410_INTPND), S3C2410_INTPND);
__raw_writel(__raw_readl(S3C2410_SRCPND), S3C2410_SRCPND);
/* call cpu specific preparation */
pm_cpu_prep();
/* flush cache back to ram */
flush_cache_all();
s3c2410_pm_check_store();
/* send the cpu to sleep... */
__raw_writel(0x00, S3C2410_CLKCON); /* turn off clocks over sleep */
/* s3c2410_cpu_save will also act as our return point from when
* we resume as it saves its own register state, so use the return
* code to differentiate return from save and return from sleep */
if (s3c2410_cpu_save(regs_save) == 0) {
flush_cache_all();
pm_cpu_sleep();
}
/* restore the cpu state */
cpu_init();
/*unset the return-from-sleep flag, to ensure reset */
tmp = __raw_readl(S3C2410_GSTATUS2);
tmp |= S3C2410_GSTATUS2_OFFRESET;
__raw_writel(tmp, S3C2410_GSTATUS2);
/* restore the system state */
s3c2410_pm_do_restore_core(core_save, ARRAY_SIZE(core_save));
s3c2410_pm_do_restore(misc_save, ARRAY_SIZE(misc_save));//
s3c2410_pm_do_restore(gpio_save, ARRAY_SIZE(gpio_save));
s3c2410_pm_do_restore(uart_save, ARRAY_SIZE(uart_save));
s3c2410_pm_debug_init();
/* check what irq (if any) restored the system */
DBG("post sleep: IRQs 0x%08x, 0x%08xn",
__raw_readl(S3C2410_SRCPND),
__raw_readl(S3C2410_EINTPEND));
s3c2410_pm_show_resume_irqs(IRQ_EINT0, __raw_readl(S3C2410_SRCPND),
s3c_irqwake_intmask);
s3c2410_pm_show_resume_irqs(IRQ_EINT4-4, __raw_readl(S3C2410_EINTPEND),
s3c_irqwake_eintmask);
DBG("post sleep, preparing to returnn");
s3c2410_pm_check_restore();
/* ok, let's return from sleep */
dump_irq_reg();
DBG("S3C2410 PM Resume (post-restore)n");
return 0;
}
2、在調試的過程中,出現(xiàn)過系統(tǒng)無法進入睡眠的情況。情況大概是串口終端已經進入睡眠了,系統(tǒng)停止了,但是用精密電源去測,發(fā)現(xiàn)電流還是沒有下降,通過跟蹤,才知道系統(tǒng)逐個調用各個驅動的suspend,按照s3c2410-ts.c原來提供的驅動結構:
static struct platform_driver s3c2410ts_driver = {
.name = "s3c2410-ts",
.bus = &platform_bus_type,
.probe = s3c2410ts_probe,
.remove = s3c2410ts_remove,
};
,系統(tǒng)無法使得觸摸品進入睡眠,至于什么原因,不是很理解,將驅動的系統(tǒng)注冊接口改為如下:
static struct platform_driver s3c2410ts_driver= {
.probe= s3c2410ts_probe,
.remove= s3c2410ts_remove,
.suspend= s3c2410ts_suspend,
.resume= s3c2410ts_resume,
.driver= {
.name= "s3c2410-ts",
.owner= THIS_MODULE,
},
};
系統(tǒng)就可以進入睡眠了。
3.在調試的過程中,還出現(xiàn)過跟LCD喚醒相關的問題。主要就是兩個問題
一個問題是,在喚醒LCD之后,LCD會花屏。原以為拿到的這個代碼已經做好了睡眠/喚醒,看了代碼才發(fā)現(xiàn),這個代碼在睡眠之前,沒有保存LCD的設置,在喚醒之后是重新初始化LCD的控制器,所以會出現(xiàn)花屏的現(xiàn)象,所以自己重新實現(xiàn)了s3c2410fb_suspend和s3c2410fb_resume兩個函數(shù),代碼如下:
static int s3c2410fb_suspend(struct platform_device *dev, pm_message_t state)
{
struct fb_info *fbinfo = platform_get_drvdata(dev);
struct s3c2410fb_info *info = fbinfo->par;
unsigned long flags;
s3c2410fb_stop_lcd(info);
local_irq_save(flags);
lcdcon1 = readl(info->io + S3C2410_LCDCON1);
lcdcon2 = readl(info->io + S3C2410_LCDCON2);
lcdcon3 = readl(info->io + S3C2410_LCDCON3);
lcdcon4 = readl(info->io + S3C2410_LCDCON4);
lcdcon5 = readl(info->io + S3C2410_LCDCON5);
lcdsaddr1 = readl(info->io + S3C2410_LCDSADDR1);
lcdsaddr2 = readl(info->io + S3C2410_LCDSADDR2);
lcdsaddr3 = readl(info->io + S3C2410_LCDSADDR3);
redlut = readl(info->io + S3C2410_REDLUT);
greenlut = readl(info->io + S3C2410_GREENLUT);
bluelut = readl(info->io + S3C2410_BLUELUT);
dithmode = readl(info->io + S3C2410_DITHMODE);
tpal = readl(info->io + S3C2410_TPAL);
lcdintpnd = readl(info->io + S3C2410_LCDINTPND);
lcdsrcpnd = readl(info->io + S3C2410_LCDSRCPND);
lcdintmsk = readl(info->io + S3C2410_LCDINTMSK);
lpcsel = readl(info->io + S3C2410_LPCSEL);
lcdcon1 &= ~S3C2410_LCDCON1_ENVID;
local_irq_restore(flags);
/* sleep before disabling the clock, we need to ensure
* the LCD DMA engine is not going to get back on the bus
* before the clock goes off again (bjd) */
msleep(1);
clk_disable(info->clk);
/*
* shutdown the LCD power and backlight power
*/
s3c2410_gpio_setpin(S3C2410_GPG12, 0);
s3c2410_gpio_setpin(S3C2410_GPG4, 1);
return 0;
}
static int s3c2410fb_resume(struct platform_device *dev)
{
struct fb_info *fbinfo = platform_get_drvdata(dev);
struct s3c2410fb_info *info = fbinfo->par;
struct s3c2410fb_mach_info *mach_info = info->dev->platform_data;
unsigned long flags;
int i;
printk("=======framebuffer resume.=====n");
s3c2410_gpio_setpin(S3C2410_GPG4, 0);
msleep(10);
//s3c2410_gpio_setpin(S3C2410_GPG12, 1);
//msleep(10);