Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: lis3: Power on corrections

Sometimes lis3 chip seems to fail to setup factory tuning at boot up.
This probably happens if there is some odd power ramp down ramp up sequence
for example in device restart. Set boot bit in control2 register to
trig boot sequence manually and wait until it is finished.

Signed-off-by: Samu Onkalo <samu.p.onkalo@nokia.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Acked-by: Eric Piel <eric.piel@tremplin-utc.net>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>

authored by

Samu Onkalo and committed by
Guenter Roeck
2a7fade7 821f6646

+12 -8
+11 -8
drivers/hwmon/lis3lv02d.c
··· 307 307 308 308 lis3->init(lis3); 309 309 310 - /* LIS3 power on delay is quite long */ 311 - msleep(lis3->pwron_delay / lis3lv02d_get_odr()); 312 - 313 310 /* 314 311 * Common configuration 315 312 * BDU: (12 bits sensors only) LSB and MSB values are not updated until 316 313 * both have been read. So the value read will always be correct. 314 + * Set BOOT bit to refresh factory tuning values. 317 315 */ 318 - if (lis3->whoami == WAI_12B) { 319 - lis3->read(lis3, CTRL_REG2, &reg); 320 - reg |= CTRL2_BDU; 321 - lis3->write(lis3, CTRL_REG2, reg); 322 - } 316 + lis3->read(lis3, CTRL_REG2, &reg); 317 + if (lis3->whoami == WAI_12B) 318 + reg |= CTRL2_BDU | CTRL2_BOOT; 319 + else 320 + reg |= CTRL2_BOOT_8B; 321 + lis3->write(lis3, CTRL_REG2, reg); 322 + 323 + /* LIS3 power on delay is quite long */ 324 + msleep(lis3->pwron_delay / lis3lv02d_get_odr()); 325 + 323 326 if (lis3->reg_ctrl) 324 327 lis3_context_restore(lis3); 325 328 }
+1
drivers/hwmon/lis3lv02d.h
··· 150 150 enum lis302d_ctrl2 { 151 151 HP_FF_WU2 = 0x08, 152 152 HP_FF_WU1 = 0x04, 153 + CTRL2_BOOT_8B = 0x40, 153 154 }; 154 155 155 156 enum lis3lv02d_ctrl3 {