-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix stm32wl adc driver with PM #72809
base: main
Are you sure you want to change the base?
Fix stm32wl adc driver with PM #72809
Conversation
Incidentally I was also trying to get the power management working for the ADC...
As the code you added uses the runtime device power management, you probably want to also set `PM_DEVICE_RUNTIME=y' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My finding is that enabling the runtime device power management for the ADC breaks the internal channels drivers. The calls to LL_ADC_SetCommonPathInternalCh
have recently been moved out of the ADC driver to the stm32_temp
, stm32_vbat
and stm32_vref
, which is not possible anymore once the ADC is suspended, as the clock is disabled.
@gautierg-st do you have any idea how to fix that?
@@ -613,6 +614,12 @@ static int adc_stm32_calibrate(const struct device *dev) | |||
} | |||
#endif /* CONFIG_SOC_SERIES_STM32H7X */ | |||
|
|||
/* enable device runtime power management */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure it is the best place to do that, you probably rather want to do that in adc_stm32_init
instead
@@ -1111,6 +1118,7 @@ static void adc_stm32_isr(const struct device *dev) | |||
} | |||
|
|||
LOG_DBG("%s ISR triggered.", dev->name); | |||
pm_device_runtime_put(dev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct, but you probably want to do the same for the DMA case
@@ -1141,6 +1149,11 @@ static int adc_stm32_read(const struct device *dev, | |||
struct adc_stm32_data *data = dev->data; | |||
int error; | |||
|
|||
error = pm_device_runtime_get(dev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
Note that I have been able to get the ADC in Stop 2 mode with the recently added PM ADC code. For that you need of course |
Answering myself, this is as simple as calling pm device runtime functions from the stm32 sensors code:
I can open a proper PR later as it does not require the current changes to work. That said that also pointed me that adding pm runtime support breaks the |
I'm not sure to understand all what you said @aurel32. |
I think your PR is still relevant, and where we want to go long term. It however had some consequences that need to be fixed first. One of them is fixed in #72989. The other is that the In the meantime a workaround is to either use |
Description
This PR introduce a fix for the issue #37352 by reinitializing the adc when going outside LPM using the Device Runtime Power Management.
Type of change
Test steps
nucleo_wl55jc.overlay
tosamples/drivers/adc/boards
CONFIG_PM=y
nucleo_wl55jc
CONFIG_PM