From 7189ade82d155e400cec743c433c72c635cc68e9 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Sat, 7 Jun 2025 21:32:07 +1000 Subject: [PATCH] drivers: voltage_divider: handle ADC PM Some ADC's draw significant power while enabled, so make sure the driver can handle ADC's that have device runtime PM enabled. Signed-off-by: Jordan Yates --- drivers/sensor/voltage_divider/voltage.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/sensor/voltage_divider/voltage.c b/drivers/sensor/voltage_divider/voltage.c index 97d2523bd77..dcba7f52bf5 100644 --- a/drivers/sensor/voltage_divider/voltage.c +++ b/drivers/sensor/voltage_divider/voltage.c @@ -11,6 +11,7 @@ #include #include #include +#include #include LOG_MODULE_REGISTER(voltage, CONFIG_SENSOR_LOG_LEVEL); @@ -125,6 +126,8 @@ static int pm_action(const struct device *dev, enum pm_device_action action) } data->earliest_sample = K_TIMEOUT_ABS_TICKS( k_uptime_ticks() + k_us_to_ticks_ceil32(config->sample_delay_us)); + /* Power up ADC */ + pm_device_runtime_get(config->voltage.port.dev); break; #ifdef CONFIG_PM_DEVICE case PM_DEVICE_ACTION_SUSPEND: @@ -132,6 +135,8 @@ static int pm_action(const struct device *dev, enum pm_device_action action) if (ret != 0) { LOG_ERR("failed to set GPIO for PM suspend"); } + /* Power down ADC */ + pm_device_runtime_put(config->voltage.port.dev); break; case PM_DEVICE_ACTION_TURN_OFF: break;