diff options
author | Daniel Mack <daniel@caiaq.de> | 2009-09-21 20:04:43 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-09-22 10:17:48 -0400 |
commit | 8873c33483e62988ed886230aab71ef4c678f710 (patch) | |
tree | 441cdc48497b84c823330241ecff147642e136a4 | |
parent | 0ec48915e8bbb37dea3df85c41e4c3498b95664b (diff) |
lis3: add free-fall/wakeup function via platform_data
This offers a way for platforms to define flags and thresholds for the
free-fall/wakeup functions of the lis302d chips.
More registers needed to be seperated as they are specific to the
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Acked-by: Pavel Machek <pavel@ucw.cz>
Cc: Eric Piel <eric.piel@tremplin-utc.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/hwmon/lis3lv02d.c | 9 | ||||
-rw-r--r-- | drivers/hwmon/lis3lv02d.h | 24 | ||||
-rw-r--r-- | include/linux/lis3lv02d.h | 9 |
3 files changed, 36 insertions, 6 deletions
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c index 271338bdb6be..cf5afb9a10ab 100644 --- a/drivers/hwmon/lis3lv02d.c +++ b/drivers/hwmon/lis3lv02d.c | |||
@@ -454,6 +454,15 @@ int lis3lv02d_init_device(struct lis3lv02d *dev) | |||
454 | (p->click_thresh_y << 4)); | 454 | (p->click_thresh_y << 4)); |
455 | } | 455 | } |
456 | 456 | ||
457 | if (p->wakeup_flags && (dev->whoami == LIS_SINGLE_ID)) { | ||
458 | dev->write(dev, FF_WU_CFG_1, p->wakeup_flags); | ||
459 | dev->write(dev, FF_WU_THS_1, p->wakeup_thresh & 0x7f); | ||
460 | /* default to 2.5ms for now */ | ||
461 | dev->write(dev, FF_WU_DURATION_1, 1); | ||
462 | /* enable high pass filter for both free-fall units */ | ||
463 | dev->write(dev, CTRL_REG2, HP_FF_WU1 | HP_FF_WU2); | ||
464 | } | ||
465 | |||
457 | if (p->irq_cfg) | 466 | if (p->irq_cfg) |
458 | dev->write(dev, CTRL_REG3, p->irq_cfg); | 467 | dev->write(dev, CTRL_REG3, p->irq_cfg); |
459 | } | 468 | } |
diff --git a/drivers/hwmon/lis3lv02d.h b/drivers/hwmon/lis3lv02d.h index e320e2f511f1..3e1ff46f72d3 100644 --- a/drivers/hwmon/lis3lv02d.h +++ b/drivers/hwmon/lis3lv02d.h | |||
@@ -58,15 +58,17 @@ enum lis3_reg { | |||
58 | OUTZ_L = 0x2C, | 58 | OUTZ_L = 0x2C, |
59 | OUTZ_H = 0x2D, | 59 | OUTZ_H = 0x2D, |
60 | OUTZ = 0x2D, | 60 | OUTZ = 0x2D, |
61 | FF_WU_CFG = 0x30, | ||
62 | FF_WU_SRC = 0x31, | ||
63 | FF_WU_ACK = 0x32, | ||
64 | FF_WU_THS_L = 0x34, | ||
65 | FF_WU_THS_H = 0x35, | ||
66 | FF_WU_DURATION = 0x36, | ||
67 | }; | 61 | }; |
68 | 62 | ||
69 | enum lis302d_reg { | 63 | enum lis302d_reg { |
64 | FF_WU_CFG_1 = 0x30, | ||
65 | FF_WU_SRC_1 = 0x31, | ||
66 | FF_WU_THS_1 = 0x32, | ||
67 | FF_WU_DURATION_1 = 0x33, | ||
68 | FF_WU_CFG_2 = 0x34, | ||
69 | FF_WU_SRC_2 = 0x35, | ||
70 | FF_WU_THS_2 = 0x36, | ||
71 | FF_WU_DURATION_2 = 0x37, | ||
70 | CLICK_CFG = 0x38, | 72 | CLICK_CFG = 0x38, |
71 | CLICK_SRC = 0x39, | 73 | CLICK_SRC = 0x39, |
72 | CLICK_THSY_X = 0x3B, | 74 | CLICK_THSY_X = 0x3B, |
@@ -77,6 +79,12 @@ enum lis302d_reg { | |||
77 | }; | 79 | }; |
78 | 80 | ||
79 | enum lis3lv02d_reg { | 81 | enum lis3lv02d_reg { |
82 | FF_WU_CFG = 0x30, | ||
83 | FF_WU_SRC = 0x31, | ||
84 | FF_WU_ACK = 0x32, | ||
85 | FF_WU_THS_L = 0x34, | ||
86 | FF_WU_THS_H = 0x35, | ||
87 | FF_WU_DURATION = 0x36, | ||
80 | DD_CFG = 0x38, | 88 | DD_CFG = 0x38, |
81 | DD_SRC = 0x39, | 89 | DD_SRC = 0x39, |
82 | DD_ACK = 0x3A, | 90 | DD_ACK = 0x3A, |
@@ -107,6 +115,10 @@ enum lis3lv02d_ctrl2 { | |||
107 | CTRL2_FS = 0x80, /* Full Scale selection */ | 115 | CTRL2_FS = 0x80, /* Full Scale selection */ |
108 | }; | 116 | }; |
109 | 117 | ||
118 | enum lis302d_ctrl2 { | ||
119 | HP_FF_WU2 = 0x08, | ||
120 | HP_FF_WU1 = 0x04, | ||
121 | }; | ||
110 | 122 | ||
111 | enum lis3lv02d_ctrl3 { | 123 | enum lis3lv02d_ctrl3 { |
112 | CTRL3_CFS0 = 0x01, | 124 | CTRL3_CFS0 = 0x01, |
diff --git a/include/linux/lis3lv02d.h b/include/linux/lis3lv02d.h index 113778b5df36..3cc2f2c53e4c 100644 --- a/include/linux/lis3lv02d.h +++ b/include/linux/lis3lv02d.h | |||
@@ -34,6 +34,15 @@ struct lis3lv02d_platform_data { | |||
34 | #define LIS3_IRQ_OPEN_DRAIN (1 << 6) | 34 | #define LIS3_IRQ_OPEN_DRAIN (1 << 6) |
35 | #define LIS3_IRQ_ACTIVE_LOW (1 << 7) | 35 | #define LIS3_IRQ_ACTIVE_LOW (1 << 7) |
36 | unsigned char irq_cfg; | 36 | unsigned char irq_cfg; |
37 | |||
38 | #define LIS3_WAKEUP_X_LO (1 << 0) | ||
39 | #define LIS3_WAKEUP_X_HI (1 << 1) | ||
40 | #define LIS3_WAKEUP_Y_LO (1 << 2) | ||
41 | #define LIS3_WAKEUP_Y_HI (1 << 3) | ||
42 | #define LIS3_WAKEUP_Z_LO (1 << 4) | ||
43 | #define LIS3_WAKEUP_Z_HI (1 << 5) | ||
44 | unsigned char wakeup_flags; | ||
45 | unsigned char wakeup_thresh; | ||
37 | }; | 46 | }; |
38 | 47 | ||
39 | #endif /* __LIS3LV02D_H_ */ | 48 | #endif /* __LIS3LV02D_H_ */ |