From: Leo Yan <[email protected]> 6D (direction) detection interrupt can be used to report data when the device is moving into 6 predefined position, see http://www.st.com/stonline/products/literature/an/15136.htm section 5 for details.
With 6D detection enabled, user space app (like window manager which needs accelerometer data to do window rotation) doesn't need to periodically poll data. It can be blocked, once 6D detection interrupt happens, it can get the required data. Signed-off-by: Leo Yan <[email protected]> Signed-off-by: Hong Liu <[email protected]> --- arch/x86/kernel/mrst.c | 8 +++++++- drivers/hwmon/lis3lv02d.c | 18 +++++++++++++++++- drivers/hwmon/lis3lv02d.h | 6 ++++++ include/linux/lis3lv02d.h | 3 +++ 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/mrst.c b/arch/x86/kernel/mrst.c index 73e0206..f2ee138 100644 --- a/arch/x86/kernel/mrst.c +++ b/arch/x86/kernel/mrst.c @@ -791,7 +791,13 @@ static void *lis3dh_platform_data(void *info) .click_latency = 5, /* 5ms */ .click_window = 100, /* 100ms */ .click_thresh_x = 0x10, /* 0.25G: 0.25G/(2G/128) = 0x10 */ - .irq_cfg = LIS3_16B_IRQ1_CLICK, /* CLICK interrupt on INT1 */ + .wakeup_flags = LIS3_WAKEUP_X_LO | LIS3_WAKEUP_X_HI | + LIS3_WAKEUP_Y_LO | LIS3_WAKEUP_Y_HI | + LIS3_WAKEUP_Z_LO | LIS3_WAKEUP_Z_HI, + .wakeup_thresh = 0x10, /* 0.25G */ + .duration1 = 50, /* 50ms */ + .irq_cfg = LIS3_16B_IRQ1_CLICK | LIS3_16B_IRQ1_AOI1, + /* click and AOI1 interrupt on INT1 */ .setup_resources = lis3dh_setup_resources, .release_resources = lis3dh_release_resources, }; diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c index 314e7b9..e5a8232 100644 --- a/drivers/hwmon/lis3lv02d.c +++ b/drivers/hwmon/lis3lv02d.c @@ -382,12 +382,20 @@ static irqreturn_t lis302dl_interrupt_thread2_8b(int irq, void *data) static irqreturn_t lis3lv02d_16b_interrupt_thread(int irq, void *data) { struct lis3lv02d *lis3 = data; + u8 int1_src; if (lis3->pdata && (lis3->pdata->irq_cfg & LIS3_16B_IRQ1_CLICK)) { lis302dl_interrupt_handle_click(lis3); } + mutex_lock(&lis3->mutex); + lis3->read(lis3, INT1_SRC, &int1_src); + mutex_unlock(&lis3->mutex); + if (int1_src & INT1_IA) + lis3lv02d_joystick_poll(lis3->idev); + + return IRQ_HANDLED; } @@ -727,8 +735,16 @@ static void lis3lv02d_16b_configure(struct lis3lv02d *dev, input_set_capability(input_dev, EV_KEY, BTN_Z); } } + + if (p->wakeup_flags) { + dev->write(dev, INT1_THS, p->wakeup_thresh); + dev->write(dev, INT1_DURATION, p->duration1); + } + /* setup INT1_CFG register, */ - dev->write(dev, INT1_CFG, INT1_ZH | INT1_YH | INT1_XH); + dev->write(dev, INT1_CFG, INT1_6D | + INT1_ZH | INT1_ZL | + INT1_YH | INT1_YL | INT1_XH | INT1_XL); } static int lis3lv02d_init_8(struct lis3lv02d *lis3) diff --git a/drivers/hwmon/lis3lv02d.h b/drivers/hwmon/lis3lv02d.h index fd835e1..6cad944 100644 --- a/drivers/hwmon/lis3lv02d.h +++ b/drivers/hwmon/lis3lv02d.h @@ -99,10 +99,16 @@ enum lis3dh_reg { CTRL4_BDU = 0x80, CTRL4_HR = 0x08, INT1_CFG = 0x30, + INT1_AOI = (1 << 7), + INT1_6D = (1 << 6), INT1_ZH = (1 << 5), + INT1_ZL = (1 << 4), INT1_YH = (1 << 3), + INT1_YL = (1 << 2), INT1_XH = (1 << 1), + INT1_XL = (1 << 0), INT1_SRC = 0x31, + INT1_IA = (1 << 6), INT1_THS = 0x32, INT1_DURATION = 0x33, /* CLICK_SRC = 0x39, */ diff --git a/include/linux/lis3lv02d.h b/include/linux/lis3lv02d.h index 98bddaa..4963bf3 100644 --- a/include/linux/lis3lv02d.h +++ b/include/linux/lis3lv02d.h @@ -35,9 +35,12 @@ struct lis3lv02d_platform_data { #define LIS3_IRQ2_MASK (7 << 3) #define LIS3_IRQ_OPEN_DRAIN (1 << 6) #define LIS3_IRQ_ACTIVE_LOW (1 << 7) +/* lis3dh IRQ1 config flags */ +#define LIS3_16B_IRQ1_AOI1 (1 << 6) #define LIS3_16B_IRQ1_CLICK (1 << 7) unsigned char irq_cfg; + unsigned char duration1; #define LIS3_WAKEUP_X_LO (1 << 0) #define LIS3_WAKEUP_X_HI (1 << 1) #define LIS3_WAKEUP_Y_LO (1 << 2) -- 1.7.2.3 _______________________________________________ MeeGo-kernel mailing list [email protected] http://lists.meego.com/listinfo/meego-kernel
