Skip to content

Commit 960a6f0

Browse files
petrosyan-vandanieldegrasse
authored andcommitted
sensor: lis2dh: cache CTRL1 on PM_DEVICE_ACTION_TURN_ON
Cache CTRL1 into reg_ctrl1_active_val inside lis2dh_init_chip() in the PM_DEVICE_ACTION_TURN_ON path. This prevents the first runtime-PM RESUME from writing 0x00 to CTRL1 and disabling the sensor when runtime-PM is enabled. Fixes: zephyrproject-rtos#92196 Signed-off-by: Van Petrosyan <van.petrosyan@sensirion.com>
1 parent 7da64e7 commit 960a6f0

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/sensor/st/lis2dh/lis2dh.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,8 @@ int lis2dh_init_chip(const struct device *dev)
439439
(uint8_t)LIS2DH_LP_EN_BIT, lis2dh->scale);
440440

441441
/* enable accel measurements and set power mode and data rate */
442-
return lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1,
443-
LIS2DH_ACCEL_EN_BITS | LIS2DH_LP_EN_BIT |
444-
LIS2DH_ODR_BITS);
442+
lis2dh->reg_ctrl1_active_val = LIS2DH_ACCEL_EN_BITS | LIS2DH_LP_EN_BIT | LIS2DH_ODR_BITS;
443+
return lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1, lis2dh->reg_ctrl1_active_val);
445444
}
446445

447446
static int lis2dh_pm_action(const struct device *dev,
@@ -467,7 +466,7 @@ static int lis2dh_pm_action(const struct device *dev,
467466
status = lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1,
468467
lis2dh->reg_ctrl1_active_val);
469468
if (status < 0) {
470-
LOG_ERR("failed to write reg_crtl1");
469+
LOG_ERR("failed to write reg_ctrl1");
471470
return status;
472471
}
473472
break;
@@ -476,13 +475,13 @@ static int lis2dh_pm_action(const struct device *dev,
476475
status = lis2dh->hw_tf->read_reg(dev, LIS2DH_REG_CTRL1,
477476
&lis2dh->reg_ctrl1_active_val);
478477
if (status < 0) {
479-
LOG_ERR("failed to read reg_crtl1");
478+
LOG_ERR("failed to read reg_ctrl1");
480479
return status;
481480
}
482481
status = lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1,
483482
LIS2DH_SUSPEND);
484483
if (status < 0) {
485-
LOG_ERR("failed to write reg_crtl1");
484+
LOG_ERR("failed to write reg_ctrl1");
486485
return status;
487486
}
488487
break;

0 commit comments

Comments
 (0)