Hello,
I'm working on a project using the nRF52840 and Zephyr, and I'm experiencing an issue when trying to use device power management (PM) with a custom sensor driver.
Environment:
-
nRF Connect SDK v2.5.2
-
Toolchains v2.7.0
-
IDE: nRF Connect for VS Code extension
I am attaching a minimal project that reproduces the problem to facilitate support.
Device Definition
I am defining the device as follows in my driver:
This should correctly register the device with a power management callback (kx132_pm_action
).
I'm also logging the following config macros at runtime to ensure they are enabled:
All of these are active in my configuration and appear in the log during startup.
The Issue
When I attempt to turn off the device using the following code:
I get the following log output:
-
The pointer and device name match as expected.
-
The state of the device is ACTIVE (0).
-
However, calling
pm_device_action_run()
always returns -134 (-ENOTSUP
). -
The callback function
kx132_pm_action()
is never called (no log inside it appears).
What I Expect
-
I expect the PM callback (
kx132_pm_action
) to be called when I runpm_device_action_run()
, but this does not happen. -
All PM macros are enabled, the device is properly registered, and the device pointer is correct.
-
If I register the device using
DEVICE_DT_INST_DEFINE
instead ofSENSOR_DEVICE_DT_INST_DEFINE
, the PM callback is called as expected.
Suspected Problem
It seems that SENSOR_DEVICE_DT_INST_DEFINE
(and possibly SENSOR_DEVICE_DT_DEFINE
) is not properly associating the PM structure with the device, or Zephyr is not enabling PM for this sensor device, despite all settings appearing to be correct.
Steps to Reproduce
-
Use the macros shown above in a sensor driver.
-
Build with
CONFIG_PM
,CONFIG_PM_DEVICE
, andCONFIG_PM_DEVICE_RUNTIME
enabled. -
Call
pm_device_action_run()
for the sensor device. -
Observe that the PM callback is not called and the return is always
-ENOTSUP
.
Could you clarify if this is a bug, a missing configuration, or if there are additional requirements for enabling PM for sensors defined with SENSOR_DEVICE_DT_INST_DEFINE
?
I'm attaching the minimal project that reproduces the issue.
Thanks in advance!