From f2934eead77af67c0294989fbee252f3b41e3f82 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 19 Nov 2008 17:09:43 +0000 Subject: add-resume-reason-sysfs.patch If you have U-Boot with uboot-add-find-wake-reason.patch, this patch will get you a wake reason report from cat /sys/devices/platform/neo1973-resume.0/resume_reason it looks like this: EINT00_ACCEL1 EINT01_GSM EINT02_BLUETOOTH EINT03_DEBUGBRD EINT04_JACK EINT05_WLAN EINT06_AUXKEY EINT07_HOLDKEY EINT08_ACCEL2 * EINT09_PMU adpins adprem usbins usbrem rtcalarm second onkeyr onkeyf exton1r exton1f exton2r exton2f exton3r exton3f * batfull chghalt thlimon thlimoff usblimon usblimoff adcrdy onkey1s lowsys lowbat hightmp autopwrfail dwn1pwrfail dwn2pwrfail ledpwrfail ledovp ldo1pwrfail ldo2pwrfail ldo3pwrfail ldo4pwrfail ldo5pwrfail ldo6pwrfail hcidopwrfail hcidoovl EINT10_NULL EINT11_NULL EINT12_GLAMO EINT13_NULL EINT14_NULL EINT15_NULL This shows a problem, false wake from suspend due to battery full Signed-off-by: Andy Green --- drivers/i2c/chips/pcf50633.c | 80 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'drivers/i2c/chips/pcf50633.c') diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c index da58aa326ad..d2ff2c156e8 100644 --- a/drivers/i2c/chips/pcf50633.c +++ b/drivers/i2c/chips/pcf50633.c @@ -120,6 +120,8 @@ struct pcf50633_data { int allow_close; int onkey_seconds; int irq; + int have_been_suspended; + unsigned char pcfirq_resume[5]; int coldplug_done; /* cleared by probe, set by first work service */ int flag_bat_voltage_read; /* ipc to /sys batt voltage read func */ @@ -597,6 +599,17 @@ static void pcf50633_work(struct work_struct *work) return; } + /* hey did we just resume? */ + + if (pcf->have_been_suspended) { + pcf->have_been_suspended = 0; + /* + * grab a copy of resume interrupt reasons + * from pcf50633 POV + */ + memcpy(pcf->pcfirq_resume, pcfirq, sizeof(pcf->pcfirq_resume)); + } + if (!pcf->coldplug_done) { DEBUGP("PMU Coldplug init\n"); @@ -1856,6 +1869,71 @@ static int pcf50633_detach_client(struct i2c_client *client) return 0; } +/* you're going to need >300 bytes in buf */ + +int pcf50633_report_resumers(struct pcf50633_data *pcf, char *buf) +{ + static char *int_names[] = { + "adpins", + "adprem", + "usbins", + "usbrem", + NULL, + NULL, + "rtcalarm", + "second", + + "onkeyr", + "onkeyf", + "exton1r", + "exton1f", + "exton2r", + "exton2f", + "exton3r", + "exton3f", + + "batfull", + "chghalt", + "thlimon", + "thlimoff", + "usblimon", + "usblimoff", + "adcrdy", + "onkey1s", + + "lowsys", + "lowbat", + "hightmp", + "autopwrfail", + "dwn1pwrfail", + "dwn2pwrfail", + "ledpwrfail", + "ledovp", + + "ldo1pwrfail", + "ldo2pwrfail", + "ldo3pwrfail", + "ldo4pwrfail", + "ldo5pwrfail", + "ldo6pwrfail", + "hcidopwrfail", + "hcidoovl" + }; + char *end = buf; + int n; + + for (n = 0; n < 40; n++) + if (int_names[n]) { + if (pcf->pcfirq_resume[n >> 3] & (1 >> (n & 7))) + end += sprintf(end, " * %s\n", int_names[n]); + else + end += sprintf(end, " %s\n", int_names[n]); + } + + return end - buf; +} + + #ifdef CONFIG_PM #define INT1M_RESUMERS (PCF50633_INT1_ADPINS | \ PCF50633_INT1_ADPREM | \ @@ -1938,6 +2016,8 @@ static int pcf50633_suspend(struct device *dev, pm_message_t state) __reg_write(pcf, PCF50633_REG_INT4M, ~INT4M_RESUMERS & 0xff); __reg_write(pcf, PCF50633_REG_INT5M, ~INT5M_RESUMERS & 0xff); + pcf->have_been_suspended = 1; + mutex_unlock(&pcf->lock); return 0; -- cgit v1.2.3