lis3: introduce platform data for second ff / wu unit
authorSamu Onkalo <samu.p.onkalo@nokia.com>
Mon, 24 May 2010 21:33:35 +0000 (14:33 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 25 May 2010 15:07:06 +0000 (08:07 -0700)
8 bit device has two wakeup / free fall units.  It was not possible to
configure the second unit.  This patch introduces configuration entry to
the platform data and also corresponding changes to the 8 bit setup
function.

High pass filters were enabled by default.  Patch introduces configuration
option for high pass filter cut off frequency and also possibility to
disable or enable the filter via platform data.  Since the control is a
new one and default state was filter enabled, new option is used to
disable the filter.  This way old platform data is still compatible with
the change.

Signed-off-by: Samu Onkalo <samu.p.onkalo@nokia.com>
Acked-by: Eric Piel <eric.piel@tremplin-utc.net>
Tested-by: Daniel Mack <daniel@caiaq.de>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/hwmon/lis3lv02d.c
include/linux/lis3lv02d.h

index 99fd45deda4120233200a32c8344951b10537670..50f312339608fa1c33e3f8b655c173b1877892f3 100644 (file)
@@ -524,6 +524,8 @@ EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs);
 static void lis3lv02d_8b_configure(struct lis3lv02d *dev,
                                struct lis3lv02d_platform_data *p)
 {
+       int ctrl2 = p->hipass_ctrl;
+
        if (p->click_flags) {
                dev->write(dev, CLICK_CFG, p->click_flags);
                dev->write(dev, CLICK_TIMELIMIT, p->click_time_limit);
@@ -540,9 +542,18 @@ static void lis3lv02d_8b_configure(struct lis3lv02d *dev,
                dev->write(dev, FF_WU_THS_1, p->wakeup_thresh & 0x7f);
                /* default to 2.5ms for now */
                dev->write(dev, FF_WU_DURATION_1, 1);
-               /* enable high pass filter for both free-fall units */
-               dev->write(dev, CTRL_REG2, HP_FF_WU1 | HP_FF_WU2);
+               ctrl2 ^= HP_FF_WU1; /* Xor to keep compatible with old pdata*/
+       }
+
+       if (p->wakeup_flags2) {
+               dev->write(dev, FF_WU_CFG_2, p->wakeup_flags2);
+               dev->write(dev, FF_WU_THS_2, p->wakeup_thresh2 & 0x7f);
+               /* default to 2.5ms for now */
+               dev->write(dev, FF_WU_DURATION_2, 1);
+               ctrl2 ^= HP_FF_WU2; /* Xor to keep compatible with old pdata*/
        }
+       /* Configure hipass filters */
+       dev->write(dev, CTRL_REG2, ctrl2);
 }
 
 /*
index f1ca0dcc162877513d922ee69e3b9ee2465df1d8..d6251995c04286a42985157e648a2f4b87a609e7 100644 (file)
@@ -43,6 +43,15 @@ struct lis3lv02d_platform_data {
 #define LIS3_WAKEUP_Z_HI       (1 << 5)
        unsigned char wakeup_flags;
        unsigned char wakeup_thresh;
+       unsigned char wakeup_flags2;
+       unsigned char wakeup_thresh2;
+#define LIS3_HIPASS_CUTFF_8HZ   0
+#define LIS3_HIPASS_CUTFF_4HZ   1
+#define LIS3_HIPASS_CUTFF_2HZ   2
+#define LIS3_HIPASS_CUTFF_1HZ   3
+#define LIS3_HIPASS1_DISABLE    (1 << 2)
+#define LIS3_HIPASS2_DISABLE    (1 << 3)
+       unsigned char hipass_ctrl;
 #define LIS3_NO_MAP            0
 #define LIS3_DEV_X             1
 #define LIS3_DEV_Y             2