From 960a6f036e9c52ea53a83197215d05df14ce75bd Mon Sep 17 00:00:00 2001 From: Van Petrosyan Date: Wed, 2 Jul 2025 14:54:01 +0200 Subject: [PATCH] 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: #92196 Signed-off-by: Van Petrosyan --- drivers/sensor/st/lis2dh/lis2dh.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/sensor/st/lis2dh/lis2dh.c b/drivers/sensor/st/lis2dh/lis2dh.c index 97efa6fdab4..6c786e59133 100644 --- a/drivers/sensor/st/lis2dh/lis2dh.c +++ b/drivers/sensor/st/lis2dh/lis2dh.c @@ -439,9 +439,8 @@ int lis2dh_init_chip(const struct device *dev) (uint8_t)LIS2DH_LP_EN_BIT, lis2dh->scale); /* enable accel measurements and set power mode and data rate */ - return lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1, - LIS2DH_ACCEL_EN_BITS | LIS2DH_LP_EN_BIT | - LIS2DH_ODR_BITS); + lis2dh->reg_ctrl1_active_val = LIS2DH_ACCEL_EN_BITS | LIS2DH_LP_EN_BIT | LIS2DH_ODR_BITS; + return lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1, lis2dh->reg_ctrl1_active_val); } static int lis2dh_pm_action(const struct device *dev, @@ -467,7 +466,7 @@ static int lis2dh_pm_action(const struct device *dev, status = lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1, lis2dh->reg_ctrl1_active_val); if (status < 0) { - LOG_ERR("failed to write reg_crtl1"); + LOG_ERR("failed to write reg_ctrl1"); return status; } break; @@ -476,13 +475,13 @@ static int lis2dh_pm_action(const struct device *dev, status = lis2dh->hw_tf->read_reg(dev, LIS2DH_REG_CTRL1, &lis2dh->reg_ctrl1_active_val); if (status < 0) { - LOG_ERR("failed to read reg_crtl1"); + LOG_ERR("failed to read reg_ctrl1"); return status; } status = lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1, LIS2DH_SUSPEND); if (status < 0) { - LOG_ERR("failed to write reg_crtl1"); + LOG_ERR("failed to write reg_ctrl1"); return status; } break;