diff --git a/boards/shields/st_mb1897_cam/Kconfig.shield b/boards/shields/st_mb1897_cam/Kconfig.shield new file mode 100644 index 000000000000..cee077071337 --- /dev/null +++ b/boards/shields/st_mb1897_cam/Kconfig.shield @@ -0,0 +1,6 @@ +# Copyright (c) 2025 STMicroelectronics + +# SPDX-License-Identifier: Apache-2.0 + +config SHIELD_ST_MB1897_CAM + def_bool $(shields_list_contains,st_mb1897_cam) diff --git a/boards/shields/st_mb1897_cam/boards/stm32mp135f_dk.conf b/boards/shields/st_mb1897_cam/boards/stm32mp135f_dk.conf new file mode 100644 index 000000000000..e37965943773 --- /dev/null +++ b/boards/shields/st_mb1897_cam/boards/stm32mp135f_dk.conf @@ -0,0 +1,3 @@ +CONFIG_VIDEO_STM32_DCMIPP_SENSOR_PIXEL_FORMAT="RGBP" +CONFIG_VIDEO_STM32_DCMIPP_SENSOR_WIDTH=640 +CONFIG_VIDEO_STM32_DCMIPP_SENSOR_HEIGHT=480 diff --git a/boards/shields/st_mb1897_cam/boards/stm32mp135f_dk.overlay b/boards/shields/st_mb1897_cam/boards/stm32mp135f_dk.overlay new file mode 100644 index 000000000000..1c41c5b97900 --- /dev/null +++ b/boards/shields/st_mb1897_cam/boards/stm32mp135f_dk.overlay @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&mipid02 { + status = "okay"; +}; + +&mco1 { + status = "okay"; +}; diff --git a/boards/shields/st_mb1897_cam/doc/index.rst b/boards/shields/st_mb1897_cam/doc/index.rst new file mode 100644 index 000000000000..5ff703613524 --- /dev/null +++ b/boards/shields/st_mb1897_cam/doc/index.rst @@ -0,0 +1,38 @@ +.. _st_mb1897_cam: + +ST_MB1897_CAM +############# + +Overview +******** + +The STM32MP135F discovery board is delivered with a CSI camera module +connected to the STM32MP135F-DK board via a 15pins FFC connector. +The camera module board (MB1897) embeds a Galaxycore GC2145 CSI sensor. + +.. figure:: st_mb1897_cam.webp + :align: center + :alt: ST-MB1897-CAM + + MB1897 Image (Credit: STMicroelectronics.) + +Requirements +************ + +The camera module bundle is compatible with STM32 Discovery kits and +Evaluation boards featuring a 15 pins FFC connector, such as the STM32MP13 +Discovery kit. + +Usage +***** + +The shield can be used in any application by setting ``SHIELD`` to +``st_mb1897_cam`` for boards with the necessary device tree node labels. + +Set ``--shield "st_mb1897_cam"`` when you invoke ``west build``. For example: + +.. zephyr-app-commands:: + :zephyr-app: samples/drivers/video/capture + :board: stm32mp135f_dk + :shield: st_mb1897_cam + :goals: build diff --git a/boards/shields/st_mb1897_cam/doc/st_mb1897_cam.webp b/boards/shields/st_mb1897_cam/doc/st_mb1897_cam.webp new file mode 100644 index 000000000000..b3e6153471c6 Binary files /dev/null and b/boards/shields/st_mb1897_cam/doc/st_mb1897_cam.webp differ diff --git a/boards/shields/st_mb1897_cam/shield.yml b/boards/shields/st_mb1897_cam/shield.yml new file mode 100644 index 000000000000..d4d378291178 --- /dev/null +++ b/boards/shields/st_mb1897_cam/shield.yml @@ -0,0 +1,6 @@ +shield: + name: st_mb1897_cam + full_name: ST MB1897 camera module + vendor: st + supported_features: + - video diff --git a/boards/shields/st_mb1897_cam/st_mb1897_cam.overlay b/boards/shields/st_mb1897_cam/st_mb1897_cam.overlay new file mode 100644 index 000000000000..61dc9cedb067 --- /dev/null +++ b/boards/shields/st_mb1897_cam/st_mb1897_cam.overlay @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 STMicroelectronics + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include + +/ { + chosen { + zephyr,camera = &csi_capture_port; + }; +}; + +&csi_interface { + status = "okay"; +}; + +&csi_ep_in { + remote-endpoint-label = "gc2145_ep_out"; + bus-type = ; + data-lanes = <1 2>; +}; + +&csi_i2c { + status = "okay"; + + gc2145: camera@3c { + compatible = "galaxycore,gc2145"; + reg = <0x3c>; + pwdn-gpios = <&csi_connector CSI_IO1 GPIO_ACTIVE_LOW>; + reset-gpios = <&csi_connector CSI_IO0 GPIO_ACTIVE_LOW>; + + port { + gc2145_ep_out: endpoint { + remote-endpoint-label = "csi_ep_in"; + data-lanes = <1 2>; + bus-type = ; + }; + }; + }; +}; diff --git a/boards/st/stm32mp135f_dk/Kconfig.defconfig b/boards/st/stm32mp135f_dk/Kconfig.defconfig new file mode 100644 index 000000000000..0a9aafe3c800 --- /dev/null +++ b/boards/st/stm32mp135f_dk/Kconfig.defconfig @@ -0,0 +1,15 @@ +# STM32MP135F DISCOVERY board configuration + +# Copyright (c) 2025 STMicroelectronics +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_STM32MP135F_DK + +if GPIO_MCP230XX + +config GPIO_MCP230XX_INIT_PRIORITY + default I2C_INIT_PRIORITY + +endif # GPIO_MCP230XX + +endif # BOARD_STM32MP135F_DK diff --git a/boards/st/stm32mp135f_dk/stm32mp135f_dk.dts b/boards/st/stm32mp135f_dk/stm32mp135f_dk.dts index 28442f9e27b1..98cf9d03c713 100644 --- a/boards/st/stm32mp135f_dk/stm32mp135f_dk.dts +++ b/boards/st/stm32mp135f_dk/stm32mp135f_dk.dts @@ -9,7 +9,9 @@ #include #include #include "zephyr/dt-bindings/display/panel.h" +#include #include +#include / { model = "STMicroelectronics STM32MP135-DK board"; @@ -62,6 +64,15 @@ led1 = &red_led_2; sw0 = &user_button; }; + + csi_connector: connector_csi { + compatible = "raspberrypi,csi-connector"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0 0x3f>; + gpio-map = , + ; + }; }; &clk_hsi { @@ -89,6 +100,17 @@ status = "okay"; }; +&pll2 { + clocks = <&clk_hse>; + div-m = <3>; + mul-n = <66>; + div-p = <2>; + div-q = <2>; + div-r = <1>; + fracn = <5120>; + status = "okay"; +}; + &rcc { clock-frequency = ; clocks = <&pll>; @@ -124,10 +146,64 @@ status = "okay"; }; -&i2c5 { +csi_i2c: &i2c5 { pinctrl-names = "default"; pinctrl-0 = <&i2c5_scl_pd1 &i2c5_sda_ph6>; status = "okay"; + + mipid02: bridge@14 { + compatible = "st,mipid02"; + reg = <0x14>; + reset-gpios = <&mcp23017 2 GPIO_ACTIVE_LOW>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + port@0 { + reg = <0>; + + csi_ep_in: endpoint { + remote-endpoint-label = ""; + }; + }; + + port@2 { + reg = <2>; + + mipid02_2: endpoint { + bus-width = <8>; + hsync-active = <0>; + vsync-active = <0>; + pclk-sample = <0>; + remote-endpoint-label = "dcmipp_ep_in"; + }; + }; + }; + }; +}; + +csi_interface: &dcmipp { + pinctrl-0 = <&dcmipp_d0_pa9 &dcmipp_d1_pd0 &dcmipp_d2_pg10 &dcmipp_d3_pe4 + &dcmipp_d4_pd11 &dcmipp_d5_pd3 &dcmipp_d6_pb8 &dcmipp_d7_pe14 + &dcmipp_pixclk_pb7 &dcmipp_vsync_pg9 &dcmipp_hsync_ph8>; + pinctrl-names = "default"; + + ports { + port@0 { + dcmipp_ep_in: endpoint { + bus-width = <8>; + hsync-active = <0>; + vsync-active = <0>; + pclk-sample = <0>; + bus-type = ; + remote-endpoint-label = "mipid02_2"; + }; + }; + + port@1 { + csi_capture_port: endpoint { }; + }; + }; }; <dc { @@ -166,3 +242,16 @@ def-back-color-green = <0xFF>; def-back-color-blue = <0xFF>; }; + +/* + * MCO1 is used to clock ST-MIPID02, keep disabled here, will be + * enabled by a shield when camera pipeline is enabled + */ +&mco1 { + clocks = <&rcc STM32_SRC_HSE MCO1_SEL(MCO1_SEL_HSE)>; + prescaler = ; + pinctrl-0 = <&rcc_mco_1_pd7>; + pinctrl-names = "default"; + + status = "disabled"; +}; diff --git a/samples/drivers/video/capture/boards/stm32mp135f_dk.conf b/samples/drivers/video/capture/boards/stm32mp135f_dk.conf new file mode 100644 index 000000000000..ef4f22db728a --- /dev/null +++ b/samples/drivers/video/capture/boards/stm32mp135f_dk.conf @@ -0,0 +1,8 @@ +CONFIG_VIDEO_PIXEL_FORMAT="RGBP" +CONFIG_VIDEO_FRAME_WIDTH=480 +CONFIG_VIDEO_FRAME_HEIGHT=272 +CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=262000 +CONFIG_VIDEO_SOURCE_CROP_LEFT=80 +CONFIG_VIDEO_SOURCE_CROP_TOP=104 +CONFIG_VIDEO_SOURCE_CROP_WIDTH=480 +CONFIG_VIDEO_SOURCE_CROP_HEIGHT=272