xref: /linux/Documentation/misc-devices/lis3lv02d.rst (revision 0898782247ae533d1f4e47a06bc5d4870931b284)
1*9b5db89eSMauro Carvalho Chehab=======================
2*9b5db89eSMauro Carvalho ChehabKernel driver lis3lv02d
3*9b5db89eSMauro Carvalho Chehab=======================
4*9b5db89eSMauro Carvalho Chehab
5*9b5db89eSMauro Carvalho ChehabSupported chips:
6*9b5db89eSMauro Carvalho Chehab
7*9b5db89eSMauro Carvalho Chehab  * STMicroelectronics LIS3LV02DL, LIS3LV02DQ (12 bits precision)
8*9b5db89eSMauro Carvalho Chehab  * STMicroelectronics LIS302DL, LIS3L02DQ, LIS331DL (8 bits) and
9*9b5db89eSMauro Carvalho Chehab    LIS331DLH (16 bits)
10*9b5db89eSMauro Carvalho Chehab
11*9b5db89eSMauro Carvalho ChehabAuthors:
12*9b5db89eSMauro Carvalho Chehab        - Yan Burman <burman.yan@gmail.com>
13*9b5db89eSMauro Carvalho Chehab	- Eric Piel <eric.piel@tremplin-utc.net>
14*9b5db89eSMauro Carvalho Chehab
15*9b5db89eSMauro Carvalho Chehab
16*9b5db89eSMauro Carvalho ChehabDescription
17*9b5db89eSMauro Carvalho Chehab-----------
18*9b5db89eSMauro Carvalho Chehab
19*9b5db89eSMauro Carvalho ChehabThis driver provides support for the accelerometer found in various HP laptops
20*9b5db89eSMauro Carvalho Chehabsporting the feature officially called "HP Mobile Data Protection System 3D" or
21*9b5db89eSMauro Carvalho Chehab"HP 3D DriveGuard". It detects automatically laptops with this sensor. Known
22*9b5db89eSMauro Carvalho Chehabmodels (full list can be found in drivers/platform/x86/hp_accel.c) will have
23*9b5db89eSMauro Carvalho Chehabtheir axis automatically oriented on standard way (eg: you can directly play
24*9b5db89eSMauro Carvalho Chehabneverball). The accelerometer data is readable via
25*9b5db89eSMauro Carvalho Chehab/sys/devices/platform/lis3lv02d. Reported values are scaled
26*9b5db89eSMauro Carvalho Chehabto mg values (1/1000th of earth gravity).
27*9b5db89eSMauro Carvalho Chehab
28*9b5db89eSMauro Carvalho ChehabSysfs attributes under /sys/devices/platform/lis3lv02d/:
29*9b5db89eSMauro Carvalho Chehab
30*9b5db89eSMauro Carvalho Chehabposition
31*9b5db89eSMauro Carvalho Chehab      - 3D position that the accelerometer reports. Format: "(x,y,z)"
32*9b5db89eSMauro Carvalho Chehabrate
33*9b5db89eSMauro Carvalho Chehab      - read reports the sampling rate of the accelerometer device in HZ.
34*9b5db89eSMauro Carvalho Chehab	write changes sampling rate of the accelerometer device.
35*9b5db89eSMauro Carvalho Chehab	Only values which are supported by HW are accepted.
36*9b5db89eSMauro Carvalho Chehabselftest
37*9b5db89eSMauro Carvalho Chehab      - performs selftest for the chip as specified by chip manufacturer.
38*9b5db89eSMauro Carvalho Chehab
39*9b5db89eSMauro Carvalho ChehabThis driver also provides an absolute input class device, allowing
40*9b5db89eSMauro Carvalho Chehabthe laptop to act as a pinball machine-esque joystick. Joystick device can be
41*9b5db89eSMauro Carvalho Chehabcalibrated. Joystick device can be in two different modes.
42*9b5db89eSMauro Carvalho ChehabBy default output values are scaled between -32768 .. 32767. In joystick raw
43*9b5db89eSMauro Carvalho Chehabmode, joystick and sysfs position entry have the same scale. There can be
44*9b5db89eSMauro Carvalho Chehabsmall difference due to input system fuzziness feature.
45*9b5db89eSMauro Carvalho ChehabEvents are also available as input event device.
46*9b5db89eSMauro Carvalho Chehab
47*9b5db89eSMauro Carvalho ChehabSelftest is meant only for hardware diagnostic purposes. It is not meant to be
48*9b5db89eSMauro Carvalho Chehabused during normal operations. Position data is not corrupted during selftest
49*9b5db89eSMauro Carvalho Chehabbut interrupt behaviour is not guaranteed to work reliably. In test mode, the
50*9b5db89eSMauro Carvalho Chehabsensing element is internally moved little bit. Selftest measures difference
51*9b5db89eSMauro Carvalho Chehabbetween normal mode and test mode. Chip specifications tell the acceptance
52*9b5db89eSMauro Carvalho Chehablimit for each type of the chip. Limits are provided via platform data
53*9b5db89eSMauro Carvalho Chehabto allow adjustment of the limits without a change to the actual driver.
54*9b5db89eSMauro Carvalho ChehabSeltest returns either "OK x y z" or "FAIL x y z" where x, y and z are
55*9b5db89eSMauro Carvalho Chehabmeasured difference between modes. Axes are not remapped in selftest mode.
56*9b5db89eSMauro Carvalho ChehabMeasurement values are provided to help HW diagnostic applications to make
57*9b5db89eSMauro Carvalho Chehabfinal decision.
58*9b5db89eSMauro Carvalho Chehab
59*9b5db89eSMauro Carvalho ChehabOn HP laptops, if the led infrastructure is activated, support for a led
60*9b5db89eSMauro Carvalho Chehabindicating disk protection will be provided as /sys/class/leds/hp::hddprotect.
61*9b5db89eSMauro Carvalho Chehab
62*9b5db89eSMauro Carvalho ChehabAnother feature of the driver is misc device called "freefall" that
63*9b5db89eSMauro Carvalho Chehabacts similar to /dev/rtc and reacts on free-fall interrupts received
64*9b5db89eSMauro Carvalho Chehabfrom the device. It supports blocking operations, poll/select and
65*9b5db89eSMauro Carvalho Chehabfasync operation modes. You must read 1 bytes from the device.  The
66*9b5db89eSMauro Carvalho Chehabresult is number of free-fall interrupts since the last successful
67*9b5db89eSMauro Carvalho Chehabread (or 255 if number of interrupts would not fit). See the freefall.c
68*9b5db89eSMauro Carvalho Chehabfile for an example on using the device.
69*9b5db89eSMauro Carvalho Chehab
70*9b5db89eSMauro Carvalho Chehab
71*9b5db89eSMauro Carvalho ChehabAxes orientation
72*9b5db89eSMauro Carvalho Chehab----------------
73*9b5db89eSMauro Carvalho Chehab
74*9b5db89eSMauro Carvalho ChehabFor better compatibility between the various laptops. The values reported by
75*9b5db89eSMauro Carvalho Chehabthe accelerometer are converted into a "standard" organisation of the axes
76*9b5db89eSMauro Carvalho Chehab(aka "can play neverball out of the box"):
77*9b5db89eSMauro Carvalho Chehab
78*9b5db89eSMauro Carvalho Chehab * When the laptop is horizontal the position reported is about 0 for X and Y
79*9b5db89eSMauro Carvalho Chehab   and a positive value for Z
80*9b5db89eSMauro Carvalho Chehab * If the left side is elevated, X increases (becomes positive)
81*9b5db89eSMauro Carvalho Chehab * If the front side (where the touchpad is) is elevated, Y decreases
82*9b5db89eSMauro Carvalho Chehab   (becomes negative)
83*9b5db89eSMauro Carvalho Chehab * If the laptop is put upside-down, Z becomes negative
84*9b5db89eSMauro Carvalho Chehab
85*9b5db89eSMauro Carvalho ChehabIf your laptop model is not recognized (cf "dmesg"), you can send an
86*9b5db89eSMauro Carvalho Chehabemail to the maintainer to add it to the database.  When reporting a new
87*9b5db89eSMauro Carvalho Chehablaptop, please include the output of "dmidecode" plus the value of
88*9b5db89eSMauro Carvalho Chehab/sys/devices/platform/lis3lv02d/position in these four cases.
89*9b5db89eSMauro Carvalho Chehab
90*9b5db89eSMauro Carvalho ChehabQ&A
91*9b5db89eSMauro Carvalho Chehab---
92*9b5db89eSMauro Carvalho Chehab
93*9b5db89eSMauro Carvalho ChehabQ: How do I safely simulate freefall? I have an HP "portable
94*9b5db89eSMauro Carvalho Chehabworkstation" which has about 3.5kg and a plastic case, so letting it
95*9b5db89eSMauro Carvalho Chehabfall to the ground is out of question...
96*9b5db89eSMauro Carvalho Chehab
97*9b5db89eSMauro Carvalho ChehabA: The sensor is pretty sensitive, so your hands can do it. Lift it
98*9b5db89eSMauro Carvalho Chehabinto free space, follow the fall with your hands for like 10
99*9b5db89eSMauro Carvalho Chehabcentimeters. That should be enough to trigger the detection.
100