Browse Source

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 <van.petrosyan@sensirion.com>
pull/92185/merge
Van Petrosyan 6 days ago committed by Daniel DeGrasse
parent
commit
960a6f036e
  1. 11
      drivers/sensor/st/lis2dh/lis2dh.c

11
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); (uint8_t)LIS2DH_LP_EN_BIT, lis2dh->scale);
/* enable accel measurements and set power mode and data rate */ /* enable accel measurements and set power mode and data rate */
return lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1, lis2dh->reg_ctrl1_active_val = LIS2DH_ACCEL_EN_BITS | LIS2DH_LP_EN_BIT | LIS2DH_ODR_BITS;
LIS2DH_ACCEL_EN_BITS | LIS2DH_LP_EN_BIT | return lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1, lis2dh->reg_ctrl1_active_val);
LIS2DH_ODR_BITS);
} }
static int lis2dh_pm_action(const struct device *dev, 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, status = lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1,
lis2dh->reg_ctrl1_active_val); lis2dh->reg_ctrl1_active_val);
if (status < 0) { if (status < 0) {
LOG_ERR("failed to write reg_crtl1"); LOG_ERR("failed to write reg_ctrl1");
return status; return status;
} }
break; break;
@ -476,13 +475,13 @@ static int lis2dh_pm_action(const struct device *dev,
status = lis2dh->hw_tf->read_reg(dev, LIS2DH_REG_CTRL1, status = lis2dh->hw_tf->read_reg(dev, LIS2DH_REG_CTRL1,
&lis2dh->reg_ctrl1_active_val); &lis2dh->reg_ctrl1_active_val);
if (status < 0) { if (status < 0) {
LOG_ERR("failed to read reg_crtl1"); LOG_ERR("failed to read reg_ctrl1");
return status; return status;
} }
status = lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1, status = lis2dh->hw_tf->write_reg(dev, LIS2DH_REG_CTRL1,
LIS2DH_SUSPEND); LIS2DH_SUSPEND);
if (status < 0) { if (status < 0) {
LOG_ERR("failed to write reg_crtl1"); LOG_ERR("failed to write reg_ctrl1");
return status; return status;
} }
break; break;

Loading…
Cancel
Save