ARM: dts: imx7d-pico-pi: add OV5645 camera support
Subsystems (2)
PATCH 1/1 ARM: dts: imx7d-pico-pi: add OV5645 camera support
Add OV5645 camera device node and enable relevant components in the video capture data path, so output stream can be captured, and the camera itself can be controlled over I²C bus.
This is roughly based on descriptions found in downstream kernel tree [1], adapted to match upstream bindings.
The camera can probe successfully and establish an image path through MIPI-CSI and CSI peripherals, but so far I wasn't able to transfer the actual image, probably due to pixel format incompatibilities between the camera and CSI peripheral drivers - yet I'm hoping, that submitting this will eventually help getting full support.
--- arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts | 60 +++++++++++++++++++++ 1 file changed, 60 insertions(+)
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts +60 -0
@@ -59,6 +59,33 @@ polytouch: touchscreen@38 { touchscreen-size-x = <800>; touchscreen-size-y = <480>; }; + + camera@3c { + compatible = "ovti,ov5645"; + reg = <0x3c>; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_camera>; + + clocks = <&clks IMX7D_CLKO1_ROOT_DIV>; + assigned-clocks = <&clks IMX7D_CLKO1_ROOT_DIV>; + assigned-clock-rates = <24000000>; + + enable-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>; + + vdda-supply = <®_2p5v>; + vdddo-supply = <®_vref_1v8>; + vddd-supply = <®_vref_1v8>; + + port { + ov5645_to_mipi_csi2: endpoint { + remote-endpoint = <&mipi_csi2_in>; + clock-lanes = <0>; + data-lanes = <1 2>; + }; + }; + }; }; &usdhc1 {
@@ -93,5 +120,38 @@ MX7D_PAD_EPDC_DATA04__GPIO2_IO4 0x14 MX7D_PAD_EPDC_DATA13__GPIO2_IO13 0x14 >; }; +}; + +&iomuxc_lpsr { + pinctrl_camera: cameragrp { + fsl,pins = < + MX7D_PAD_LPSR_GPIO1_IO04__GPIO1_IO4 0x15 + MX7D_PAD_LPSR_GPIO1_IO05__GPIO1_IO5 0x15 + MX7D_PAD_LPSR_GPIO1_IO02__CCM_CLKO1 0x7d + >; + }; +}; + +&csi { + status = "okay"; +}; + +&mipi_csi { + status = "okay"; + clock-frequency = <24000000>; + + ports { + port@0 { + reg = <0>; + + mipi_csi2_in: endpoint { + remote-endpoint = <&ov5645_to_mipi_csi2>; + data-lanes = <1 2>; + }; + }; + }; +}; +&video_mux { + status = "okay"; };
base-commit: 79bd2dded182b1d458b18e62684b7f82ffc682e5
Signature · 1 line
2.47.3
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Incorrect `clock-frequency` assignment in the `&mipi_csi` node drastically reduces the MIPI CSI…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Incorrect clock-frequency assignment in the &mipi_csi node drastically reduces the MIPI CSI wrapper clock, causing image capture failures. --
commit aa98f4a3e7fa5b72ccc19a9fd456c518fe7ea6ff
Author: Lech Perczak <[email protected]>
ARM: dts: imx7d-pico-pi: add OV5645 camera support
This commit adds the OV5645 camera device node and enables the relevant components in the video capture data path for the imx7d-pico-pi. The author noted that the camera probes successfully but image transfer fails, suspecting pixel format incompatibilities.
Quoted 4 lines
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts +0
-0
[ ... ]
Quoted 1 line
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts +0
-0@@ -93,5 +120,38 @@ MX7D_PAD_EPDC_DATA04__GPIO2_IO4 0x14
[ ... ]
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts
Quoted 3 lines
+&mipi_csi {
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts +2
-0+ status = "okay"; + clock-frequency = <24000000>;
[Severity: Medium]
Could this clock-frequency assignment be the cause of the image capture failures mentioned in the commit message?
According to the nxp,imx-mipi-csi2.yaml binding schema and the imx-mipi-csis.c driver, this deprecated property overrides the MIPI CSI-2 receiver's internal wrap clock.
By forcing this clock to 24 MHz, it drastically underclocks the peripheral from its default of 166 MHz. This renders it too slow to process incoming high-speed MIPI CSI-2 data.
Removing this property should allow the peripheral to use its proper high-speed default clock.
Quoted 3 lines
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts +3
-0+ + ports { + port@0 {
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v2 1/1 ARM: dts: imx7d-pico-pi: add OV5645 camera support
In reply to Lech PerczakAdd OV5645 camera device node and enable relevant components in the video capture data path, so output stream can be captured, and the camera itself can be controlled over I²C bus.
This is roughly based on descriptions found in downstream kernel tree [1], adapted to match upstream bindings.
The camera can probe successfully and establish an image path through MIPI-CSIS and CSI peripherals, and capture the picture at 1280x960px resolution, or even more, although i.MX7D is a bit underpowered to stream this uncompressed.
---
v2:
- Confirmed the video capture is actually possible with this setup. 24MHz wrap clock actually works.
- Updated MIPI wrap clock to use assigned-clocks binding.
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts | 61 +++++++++++++++++++++ 1 file changed, 61 insertions(+)
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts +61 -0
@@ -59,6 +59,33 @@ polytouch: touchscreen@38 { touchscreen-size-x = <800>; touchscreen-size-y = <480>; }; + + camera@3c { + compatible = "ovti,ov5645"; + reg = <0x3c>; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_camera>; + + clocks = <&clks IMX7D_CLKO1_ROOT_DIV>; + assigned-clocks = <&clks IMX7D_CLKO1_ROOT_DIV>; + assigned-clock-rates = <24000000>; + + enable-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>; + + vdda-supply = <®_2p5v>; + vdddo-supply = <®_vref_1v8>; + vddd-supply = <®_vref_1v8>; + + port { + ov5645_to_mipi_csi2: endpoint { + remote-endpoint = <&mipi_csi2_in>; + clock-lanes = <0>; + data-lanes = <1 2>; + }; + }; + }; }; &usdhc1 {
@@ -93,5 +120,39 @@ MX7D_PAD_EPDC_DATA04__GPIO2_IO4 0x14 MX7D_PAD_EPDC_DATA13__GPIO2_IO13 0x14 >; }; +}; + +&iomuxc_lpsr { + pinctrl_camera: cameragrp { + fsl,pins = < + MX7D_PAD_LPSR_GPIO1_IO04__GPIO1_IO4 0x15 + MX7D_PAD_LPSR_GPIO1_IO05__GPIO1_IO5 0x15 + MX7D_PAD_LPSR_GPIO1_IO02__CCM_CLKO1 0x7d + >; + }; +}; + +&csi { + status = "okay"; +}; + +&mipi_csi { + status = "okay"; + assigned-clocks = <&clks IMX7D_MIPI_CSI_ROOT_CLK>; + assigned-clock-rates = <24000000>; + + ports { + port@0 { + reg = <0>; + + mipi_csi2_in: endpoint { + remote-endpoint = <&ov5645_to_mipi_csi2>; + data-lanes = <1 2>; + }; + }; + }; +}; +&video_mux { + status = "okay"; };
base-commit: 79bd2dded182b1d458b18e62684b7f82ffc682e5
Signature · 1 line
2.47.3
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Critical] The OV5645 digital core voltage (`vddd-supply`) is mapped to a 1.8V regulator, violating the…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] The OV5645 digital core voltage (vddd-supply) is mapped to a 1.8V regulator, violating the sensor's maximum voltage rating.
- [High] The MIPI CSI core wrap clock is severely underclocked to 24MHz, causing performance bottlenecks and dropped frames. --
commit dd6924fa219eeb7e7a60387b7bc6b921c2ef8a7b
Author: Lech Perczak <[email protected]>
ARM: dts: imx7d-pico-pi: add OV5645 camera support
Add OV5645 camera device node and enable relevant components in the video capture data path. It establishes an image path through MIPI-CSIS and CSI peripherals to capture pictures at 1280x960px resolution.
Quoted 16 lines
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts +8
-0@@ -59,6 +59,33 @@ polytouch: touchscreen@38 { touchscreen-size-x = <800>; touchscreen-size-y = <480>; }; + + camera@3c { + compatible = "ovti,ov5645"; + reg = <0x3c>; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_camera>; +
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts polytouch: touchscreen@38 { · line 79
Quoted 10 lines
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts +10
-0+ clocks = <&clks IMX7D_CLKO1_ROOT_DIV>; + assigned-clocks = <&clks IMX7D_CLKO1_ROOT_DIV>; + assigned-clock-rates = <24000000>; + + enable-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>; + + vdda-supply = <®_2p5v>; + vdddo-supply = <®_vref_1v8>; + vddd-supply = <®_vref_1v8>;
[Severity: Critical]
Is the vddd-supply voltage correct here?
According to the ovti,ov5645.yaml bindings and hardware specifications, the digital core voltage (vddd-supply) should strictly be 1.5V.
Connecting this to a 1.8V regulator appears to subject the sensor to an overvoltage condition that exceeds its maximum ratings, which might lead to overheating or hardware damage.
Quoted 11 lines
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts +9
-0+ + port { + ov5645_to_mipi_csi2: endpoint { + remote-endpoint = <&mipi_csi2_in>; + clock-lanes = <0>; + data-lanes = <1 2>; + }; + }; + }; };
[ ... ]
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts MX7D_PAD_EPDC_DATA04__GPIO2_IO4 0x14 · line 142
Quoted 4 lines
+&mipi_csi {
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts +3
-0+ status = "okay"; + assigned-clocks = <&clks IMX7D_MIPI_CSI_ROOT_CLK>; + assigned-clock-rates = <24000000>;
[Severity: High]
Could this be the cause of the performance bottleneck mentioned in the commit message?
The nxp,imx-mipi-csi2.yaml bindings indicate that the CSI core wrap clock should be configured to 166MHz (<166000000>).
Setting it to 24MHz limits the processing bandwidth to ~24 Mpixels/sec, which seems insufficient for streaming uncompressed 1280x960 video. Setting the clock to 166MHz might resolve the underpowered streaming performance.
Quoted 12 lines
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts +12
-0+ + ports { + port@0 { + reg = <0>; + + mipi_csi2_in: endpoint { + remote-endpoint = <&ov5645_to_mipi_csi2>; + data-lanes = <1 2>; + }; + }; + }; +};
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v3 1/1 ARM: dts: imx7d-pico-pi: add OV5645 camera support
In reply to Lech PerczakAdd OV5645 camera device node and enable relevant components in the video capture data path, so output stream can be captured, and the camera itself can be controlled over I²C bus.
This is roughly based on descriptions found in downstream kernel tree [1], adapted to match upstream bindings.
The camera can probe successfully and establish an image path through MIPI-CSIS and CSI peripherals, and capture the picture at 1280x960px resolution, or even more, although i.MX7D is a bit underpowered to stream this uncompressed.
---
v3:
- drop the CSI wrap clock override - it is unnecessary to alter it, camera can work just with default 166MHz set there. While testing v2, I actually had it set at 144MHz by accident.
- Add explicit 1.5V regulator-fixed for the cameras vddd-supply, instead of previous 1.8V fixed regulator. This doesn't affect camera operation - I can only assume the hardware provides correct voltage anyway, as I don't have the device schematics.
v2:
- Confirmed the video capture is actually possible with this setup. 24MHz wrap clock actually works.
- Updated MIPI wrap clock to use assigned-clocks binding.
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts | 67 +++++++++++++++++++++ 1 file changed, 67 insertions(+)
arch/arm/boot/dts/nxp/imx/imx7d-pico-pi.dts +67 -0
@@ -19,6 +19,14 @@ led { }; }; + reg_1p5v: regulator-1p5v { + compatible = "regulator-fixed"; + regulator-name = "1P5V"; + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <1500000>; + regulator-always-on; + }; + sound { compatible = "simple-audio-card"; simple-audio-card,name = "imx7-sgtl5000";
@@ -59,6 +67,33 @@ polytouch: touchscreen@38 { touchscreen-size-x = <800>; touchscreen-size-y = <480>; }; + + camera@3c { + compatible = "ovti,ov5645"; + reg = <0x3c>; + + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_camera>; + + clocks = <&clks IMX7D_CLKO1_ROOT_DIV>; + assigned-clocks = <&clks IMX7D_CLKO1_ROOT_DIV>; + assigned-clock-rates = <24000000>; + + enable-gpios = <&gpio1 4 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>; + + vdda-supply = <®_2p5v>; + vdddo-supply = <®_vref_1v8>; + vddd-supply = <®_1p5v>; + + port { + ov5645_to_mipi_csi2: endpoint { + remote-endpoint = <&mipi_csi2_in>; + clock-lanes = <0>; + data-lanes = <1 2>; + }; + }; + }; }; &usdhc1 {
@@ -93,5 +128,37 @@ MX7D_PAD_EPDC_DATA04__GPIO2_IO4 0x14 MX7D_PAD_EPDC_DATA13__GPIO2_IO13 0x14 >; }; +}; + +&iomuxc_lpsr { + pinctrl_camera: cameragrp { + fsl,pins = < + MX7D_PAD_LPSR_GPIO1_IO04__GPIO1_IO4 0x15 + MX7D_PAD_LPSR_GPIO1_IO05__GPIO1_IO5 0x15 + MX7D_PAD_LPSR_GPIO1_IO02__CCM_CLKO1 0x7d + >; + }; +}; + +&csi { + status = "okay"; +}; + +&mipi_csi { + status = "okay"; + + ports { + port@0 { + reg = <0>; + + mipi_csi2_in: endpoint { + remote-endpoint = <&ov5645_to_mipi_csi2>; + data-lanes = <1 2>; + }; + }; + }; +}; +&video_mux { + status = "okay"; };
base-commit: 79bd2dded182b1d458b18e62684b7f82ffc682e5
Signature · 1 line
2.47.3
[email protected]
AppliedFrom: Frank Li <[email protected]>
Quoted 8 lines · Lech Perczak
Add OV5645 camera device node and enable relevant components in the video capture data path, so output stream can be captured, and the camera itself can be controlled over I²C bus.
This is roughly based on descriptions found in downstream kernel tree [1], adapted to match upstream bindings.
[...]
Applied, thanks!
[1/1] ARM: dts: imx7d-pico-pi: add OV5645 camera support
commit: ddcc0ca8809b4fe5b80510f611eedcc0679abe5a
Remove always-on for regulor and truncate commit message by remote testing part.
Best regards,
--
Frank Li <[email protected]>