From 7db83bf5b09ebc07e5e70bc88496a60b9abecdc4 Mon Sep 17 00:00:00 2001
From: Lee Jackson <info@arducam.com>
Date: Mon, 27 Feb 2023 19:38:05 +0800
Subject: [PATCH] dtoverlays: Add Arducam64MP support to camera mux
 overlays

Signed-off-by: Lee Jackson <lee.jackson@arducam.com>
---
 arch/arm/boot/dts/overlays/README             | 10 ++-
 .../dts/overlays/camera-mux-2port-overlay.dts | 32 ++++++++++
 .../dts/overlays/camera-mux-4port-overlay.dts | 64 +++++++++++++++++++
 3 files changed, 104 insertions(+), 2 deletions(-)

--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -714,7 +714,8 @@ Info:   Configures a 2 port camera multi
         Note that currently ALL IMX290 modules share a common clock, therefore
         all modules will need to have the same clock frequency.
 Load:   dtoverlay=camera-mux-2port,<param>=<val>
-Params: cam0-imx219             Select IMX219 for camera on port 0
+Params: cam0-arducam-64mp       Select Arducam64MP for camera on port 0
+        cam0-imx219             Select IMX219 for camera on port 0
         cam0-imx258             Select IMX258 for camera on port 0
         cam0-imx290             Select IMX290 for camera on port 0
         cam0-imx477             Select IMX477 for camera on port 0
@@ -725,6 +726,7 @@ Params: cam0-imx219             Select I
         cam0-ov7251             Select OV7251 for camera on port 0
         cam0-ov9281             Select OV9281 for camera on port 0
         cam0-imx290-clk-freq    Set clock frequency for an IMX290 on port 0
+        cam1-arducam-64mp       Select Arducam64MP for camera on port 1
         cam1-imx219             Select IMX219 for camera on port 1
         cam1-imx258             Select IMX258 for camera on port 1
         cam1-imx290             Select IMX290 for camera on port 1
@@ -743,7 +745,8 @@ Info:   Configures a 4 port camera multi
         Note that currently ALL IMX290 modules share a common clock, therefore
         all modules will need to have the same clock frequency.
 Load:   dtoverlay=camera-mux-4port,<param>=<val>
-Params: cam0-imx219             Select IMX219 for camera on port 0
+Params: cam0-arducam-64mp       Select Arducam64MP for camera on port 0
+        cam0-imx219             Select IMX219 for camera on port 0
         cam0-imx258             Select IMX258 for camera on port 0
         cam0-imx290             Select IMX290 for camera on port 0
         cam0-imx477             Select IMX477 for camera on port 0
@@ -754,6 +757,7 @@ Params: cam0-imx219             Select I
         cam0-ov7251             Select OV7251 for camera on port 0
         cam0-ov9281             Select OV9281 for camera on port 0
         cam0-imx290-clk-freq    Set clock frequency for an IMX290 on port 0
+        cam1-arducam-64mp       Select Arducam64MP for camera on port 1
         cam1-imx219             Select IMX219 for camera on port 1
         cam1-imx258             Select IMX258 for camera on port 1
         cam1-imx290             Select IMX290 for camera on port 1
@@ -765,6 +769,7 @@ Params: cam0-imx219             Select I
         cam1-ov7251             Select OV7251 for camera on port 1
         cam1-ov9281             Select OV9281 for camera on port 1
         cam1-imx290-clk-freq    Set clock frequency for an IMX290 on port 1
+        cam2-arducam-64mp       Select Arducam64MP for camera on port 2
         cam2-imx219             Select IMX219 for camera on port 2
         cam2-imx258             Select IMX258 for camera on port 2
         cam2-imx290             Select IMX290 for camera on port 2
@@ -776,6 +781,7 @@ Params: cam0-imx219             Select I
         cam2-ov7251             Select OV7251 for camera on port 2
         cam2-ov9281             Select OV9281 for camera on port 2
         cam2-imx290-clk-freq    Set clock frequency for an IMX290 on port 2
+        cam3-arducam-64mp       Select Arducam64MP for camera on port 3
         cam3-imx219             Select IMX219 for camera on port 3
         cam3-imx258             Select IMX258 for camera on port 3
         cam3-imx290             Select IMX290 for camera on port 3
--- a/arch/arm/boot/dts/overlays/camera-mux-2port-overlay.dts
+++ b/arch/arm/boot/dts/overlays/camera-mux-2port-overlay.dts
@@ -96,6 +96,16 @@
 					#address-cells = <1>;
 					#size-cells = <0>;
 
+					#define cam_node arducam_64mp_0
+					#define cam_endpoint arducam_64mp_0_ep
+					#define vcm_node arducam_64mp_0_vcm
+					#define cam1_clk clk_24mhz
+					#include "arducam-64mp.dtsi"
+					#undef cam_node
+					#undef cam_endpoint
+					#undef vcm_node
+					#undef cam1_clk
+
 					#define cam_node imx219_0
 					#define cam_endpoint imx219_0_ep
 					#define cam1_clk clk_24mhz
@@ -186,6 +196,16 @@
 					#address-cells = <1>;
 					#size-cells = <0>;
 
+					#define cam_node arducam_64mp_1
+					#define cam_endpoint arducam_64mp_1_ep
+					#define vcm_node arducam_64mp_1_vcm
+					#define cam1_clk clk_24mhz
+					#include "arducam-64mp.dtsi"
+					#undef cam_node
+					#undef cam_endpoint
+					#undef vcm_node
+					#undef cam1_clk
+
 					#define cam_node imx219_1
 					#define cam_endpoint imx219_1_ep
 					#define cam1_clk clk_24mhz
@@ -385,6 +405,12 @@
 	};
 
 	__overrides__ {
+		cam0-arducam-64mp = <&mux_in0>, "remote-endpoint:0=",<&arducam_64mp_0_ep>,
+				    <&arducam_64mp_0_ep>, "remote-endpoint:0=",<&mux_in0>,
+				    <&mux_in0>, "clock-noncontinuous?",
+				    <&arducam_64mp_0>, "status=okay",
+				    <&arducam_64mp_0_vcm>, "status=okay",
+				    <&arducam_64mp_0>,"lens-focus:0=", <&arducam_64mp_0_vcm>;
 		cam0-imx219 = <&mux_in0>, "remote-endpoint:0=",<&imx219_0_ep>,
 			      <&imx219_0_ep>, "remote-endpoint:0=",<&mux_in0>,
 			      <&mux_in0>, "clock-noncontinuous?",
@@ -425,6 +451,12 @@
 			      <&ov2311_0_ep>, "remote-endpoint:0=",<&mux_in0>,
 			      <&ov2311_0>, "status=okay";
 
+		cam1-arducam-64mp = <&mux_in1>, "remote-endpoint:0=",<&arducam_64mp_1_ep>,
+				    <&arducam_64mp_1_ep>, "remote-endpoint:0=",<&mux_in1>,
+				    <&mux_in1>, "clock-noncontinuous?",
+				    <&arducam_64mp_1>, "status=okay",
+				    <&arducam_64mp_1_vcm>, "status=okay",
+				    <&arducam_64mp_1>,"lens-focus:0=", <&arducam_64mp_1_vcm>;
 		cam1-imx219 = <&mux_in1>, "remote-endpoint:0=",<&imx219_1_ep>,
 			      <&imx219_1_ep>, "remote-endpoint:0=",<&mux_in1>,
 			      <&mux_in1>, "clock-noncontinuous?",
--- a/arch/arm/boot/dts/overlays/camera-mux-4port-overlay.dts
+++ b/arch/arm/boot/dts/overlays/camera-mux-4port-overlay.dts
@@ -154,6 +154,16 @@
 					#address-cells = <1>;
 					#size-cells = <0>;
 
+					#define cam_node arducam_64mp_0
+					#define cam_endpoint arducam_64mp_0_ep
+					#define vcm_node arducam_64mp_0_vcm
+					#define cam1_clk clk_24mhz
+					#include "arducam-64mp.dtsi"
+					#undef cam_node
+					#undef cam_endpoint
+					#undef vcm_node
+					#undef cam1_clk
+
 					#define cam_node imx219_0
 					#define cam_endpoint imx219_0_ep
 					#define cam1_clk clk_24mhz
@@ -244,6 +254,16 @@
 					#address-cells = <1>;
 					#size-cells = <0>;
 
+					#define cam_node arducam_64mp_1
+					#define cam_endpoint arducam_64mp_1_ep
+					#define vcm_node arducam_64mp_1_vcm
+					#define cam1_clk clk_24mhz
+					#include "arducam-64mp.dtsi"
+					#undef cam_node
+					#undef cam_endpoint
+					#undef vcm_node
+					#undef cam1_clk
+
 					#define cam_node imx219_1
 					#define cam_endpoint imx219_1_ep
 					#define cam1_clk clk_24mhz
@@ -334,6 +354,16 @@
 					#address-cells = <1>;
 					#size-cells = <0>;
 
+					#define cam_node arducam_64mp_2
+					#define cam_endpoint arducam_64mp_2_ep
+					#define vcm_node arducam_64mp_2_vcm
+					#define cam1_clk clk_24mhz
+					#include "arducam-64mp.dtsi"
+					#undef cam_node
+					#undef cam_endpoint
+					#undef vcm_node
+					#undef cam1_clk
+
 					#define cam_node imx219_2
 					#define cam_endpoint imx219_2_ep
 					#define cam1_clk clk_24mhz
@@ -424,6 +454,16 @@
 					#address-cells = <1>;
 					#size-cells = <0>;
 
+					#define cam_node arducam_64mp_3
+					#define cam_endpoint arducam_64mp_3_ep
+					#define vcm_node arducam_64mp_3_vcm
+					#define cam1_clk clk_24mhz
+					#include "arducam-64mp.dtsi"
+					#undef cam_node
+					#undef cam_endpoint
+					#undef vcm_node
+					#undef cam1_clk
+
 					#define cam_node imx219_3
 					#define cam_endpoint imx219_3_ep
 					#define cam1_clk clk_24mhz
@@ -640,6 +680,12 @@
 	};
 
 	__overrides__ {
+		cam0-arducam-64mp = <&mux_in0>, "remote-endpoint:0=",<&arducam_64mp_0_ep>,
+				    <&arducam_64mp_0_ep>, "remote-endpoint:0=",<&mux_in0>,
+				    <&mux_in0>, "clock-noncontinuous?",
+				    <&arducam_64mp_0>, "status=okay",
+				    <&arducam_64mp_0_vcm>, "status=okay",
+				    <&arducam_64mp_0>,"lens-focus:0=", <&arducam_64mp_0_vcm>;
 		cam0-imx219 = <&mux_in0>, "remote-endpoint:0=",<&imx219_0_ep>,
 			      <&imx219_0_ep>, "remote-endpoint:0=",<&mux_in0>,
 			      <&mux_in0>, "clock-noncontinuous?",
@@ -680,6 +726,12 @@
 			      <&ov2311_0_ep>, "remote-endpoint:0=",<&mux_in0>,
 			      <&ov2311_0>, "status=okay";
 
+		cam1-arducam-64mp = <&mux_in1>, "remote-endpoint:0=",<&arducam_64mp_1_ep>,
+				    <&arducam_64mp_1_ep>, "remote-endpoint:0=",<&mux_in1>,
+				    <&mux_in1>, "clock-noncontinuous?",
+				    <&arducam_64mp_1>, "status=okay",
+				    <&arducam_64mp_1_vcm>, "status=okay",
+				    <&arducam_64mp_1>,"lens-focus:0=", <&arducam_64mp_1_vcm>;
 		cam1-imx219 = <&mux_in1>, "remote-endpoint:0=",<&imx219_1_ep>,
 			      <&imx219_1_ep>, "remote-endpoint:0=",<&mux_in1>,
 			      <&mux_in1>, "clock-noncontinuous?",
@@ -720,6 +772,12 @@
 			      <&ov2311_1_ep>, "remote-endpoint:0=",<&mux_in1>,
 			      <&ov2311_1>, "status=okay";
 
+		cam2-arducam-64mp = <&mux_in2>, "remote-endpoint:0=",<&arducam_64mp_2_ep>,
+				    <&arducam_64mp_2_ep>, "remote-endpoint:0=",<&mux_in2>,
+				    <&mux_in2>, "clock-noncontinuous?",
+				    <&arducam_64mp_2>, "status=okay",
+				    <&arducam_64mp_2_vcm>, "status=okay",
+				    <&arducam_64mp_2>,"lens-focus:0=", <&arducam_64mp_2_vcm>;
 		cam2-imx219 = <&mux_in2>, "remote-endpoint:0=",<&imx219_2_ep>,
 			      <&imx219_2_ep>, "remote-endpoint:0=",<&mux_in2>,
 			      <&mux_in2>, "clock-noncontinuous?",
@@ -760,6 +818,12 @@
 			      <&ov2311_2_ep>, "remote-endpoint:0=",<&mux_in2>,
 			      <&ov2311_2>, "status=okay";
 
+		cam3-arducam-64mp = <&mux_in3>, "remote-endpoint:0=",<&arducam_64mp_3_ep>,
+				    <&arducam_64mp_3_ep>, "remote-endpoint:0=",<&mux_in3>,
+				    <&mux_in3>, "clock-noncontinuous?",
+				    <&arducam_64mp_3>, "status=okay",
+				    <&arducam_64mp_3_vcm>, "status=okay",
+				    <&arducam_64mp_3>,"lens-focus:0=", <&arducam_64mp_3_vcm>;
 		cam3-imx219 = <&mux_in3>, "remote-endpoint:0=",<&imx219_3_ep>,
 			      <&imx219_3_ep>, "remote-endpoint:0=",<&mux_in3>,
 			      <&mux_in3>, "clock-noncontinuous?",
