diff options
author | Éric Piel <eric.piel@tremplin-utc.net> | 2009-12-14 21:01:39 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-15 11:53:36 -0500 |
commit | bc62c1471773fc32adcfc05100abd16fa2b6e126 (patch) | |
tree | 34894261672d0c73c01b46ed92ebad7eb75ea8c4 /drivers/hwmon | |
parent | 66c8569bf990064b3f11e0f211a81a46e0b627ff (diff) |
lis3: update documentation and comments
Most of the documentation and comments were written when the driver was
only supporting one type of chip, only via ACPI/HP. Update the info to
the much clearer understanding that we have now.
Signed-off-by: Éric Piel <eric.piel@tremplin-utc.net>
Signed-off-by: Samu Onkalo <samu.p.onkalo@nokia.com>
Cc: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/Kconfig | 22 | ||||
-rw-r--r-- | drivers/hwmon/lis3lv02d.c | 20 | ||||
-rw-r--r-- | drivers/hwmon/lis3lv02d.h | 28 |
3 files changed, 38 insertions, 32 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 9e640c62ebd9..95ccbe377f9c 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig | |||
@@ -1046,25 +1046,27 @@ config SENSORS_ATK0110 | |||
1046 | will be called asus_atk0110. | 1046 | will be called asus_atk0110. |
1047 | 1047 | ||
1048 | config SENSORS_LIS3LV02D | 1048 | config SENSORS_LIS3LV02D |
1049 | tristate "STMicroeletronics LIS3LV02Dx three-axis digital accelerometer" | 1049 | tristate "STMicroeletronics LIS3* three-axis digital accelerometer" |
1050 | depends on INPUT | 1050 | depends on INPUT |
1051 | select INPUT_POLLDEV | 1051 | select INPUT_POLLDEV |
1052 | select NEW_LEDS | 1052 | select NEW_LEDS |
1053 | select LEDS_CLASS | 1053 | select LEDS_CLASS |
1054 | default n | 1054 | default n |
1055 | help | 1055 | help |
1056 | This driver provides support for the LIS3LV02Dx accelerometer. In | 1056 | This driver provides support for the LIS3* accelerometers, such as the |
1057 | particular, it can be found in a number of HP laptops, which have the | 1057 | LIS3LV02DL or the LIS331DL. In particular, it can be found in a number |
1058 | "Mobile Data Protection System 3D" or "3D DriveGuard" feature. On such | 1058 | of HP laptops, which have the "Mobile Data Protection System 3D" or |
1059 | systems the driver should load automatically (via ACPI). The | 1059 | "3D DriveGuard" feature. On such systems the driver should load |
1060 | accelerometer might also be found in other systems, connected via SPI | 1060 | automatically (via ACPI alias). The accelerometer might also be found |
1061 | or I2C. The accelerometer data is readable via | 1061 | in other systems, connected via SPI or I2C. The accelerometer data is |
1062 | /sys/devices/platform/lis3lv02d. | 1062 | readable via /sys/devices/platform/lis3lv02d. |
1063 | 1063 | ||
1064 | This driver also provides an absolute input class device, allowing | 1064 | This driver also provides an absolute input class device, allowing |
1065 | the laptop to act as a pinball machine-esque joystick. On HP laptops, | 1065 | a laptop to act as a pinball machine-esque joystick. It provides also |
1066 | a misc device which can be used to detect free-fall. On HP laptops, | ||
1066 | if the led infrastructure is activated, support for a led indicating | 1067 | if the led infrastructure is activated, support for a led indicating |
1067 | disk protection will be provided as hp:red:hddprotection. | 1068 | disk protection will be provided as hp::hddprotect. For more |
1069 | information on the feature, refer to Documentation/hwmon/lis3lv02d. | ||
1068 | 1070 | ||
1069 | This driver can also be built as modules. If so, the core module | 1071 | This driver can also be built as modules. If so, the core module |
1070 | will be called lis3lv02d and a specific module for HP laptops will be | 1072 | will be called lis3lv02d and a specific module for HP laptops will be |
diff --git a/drivers/hwmon/lis3lv02d.c b/drivers/hwmon/lis3lv02d.c index dbd0b055d4b9..1c8f10817e69 100644 --- a/drivers/hwmon/lis3lv02d.c +++ b/drivers/hwmon/lis3lv02d.c | |||
@@ -43,7 +43,7 @@ | |||
43 | #define MDPS_POLL_INTERVAL 50 | 43 | #define MDPS_POLL_INTERVAL 50 |
44 | /* | 44 | /* |
45 | * The sensor can also generate interrupts (DRDY) but it's pretty pointless | 45 | * The sensor can also generate interrupts (DRDY) but it's pretty pointless |
46 | * because their are generated even if the data do not change. So it's better | 46 | * because they are generated even if the data do not change. So it's better |
47 | * to keep the interrupt for the free-fall event. The values are updated at | 47 | * to keep the interrupt for the free-fall event. The values are updated at |
48 | * 40Hz (at the lowest frequency), but as it can be pretty time consuming on | 48 | * 40Hz (at the lowest frequency), but as it can be pretty time consuming on |
49 | * some low processor, we poll the sensor only at 20Hz... enough for the | 49 | * some low processor, we poll the sensor only at 20Hz... enough for the |
@@ -65,7 +65,7 @@ static s16 lis3lv02d_read_8(struct lis3lv02d *lis3, int reg) | |||
65 | return lo; | 65 | return lo; |
66 | } | 66 | } |
67 | 67 | ||
68 | static s16 lis3lv02d_read_16(struct lis3lv02d *lis3, int reg) | 68 | static s16 lis3lv02d_read_12(struct lis3lv02d *lis3, int reg) |
69 | { | 69 | { |
70 | u8 lo, hi; | 70 | u8 lo, hi; |
71 | 71 | ||
@@ -411,20 +411,20 @@ EXPORT_SYMBOL_GPL(lis3lv02d_remove_fs); | |||
411 | 411 | ||
412 | /* | 412 | /* |
413 | * Initialise the accelerometer and the various subsystems. | 413 | * Initialise the accelerometer and the various subsystems. |
414 | * Should be rather independant of the bus system. | 414 | * Should be rather independent of the bus system. |
415 | */ | 415 | */ |
416 | int lis3lv02d_init_device(struct lis3lv02d *dev) | 416 | int lis3lv02d_init_device(struct lis3lv02d *dev) |
417 | { | 417 | { |
418 | dev->whoami = lis3lv02d_read_8(dev, WHO_AM_I); | 418 | dev->whoami = lis3lv02d_read_8(dev, WHO_AM_I); |
419 | 419 | ||
420 | switch (dev->whoami) { | 420 | switch (dev->whoami) { |
421 | case LIS_DOUBLE_ID: | 421 | case WAI_12B: |
422 | printk(KERN_INFO DRIVER_NAME ": 2-byte sensor found\n"); | 422 | printk(KERN_INFO DRIVER_NAME ": 12 bits sensor found\n"); |
423 | dev->read_data = lis3lv02d_read_16; | 423 | dev->read_data = lis3lv02d_read_12; |
424 | dev->mdps_max_val = 2048; | 424 | dev->mdps_max_val = 2048; |
425 | break; | 425 | break; |
426 | case LIS_SINGLE_ID: | 426 | case WAI_8B: |
427 | printk(KERN_INFO DRIVER_NAME ": 1-byte sensor found\n"); | 427 | printk(KERN_INFO DRIVER_NAME ": 8 bits sensor found\n"); |
428 | dev->read_data = lis3lv02d_read_8; | 428 | dev->read_data = lis3lv02d_read_8; |
429 | dev->mdps_max_val = 128; | 429 | dev->mdps_max_val = 128; |
430 | break; | 430 | break; |
@@ -445,7 +445,7 @@ int lis3lv02d_init_device(struct lis3lv02d *dev) | |||
445 | if (dev->pdata) { | 445 | if (dev->pdata) { |
446 | struct lis3lv02d_platform_data *p = dev->pdata; | 446 | struct lis3lv02d_platform_data *p = dev->pdata; |
447 | 447 | ||
448 | if (p->click_flags && (dev->whoami == LIS_SINGLE_ID)) { | 448 | if (p->click_flags && (dev->whoami == WAI_8B)) { |
449 | dev->write(dev, CLICK_CFG, p->click_flags); | 449 | dev->write(dev, CLICK_CFG, p->click_flags); |
450 | dev->write(dev, CLICK_TIMELIMIT, p->click_time_limit); | 450 | dev->write(dev, CLICK_TIMELIMIT, p->click_time_limit); |
451 | dev->write(dev, CLICK_LATENCY, p->click_latency); | 451 | dev->write(dev, CLICK_LATENCY, p->click_latency); |
@@ -456,7 +456,7 @@ int lis3lv02d_init_device(struct lis3lv02d *dev) | |||
456 | (p->click_thresh_y << 4)); | 456 | (p->click_thresh_y << 4)); |
457 | } | 457 | } |
458 | 458 | ||
459 | if (p->wakeup_flags && (dev->whoami == LIS_SINGLE_ID)) { | 459 | if (p->wakeup_flags && (dev->whoami == WAI_8B)) { |
460 | dev->write(dev, FF_WU_CFG_1, p->wakeup_flags); | 460 | dev->write(dev, FF_WU_CFG_1, p->wakeup_flags); |
461 | dev->write(dev, FF_WU_THS_1, p->wakeup_thresh & 0x7f); | 461 | dev->write(dev, FF_WU_THS_1, p->wakeup_thresh & 0x7f); |
462 | /* default to 2.5ms for now */ | 462 | /* default to 2.5ms for now */ |
diff --git a/drivers/hwmon/lis3lv02d.h b/drivers/hwmon/lis3lv02d.h index 3e1ff46f72d3..2431c5199534 100644 --- a/drivers/hwmon/lis3lv02d.h +++ b/drivers/hwmon/lis3lv02d.h | |||
@@ -2,7 +2,7 @@ | |||
2 | * lis3lv02d.h - ST LIS3LV02DL accelerometer driver | 2 | * lis3lv02d.h - ST LIS3LV02DL accelerometer driver |
3 | * | 3 | * |
4 | * Copyright (C) 2007-2008 Yan Burman | 4 | * Copyright (C) 2007-2008 Yan Burman |
5 | * Copyright (C) 2008 Eric Piel | 5 | * Copyright (C) 2008-2009 Eric Piel |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
@@ -22,20 +22,18 @@ | |||
22 | #include <linux/input-polldev.h> | 22 | #include <linux/input-polldev.h> |
23 | 23 | ||
24 | /* | 24 | /* |
25 | * The actual chip is STMicroelectronics LIS3LV02DL or LIS3LV02DQ that seems to | 25 | * This driver tries to support the "digital" accelerometer chips from |
26 | * be connected via SPI. There exists also several similar chips (such as LIS302DL or | 26 | * STMicroelectronics such as LIS3LV02DL, LIS302DL, LIS3L02DQ, LIS331DL, |
27 | * LIS3L02DQ) and they have slightly different registers, but we can provide a | 27 | * LIS35DE, or LIS202DL. They are very similar in terms of programming, with |
28 | * common interface for all of them. | 28 | * almost the same registers. In addition to differing on physical properties, |
29 | * They can also be connected via I²C. | 29 | * they differ on the number of axes (2/3), precision (8/12 bits), and special |
30 | * features (freefall detection, click...). Unfortunately, not all the | ||
31 | * differences can be probed via a register. | ||
32 | * They can be connected either via I²C or SPI. | ||
30 | */ | 33 | */ |
31 | 34 | ||
32 | #include <linux/lis3lv02d.h> | 35 | #include <linux/lis3lv02d.h> |
33 | 36 | ||
34 | /* 2-byte registers */ | ||
35 | #define LIS_DOUBLE_ID 0x3A /* LIS3LV02D[LQ] */ | ||
36 | /* 1-byte registers */ | ||
37 | #define LIS_SINGLE_ID 0x3B /* LIS[32]02DL and others */ | ||
38 | |||
39 | enum lis3_reg { | 37 | enum lis3_reg { |
40 | WHO_AM_I = 0x0F, | 38 | WHO_AM_I = 0x0F, |
41 | OFFSET_X = 0x16, | 39 | OFFSET_X = 0x16, |
@@ -94,6 +92,12 @@ enum lis3lv02d_reg { | |||
94 | DD_THSE_H = 0x3F, | 92 | DD_THSE_H = 0x3F, |
95 | }; | 93 | }; |
96 | 94 | ||
95 | enum lis3_who_am_i { | ||
96 | WAI_12B = 0x3A, /* 12 bits: LIS3LV02D[LQ]... */ | ||
97 | WAI_8B = 0x3B, /* 8 bits: LIS[23]02D[LQ]... */ | ||
98 | WAI_6B = 0x52, /* 6 bits: LIS331DLF - not supported */ | ||
99 | }; | ||
100 | |||
97 | enum lis3lv02d_ctrl1 { | 101 | enum lis3lv02d_ctrl1 { |
98 | CTRL1_Xen = 0x01, | 102 | CTRL1_Xen = 0x01, |
99 | CTRL1_Yen = 0x02, | 103 | CTRL1_Yen = 0x02, |
@@ -194,7 +198,7 @@ struct lis3lv02d { | |||
194 | int (*write) (struct lis3lv02d *lis3, int reg, u8 val); | 198 | int (*write) (struct lis3lv02d *lis3, int reg, u8 val); |
195 | int (*read) (struct lis3lv02d *lis3, int reg, u8 *ret); | 199 | int (*read) (struct lis3lv02d *lis3, int reg, u8 *ret); |
196 | 200 | ||
197 | u8 whoami; /* 3Ah: 2-byte registries, 3Bh: 1-byte registries */ | 201 | u8 whoami; /* indicates measurement precision */ |
198 | s16 (*read_data) (struct lis3lv02d *lis3, int reg); | 202 | s16 (*read_data) (struct lis3lv02d *lis3, int reg); |
199 | int mdps_max_val; | 203 | int mdps_max_val; |
200 | 204 | ||