ARM: dts: r8a7742-iwg21d-q7-dbcm-ca: Separate out ov5640 nodes
authorLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Fri, 22 Jan 2021 11:34:23 +0000 (12:34 +0100)
committerGeert Uytterhoeven <geert+renesas@glider.be>
Mon, 8 Mar 2021 09:22:38 +0000 (10:22 +0100)
The camera daughter board can also be connected to 8-bit ov7725 sensors,
so in preparation for configurable option to choose depending on the
camera's connected separate out the ov5640 nodes in a dtsi file.

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
[geert: describe a single camera in the .dtsi, include multiple times]
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Link: https://lore.kernel.org/r/20210122113424.2833127-2-geert+renesas@glider.be
arch/arm/boot/dts/r8a7742-iwg21d-q7-dbcm-ca.dts
arch/arm/boot/dts/r8a7742-iwg21d-q7-dbcm-ov5640-single.dtsi [new file with mode: 0644]

index 98c3fbd89fa6c5c79c248bf011958fdb46a85872..bc8280b2ac47e3ec86cfe059695b270d62513f84 100644 (file)
        status = "okay";
 };
 
-&i2c0 {
-       ov5640@3c {
-               compatible = "ovti,ov5640";
-               reg = <0x3c>;
-               clocks = <&mclk_cam1>;
-               clock-names = "xclk";
-
-               port {
-                       ov5640_0: endpoint {
-                               bus-width = <8>;
-                               data-shift = <2>;
-                               bus-type = <6>;
-                               pclk-sample = <1>;
-                               remote-endpoint = <&vin0ep>;
-                       };
-               };
-       };
-};
-
 &i2c1 {
        pinctrl-0 = <&i2c1_pins>;
        pinctrl-names = "default";
 
-       status = "okay";
+       /* status set to "okay" when needed by camera configuration below */
        clock-frequency = <400000>;
-
-       ov5640@3c {
-               compatible = "ovti,ov5640";
-               reg = <0x3c>;
-               clocks = <&mclk_cam2>;
-               clock-names = "xclk";
-
-               port {
-                       ov5640_1: endpoint {
-                               bus-width = <8>;
-                               data-shift = <2>;
-                               bus-type = <6>;
-                               pclk-sample = <1>;
-                               remote-endpoint = <&vin1ep>;
-                       };
-               };
-       };
-};
-
-&i2c2 {
-       ov5640@3c {
-               compatible = "ovti,ov5640";
-               reg = <0x3c>;
-               clocks = <&mclk_cam3>;
-               clock-names = "xclk";
-
-               port {
-                       ov5640_2: endpoint {
-                               bus-width = <8>;
-                               data-shift = <2>;
-                               bus-type = <6>;
-                               pclk-sample = <1>;
-                               remote-endpoint = <&vin2ep>;
-                       };
-               };
-       };
 };
 
 &i2c3 {
        pinctrl-0 = <&i2c3_pins>;
        pinctrl-names = "default";
 
-       status = "okay";
+       /* status set to "okay" when needed by camera configuration below */
        clock-frequency = <400000>;
-
-       ov5640@3c {
-               compatible = "ovti,ov5640";
-               reg = <0x3c>;
-               clocks = <&mclk_cam4>;
-               clock-names = "xclk";
-
-               port {
-                       ov5640_3: endpoint {
-                               bus-width = <8>;
-                               data-shift = <2>;
-                               bus-type = <6>;
-                               pclk-sample = <1>;
-                               remote-endpoint = <&vin3ep>;
-                       };
-               };
-       };
 };
 
 &pfc {
        cts-gpios = <&gpio4 17 GPIO_ACTIVE_LOW>;
 };
 
+/*
+ * Below configuration ties VINx endpoints to ov5640/ov7725 camera endpoints
+ *
+ * Uncomment the #include statements to change configuration
+ */
+
+/* 8bit CMOS Camera 1 (J13) */
+#define CAM_PARENT_I2C         i2c0
+#define MCLK_CAM               mclk_cam1
+#define CAM_EP                 cam0ep
+#define VIN_EP                 vin0ep
+#undef CAM_ENABLED
+#include "r8a7742-iwg21d-q7-dbcm-ov5640-single.dtsi"
+
+#ifdef CAM_ENABLED
 &vin0 {
        /*
         * Set SW2 switch on the SOM to 'ON'
 
        port {
                vin0ep: endpoint {
-                       remote-endpoint = <&ov5640_0>;
+                       remote-endpoint = <&cam0ep>;
                        bus-width = <8>;
                        bus-type = <6>;
                };
        };
 };
-
+#endif /* CAM_ENABLED */
+
+#undef CAM_PARENT_I2C
+#undef MCLK_CAM
+#undef CAM_EP
+#undef VIN_EP
+
+/* 8bit CMOS Camera 2 (J14) */
+#define CAM_PARENT_I2C         i2c1
+#define MCLK_CAM               mclk_cam2
+#define CAM_EP                 cam1ep
+#define VIN_EP                 vin1ep
+#undef CAM_ENABLED
+#include "r8a7742-iwg21d-q7-dbcm-ov5640-single.dtsi"
+
+#ifdef CAM_ENABLED
 &vin1 {
        /* Set SW1 switch on the SOM to 'ON' */
        status = "okay";
 
        port {
                vin1ep: endpoint {
-                       remote-endpoint = <&ov5640_1>;
+                       remote-endpoint = <&cam1ep>;
                        bus-width = <8>;
                        bus-type = <6>;
                };
        };
 };
 
+#endif /* CAM_ENABLED */
+
+#undef CAM_PARENT_I2C
+#undef MCLK_CAM
+#undef CAM_EP
+#undef VIN_EP
+
+/* 8bit CMOS Camera 3 (J12) */
+#define CAM_PARENT_I2C         i2c2
+#define MCLK_CAM               mclk_cam3
+#define CAM_EP                 cam2ep
+#define VIN_EP                 vin2ep
+#undef CAM_ENABLED
+#include "r8a7742-iwg21d-q7-dbcm-ov5640-single.dtsi"
+
+#ifdef CAM_ENABLED
 &vin2 {
        status = "okay";
        pinctrl-0 = <&vin2_pins>;
 
        port {
                vin2ep: endpoint {
-                       remote-endpoint = <&ov5640_2>;
+                       remote-endpoint = <&cam2ep>;
                        bus-width = <8>;
                        data-shift = <8>;
                        bus-type = <6>;
                };
        };
 };
-
+#endif /* CAM_ENABLED */
+
+#undef CAM_PARENT_I2C
+#undef MCLK_CAM
+#undef CAM_EP
+#undef VIN_EP
+
+/* 8bit CMOS Camera 4 (J11) */
+#define CAM_PARENT_I2C         i2c3
+#define MCLK_CAM               mclk_cam4
+#define CAM_EP                 cam3ep
+#define VIN_EP                 vin3ep
+#undef CAM_ENABLED
+#include "r8a7742-iwg21d-q7-dbcm-ov5640-single.dtsi"
+
+#ifdef CAM_ENABLED
 &vin3 {
        status = "okay";
        pinctrl-0 = <&vin3_pins>;
 
        port {
                vin3ep: endpoint {
-                       remote-endpoint = <&ov5640_3>;
+                       remote-endpoint = <&cam3ep>;
                        bus-width = <8>;
                        bus-type = <6>;
                };
        };
 };
+#endif /* CAM_ENABLED */
+
+#undef CAM_PARENT_I2C
+#undef MCLK_CAM
+#undef CAM_EP
+#undef VIN_EP
diff --git a/arch/arm/boot/dts/r8a7742-iwg21d-q7-dbcm-ov5640-single.dtsi b/arch/arm/boot/dts/r8a7742-iwg21d-q7-dbcm-ov5640-single.dtsi
new file mode 100644 (file)
index 0000000..70c72ba
--- /dev/null
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * This include file ties a VIN interface with a single ov5640 sensor on
+ * the iWave-RZ/G1H Qseven board development platform connected with the
+ * camera daughter board.
+ *
+ * Copyright (C) 2020 Renesas Electronics Corp.
+ */
+
+#define CAM_ENABLED    1
+
+&CAM_PARENT_I2C {
+       status = "okay";
+
+       ov5640@3c {
+               compatible = "ovti,ov5640";
+               reg = <0x3c>;
+               clocks = <&MCLK_CAM>;
+               clock-names = "xclk";
+               status = "okay";
+
+               port {
+                       CAM_EP: endpoint {
+                               bus-width = <8>;
+                               data-shift = <2>;
+                               bus-type = <6>;
+                               pclk-sample = <1>;
+                               remote-endpoint = <&VIN_EP>;
+                       };
+               };
+       };
+};