diff options
Diffstat (limited to 'drivers/misc/lis3lv02d/lis3lv02d.c')
-rw-r--r-- | drivers/misc/lis3lv02d/lis3lv02d.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c index a981e2a42f92..9d37c576d526 100644 --- a/drivers/misc/lis3lv02d/lis3lv02d.c +++ b/drivers/misc/lis3lv02d/lis3lv02d.c | |||
@@ -80,6 +80,14 @@ | |||
80 | #define LIS3_SENSITIVITY_12B ((LIS3_ACCURACY * 1000) / 1024) | 80 | #define LIS3_SENSITIVITY_12B ((LIS3_ACCURACY * 1000) / 1024) |
81 | #define LIS3_SENSITIVITY_8B (18 * LIS3_ACCURACY) | 81 | #define LIS3_SENSITIVITY_8B (18 * LIS3_ACCURACY) |
82 | 82 | ||
83 | /* | ||
84 | * LIS3331DLH spec says 1LSBs corresponds 4G/1024 -> 1LSB is 1000/1024 mG. | ||
85 | * Sensitivity values for +/-2G, outdata in 12 bits for +/-2G scale. so 4 | ||
86 | * bits adjustment is required | ||
87 | */ | ||
88 | #define LIS3DLH_SENSITIVITY_2G ((LIS3_ACCURACY * 1000) / 1024) | ||
89 | #define SHIFT_ADJ_2G 4 | ||
90 | |||
83 | #define LIS3_DEFAULT_FUZZ_12B 3 | 91 | #define LIS3_DEFAULT_FUZZ_12B 3 |
84 | #define LIS3_DEFAULT_FLAT_12B 3 | 92 | #define LIS3_DEFAULT_FLAT_12B 3 |
85 | #define LIS3_DEFAULT_FUZZ_8B 1 | 93 | #define LIS3_DEFAULT_FUZZ_8B 1 |
@@ -135,6 +143,19 @@ static s16 lis3lv02d_read_12(struct lis3lv02d *lis3, int reg) | |||
135 | return (s16)((hi << 8) | lo); | 143 | return (s16)((hi << 8) | lo); |
136 | } | 144 | } |
137 | 145 | ||
146 | /* 12bits for 2G range, 13 bits for 4G range and 14 bits for 8G range */ | ||
147 | static s16 lis3lv02d_read_16(struct lis3lv02d *lis3, int reg) | ||
148 | { | ||
149 | u8 lo, hi; | ||
150 | int v; | ||
151 | |||
152 | lis3->read(lis3, reg - 1, &lo); | ||
153 | lis3->read(lis3, reg, &hi); | ||
154 | v = (int) ((hi << 8) | lo); | ||
155 | |||
156 | return (s16) v >> lis3->shift_adj; | ||
157 | } | ||
158 | |||
138 | /** | 159 | /** |
139 | * lis3lv02d_get_axis - For the given axis, give the value converted | 160 | * lis3lv02d_get_axis - For the given axis, give the value converted |
140 | * @axis: 1,2,3 - can also be negative | 161 | * @axis: 1,2,3 - can also be negative |
@@ -195,6 +216,7 @@ static void lis3lv02d_get_xyz(struct lis3lv02d *lis3, int *x, int *y, int *z) | |||
195 | static int lis3_12_rates[4] = {40, 160, 640, 2560}; | 216 | static int lis3_12_rates[4] = {40, 160, 640, 2560}; |
196 | static int lis3_8_rates[2] = {100, 400}; | 217 | static int lis3_8_rates[2] = {100, 400}; |
197 | static int lis3_3dc_rates[16] = {0, 1, 10, 25, 50, 100, 200, 400, 1600, 5000}; | 218 | static int lis3_3dc_rates[16] = {0, 1, 10, 25, 50, 100, 200, 400, 1600, 5000}; |
219 | static int lis3_3dlh_rates[4] = {50, 100, 400, 1000}; | ||
198 | 220 | ||
199 | /* ODR is Output Data Rate */ | 221 | /* ODR is Output Data Rate */ |
200 | static int lis3lv02d_get_odr(struct lis3lv02d *lis3) | 222 | static int lis3lv02d_get_odr(struct lis3lv02d *lis3) |
@@ -267,7 +289,7 @@ static int lis3lv02d_selftest(struct lis3lv02d *lis3, s16 results[3]) | |||
267 | (LIS3_IRQ1_DATA_READY | LIS3_IRQ2_DATA_READY)); | 289 | (LIS3_IRQ1_DATA_READY | LIS3_IRQ2_DATA_READY)); |
268 | } | 290 | } |
269 | 291 | ||
270 | if (lis3->whoami == WAI_3DC) { | 292 | if ((lis3->whoami == WAI_3DC) || (lis3->whoami == WAI_3DLH)) { |
271 | ctlreg = CTRL_REG4; | 293 | ctlreg = CTRL_REG4; |
272 | selftest = CTRL4_ST0; | 294 | selftest = CTRL4_ST0; |
273 | } else { | 295 | } else { |
@@ -398,9 +420,17 @@ int lis3lv02d_poweron(struct lis3lv02d *lis3) | |||
398 | lis3->read(lis3, CTRL_REG2, ®); | 420 | lis3->read(lis3, CTRL_REG2, ®); |
399 | if (lis3->whoami == WAI_12B) | 421 | if (lis3->whoami == WAI_12B) |
400 | reg |= CTRL2_BDU | CTRL2_BOOT; | 422 | reg |= CTRL2_BDU | CTRL2_BOOT; |
423 | else if (lis3->whoami == WAI_3DLH) | ||
424 | reg |= CTRL2_BOOT_3DLH; | ||
401 | else | 425 | else |
402 | reg |= CTRL2_BOOT_8B; | 426 | reg |= CTRL2_BOOT_8B; |
403 | lis3->write(lis3, CTRL_REG2, reg); | 427 | lis3->write(lis3, CTRL_REG2, reg); |
428 | |||
429 | if (lis3->whoami == WAI_3DLH) { | ||
430 | lis3->read(lis3, CTRL_REG4, ®); | ||
431 | reg |= CTRL4_BDU; | ||
432 | lis3->write(lis3, CTRL_REG4, reg); | ||
433 | } | ||
404 | } | 434 | } |
405 | 435 | ||
406 | err = lis3lv02d_get_pwron_wait(lis3); | 436 | err = lis3lv02d_get_pwron_wait(lis3); |
@@ -956,6 +986,16 @@ int lis3lv02d_init_device(struct lis3lv02d *lis3) | |||
956 | lis3->odr_mask = CTRL1_ODR0|CTRL1_ODR1|CTRL1_ODR2|CTRL1_ODR3; | 986 | lis3->odr_mask = CTRL1_ODR0|CTRL1_ODR1|CTRL1_ODR2|CTRL1_ODR3; |
957 | lis3->scale = LIS3_SENSITIVITY_8B; | 987 | lis3->scale = LIS3_SENSITIVITY_8B; |
958 | break; | 988 | break; |
989 | case WAI_3DLH: | ||
990 | pr_info("16 bits 3DLH sensor found\n"); | ||
991 | lis3->read_data = lis3lv02d_read_16; | ||
992 | lis3->mdps_max_val = 2048; /* 12 bits for 2G */ | ||
993 | lis3->shift_adj = SHIFT_ADJ_2G; | ||
994 | lis3->pwron_delay = LIS3_PWRON_DELAY_WAI_8B; | ||
995 | lis3->odrs = lis3_3dlh_rates; | ||
996 | lis3->odr_mask = CTRL1_DR0 | CTRL1_DR1; | ||
997 | lis3->scale = LIS3DLH_SENSITIVITY_2G; | ||
998 | break; | ||
959 | default: | 999 | default: |
960 | pr_err("unknown sensor type 0x%X\n", lis3->whoami); | 1000 | pr_err("unknown sensor type 0x%X\n", lis3->whoami); |
961 | return -EINVAL; | 1001 | return -EINVAL; |