From 177c559bc58379e4cbd5756b4c40ffa60883bd99 Mon Sep 17 00:00:00 2001 From: Neil Chen Date: Tue, 24 Jun 2025 11:06:01 +0800 Subject: [PATCH 1/4] dts: arm/nxp: Add smartdma nodes to NXP MCXN23x dtsi file Add smartdma nodes to NXP MCXN23x dtsi file Signed-off-by: Neil Chen --- dts/arm/nxp/nxp_mcxn23x_common.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dts/arm/nxp/nxp_mcxn23x_common.dtsi b/dts/arm/nxp/nxp_mcxn23x_common.dtsi index 4e2b28ebe5e10..ddd512249d770 100644 --- a/dts/arm/nxp/nxp_mcxn23x_common.dtsi +++ b/dts/arm/nxp/nxp_mcxn23x_common.dtsi @@ -897,6 +897,15 @@ clock-src = <0>; alarms-count = <1>; }; + + smartdma: smartdma@33000 { + compatible = "nxp,smartdma"; + reg = <0x33000 0x1000>; + status = "disabled"; + interrupts = <53 0>; + program-mem = <0x4000000>; + #dma-cells = <0>; + }; }; &systick { From bc5167a06b0048a0e98f95e622704a7d1febc8f9 Mon Sep 17 00:00:00 2001 From: Neil Chen Date: Tue, 24 Jun 2025 11:10:45 +0800 Subject: [PATCH 2/4] boards: nxp: frdm_mcxn236: Support i3c for NXP frdm_mcxn236 board Support smartdma and flexcomm0 for NXP frdm_mcxn236 board. The default console pins are duplicated with camera header pins, so add flexcomm0_lpuart0 for smartdma_camera serial output. Signed-off-by: Neil Chen --- boards/nxp/frdm_mcxn236/board.c | 19 ++++++++ .../frdm_mcxn236/frdm_mcxn236-pinctrl.dtsi | 30 +++++++++++++ boards/nxp/frdm_mcxn236/frdm_mcxn236.dtsi | 43 +++++++++++++++++++ boards/nxp/frdm_mcxn236/frdm_mcxn236.yaml | 1 + 4 files changed, 93 insertions(+) diff --git a/boards/nxp/frdm_mcxn236/board.c b/boards/nxp/frdm_mcxn236/board.c index f990251a4f335..5d2525e5ff8d8 100644 --- a/boards/nxp/frdm_mcxn236/board.c +++ b/boards/nxp/frdm_mcxn236/board.c @@ -122,6 +122,12 @@ void board_early_init_hook(void) CLOCK_SetClkDiv(kCLOCK_DivPLL1Clk0, 1U); #endif +#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm0)) + /* Configure input clock to be able to reach the datasheet specified SPI band rate. */ + CLOCK_SetClkDiv(kCLOCK_DivFlexcom0Clk, 1u); + CLOCK_AttachClk(kFRO_HF_DIV_to_FLEXCOMM0); +#endif + #if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(flexcomm1)) /* Configure input clock to be able to reach the datasheet specified SPI band rate. */ CLOCK_SetClkDiv(kCLOCK_DivFlexcom1Clk, 1u); @@ -305,6 +311,19 @@ void board_early_init_hook(void) CLOCK_AttachClk(kPLL0_to_I3C1FCLK); #endif +#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(smartdma)) + CLOCK_EnableClock(kCLOCK_Smartdma); + RESET_PeripheralReset(kSMART_DMA_RST_SHIFT_RSTn); +#if DT_NODE_HAS_STATUS_OKAY(DT_NODELABEL(video_sdma)) + /* Drive CLKOUT from main clock, divided by 25 to yield 6MHz clock + * The camera will use this clock signal to generate + * PCLK, HSYNC, and VSYNC + */ + CLOCK_AttachClk(kMAIN_CLK_to_CLKOUT); + CLOCK_SetClkDiv(kCLOCK_DivClkOut, 25U); +#endif +#endif + /* Set SystemCoreClock variable. */ SystemCoreClock = CLOCK_INIT_CORE_CLOCK; } diff --git a/boards/nxp/frdm_mcxn236/frdm_mcxn236-pinctrl.dtsi b/boards/nxp/frdm_mcxn236/frdm_mcxn236-pinctrl.dtsi index 19a06b8453fed..0b629c88a4e3f 100644 --- a/boards/nxp/frdm_mcxn236/frdm_mcxn236-pinctrl.dtsi +++ b/boards/nxp/frdm_mcxn236/frdm_mcxn236-pinctrl.dtsi @@ -7,6 +7,16 @@ #include &pinctrl { + pinmux_flexcomm0_lpuart: pinmux_flexcomm0_lpuart { + group0 { + pinmux = , + ; + slew-rate = "fast"; + drive-strength = "low"; + input-enable; + }; + }; + pinmux_flexcomm2_lpuart: pinmux_flexcomm2_lpuart { group0 { pinmux = , @@ -177,4 +187,24 @@ bias-pull-up; }; }; + + pinmux_smartdma_camera: pinmux_smartdma_camera { + group0 { + pinmux = , + , + , + , + , + , + , + , + , + , + , + ; + drive-strength = "low"; + slew-rate = "fast"; + input-enable; + }; + }; }; diff --git a/boards/nxp/frdm_mcxn236/frdm_mcxn236.dtsi b/boards/nxp/frdm_mcxn236/frdm_mcxn236.dtsi index 8223342b4140c..94415366820f3 100644 --- a/boards/nxp/frdm_mcxn236/frdm_mcxn236.dtsi +++ b/boards/nxp/frdm_mcxn236/frdm_mcxn236.dtsi @@ -7,6 +7,7 @@ #include "frdm_mcxn236-pinctrl.dtsi" #include #include +#include / { aliases{ @@ -62,6 +63,12 @@ }; }; +&flexcomm0_lpuart0 { + current-speed = <115200>; + pinctrl-0 = <&pinmux_flexcomm0_lpuart>; + pinctrl-names = "default"; +}; + &flexcomm2_lpuart2 { current-speed = <115200>; pinctrl-0 = <&pinmux_flexcomm2_lpuart>; @@ -185,3 +192,39 @@ zephyr_mipi_dbi_parallel: &flexio0_lcd { p3t1755dp_ard_i3c_interface: &i3c1 {}; p3t1755dp_ard_i2c_interface: &flexcomm5_lpi2c5 {}; + +/* SmartDMA is used for video driver on this board */ +&smartdma { + /* Shields do not enable video-sdma parent node so enable it by default */ + status = "okay"; + program-mem = <0x4000000>; + + video_sdma: video-sdma { + status = "disabled"; + compatible = "nxp,video-smartdma"; + pinctrl-0 = <&pinmux_smartdma_camera>; + pinctrl-names = "default"; + vsync-pin = <4>; + hsync-pin = <5>; + pclk-pin = <7>; + }; +}; + +/* + * Connection with camera modules such as the dvp_20pin_ov7670 shield + */ + +/ { + dvp_20pin_connector: dvp-20pin-connector { + compatible = "arducam,dvp-20pin-connector"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0x0 GPIO_DT_FLAGS_MASK>; + gpio-map = , + ; + }; +}; + +dvp_20pin_i2c: &flexcomm2_lpi2c2 {}; + +dvp_20pin_interface: &video_sdma {}; diff --git a/boards/nxp/frdm_mcxn236/frdm_mcxn236.yaml b/boards/nxp/frdm_mcxn236/frdm_mcxn236.yaml index 1a234da09cde4..ded66dd4b3ef4 100644 --- a/boards/nxp/frdm_mcxn236/frdm_mcxn236.yaml +++ b/boards/nxp/frdm_mcxn236/frdm_mcxn236.yaml @@ -26,5 +26,6 @@ supported: - regulator - spi - usbd + - video - watchdog vendor: nxp From 6de1629019820c65486657140c76e478d9831341 Mon Sep 17 00:00:00 2001 From: Neil Chen Date: Wed, 25 Jun 2025 14:54:16 +0800 Subject: [PATCH 3/4] samples: video: Add support for smartdma video on FRDM_MCXN236 Add support for using the SMARTDMA engine on the FRDM-MCXN236 board with the video capture sample. Replace console pins, because default console pins(P1_8, P1_9) are duplicated with camera header pins. Signed-off-by: Neil Chen --- .../video/capture/boards/frdm_mcxn236.conf | 1 + .../video/capture/boards/frdm_mcxn236.overlay | 23 +++++++++++++++++++ samples/drivers/video/capture/sample.yaml | 2 ++ 3 files changed, 26 insertions(+) create mode 100644 samples/drivers/video/capture/boards/frdm_mcxn236.conf create mode 100644 samples/drivers/video/capture/boards/frdm_mcxn236.overlay diff --git a/samples/drivers/video/capture/boards/frdm_mcxn236.conf b/samples/drivers/video/capture/boards/frdm_mcxn236.conf new file mode 100644 index 0000000000000..0f4576e59d11d --- /dev/null +++ b/samples/drivers/video/capture/boards/frdm_mcxn236.conf @@ -0,0 +1 @@ +CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=40000 diff --git a/samples/drivers/video/capture/boards/frdm_mcxn236.overlay b/samples/drivers/video/capture/boards/frdm_mcxn236.overlay new file mode 100644 index 0000000000000..b7605086b0641 --- /dev/null +++ b/samples/drivers/video/capture/boards/frdm_mcxn236.overlay @@ -0,0 +1,23 @@ +/* + * Copyright 2025 NXP + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + chosen { + /* Switch to flexcomm0_lpuart0(P0_16,P0_17), since default console + * pins are duplicated with camera header pins + */ + zephyr,console = &flexcomm0_lpuart0; + zephyr,shell-uart = &flexcomm0_lpuart0; + }; +}; + +&flexcomm0 { + status = "okay"; +}; + +&flexcomm0_lpuart0 { + status = "okay"; +}; diff --git a/samples/drivers/video/capture/sample.yaml b/samples/drivers/video/capture/sample.yaml index e52f26aa7cd17..7c23fb7ebb295 100644 --- a/samples/drivers/video/capture/sample.yaml +++ b/samples/drivers/video/capture/sample.yaml @@ -11,6 +11,7 @@ tests: - platform:mimxrt1170_evk/mimxrt1176/cm7:SHIELD="nxp_btb44_ov5640;rk055hdmipi4ma0" - platform:mimxrt1170_evk@B/mimxrt1176/cm7:SHIELD="nxp_btb44_ov5640;rk055hdmipi4ma0" - platform:frdm_mcxn947/mcxn947/cpu0:SHIELD="dvp_20pin_ov7670;lcd_par_s035_8080" + - platform:frdm_mcxn236/mcxn236:SHIELD="dvp_20pin_ov7670;lcd_par_s035_8080" extra_configs: - CONFIG_TEST=y - CONFIG_FPU=y @@ -30,6 +31,7 @@ tests: - mimxrt1170_evk/mimxrt1176/cm7 - mimxrt1170_evk@B/mimxrt1176/cm7 - frdm_mcxn947/mcxn947/cpu0 + - frdm_mcxn236/mcxn236 - mm_swiftio - esp32s3_eye/esp32s3/procpu depends_on: video From 33667b41a61d4b458e170b64218659c1e931eb16 Mon Sep 17 00:00:00 2001 From: Neil Chen Date: Wed, 25 Jun 2025 14:57:08 +0800 Subject: [PATCH 4/4] boards: nxp: frdm_mcxn947: Add video support in frdm_mcxn947 board yaml Add video support in frdm_mcxn947 board yaml Signed-off-by: Neil Chen --- boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.yaml b/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.yaml index 1648313dc3d37..462e1eb809fd5 100644 --- a/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.yaml +++ b/boards/nxp/frdm_mcxn947/frdm_mcxn947_mcxn947_cpu0.yaml @@ -31,5 +31,6 @@ supported: - sdhc - spi - usb_device + - video - watchdog vendor: nxp