|
From: <hap...@us...> - 2007-01-31 18:52:39
|
Revision: 786
http://svn.sourceforge.net/hackndev/?rev=786&view=rev
Author: happy-slapin
Date: 2007-01-31 10:52:36 -0800 (Wed, 31 Jan 2007)
Log Message:
-----------
z72: Preparations for delayed resume
Modified Paths:
--------------
linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/palmz72_pm.c
Modified: linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/palmz72_pm.c
===================================================================
--- linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/palmz72_pm.c 2007-01-30 12:54:28 UTC (rev 785)
+++ linux4palm/linux/trunk/arch/arm/mach-pxa/palmz72/palmz72_pm.c 2007-01-31 18:52:36 UTC (rev 786)
@@ -24,11 +24,15 @@
#include <asm/arch/pxa-regs.h>
#include <asm/arch/palmz72-gpio.h>
+#include <asm/arch/pxa27x_keyboard.h>
+#define KPASMKP(col) (col/2==0 ? KPASMKP0 : col/2==1 ? KPASMKP1 : col/2==2 ? KPASMKP2 : KPASMKP3)
+#define KPASMKPx_MKC(row, col) (1 << (row + 16*(col%2)))
+
struct pm_save_data
{
int brightness;
- u32 jiffies;
+ u32 rcnr;
};
static struct pm_save_data pm_save_data;
@@ -36,24 +40,25 @@
#ifdef CONFIG_PM
static int palmz72_suspend(struct device *dev, pm_message_t state)
{
- /* Wake-Up on Voice memo button - GPIO 13 */
- PWER |= PWER_GPIO13 | PWER_RTC | PWER_WEP1;
+ /* Wake-Up on RTC event, etc. */
+ PWER |= PWER_RTC | PWER_WEP1;
/* Wakeup by keyboard :) */
- PKWR |= 0xe0000;
+ PKWR = 0xe0001;
- PRER |= PWER_GPIO13;
/* Enabled Deep-Sleep mode ?? */
PCFR |= PCFR_DS;
/* Low power mode */
PCFR |= PCFR_OPDE;
+
+ /* 3.6.8.1 */
+ while(!(OSCC & OSCC_OOK))
+ {}
/* Here are all of special for suspend PalmOne Zire 72 */
//printk("Palmz72_suspend: suspending...");
- SET_PALMZ72_GPIO(LED, 0);
-
/* Turn off LCD power */
SET_PALMZ72_GPIO(LCD_POWER,0);
/* Turn off USB power */
@@ -83,8 +88,6 @@
/* Turn on USB power */
SET_PALMZ72_GPIO(USB_POWER,1);
- SET_PALMZ72_GPIO(LED, 1);
-
return 0;
}
#else
@@ -108,41 +111,83 @@
.resume = palmz72_pxa_ll_pm_resume,
};
-static int (*pxa_pm_enter)(suspend_state_t state);
+static int (*pxa_pm_enter_orig)(suspend_state_t state);
+#define KBD_ROWS 4
+#define KBD_COLS 3
+#if 0
+static int check_buttons(void)
+{
+ int data = 0, row, col;
+ u32 storekpc = KPC;
+
+ data = GET_GPIO(GPIO_NR_PALMZ72_KP_DKIN7) && 1;
+
+ pxa_set_cken(CKEN19_KEYPAD, 1);
-static void zire72_goto_sleep(suspend_state_t state)
-{
- pxa_pm_enter(state);
+ KPC |= KBD_ROWS << 26;
+ KPC |= KBD_COLS << 23;
+
+ KPC &= ~(KPC_ASACT|KPC_AS|KPC_IMKP|KPC_DE|KPC_DIE|KPC_MIE);
+
+ /* Processing automatic scan once */
+ KPC |= KPC_ME | KPC_AS;
+
+ for (row=0; row < KBD_ROWS; row++) {
+ for (col=0; col < KBD_COLS; col++) {
+ data |= (KPASMKP(col) & KPASMKPx_MKC(row, col) && 1) << 2;
+ }
+ }
+
+
+// pxa_set_cken(CKEN19_KEYPAD, 0);
+ KPC = storekpc;
+ return data;
}
-
+#endif
static int zire72_enter_suspend(suspend_state_t state)
{
/* Here we should implement wakeup conditions
If we have none, just return 1 to continue
sleeping */
- if(PKSR & 0x00001) {
- printk(KERN_NOTICE "Returning from sleep due to GPIO13\n");
- return 0;
- }
- if(jiffies < ( pm_save_data.jiffies + msecs_to_jiffies(5000))) {
- if(!(PKSR & 0xe0001))
- pm_save_data.jiffies = jiffies;
- zire72_goto_sleep(state);
+ int data = 0;
+
+ /* Do not suspend on active keypress */
+#if 0
+ if(check_buttons())
return 1;
+#endif
+ pxa_pm_enter_orig(state);
+
+#if 0
+ if(!pm_save_data.rcnr) pm_save_data.rcnr = RCNR;
+ while(RCNR < ( pm_save_data.rcnr + 3)) {
+
+ /* If we release button, sleep back */
+ if(!(data = check_buttons())) {
+ pm_save_data.rcnr = 0;
+ return 1;
+ }
}
- if(PKSR & 0xe0001) {
- printk(KERN_NOTICE "Returning from sleep due to GPIOs 100-102 or 13\n");
- return 0;
- }
- return 1;
+#endif
+ printk(KERN_NOTICE "Returning from sleep due to GPIOs 100-102 or 13\n");
+ printk(KERN_NOTICE "RCNR = %u pm_save_data.rcnr = %u\n", RCNR, pm_save_data.rcnr);
+ printk(KERN_NOTICE "Keys pressed: %d\n", data);
+ pm_save_data.rcnr = 0;
+ return 0;
}
static int zire72_pxa_pm_enter(suspend_state_t state)
{
- pm_save_data.jiffies = jiffies;
- zire72_goto_sleep(state);
+ pm_save_data.rcnr = 0;
+#if 0
+ /* Do not suspend on active keypress */
+ if(check_buttons())
+ return 0;
+#endif
+ pxa_pm_enter_orig(state);
+
while (zire72_enter_suspend(state))
{}
return 0;
@@ -160,9 +205,6 @@
static int palmz72_pm_probe(struct device *dev)
{
- pm_save_data.jiffies = jiffies;
- pxa_pm_enter = pxa_pm_ops.enter;
- pm_set_ops(&zire72_pm_ops);
printk(KERN_NOTICE "PalmOne Zire72 power management driver registered\n");
return 0;
}
@@ -177,18 +219,20 @@
static int __init palmz72_pm_init(void)
{
+ pxa_pm_enter_orig = pxa_pm_ops.enter;
+ pxa_pm_ops.enter = zire72_pxa_pm_enter;
return driver_register(&palmz72_pm_driver);
}
static void __exit palmz72_pm_exit(void)
{
- pxa_pm_ops.enter = pxa_pm_enter;
+ pxa_pm_ops.enter = pxa_pm_enter_orig;
driver_unregister(&palmz72_pm_driver);
}
module_init(palmz72_pm_init);
module_exit(palmz72_pm_exit);
-MODULE_AUTHOR("Jan Herman <2h...@se...>");
+MODULE_AUTHOR("Jan Herman <2h...@se...>, Sergey Lapin <sla...@gm...>");
MODULE_DESCRIPTION("PalmOne Zire 72 power management driver");
MODULE_LICENSE("GPL");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|