From f8b75a1bcdbf2b5cc591079cafad3b94cc74ff48 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Sat, 20 Nov 2021 14:43:29 +0000
Subject: [PATCH] dtoverlays: Convert the camera sensor overlays to use
 the new regs and clks.

Now that we have regulators and clocks defined in the base DT for
image sensors, switch the overlays to use them.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 arch/arm/boot/dts/overlays/imx219-overlay.dts | 40 ++++---------------
 .../boot/dts/overlays/imx290_327-overlay.dtsi | 40 ++++---------------
 .../boot/dts/overlays/imx477_378-overlay.dtsi | 31 +++-----------
 arch/arm/boot/dts/overlays/imx519-overlay.dts | 38 +++---------------
 arch/arm/boot/dts/overlays/ov5647-overlay.dts | 18 +++++----
 arch/arm/boot/dts/overlays/ov7251-overlay.dts | 37 +++--------------
 arch/arm/boot/dts/overlays/ov9281-overlay.dts | 39 ++++--------------
 7 files changed, 50 insertions(+), 193 deletions(-)

--- a/arch/arm/boot/dts/overlays/imx219-overlay.dts
+++ b/arch/arm/boot/dts/overlays/imx219-overlay.dts
@@ -20,12 +20,12 @@
 				reg = <0x10>;
 				status = "okay";
 
-				clocks = <&imx219_clk>;
+				clocks = <&cam1_clk>;
 				clock-names = "xclk";
 
 				VANA-supply = <&cam1_reg>;	/* 2.8v */
-				VDIG-supply = <&imx219_vdig>;	/* 1.8v */
-				VDDL-supply = <&imx219_vddl>;	/* 1.2v */
+				VDIG-supply = <&cam_dummy_reg>;	/* 1.8v */
+				VDDL-supply = <&cam_dummy_reg>;	/* 1.2v */
 
 				rotation = <180>;
 				orientation = <2>;
@@ -68,26 +68,10 @@
 	};
 
 	fragment@3 {
-		target-path="/";
+		target = <&cam1_clk>;
 		__overlay__ {
-			imx219_vdig: fixedregulator@1 {
-				compatible = "regulator-fixed";
-				regulator-name = "imx219_vdig";
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-			};
-			imx219_vddl: fixedregulator@2 {
-				compatible = "regulator-fixed";
-				regulator-name = "imx219_vddl";
-				regulator-min-microvolt = <1200000>;
-				regulator-max-microvolt = <1200000>;
-			};
-
-			imx219_clk: camera-clk {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <24000000>;
-			};
+			status = "okay";
+			clock-frequency = <24000000>;
 		};
 	};
 
@@ -99,16 +83,6 @@
 	};
 
 	fragment@5 {
-		target = <&cam1_reg>;
-		__overlay__ {
-			status = "okay";
-			regulator-name = "imx219_vana";
-			regulator-min-microvolt = <2800000>;
-			regulator-max-microvolt = <2800000>;
-		};
-	};
-
-	fragment@6 {
 		target = <&csi1>;
 		__overlay__ {
 			brcm,media-controller;
@@ -118,6 +92,6 @@
 	__overrides__ {
 		rotation = <&imx219>,"rotation:0";
 		orientation = <&imx219>,"orientation:0";
-		media-controller = <0>,"=6";
+		media-controller = <0>,"=5";
 	};
 };
--- a/arch/arm/boot/dts/overlays/imx290_327-overlay.dtsi
+++ b/arch/arm/boot/dts/overlays/imx290_327-overlay.dtsi
@@ -20,7 +20,7 @@
 				reg = <0x1a>;
 				status = "okay";
 
-				clocks = <&imx290_clk>;
+				clocks = <&cam1_clk>;
 				clock-names = "xclk";
 				clock-frequency = <37125000>;
 
@@ -28,8 +28,8 @@
 				orientation = <2>;
 
 				vdda-supply = <&cam1_reg>;	/* 2.8v */
-				vdddo-supply = <&imx290_vdddo>;	/* 1.8v */
-				vddd-supply = <&imx290_vddd>;	/* 1.5v */
+				vdddo-supply = <&cam_dummy_reg>;	/* 1.8v */
+				vddd-supply = <&cam_dummy_reg>;	/* 1.5v */
 
 				port {
 					imx290_0: endpoint {
@@ -62,26 +62,10 @@
 	};
 
 	fragment@3 {
-		target-path="/";
+		target = <&cam1_clk>;
 		__overlay__ {
-			imx290_vdddo: fixedregulator@1 {
-				compatible = "regulator-fixed";
-				regulator-name = "imx290_vdddo";
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-			};
-			imx290_vddd: fixedregulator@2 {
-				compatible = "regulator-fixed";
-				regulator-name = "imx290_vddd";
-				regulator-min-microvolt = <1500000>;
-				regulator-max-microvolt = <1500000>;
-			};
-
-			imx290_clk: camera-clk {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <37125000>;
-			};
+			status = "okay";
+			clock-frequency = <37125000>;
 		};
 	};
 
@@ -92,16 +76,6 @@
 		};
 	};
 
-	fragment@5 {
-		target = <&cam1_reg>;
-		__overlay__ {
-			status = "okay";
-			regulator-name = "imx290_vdda";
-			regulator-min-microvolt = <2800000>;
-			regulator-max-microvolt = <2800000>;
-		};
-	};
-
 	fragment@6 {
 		target = <&imx290_0>;
 		__overlay__ {
@@ -143,7 +117,7 @@
 
 	__overrides__ {
 		4lane = <0>, "-6+7-8+9";
-		clock-frequency = <&imx290_clk>,"clock-frequency:0",
+		clock-frequency = <&cam1_clk>,"clock-frequency:0",
 				  <&imx290>,"clock-frequency:0";
 		rotation = <&imx290>,"rotation:0";
 		orientation = <&imx290>,"orientation:0";
--- a/arch/arm/boot/dts/overlays/imx477_378-overlay.dtsi
+++ b/arch/arm/boot/dts/overlays/imx477_378-overlay.dtsi
@@ -15,12 +15,12 @@
 				reg = <0x1a>;
 				status = "okay";
 
-				clocks = <&imx477_clk>;
+				clocks = <&cam1_clk>;
 				clock-names = "xclk";
 
 				VANA-supply = <&cam1_reg>;	/* 2.8v */
-				VDIG-supply = <&imx477_vdig>;	/* 1.05v */
-				VDDL-supply = <&imx477_vddl>;	/* 1.8v */
+				VDIG-supply = <&cam_dummy_reg>;	/* 1.05v */
+				VDDL-supply = <&cam_dummy_reg>;	/* 1.8v */
 
 				rotation = <180>;
 				orientation = <2>;
@@ -63,25 +63,10 @@
 	};
 
 	fragment@3 {
-		target-path="/";
+		target = <&cam1_clk>;
 		__overlay__ {
-			imx477_vdig: fixedregulator@0 {
-				compatible = "regulator-fixed";
-				regulator-name = "imx477_vdig";
-				regulator-min-microvolt = <1050000>;
-				regulator-max-microvolt = <1050000>;
-			};
-			imx477_vddl: fixedregulator@1 {
-				compatible = "regulator-fixed";
-				regulator-name = "imx477_vddl";
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-			};
-			imx477_clk: camera-clk {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <24000000>;
-			};
+			clock-frequency = <24000000>;
+			status = "okay";
 		};
 	};
 
@@ -95,11 +80,7 @@
 	fragment@5 {
 		target = <&cam1_reg>;
 		__overlay__ {
-			status = "okay";
-			regulator-name = "imx477_vana";
 			startup-delay-us = <300000>;
-			regulator-min-microvolt = <2800000>;
-			regulator-max-microvolt = <2800000>;
 		};
 	};
 
--- a/arch/arm/boot/dts/overlays/imx519-overlay.dts
+++ b/arch/arm/boot/dts/overlays/imx519-overlay.dts
@@ -20,12 +20,12 @@
 				reg = <0x1a>;
 				status = "okay";
 
-				clocks = <&imx519_clk>;
+				clocks = <&cam1_clk>;
 				clock-names = "xclk";
 
 				VANA-supply = <&cam1_reg>;	/* 2.8v */
-				VDIG-supply = <&imx519_vdig>;	/* 1.8v */
-				VDDL-supply = <&imx519_vddl>;	/* 1.2v */
+				VDIG-supply = <&cam_dummy_reg>;	/* 1.8v */
+				VDDL-supply = <&cam_dummy_reg>;	/* 1.2v */
 
 				rotation = <0>;
 				orientation = <2>;
@@ -68,26 +68,10 @@
 	};
 
 	fragment@3 {
-		target-path="/";
+		target = <&cam1_clk>;
 		__overlay__ {
-			imx519_vdig: fixedregulator@1 {
-				compatible = "regulator-fixed";
-				regulator-name = "imx519_vdig";
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-			};
-			imx519_vddl: fixedregulator@2 {
-				compatible = "regulator-fixed";
-				regulator-name = "imx519_vddl";
-				regulator-min-microvolt = <1200000>;
-				regulator-max-microvolt = <1200000>;
-			};
-
-			imx519_clk: camera-clk {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <24000000>;
-			};
+			clock-frequency = <24000000>;
+			status = "okay";
 		};
 	};
 
@@ -98,16 +82,6 @@
 		};
 	};
 
-	fragment@5 {
-		target = <&cam1_reg>;
-		__overlay__ {
-			status = "okay";
-			regulator-name = "imx519_vana";
-			regulator-min-microvolt = <2800000>;
-			regulator-max-microvolt = <2800000>;
-		};
-	};
-
 	fragment@6 {
 		target = <&csi1>;
 		__overlay__ {
--- a/arch/arm/boot/dts/overlays/ov5647-overlay.dts
+++ b/arch/arm/boot/dts/overlays/ov5647-overlay.dts
@@ -19,7 +19,7 @@
 				status = "okay";
 
 				pwdn-gpios = <&gpio 41 1>, <&gpio 32 1>;
-				clocks = <&ov5647_clk>;
+				clocks = <&cam1_clk>;
 
 				rotation = <0>;
 				orientation = <2>;
@@ -77,13 +77,10 @@
 	};
 
 	fragment@5 {
-		target-path = "/";
+		target = <&cam1_clk>;
 		__overlay__ {
-			ov5647_clk: camera-clk {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <25000000>;
-			};
+			status = "okay";
+			clock-frequency = <25000000>;
 		};
 	};
 
@@ -94,6 +91,13 @@
 		};
 	};
 
+	fragment@7 {
+		target = <&cam1_reg>;
+		__overlay__ {
+			status = "disabled";
+		};
+	};
+
 	__overrides__ {
 		rotation = <&ov5647>,"rotation:0";
 		orientation = <&ov5647>,"orientation:0";
--- a/arch/arm/boot/dts/overlays/ov7251-overlay.dts
+++ b/arch/arm/boot/dts/overlays/ov7251-overlay.dts
@@ -20,13 +20,13 @@
 				reg = <0x60>;
 				status = "okay";
 
-				clocks = <&ov7251_clk>;
+				clocks = <&cam1_clk>;
 				clock-names = "xclk";
 				clock-frequency = <24000000>;
 
-				vdddo-supply = <&ov7251_dovdd>;
+				vdddo-supply = <&cam_dummy_reg>;
 				vdda-supply = <&cam1_reg>;
-				vddd-supply = <&ov7251_dvdd>;
+				vddd-supply = <&cam_dummy_reg>;
 
 				rotation = <0>;
 				orientation = <2>;
@@ -67,25 +67,10 @@
 	};
 
 	fragment@3 {
-		target-path="/";
+		target = <&cam1_clk>;
 		__overlay__ {
-			ov7251_dovdd: fixedregulator@1 {
-				compatible = "regulator-fixed";
-				regulator-name = "ov7251_dovdd";
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-			};
-			ov7251_dvdd: fixedregulator@2 {
-				compatible = "regulator-fixed";
-				regulator-name = "ov7251_dvdd";
-				regulator-min-microvolt = <1200000>;
-				regulator-max-microvolt = <1200000>;
-			};
-			ov7251_clk: ov7251-clk {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <24000000>;
-			};
+			status = "okay";
+			clock-frequency = <24000000>;
 		};
 	};
 
@@ -96,16 +81,6 @@
 		};
 	};
 
-	fragment@5 {
-		target = <&cam1_reg>;
-		__overlay__ {
-			status = "okay";
-			regulator-name = "ov7251_avdd";
-			regulator-min-microvolt = <2800000>;
-			regulator-max-microvolt = <2800000>;
-		};
-	};
-
 	fragment@6 {
 		target = <&csi1>;
 		__dormant__ {
--- a/arch/arm/boot/dts/overlays/ov9281-overlay.dts
+++ b/arch/arm/boot/dts/overlays/ov9281-overlay.dts
@@ -20,12 +20,12 @@
 				reg = <0x60>;
 				status = "okay";
 
-				clocks = <&ov9281_clk>;
+				clocks = <&cam1_clk>;
 				clock-names = "xvclk";
 
 				avdd-supply = <&cam1_reg>;
-				dovdd-supply = <&ov9281_dovdd>;
-				dvdd-supply = <&ov9281_dvdd>;
+				dovdd-supply = <&cam_dummy_reg>;
+				dvdd-supply = <&cam_dummy_reg>;
 
 				rotation = <0>;
 				orientation = <2>;
@@ -67,25 +67,10 @@
 	};
 
 	fragment@3 {
-		target-path="/";
+		target = <&cam1_clk>;
 		__overlay__ {
-			ov9281_dovdd: fixedregulator@1 {
-				compatible = "regulator-fixed";
-				regulator-name = "ov9281_dovdd";
-				regulator-min-microvolt = <1800000>;
-				regulator-max-microvolt = <1800000>;
-			};
-			ov9281_dvdd: fixedregulator@2 {
-				compatible = "regulator-fixed";
-				regulator-name = "ov9281_dvdd";
-				regulator-min-microvolt = <1200000>;
-				regulator-max-microvolt = <1200000>;
-			};
-			ov9281_clk: ov9281-clk {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <24000000>;
-			};
+			status = "okay";
+			clock-frequency = <24000000>;
 		};
 	};
 
@@ -97,16 +82,6 @@
 	};
 
 	fragment@5 {
-		target = <&cam1_reg>;
-		__overlay__ {
-			status = "okay";
-			regulator-name = "ov9281_avdd";
-			regulator-min-microvolt = <2800000>;
-			regulator-max-microvolt = <2800000>;
-		};
-	};
-
-	fragment@6 {
 		target = <&csi1>;
 		__overlay__ {
 			brcm,media-controller;
@@ -116,6 +91,6 @@
 	__overrides__ {
 		rotation = <&ov9281>,"rotation:0";
 		orientation = <&ov9281>,"orientation:0";
-		media-controller = <0>,"=6";
+		media-controller = <0>,"=5";
 	};
 };
