-
Notifications
You must be signed in to change notification settings - Fork 8.2k
driver: adc: stm32: combine shared and separate irqs #65266
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
driver: adc: stm32: combine shared and separate irqs #65266
Conversation
|
Has been tried on an STM32G473 which fixed an issue encountered when using ADC1,2,4 in a single application; however, as there are a wide number of STM32 variants, I am unsure if there isnt something in one of that that is still unaccounted for |
erwango
left a comment
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.
Thanks for working on this.
Initially I thought you used #61422, but I can see this isn't the case. Did you explore this solution ?
I guess your option might be more optimized but maybe #61422 could bring some code simplification ?
Regarding testing, i'm not sure what's the best option. We can perform a non regression on few boards, but it won't help testing all combinations.
Also, please the issue reported by bot.
Since we were working off of v3.4.0, I didn't realize that a more general shared interrupts was available in mainline though I did start looking at it - this why I haven't yet fixed all the issues here. With this solution, I am unsure as to whether when |
I tend to agree. My only concern with current solution is the complexity and readability issue involved. But there are ways to enhance this. |
Several STM32 variants include both shared IRQs for some ADCs and separate IRQs for others (for example, STM32G473 has 5 ADCs, ADC1 and ADC2 share one IRQ while ADC3, ADC4 and ADC5 each have unique IRQs). The STM32 ADC driver however previously only supported either separate IRQ lines for each operational ADC in the devicetree or a single shared IRQ for all operational ADCs in the devicetree which prevented all ADCs from being usable at the same time when the variant contained a mix of both shared and separate ADC IRQ lines (only either all the shared or all the separate and one of the shared might be used at most for one application). To allow for all ADCs in an STM32 variant to be usable in a single application, generate an ISR and initialization function for each unique IRQn as defined in the devicetree and give the task of initialization to the first ADC which connects to that particular IRQ. Each ISR function will generate code to call the ISR for each ADC associated with that IRQn as was previously done for CONFIG_ADC_STM32_SHARED_IRQS, allowing an ISR to be shared for the ADCs sharing an IRQ while simultaneously providing separate ISRs for each IRQ. Thus, the only information required to have ADCs either share an ISR or not is provided by the devicetree. Signed-off-by: Michael R Rosen <[email protected]>
8ed0db0 to
718b874
Compare
|
@erwango @ycsin Sorry for the delay I was able to test this fix using two different STM32 platforms (STM32F042K6 and STM32G473QE; custom boards), one with a single ADC for a simple check and the other using 3 ADCs (1, 2 which share an interrupt; 3 which uses a separate interrupt) with the ADC driver sample application and it all checked out. I do agree with the discussion here regarding shared interrupts infrastructure and how this PR might fit in or not but as mentioned, I do think it's easy to miss enabling it, it would be hard to enable automatically when the set of enabled devicetree devices requires it, and there is a code size penalty for it. I think it might be worth merging this in as it does fix the currently broken |
|
@mrrosen Back from holidays, please give me some time. |
|
I'll try to review this week. Sorry for the delay |
Several STM32 variants include both shared IRQs for some ADCs and separate IRQs for others (for example, STM32G473 has 5 ADCs, ADC1 and ADC2 share one IRQ while ADC3, ADC4 and ADC5 each have unique IRQs). The STM32 ADC driver however previously only supported either separate IRQ lines for each operational ADC in the devicetree or a single shared IRQ for all operational ADCs in the devicetree which prevented all ADCs from being usable at the same time when the variant contained a mix of both shared and separate ADC IRQ lines (only either all the shared or all the separate and one of the shared might be used at most for one application).
To allow for all ADCs in an STM32 variant to be usable in a single application, generate an ISR and initialization function for each unique IRQn as defined in the devicetree and give the task of initialization to the first ADC which connects to that particular IRQ. Each ISR function will generate code to check each ADC associated with its IRQn as was previously done for CONFIG_ADC_STM32_SHARED_IRQS, allowing an ISR to be shared for the ADCs sharing an IRQ while simultaneously providing separate ISRs for each IRQ. Thus, the only information required to have ADCs either share an ISR or not is provided by the devicetree.