From ca1159109b527af8450b627936c6eb732f496c14 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Wed, 6 Jan 2021 17:42:31 +0000
Subject: [PATCH] dtoverlays: Update sensor overlays to use cam1_reg
 where possible

Update those overlays that use the regulator framework to use the
new cam1_reg node to control the camera shutdown line, and remove
the firmware workaround nodes.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 arch/arm/boot/dts/overlays/imx219-overlay.dts | 18 +++++---------
 .../boot/dts/overlays/imx290_327-overlay.dtsi | 18 +++++---------
 arch/arm/boot/dts/overlays/imx477-overlay.dts | 24 +++++++------------
 arch/arm/boot/dts/overlays/ov7251-overlay.dts | 18 +++++---------
 arch/arm/boot/dts/overlays/ov9281-overlay.dts | 19 ++++++---------
 5 files changed, 34 insertions(+), 63 deletions(-)

--- a/arch/arm/boot/dts/overlays/imx219-overlay.dts
+++ b/arch/arm/boot/dts/overlays/imx219-overlay.dts
@@ -23,7 +23,7 @@
 				clocks = <&imx219_clk>;
 				clock-names = "xclk";
 
-				VANA-supply = <&imx219_vana>;	/* 2.8v */
+				VANA-supply = <&cam1_reg>;	/* 2.8v */
 				VDIG-supply = <&imx219_vdig>;	/* 1.8v */
 				VDDL-supply = <&imx219_vddl>;	/* 1.2v */
 
@@ -69,14 +69,6 @@
 	fragment@3 {
 		target-path="/";
 		__overlay__ {
-			imx219_vana: fixedregulator@0 {
-				compatible = "regulator-fixed";
-				regulator-name = "imx219_vana";
-				regulator-min-microvolt = <2800000>;
-				regulator-max-microvolt = <2800000>;
-				gpio = <&gpio 41 GPIO_ACTIVE_HIGH>;
-				enable-active-high;
-			};
 			imx219_vdig: fixedregulator@1 {
 				compatible = "regulator-fixed";
 				regulator-name = "imx219_vdig";
@@ -106,10 +98,12 @@
 	};
 
 	fragment@5 {
-		target-path="/__overrides__";
+		target = <&cam1_reg>;
 		__overlay__ {
-			cam0-pwdn-ctrl = <&imx219_vana>,"gpio:0";
-			cam0-pwdn      = <&imx219_vana>,"gpio:4";
+			status = "okay";
+			regulator-name = "imx219_vana";
+			regulator-min-microvolt = <2800000>;
+			regulator-max-microvolt = <2800000>;
 		};
 	};
 
--- a/arch/arm/boot/dts/overlays/imx290_327-overlay.dtsi
+++ b/arch/arm/boot/dts/overlays/imx290_327-overlay.dtsi
@@ -24,7 +24,7 @@
 				clock-names = "xclk";
 				clock-frequency = <37125000>;
 
-				vdda-supply = <&imx290_vdda>;	/* 2.8v */
+				vdda-supply = <&cam1_reg>;	/* 2.8v */
 				vdddo-supply = <&imx290_vdddo>;	/* 1.8v */
 				vddd-supply = <&imx290_vddd>;	/* 1.5v */
 
@@ -61,14 +61,6 @@
 	fragment@3 {
 		target-path="/";
 		__overlay__ {
-			imx290_vdda: fixedregulator@0 {
-				compatible = "regulator-fixed";
-				regulator-name = "imx290_vdda";
-				regulator-min-microvolt = <2800000>;
-				regulator-max-microvolt = <2800000>;
-				gpio = <&gpio 41 GPIO_ACTIVE_HIGH>;
-				enable-active-high;
-			};
 			imx290_vdddo: fixedregulator@1 {
 				compatible = "regulator-fixed";
 				regulator-name = "imx290_vdddo";
@@ -98,10 +90,12 @@
 	};
 
 	fragment@5 {
-		target-path="/__overrides__";
+		target = <&cam1_reg>;
 		__overlay__ {
-			cam0-pwdn-ctrl = <&imx290_vdda>,"gpio:0";
-			cam0-pwdn      = <&imx290_vdda>,"gpio:4";
+			status = "okay";
+			regulator-name = "imx290_vdda";
+			regulator-min-microvolt = <2800000>;
+			regulator-max-microvolt = <2800000>;
 		};
 	};
 
--- a/arch/arm/boot/dts/overlays/imx477-overlay.dts
+++ b/arch/arm/boot/dts/overlays/imx477-overlay.dts
@@ -23,7 +23,7 @@
 				clocks = <&imx477_clk>;
 				clock-names = "xclk";
 
-				VANA-supply = <&imx477_vana>;	/* 2.8v */
+				VANA-supply = <&cam1_reg>;	/* 2.8v */
 				VDIG-supply = <&imx477_vdig>;	/* 1.05v */
 				VDDL-supply = <&imx477_vddl>;	/* 1.8v */
 
@@ -69,22 +69,13 @@
 	fragment@3 {
 		target-path="/";
 		__overlay__ {
-			imx477_vana: fixedregulator@0 {
-				compatible = "regulator-fixed";
-				regulator-name = "imx477_vana";
-				regulator-min-microvolt = <2800000>;
-				regulator-max-microvolt = <2800000>;
-				gpio = <&gpio 41 GPIO_ACTIVE_HIGH>;
-				enable-active-high;
-				startup-delay-us = <300000>;
-			};
-			imx477_vdig: fixedregulator@1 {
+			imx477_vdig: fixedregulator@0 {
 				compatible = "regulator-fixed";
 				regulator-name = "imx477_vdig";
 				regulator-min-microvolt = <1050000>;
 				regulator-max-microvolt = <1050000>;
 			};
-			imx477_vddl: fixedregulator@2 {
+			imx477_vddl: fixedregulator@1 {
 				compatible = "regulator-fixed";
 				regulator-name = "imx477_vddl";
 				regulator-min-microvolt = <1800000>;
@@ -106,10 +97,13 @@
 	};
 
 	fragment@5 {
-		target-path="/__overrides__";
+		target = <&cam1_reg>;
 		__overlay__ {
-			cam0-pwdn-ctrl = <&imx477_vana>,"gpio:0";
-			cam0-pwdn      = <&imx477_vana>,"gpio:4";
+			status = "okay";
+			regulator-name = "imx477_vana";
+			startup-delay-us = <300000>;
+			regulator-min-microvolt = <2800000>;
+			regulator-max-microvolt = <2800000>;
 		};
 	};
 
--- a/arch/arm/boot/dts/overlays/ov7251-overlay.dts
+++ b/arch/arm/boot/dts/overlays/ov7251-overlay.dts
@@ -25,11 +25,9 @@
 				clock-frequency = <24000000>;
 
 				vdddo-supply = <&ov7251_dovdd>;
-				vdda-supply = <&ov7251_avdd>;
+				vdda-supply = <&cam1_reg>;
 				vddd-supply = <&ov7251_dvdd>;
 
-				enable-gpios = <&gpio 41 GPIO_ACTIVE_HIGH>;
-
 				port {
 					ov7251_0: endpoint {
 						remote-endpoint = <&csi1_ep>;
@@ -68,12 +66,6 @@
 	fragment@3 {
 		target-path="/";
 		__overlay__ {
-			ov7251_avdd: fixedregulator@0 {
-				compatible = "regulator-fixed";
-				regulator-name = "ov7251_avdd";
-				regulator-min-microvolt = <2800000>;
-				regulator-max-microvolt = <2800000>;
-			};
 			ov7251_dovdd: fixedregulator@1 {
 				compatible = "regulator-fixed";
 				regulator-name = "ov7251_dovdd";
@@ -102,10 +94,12 @@
 	};
 
 	fragment@5 {
-		target-path="/__overrides__";
+		target = <&cam1_reg>;
 		__overlay__ {
-			cam0-pwdn-ctrl = <&ov7251>,"enable-gpios:0";
-			cam0-pwdn      = <&ov7251>,"enable-gpios:4";
+			status = "okay";
+			regulator-name = "ov7251_avdd";
+			regulator-min-microvolt = <2800000>;
+			regulator-max-microvolt = <2800000>;
 		};
 	};
 };
--- a/arch/arm/boot/dts/overlays/ov9281-overlay.dts
+++ b/arch/arm/boot/dts/overlays/ov9281-overlay.dts
@@ -23,7 +23,7 @@
 				clocks = <&ov9281_clk>;
 				clock-names = "xvclk";
 
-				avdd-supply = <&ov9281_avdd>;
+				avdd-supply = <&cam1_reg>;
 				dovdd-supply = <&ov9281_dovdd>;
 				dvdd-supply = <&ov9281_dvdd>;
 
@@ -66,14 +66,6 @@
 	fragment@3 {
 		target-path="/";
 		__overlay__ {
-			ov9281_avdd: fixedregulator@0 {
-				compatible = "regulator-fixed";
-				regulator-name = "ov9281_avdd";
-				regulator-min-microvolt = <2800000>;
-				regulator-max-microvolt = <2800000>;
-				gpio = <&gpio 41 GPIO_ACTIVE_HIGH>;
-				enable-active-high;
-			};
 			ov9281_dovdd: fixedregulator@1 {
 				compatible = "regulator-fixed";
 				regulator-name = "ov9281_dovdd";
@@ -102,10 +94,13 @@
 	};
 
 	fragment@5 {
-		target-path="/__overrides__";
+		target = <&cam1_reg>;
 		__overlay__ {
-			cam0-pwdn-ctrl = <&ov9281_avdd>,"gpio:0";
-			cam0-pwdn      = <&ov9281_avdd>,"gpio:4";
+			status = "okay";
+			regulator-name = "ov9281_avdd";
+			regulator-min-microvolt = <2800000>;
+			regulator-max-microvolt = <2800000>;
 		};
 	};
+
 };
