summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/lis3lv02d.c
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2009-06-17 00:34:17 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-17 04:47:57 +0200
commit8f3128e714ded7cf1e8c786c204a4f253b5d8ff4 (patch)
treecb3c1e9df2da5e4817acfeb75284e8d7b92eae33 /drivers/hwmon/lis3lv02d.c
parentlis3: add three new laptop models (diff)
downloadlinux-8f3128e714ded7cf1e8c786c204a4f253b5d8ff4.tar.xz
linux-8f3128e714ded7cf1e8c786c204a4f253b5d8ff4.zip
lis3: add click function
The LIS302DL accelerometer chip has a 'click' feature which can be used to detect sudden motion on any of the three axis. Configuration data is passed via spi platform_data and no action is taken if that's not specified, so it won't harm any existing platform. To make the configuration effective, the IRQ lines need to be set up appropriately. This patch also adds a way to do that from board support code. The DD_* definitions were factored out to an own enum because they are specific to LIS3LV02D devices. Signed-off-by: Daniel Mack <daniel@caiaq.de> Acked-by: Pavel Machek <pavel@ucw.cz> Acked-by: 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>
Diffstat (limited to 'drivers/hwmon/lis3lv02d.c')
-rw-r--r--drivers/hwmon/lis3lv02d.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c
index 366190609c73..271338bdb6be 100644
--- a/drivers/hwmon/lis3lv02d.c
+++ b/drivers/hwmon/lis3lv02d.c
@@ -438,6 +438,26 @@ int lis3lv02d_init_device(struct lis3lv02d *dev)
if (lis3lv02d_joystick_enable())
printk(KERN_ERR DRIVER_NAME ": joystick initialization failed\n");
+ /* passing in platform specific data is purely optional and only
+ * used by the SPI transport layer at the moment */
+ if (dev->pdata) {
+ struct lis3lv02d_platform_data *p = dev->pdata;
+
+ if (p->click_flags && (dev->whoami == LIS_SINGLE_ID)) {
+ dev->write(dev, CLICK_CFG, p->click_flags);
+ dev->write(dev, CLICK_TIMELIMIT, p->click_time_limit);
+ dev->write(dev, CLICK_LATENCY, p->click_latency);
+ dev->write(dev, CLICK_WINDOW, p->click_window);
+ dev->write(dev, CLICK_THSZ, p->click_thresh_z & 0xf);
+ dev->write(dev, CLICK_THSY_X,
+ (p->click_thresh_x & 0xf) |
+ (p->click_thresh_y << 4));
+ }
+
+ if (p->irq_cfg)
+ dev->write(dev, CTRL_REG3, p->irq_cfg);
+ }
+
/* bail if we did not get an IRQ from the bus layer */
if (!dev->irq) {
printk(KERN_ERR DRIVER_NAME