Read APIC regiters to track source wakeups
authorAxel Haslam <axelx.haslam@intel.com>
Fri, 17 Feb 2012 14:02:33 +0000 (15:02 +0100)
committerbuildbot <buildbot@intel.com>
Fri, 24 Feb 2012 13:09:00 +0000 (05:09 -0800)
BZ: 23525

Read Interrupt Request Register form apic to track
wakeups that are not from GPIO. This helps us log
wakeups from sources like power button, alarm, and
headset plug.

Change-Id: I4e9ea82541e2e56e39d5de1d761fa9b89656ea7b
Signed-off-by: Axel Haslam <axelx.haslam@intel.com>
Reviewed-on: http://android.intel.com:8080/36068
Reviewed-by: Mansoor, Illyas <illyas.mansoor@intel.com>
Reviewed-by: Fiat, Christophe <christophe.fiat@intel.com>
Tested-by: Cuesta, FernandX <fernandx.cuesta@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
arch/x86/platform/intel-mid/mfld-pmu.c

index b6fbe7b..e39a6ed 100644 (file)
@@ -889,6 +889,28 @@ static int pmu_send_set_config_command(union pmu_pm_set_cfg_cmd_t
        return 0;
 }
 
+static void log_wakeup_irq(void)
+{
+       unsigned int irr = 0, vector = 0;
+       int offset = 0, irq = 0;
+       for (offset = (FIRST_EXTERNAL_VECTOR/32);
+                       offset < (NR_VECTORS/32); offset++) {
+               irr = apic_read(APIC_IRR + (offset * 0x10));
+               while (irr) {
+                       vector = __ffs(irr);
+                       irr &= ~(1 << vector);
+
+                       irq = __this_cpu_read(
+                               vector_irq[vector + (offset * 32)]);
+                       if (irq < 0)
+                               continue;
+
+                       pr_info("wakeup from  IRQ %d\n", irq);
+               }
+       }
+       return;
+}
+
 /* return the last wake source id, and make statistics about wake sources */
 static int pmu_get_wake_source(void)
 {
@@ -931,7 +953,7 @@ static int pmu_get_wake_source(void)
                        pr_info("wakeup from HSI.\n");
                        break;
                default:
-                       pr_info("wakeup from OTHER.\n");
+                       log_wakeup_irq();
                }
 
        return source;