Skip to content

drivers: video: dcmi: use devicetree compatibles for platform-detection #92308

@josuah

Description

@josuah

Summary

In order to allow some platform-specific HAL features to be detected, DCMI uses #if defined(CONFIG_SOC_SERIES_STM32F7X) || defined(CONFIG_SOC_SERIES_STM32H7X).
A suggestion from #92018 (comment) was to use the devicetree instead, with a different compatible for each variant.

Describe the solution you'd like

This can be migrated to the same strategy as i.e. i2s, and use platform-specific compatibles:

diff --git a/dts/arm/st/h7/stm32h7.dtsi b/dts/arm/st/h7/stm32h7.dtsi
index 5cbf3c9b090..6c05239127d 100644
--- a/dts/arm/st/h7/stm32h7.dtsi
+++ b/dts/arm/st/h7/stm32h7.dtsi
@@ -1081,7 +1081,7 @@
                };

                dcmi: dcmi@48020000 {
-                       compatible = "st,stm32-dcmi";
+                       compatible = "st,stm32h7-dcmi", "st,stm32-dcmi";
                        reg = <0x48020000 0x400>;
                        interrupts = <78 0>;
                        interrupt-names = "dcmi";
diff --git a/dts/arm/st/l4/stm32l4p5.dtsi b/dts/arm/st/l4/stm32l4p5.dtsi
index 9b0aca624ed..907674731f9 100644
--- a/dts/arm/st/l4/stm32l4p5.dtsi
+++ b/dts/arm/st/l4/stm32l4p5.dtsi
@@ -336,7 +336,7 @@
                };

                dcmi: dcmi@50050000 {
-                       compatible = "st,stm32-dcmi";
+                       compatible = "st,stm32l4-dcmi", "st,stm32-dcmi";
                        reg = <0x50050000 0x400>;
                        interrupts = <85 0>;
                        interrupt-names = "dcmi";

Then in the dcmi driver, do like on I2S:

#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_i2s)
                        (void *)LL_SPI_DMA_GetRxRegAddr(cfg->i2s),
#else
                        (void *)LL_SPI_DMA_GetRegAddr(cfg->i2s),
#endif

Alternatives

Use CONFIG_SOC_SERIES_STM32H7X like now, which is also used by drivers.

Additional Context

No preference on my side! Only making sure that the preferred way is the one in use.

Metadata

Metadata

Assignees

Labels

EnhancementChanges/Updates/Additions to existing featuresarea: VideoVideo subsystemplatform: STM32ST Micro STM32

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions