diff options
Diffstat (limited to 'drivers/hwmon/lis3lv02d.h')
-rw-r--r-- | drivers/hwmon/lis3lv02d.h | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/drivers/hwmon/lis3lv02d.h b/drivers/hwmon/lis3lv02d.h index 3e1ff46f72d3..e6a01f44709b 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,7 +92,13 @@ enum lis3lv02d_reg { | |||
94 | DD_THSE_H = 0x3F, | 92 | DD_THSE_H = 0x3F, |
95 | }; | 93 | }; |
96 | 94 | ||
97 | enum lis3lv02d_ctrl1 { | 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 | |||
101 | enum lis3lv02d_ctrl1_12b { | ||
98 | CTRL1_Xen = 0x01, | 102 | CTRL1_Xen = 0x01, |
99 | CTRL1_Yen = 0x02, | 103 | CTRL1_Yen = 0x02, |
100 | CTRL1_Zen = 0x04, | 104 | CTRL1_Zen = 0x04, |
@@ -104,6 +108,16 @@ enum lis3lv02d_ctrl1 { | |||
104 | CTRL1_PD0 = 0x40, | 108 | CTRL1_PD0 = 0x40, |
105 | CTRL1_PD1 = 0x80, | 109 | CTRL1_PD1 = 0x80, |
106 | }; | 110 | }; |
111 | |||
112 | /* Delta to ctrl1_12b version */ | ||
113 | enum lis3lv02d_ctrl1_8b { | ||
114 | CTRL1_STM = 0x08, | ||
115 | CTRL1_STP = 0x10, | ||
116 | CTRL1_FS = 0x20, | ||
117 | CTRL1_PD = 0x40, | ||
118 | CTRL1_DR = 0x80, | ||
119 | }; | ||
120 | |||
107 | enum lis3lv02d_ctrl2 { | 121 | enum lis3lv02d_ctrl2 { |
108 | CTRL2_DAS = 0x01, | 122 | CTRL2_DAS = 0x01, |
109 | CTRL2_SIM = 0x02, | 123 | CTRL2_SIM = 0x02, |
@@ -194,16 +208,20 @@ struct lis3lv02d { | |||
194 | int (*write) (struct lis3lv02d *lis3, int reg, u8 val); | 208 | int (*write) (struct lis3lv02d *lis3, int reg, u8 val); |
195 | int (*read) (struct lis3lv02d *lis3, int reg, u8 *ret); | 209 | int (*read) (struct lis3lv02d *lis3, int reg, u8 *ret); |
196 | 210 | ||
197 | u8 whoami; /* 3Ah: 2-byte registries, 3Bh: 1-byte registries */ | 211 | int *odrs; /* Supported output data rates */ |
212 | u8 odr_mask; /* ODR bit mask */ | ||
213 | u8 whoami; /* indicates measurement precision */ | ||
198 | s16 (*read_data) (struct lis3lv02d *lis3, int reg); | 214 | s16 (*read_data) (struct lis3lv02d *lis3, int reg); |
199 | int mdps_max_val; | 215 | int mdps_max_val; |
216 | int pwron_delay; | ||
217 | int scale; /* | ||
218 | * relationship between 1 LBS and mG | ||
219 | * (1/1000th of earth gravity) | ||
220 | */ | ||
200 | 221 | ||
201 | struct input_polled_dev *idev; /* input device */ | 222 | struct input_polled_dev *idev; /* input device */ |
202 | struct platform_device *pdev; /* platform device */ | 223 | struct platform_device *pdev; /* platform device */ |
203 | atomic_t count; /* interrupt count after last read */ | 224 | atomic_t count; /* interrupt count after last read */ |
204 | int xcalib; /* calibrated null value for x */ | ||
205 | int ycalib; /* calibrated null value for y */ | ||
206 | int zcalib; /* calibrated null value for z */ | ||
207 | struct axis_conversion ac; /* hw -> logical axis */ | 225 | struct axis_conversion ac; /* hw -> logical axis */ |
208 | 226 | ||
209 | u32 irq; /* IRQ number */ | 227 | u32 irq; /* IRQ number */ |
@@ -212,6 +230,7 @@ struct lis3lv02d { | |||
212 | unsigned long misc_opened; /* bit0: whether the device is open */ | 230 | unsigned long misc_opened; /* bit0: whether the device is open */ |
213 | 231 | ||
214 | struct lis3lv02d_platform_data *pdata; /* for passing board config */ | 232 | struct lis3lv02d_platform_data *pdata; /* for passing board config */ |
233 | struct mutex mutex; /* Serialize poll and selftest */ | ||
215 | }; | 234 | }; |
216 | 235 | ||
217 | int lis3lv02d_init_device(struct lis3lv02d *lis3); | 236 | int lis3lv02d_init_device(struct lis3lv02d *lis3); |