summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsravan <sravan@mindtribe.com>2015-07-27 19:53:23 -0700
committerEvan Wilson <evan@oliodevices.com>2015-08-07 12:53:29 -0700
commit520faa59b2288d97379977b7863a7b3543ad2438 (patch)
treea5dc551fc9b9fa2d23a978efb766d87a1a12926c
parentfb2a8e4a7820040a7968731cf679c5a8e13cd17b (diff)
downloadolio-linux-3.10-520faa59b2288d97379977b7863a7b3543ad2438.tar.xz
olio-linux-3.10-520faa59b2288d97379977b7863a7b3543ad2438.zip
Checking the wakeup reason to get around the ST IMU not latching tap interrupts
Signed-off-by: Evan Wilson <evan@oliodevices.com> Change-Id: Iebe64b4c5de646f408fff0431d17d79ea9692e1f
-rw-r--r--drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_trigger.c6
-rw-r--r--include/linux/wakeup_reason.h2
-rw-r--r--kernel/power/wakeup_reason.c26
3 files changed, 33 insertions, 1 deletions
diff --git a/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_trigger.c b/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_trigger.c
index 2e7af62ed47..9fe257039bb 100644
--- a/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_trigger.c
+++ b/drivers/iio/imu/st_lsm6ds3/st_lsm6ds3_trigger.c
@@ -19,6 +19,7 @@
#include <linux/interrupt.h>
#include <linux/iio/events.h>
#include <linux/wakelock.h>
+#include <linux/wakeup_reason.h>
#include "st_lsm6ds3.h"
@@ -69,11 +70,14 @@ static void st_lsm6ds3_irq_management(struct work_struct *data_work)
u8 src_value = 0x00, src_fifo = 0x00;
u8 d6d_event = 0;
u8 tap_event = 0;
+ int wake_irq;
cdata = container_of((struct work_struct *)data_work,
struct lsm6ds3_data, data_work);
+ wake_irq = last_wakeup_reason_test(cdata->irq);
+
if(!wake_lock_active(&cdata->wlock))
wake_lock(&cdata->wlock);
mutex_lock(&cdata->fifo_lock);
@@ -107,7 +111,7 @@ static void st_lsm6ds3_irq_management(struct work_struct *data_work)
dev_info(cdata->dev, "Ignoring tap");
}
}
- if(cdata->first_irq_from_resume){
+ if(cdata->first_irq_from_resume && wake_irq){
dev_info(cdata->dev, "First IRQ from a RESUME");
if(!d6d_event && !tap_event){
dev_info(cdata->dev, "No event from first resume, assuming lost TAP");
diff --git a/include/linux/wakeup_reason.h b/include/linux/wakeup_reason.h
index 7ce50f0debc..b58723ab7c7 100644
--- a/include/linux/wakeup_reason.h
+++ b/include/linux/wakeup_reason.h
@@ -19,5 +19,7 @@
#define _LINUX_WAKEUP_REASON_H
void log_wakeup_reason(int irq);
+int get_last_wakeup_reason();
+int last_wakeup_reason_test(int reason);
#endif /* _LINUX_WAKEUP_REASON_H */
diff --git a/kernel/power/wakeup_reason.c b/kernel/power/wakeup_reason.c
index 9823d9ccde4..635ed61926c 100644
--- a/kernel/power/wakeup_reason.c
+++ b/kernel/power/wakeup_reason.c
@@ -63,6 +63,32 @@ static struct attribute_group attr_group = {
.attrs = attrs,
};
+
+
+int get_last_wakeup_reason()
+{
+ if(irq_count)
+ return irq_list[irq_count-1];
+ else
+ return -EINVAL;
+}
+
+int last_wakeup_reason_test(int reason)
+{
+ int irq_no;
+ unsigned long flags;
+ int ret = 0;
+ spin_lock_irqsave(&resume_reason_lock, flags);
+ for (irq_no = 0; irq_no < irq_count; irq_no++) {
+ if(reason == irq_list[irq_no]){
+ ret = 1;
+ break;
+ }
+ }
+ spin_unlock_irqrestore(&resume_reason_lock, flags);
+ return ret;
+}
+
/*
* logs all the wake up reasons to the kernel
* stores the irqs to expose them to the userspace via sysfs