2022-05-16 14:13:38

by Max Krummenacher

[permalink] [raw]
Subject: [PATCH v1 11/17] ARM: dts: imx6q-apalis: Add ov5640 mipi csi camera

From: Oleksandr Suvorov <[email protected]>

The Apalis iMX6 modules allow connecting a mipi-csi video input.
Add support for our OV5640 camera module but have it disabled.
This allows to enable it in an overlay per the current system
configuration.

Signed-off-by: Oleksandr Suvorov <[email protected]>
Signed-off-by: Max Krummenacher <[email protected]>
---

arch/arm/boot/dts/imx6qdl-apalis.dtsi | 67 ++++++++++++++++++++++++++-
1 file changed, 66 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/imx6qdl-apalis.dtsi b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
index 506d040ea37a..0d1004eede62 100644
--- a/arch/arm/boot/dts/imx6qdl-apalis.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
@@ -29,6 +29,12 @@
status = "disabled";
};

+ clk_ov5640_osc: clk_ov5640_osc_int {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ clock-frequency = <24000000>;
+ };
+
lcd_display: disp0 {
compatible = "fsl,imx-parallel-display";
#address-cells = <1>;
@@ -96,6 +102,26 @@
regulator-always-on;
};

+ reg_ov5640_1v8_d_o_vdd: regulator-ov5640-1v8-d-o-vdd {
+ compatible = "regulator-fixed";
+ regulator-always-on;
+ regulator-max-microvolt = <1800000>;
+ regulator-min-microvolt = <1800000>;
+ regulator-name = "DOVDD/DVDD_1.8V";
+ /* Note: The CSI module uses on-board 3.3V_SW supply */
+ vin-supply = <&reg_module_3v3>;
+ };
+
+ reg_ov5640_2v8_a_vdd: regulator-ov5640-2v8-a-vdd {
+ compatible = "regulator-fixed";
+ regulator-always-on;
+ regulator-max-microvolt = <2800000>;
+ regulator-min-microvolt = <2800000>;
+ regulator-name = "AVDD/AFVDD_2.8V";
+ /* Note: The CSI module uses on-board 3.3V_SW supply */
+ vin-supply = <&reg_module_3v3>;
+ };
+
reg_usb_otg_vbus: regulator-usb-otg-vbus {
compatible = "regulator-fixed";
pinctrl-names = "default";
@@ -438,7 +464,6 @@
reset-gpios = <&gpio6 9 GPIO_ACTIVE_LOW>; /* MXM3_13 */
status = "disabled";
};
-
};

/*
@@ -617,6 +642,30 @@
scl-gpios = <&gpio3 17 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
sda-gpios = <&gpio3 18 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
status = "disabled";
+
+ ov5640_csi_cam: ov5640_mipi@3c {
+ compatible = "ovti,ov5640";
+ AVDD-supply = <&reg_ov5640_2v8_a_vdd>;
+ DOVDD-supply = <&reg_ov5640_1v8_d_o_vdd>;
+ DVDD-supply = <&reg_ov5640_1v8_d_o_vdd>;
+ clocks = <&clks IMX6QDL_CLK_CKO2>;
+ clock-names = "xclk";
+ pinctrl-names = "default";
+ pinctrl-0 = <&pinctrl_cam_mclk>;
+ /* These GPIOs are muxed with the iomuxc node */
+ powerdown-gpios = <&gpio2 5 GPIO_ACTIVE_HIGH>;
+ reg = <0x3c>;
+ reset-gpios = <&gpio2 4 GPIO_ACTIVE_LOW>;
+ status = "disabled";
+
+ port {
+ ov5640_to_mipi_csi2: endpoint {
+ clock-lanes = <0>;
+ data-lanes = <1 2>;
+ remote-endpoint = <&mipi_csi_from_ov5640>;
+ };
+ };
+ };
};

&ipu1_di1_disp1 {
@@ -647,6 +696,22 @@
};
};

+&mipi_csi {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ status = "disabled";
+
+ port@0 {
+ reg = <0>;
+
+ mipi_csi_from_ov5640: endpoint {
+ clock-lanes = <0>;
+ data-lanes = <1 2>;
+ remote-endpoint = <&ov5640_to_mipi_csi2>;
+ };
+ };
+};
+
&pwm1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_pwm1>;
--
2.20.1



2022-05-16 22:48:30

by Fabio Estevam

[permalink] [raw]
Subject: Re: [PATCH v1 11/17] ARM: dts: imx6q-apalis: Add ov5640 mipi csi camera

Hi Max,

On Mon, May 16, 2022 at 8:59 AM Max Krummenacher <[email protected]> wrote:
>
> From: Oleksandr Suvorov <[email protected]>
>
> The Apalis iMX6 modules allow connecting a mipi-csi video input.
> Add support for our OV5640 camera module but have it disabled.
> This allows to enable it in an overlay per the current system
> configuration.
>
> Signed-off-by: Oleksandr Suvorov <[email protected]>
> Signed-off-by: Max Krummenacher <[email protected]>
> ---
>
> arch/arm/boot/dts/imx6qdl-apalis.dtsi | 67 ++++++++++++++++++++++++++-
> 1 file changed, 66 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/dts/imx6qdl-apalis.dtsi b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> index 506d040ea37a..0d1004eede62 100644
> --- a/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> +++ b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> @@ -29,6 +29,12 @@
> status = "disabled";
> };
>
> + clk_ov5640_osc: clk_ov5640_osc_int {

Node names should have "-", not "_"

clk_ov5640_osc: clk-ov5640-osc

Also, no need for the _int suffix.

Just curious: is ov5640 mipi support functional?

I recalled that I had issues in getting Gstreamer pipeline to capture
from the ov5640 mipi.

There were some errors related to LP-11 during the start of the capture.

2022-05-18 03:54:54

by Fabio Estevam

[permalink] [raw]
Subject: Re: [PATCH v1 11/17] ARM: dts: imx6q-apalis: Add ov5640 mipi csi camera

Hi Max,

On Mon, May 16, 2022 at 8:59 AM Max Krummenacher <[email protected]> wrote:

> + ov5640_csi_cam: ov5640_mipi@3c {
> + compatible = "ovti,ov5640";

Does it make sense to describe the ov5640 camera in the Apalis SoM dtsi?

The camera is not populated in the SoM. What if the customer baseboard
uses a different camera?

The same applies to the adv720 description.

2022-05-18 14:27:24

by Max Krummenacher

[permalink] [raw]
Subject: Re: [PATCH v1 11/17] ARM: dts: imx6q-apalis: Add ov5640 mipi csi camera

Hi Fabio

On Mon, May 16, 2022 at 2:08 PM Fabio Estevam <[email protected]> wrote:
>
> Hi Max,
>
> On Mon, May 16, 2022 at 8:59 AM Max Krummenacher <[email protected]> wrote:
> >
> > From: Oleksandr Suvorov <[email protected]>
> >
> > The Apalis iMX6 modules allow connecting a mipi-csi video input.
> > Add support for our OV5640 camera module but have it disabled.
> > This allows to enable it in an overlay per the current system
> > configuration.
> >
> > Signed-off-by: Oleksandr Suvorov <[email protected]>
> > Signed-off-by: Max Krummenacher <[email protected]>
> > ---
> >
> > arch/arm/boot/dts/imx6qdl-apalis.dtsi | 67 ++++++++++++++++++++++++++-
> > 1 file changed, 66 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm/boot/dts/imx6qdl-apalis.dtsi b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> > index 506d040ea37a..0d1004eede62 100644
> > --- a/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> > +++ b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> > @@ -29,6 +29,12 @@
> > status = "disabled";
> > };
> >
> > + clk_ov5640_osc: clk_ov5640_osc_int {
>
> Node names should have "-", not "_"

Ups, missed that one. Will fix it in V2. Thanks.

>
> clk_ov5640_osc: clk-ov5640-osc
>
> Also, no need for the _int suffix.
>
> Just curious: is ov5640 mipi support functional?
>
> I recalled that I had issues in getting Gstreamer pipeline to capture
> from the ov5640 mipi.
>
> There were some errors related to LP-11 during the start of the capture.

In my (limited) testing I saw no issues that the camera would not come up.
It takes 2 to 3 seconds until the pipeline is running but I noted no hickups.
I did this with setting the resolution to 640x480 and 1920x1080 which
probably would not relate to the LP-11 issue you mention.

I.e. I set up the v4l2 pipeline and start capture to the screen as follows:
```
media-ctl -l "'ov5640 1-003c':0 -> 'imx6-mipi-csi2':0[1]"
media-ctl -l "'imx6-mipi-csi2':2 -> 'ipu1_csi1':0[1]"
media-ctl -l "'ipu1_csi1':2 -> 'ipu1_csi1 capture':0[1]"
media-ctl -V "'ov5640 1-003c':0 [fmt:UYVY2X8/640x480 field:none]"
media-ctl -V "'imx6-mipi-csi2':2 [fmt:UYVY2X8/640x480 field:none]"
media-ctl -V "'ipu1_csi1':2 [fmt:AYUV32/640x480 field:none]"
gst-launch-1.0 v4l2src device='/dev/video0' ! videoconvert ! waylandsink
```

Max

2022-05-18 14:28:16

by Fabio Estevam

[permalink] [raw]
Subject: Re: [PATCH v1 11/17] ARM: dts: imx6q-apalis: Add ov5640 mipi csi camera

Hi Max,

On Wed, May 18, 2022 at 11:21 AM Max Krummenacher <[email protected]> wrote:

> In my (limited) testing I saw no issues that the camera would not come up.
> It takes 2 to 3 seconds until the pipeline is running but I noted no hickups.
> I did this with setting the resolution to 640x480 and 1920x1080 which
> probably would not relate to the LP-11 issue you mention.
>
> I.e. I set up the v4l2 pipeline and start capture to the screen as follows:

Just curious: which baseboard did you use to test the ov5640 camera?

Most likely there was an issue with the customer's baseboard that
prevented the camera capture to start.

Thanks

2022-05-18 14:31:18

by Max Krummenacher

[permalink] [raw]
Subject: Re: [PATCH v1 11/17] ARM: dts: imx6q-apalis: Add ov5640 mipi csi camera

Hi Fabio

On Tue, May 17, 2022 at 8:28 PM Fabio Estevam <[email protected]> wrote:
>
> Hi Max,
>
> On Mon, May 16, 2022 at 8:59 AM Max Krummenacher <[email protected]> wrote:
>
> > + ov5640_csi_cam: ov5640_mipi@3c {
> > + compatible = "ovti,ov5640";
>
> Does it make sense to describe the ov5640 camera in the Apalis SoM dtsi?
>
> The camera is not populated in the SoM. What if the customer baseboard
> uses a different camera?
>
> The same applies to the adv720 description.

We moved to a pattern where we do describe the 'Toradex' peripherals
in the SoM dtsi but
keep their status disabled. Then if the peripheral is on the carrier
board we only have to
enable it in the carrier board dts, for peripherals attached to the
carrier boards (e.g. like the
cameras) we enable it in device tree overlays.
This did reduce code duplication a lot.
A customer who attaches a different camera would add its camera node
in its device tree
or overlay and keep the ov5640 or adv7280 nodes disabled.

So I would rather not change anything here.

Max

2022-05-18 14:55:27

by Max Krummenacher

[permalink] [raw]
Subject: Re: [PATCH v1 11/17] ARM: dts: imx6q-apalis: Add ov5640 mipi csi camera

Hi Fabio

On Wed, May 18, 2022 at 4:25 PM Fabio Estevam <[email protected]> wrote:
>
> Hi Max,
>
> On Wed, May 18, 2022 at 11:21 AM Max Krummenacher <[email protected]> wrote:
>
> > In my (limited) testing I saw no issues that the camera would not come up.
> > It takes 2 to 3 seconds until the pipeline is running but I noted no hickups.
> > I did this with setting the resolution to 640x480 and 1920x1080 which
> > probably would not relate to the LP-11 issue you mention.
> >
> > I.e. I set up the v4l2 pipeline and start capture to the screen as follows:
>
> Just curious: which baseboard did you use to test the ov5640 camera?
>
> Most likely there was an issue with the customer's baseboard that
> prevented the camera capture to start.

I used an 'Apalis Evaluation Board' with an 'Apalis iMX6 Mezannine V2.0A'.
Now I did retry and it works equally well on an 'Ixora V1.1A'

Note that in the beginning the camera module required the SoM to provide
a 24MHz clock. The V1.1B HW version then got its local oscillator and the
clock input no longer requires a clock. That may or may not have been the
issue your customer saw.

Max