diff options
-rw-r--r-- | Documentation/hwmon/lis3lv02d | 24 | ||||
-rw-r--r-- | drivers/hwmon/Kconfig | 22 | ||||
-rw-r--r-- | drivers/hwmon/lis3lv02d.c | 20 | ||||
-rw-r--r-- | drivers/hwmon/lis3lv02d.h | 28 |
4 files changed, 52 insertions, 42 deletions
diff --git a/Documentation/hwmon/lis3lv02d b/Documentation/hwmon/lis3lv02d index effe949a7282..21f090252209 100644 --- a/Documentation/hwmon/lis3lv02d +++ b/Documentation/hwmon/lis3lv02d | |||
@@ -3,7 +3,8 @@ Kernel driver lis3lv02d | |||
3 | 3 | ||
4 | Supported chips: | 4 | Supported chips: |
5 | 5 | ||
6 | * STMicroelectronics LIS3LV02DL and LIS3LV02DQ | 6 | * STMicroelectronics LIS3LV02DL, LIS3LV02DQ (12 bits precision) |
7 | * STMicroelectronics LIS302DL, LIS3L02DQ, LIS331DL (8 bits) | ||
7 | 8 | ||
8 | Authors: | 9 | Authors: |
9 | Yan Burman <burman.yan@gmail.com> | 10 | Yan Burman <burman.yan@gmail.com> |
@@ -13,13 +14,12 @@ Authors: | |||
13 | Description | 14 | Description |
14 | ----------- | 15 | ----------- |
15 | 16 | ||
16 | This driver provides support for the accelerometer found in various HP | 17 | This driver provides support for the accelerometer found in various HP laptops |
17 | laptops sporting the feature officially called "HP Mobile Data | 18 | sporting the feature officially called "HP Mobile Data Protection System 3D" or |
18 | Protection System 3D" or "HP 3D DriveGuard". It detects automatically | 19 | "HP 3D DriveGuard". It detects automatically laptops with this sensor. Known |
19 | laptops with this sensor. Known models (for now the HP 2133, nc6420, | 20 | models (full list can be found in drivers/hwmon/hp_accel.c) will have their |
20 | nc2510, nc8510, nc84x0, nw9440 and nx9420) will have their axis | 21 | axis automatically oriented on standard way (eg: you can directly play |
21 | automatically oriented on standard way (eg: you can directly play | 22 | neverball). The accelerometer data is readable via |
22 | neverball). The accelerometer data is readable via | ||
23 | /sys/devices/platform/lis3lv02d. | 23 | /sys/devices/platform/lis3lv02d. |
24 | 24 | ||
25 | Sysfs attributes under /sys/devices/platform/lis3lv02d/: | 25 | Sysfs attributes under /sys/devices/platform/lis3lv02d/: |
@@ -33,12 +33,16 @@ rate - reports the sampling rate of the accelerometer device in HZ | |||
33 | This driver also provides an absolute input class device, allowing | 33 | This driver also provides an absolute input class device, allowing |
34 | the laptop to act as a pinball machine-esque joystick. | 34 | the laptop to act as a pinball machine-esque joystick. |
35 | 35 | ||
36 | On HP laptops, if the led infrastructure is activated, support for a led | ||
37 | indicating disk protection will be provided as /sys/class/leds/hp::hddprotect. | ||
38 | |||
36 | Another feature of the driver is misc device called "freefall" that | 39 | Another feature of the driver is misc device called "freefall" that |
37 | acts similar to /dev/rtc and reacts on free-fall interrupts received | 40 | acts similar to /dev/rtc and reacts on free-fall interrupts received |
38 | from the device. It supports blocking operations, poll/select and | 41 | from the device. It supports blocking operations, poll/select and |
39 | fasync operation modes. You must read 1 bytes from the device. The | 42 | fasync operation modes. You must read 1 bytes from the device. The |
40 | result is number of free-fall interrupts since the last successful | 43 | result is number of free-fall interrupts since the last successful |
41 | read (or 255 if number of interrupts would not fit). | 44 | read (or 255 if number of interrupts would not fit). See the hpfall.c |
45 | file for an example on using the device. | ||
42 | 46 | ||
43 | 47 | ||
44 | Axes orientation | 48 | Axes orientation |
@@ -55,7 +59,7 @@ the accelerometer are converted into a "standard" organisation of the axes | |||
55 | * If the laptop is put upside-down, Z becomes negative | 59 | * If the laptop is put upside-down, Z becomes negative |
56 | 60 | ||
57 | If your laptop model is not recognized (cf "dmesg"), you can send an | 61 | If your laptop model is not recognized (cf "dmesg"), you can send an |
58 | email to the authors to add it to the database. When reporting a new | 62 | email to the maintainer to add it to the database. When reporting a new |
59 | laptop, please include the output of "dmidecode" plus the value of | 63 | laptop, please include the output of "dmidecode" plus the value of |
60 | /sys/devices/platform/lis3lv02d/position in these four cases. | 64 | /sys/devices/platform/lis3lv02d/position in these four cases. |
61 | 65 | ||
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 | ||