From 0bda3692e0fa20e793ad3857a6ffde6bca7d49ca Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Mon, 22 Nov 2021 12:44:29 +0000
Subject: [PATCH] dtoverlays: Add option to select camera as on CAM0 of
 CM

Parameterise the overlays so that they can have an optional
cam0 parameter to switch to i2c_vc and csi0.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 arch/arm/boot/dts/bcm2708-rpi-cm.dts          |  1 +
 arch/arm/boot/dts/bcm2708-rpi-cm.dtsi         |  4 +
 arch/arm/boot/dts/bcm2710-rpi-cm3.dts         |  5 ++
 arch/arm/boot/dts/bcm2711-rpi-cm4s.dts        | 25 +++---
 arch/arm/boot/dts/overlays/README             | 30 +++++++
 arch/arm/boot/dts/overlays/imx219-overlay.dts | 67 ++++++++-------
 .../boot/dts/overlays/imx290_327-overlay.dtsi | 27 +++---
 .../boot/dts/overlays/imx477_378-overlay.dtsi | 84 +++++++++----------
 arch/arm/boot/dts/overlays/imx519-overlay.dts | 23 +++--
 .../arm/boot/dts/overlays/irs1125-overlay.dts | 35 ++++----
 arch/arm/boot/dts/overlays/ov5647-overlay.dts | 33 +++-----
 arch/arm/boot/dts/overlays/ov7251-overlay.dts | 28 +++----
 arch/arm/boot/dts/overlays/ov9281-overlay.dts | 29 ++++---
 .../boot/dts/overlays/tc358743-overlay.dts    | 43 ++++------
 14 files changed, 221 insertions(+), 213 deletions(-)

--- a/arch/arm/boot/dts/bcm2708-rpi-cm.dts
+++ b/arch/arm/boot/dts/bcm2708-rpi-cm.dts
@@ -12,6 +12,7 @@
 
 &cam1_reg {
 	gpio = <&gpio 2 GPIO_ACTIVE_HIGH>;
+	status = "disabled";
 };
 
 cam0_reg: &cam0_regulator {
--- a/arch/arm/boot/dts/bcm2708-rpi-cm.dtsi
+++ b/arch/arm/boot/dts/bcm2708-rpi-cm.dtsi
@@ -14,5 +14,9 @@
 		act_led_gpio = <&act_led>,"gpios:4";
 		act_led_activelow = <&act_led>,"gpios:8";
 		act_led_trigger = <&act_led>,"linux,default-trigger";
+		cam0_reg = <&cam0_reg>,"status";
+		cam0_reg_gpio = <&cam0_reg>,"gpios:4";
+		cam1_reg = <&cam1_reg>,"status";
+		cam1_reg_gpio = <&cam1_reg>,"gpios:4";
 	};
 };
--- a/arch/arm/boot/dts/bcm2710-rpi-cm3.dts
+++ b/arch/arm/boot/dts/bcm2710-rpi-cm3.dts
@@ -12,6 +12,7 @@
 
 &cam1_reg {
 	gpio = <&gpio 2 GPIO_ACTIVE_HIGH>;
+	status = "disabled";
 };
 
 cam0_reg: &cam0_regulator {
@@ -137,5 +138,9 @@ cam0_reg: &cam0_regulator {
 		act_led_gpio = <&act_led>,"gpios:4";
 		act_led_activelow = <&act_led>,"gpios:8";
 		act_led_trigger = <&act_led>,"linux,default-trigger";
+		cam0_reg = <&cam0_reg>,"status";
+		cam0_reg_gpio = <&cam0_reg>,"gpios:4";
+		cam1_reg = <&cam1_reg>,"status";
+		cam1_reg_gpio = <&cam1_reg>,"gpios:4";
 	};
 };
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4s.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4s.dts
@@ -162,21 +162,6 @@
 		bootargs = "coherent_pool=1M 8250.nr_uarts=1 snd_bcm2835.enable_compat_alsa=0 snd_bcm2835.enable_hdmi=1";
 	};
 
-	cam1_reg: cam1_reg {
-		compatible = "regulator-fixed";
-		regulator-name = "cam1-regulator";
-		gpio = <&gpio 2 GPIO_ACTIVE_HIGH>;
-		enable-active-high;
-		status = "disabled";
-	};
-	cam0_reg: cam0_reg {
-		compatible = "regulator-fixed";
-		regulator-name = "cam0-regulator";
-		gpio = <&gpio 30 GPIO_ACTIVE_HIGH>;
-		enable-active-high;
-		status = "disabled";
-	};
-
 	aliases {
 		serial0 = &uart0;
 		mmc0 = &emmc2;
@@ -399,6 +384,16 @@
 	brcm,disable-headphones = <1>;
 };
 
+&cam1_reg {
+	gpio = <&gpio 2 GPIO_ACTIVE_HIGH>;
+	status = "disabled";
+};
+
+cam0_reg: &cam0_regulator {
+	gpio = <&gpio 30 GPIO_ACTIVE_HIGH>;
+	status = "disabled";
+};
+
 / {
 	__overrides__ {
 		act_led_gpio = <&act_led>,"gpios:4";
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -144,6 +144,16 @@ Params:
                                 See /sys/kernel/debug/raspberrypi_axi_monitor
                                 for the results.
 
+        cam0_reg                Enables CAM 0 regulator. CM1 & 3 only.
+
+        cam0_reg_gpio           Set GPIO for CAM 0 regulator. Default 30.
+                                CM1 & 3 only.
+
+        cam1_reg                Enables CAM 1 regulator. CM1 & 3 only.
+
+        cam1_reg_gpio           Set GPIO for CAM 1 regulator. Default 2.
+                                CM1 & 3 only.
+
         eee                     Enable Energy Efficient Ethernet support for
                                 compatible devices (default "on"). See also
                                 "tx_lpi_timer". Pi3B+ only.
@@ -1845,6 +1855,8 @@ Params: rotation                Mounting
                                 2 = external, default external)
         media-controller        Configure use of Media Controller API for
                                 configuring the sensor (default on)
+        cam0                    Adopt the default configuration for CAM0 on a
+                                Compute Module (CSI0, i2c_vc, and cam0_reg).
 
 
 Name:   imx290
@@ -1867,6 +1879,8 @@ Params: 4lane                   Enable 4
                                 180, default 0)
         media-controller        Configure use of Media Controller API for
                                 configuring the sensor (default on)
+        cam0                    Adopt the default configuration for CAM0 on a
+                                Compute Module (CSI0, i2c_vc, and cam0_reg).
 
 
 Name:   imx378
@@ -1880,6 +1894,8 @@ Params: rotation                Mounting
                                 2 = external, default external)
         media-controller        Configure use of Media Controller API for
                                 configuring the sensor (default on)
+        cam0                    Adopt the default configuration for CAM0 on a
+                                Compute Module (CSI0, i2c_vc, and cam0_reg).
 
 
 Name:   imx477
@@ -1893,6 +1909,8 @@ Params: rotation                Mounting
                                 2 = external, default external)
         media-controller        Configure use of Media Controller API for
                                 configuring the sensor (default on)
+        cam0                    Adopt the default configuration for CAM0 on a
+                                Compute Module (CSI0, i2c_vc, and cam0_reg).
 
 
 Name:   imx519
@@ -1906,6 +1924,8 @@ Params: rotation                Mounting
                                 2 = external, default external)
         media-controller        Configure use of Media Controller API for
                                 configuring the sensor (default on)
+        cam0                    Adopt the default configuration for CAM0 on a
+                                Compute Module (CSI0, i2c_vc, and cam0_reg).
 
 
 Name:   iqaudio-codec
@@ -1972,6 +1992,8 @@ Info:   Infineon irs1125 TOF camera modu
 Load:   dtoverlay=irs1125,<param>=<val>
 Params: media-controller        Configure use of Media Controller API for
                                 configuring the sensor (default off)
+        cam0                    Adopt the default configuration for CAM0 on a
+                                Compute Module (CSI0, i2c_vc, and cam0_reg).
 
 
 Name:   jedec-spi-nor
@@ -2385,6 +2407,8 @@ Params: rotation                Mounting
                                 2 = external, default external)
         media-controller        Configure use of Media Controller API for
                                 configuring the sensor (default on)
+        cam0                    Adopt the default configuration for CAM0 on a
+                                Compute Module (CSI0, i2c_vc, and cam0_reg).
 
 
 Name:   ov7251
@@ -2398,6 +2422,8 @@ Params: rotation                Mounting
                                 2 = external, default external)
         media-controller        Configure use of Media Controller API for
                                 configuring the sensor (default off)
+        cam0                    Adopt the default configuration for CAM0 on a
+                                Compute Module (CSI0, i2c_vc, and cam0_reg).
 
 
 Name:   ov9281
@@ -2411,6 +2437,8 @@ Params: rotation                Mounting
                                 2 = external, default external)
         media-controller        Configure use of Media Controller API for
                                 configuring the sensor (default on)
+        cam0                    Adopt the default configuration for CAM0 on a
+                                Compute Module (CSI0, i2c_vc, and cam0_reg).
 
 
 Name:   papirus
@@ -3393,6 +3421,8 @@ Params: 4lane                   Use 4 la
                                 are supported by the driver.
         media-controller        Configure use of Media Controller API for
                                 configuring the sensor (default off)
+        cam0                    Adopt the default configuration for CAM0 on a
+                                Compute Module (CSI0, i2c_vc, and cam0_reg).
 
 
 Name:   tc358743-audio
--- a/arch/arm/boot/dts/overlays/imx219-overlay.dts
+++ b/arch/arm/boot/dts/overlays/imx219-overlay.dts
@@ -9,6 +9,28 @@
 	compatible = "brcm,bcm2835";
 
 	fragment@0 {
+		target = <&i2c0if>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+
+	clk_frag: fragment@1 {
+		target = <&cam1_clk>;
+		__overlay__ {
+			status = "okay";
+			clock-frequency = <24000000>;
+		};
+	};
+
+	fragment@2 {
+		target = <&i2c0mux>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+
+	i2c_frag: fragment@100 {
 		target = <&i2c_csi_dsi>;
 		__overlay__ {
 			#address-cells = <1>;
@@ -32,7 +54,7 @@
 
 				port {
 					imx219_0: endpoint {
-						remote-endpoint = <&csi1_ep>;
+						remote-endpoint = <&csi_ep>;
 						clock-lanes = <0>;
 						data-lanes = <1 2>;
 						clock-noncontinuous;
@@ -44,13 +66,14 @@
 		};
 	};
 
-	fragment@1 {
+	csi_frag: fragment@101 {
 		target = <&csi1>;
-		__overlay__ {
+		csi: __overlay__ {
 			status = "okay";
+			brcm,media-controller;
 
 			port {
-				csi1_ep: endpoint {
+				csi_ep: endpoint {
 					remote-endpoint = <&imx219_0>;
 					clock-lanes = <0>;
 					data-lanes = <1 2>;
@@ -60,38 +83,14 @@
 		};
 	};
 
-	fragment@2 {
-		target = <&i2c0if>;
-		__overlay__ {
-			status = "okay";
-		};
-	};
-
-	fragment@3 {
-		target = <&cam1_clk>;
-		__overlay__ {
-			status = "okay";
-			clock-frequency = <24000000>;
-		};
-	};
-
-	fragment@4 {
-		target = <&i2c0mux>;
-		__overlay__ {
-			status = "okay";
-		};
-	};
-
-	fragment@5 {
-		target = <&csi1>;
-		__overlay__ {
-			brcm,media-controller;
-		};
-	};
-
 	__overrides__ {
 		rotation = <&imx219>,"rotation:0";
 		orientation = <&imx219>,"orientation:0";
-		media-controller = <0>,"=5";
+		media-controller = <&csi>,"brcm,media-controller?";
+		cam0 = <&i2c_frag>, "target:0=",<&i2c_vc>,
+		       <&csi_frag>, "target:0=",<&csi0>,
+		       <&clk_frag>, "target:0=",<&cam0_clk>,
+		       <&imx219>, "clocks:0=",<&cam0_clk>,
+		       <&imx219>, "VANA-supply:0=",<&cam0_reg>;
 	};
 };
--- a/arch/arm/boot/dts/overlays/imx290_327-overlay.dtsi
+++ b/arch/arm/boot/dts/overlays/imx290_327-overlay.dtsi
@@ -9,7 +9,7 @@
 /{
 	compatible = "brcm,bcm2835";
 
-	fragment@0 {
+	i2c_frag: fragment@0 {
 		target = <&i2c_csi_dsi>;
 		__overlay__ {
 			#address-cells = <1>;
@@ -41,10 +41,11 @@
 		};
 	};
 
-	fragment@1 {
+	csi_frag: fragment@1 {
 		target = <&csi1>;
-		__overlay__ {
+		csi: __overlay__ {
 			status = "okay";
+			brcm,media-controller;
 
 			port {
 				csi1_ep: endpoint {
@@ -61,9 +62,9 @@
 		};
 	};
 
-	fragment@3 {
+	clk_frag: fragment@3 {
 		target = <&cam1_clk>;
-		__overlay__ {
+		cam_clk: __overlay__ {
 			status = "okay";
 			clock-frequency = <37125000>;
 		};
@@ -108,19 +109,17 @@
 		};
 	};
 
-	fragment@10 {
-		target = <&csi1>;
-		__overlay__ {
-			brcm,media-controller;
-		};
-	};
-
 	__overrides__ {
 		4lane = <0>, "-6+7-8+9";
-		clock-frequency = <&cam1_clk>,"clock-frequency:0",
+		clock-frequency = <&cam_clk>,"clock-frequency:0",
 				  <&imx290>,"clock-frequency:0";
 		rotation = <&imx290>,"rotation:0";
 		orientation = <&imx290>,"orientation:0";
-		media-controller = <0>,"=10";
+		media-controller = <&csi>,"brcm,media-controller?";
+		cam0 = <&i2c_frag>, "target:0=",<&i2c_vc>,
+		       <&csi_frag>, "target:0=",<&csi0>,
+		       <&clk_frag>, "target:0=",<&cam0_clk>,
+		       <&imx290>, "clocks:0=",<&cam0_clk>,
+		       <&imx290>, "vdda-supply:0=",<&cam0_reg>;
 	};
 };
--- a/arch/arm/boot/dts/overlays/imx477_378-overlay.dtsi
+++ b/arch/arm/boot/dts/overlays/imx477_378-overlay.dtsi
@@ -4,7 +4,36 @@
 /{
 	compatible = "brcm,bcm2835";
 
-	fragment@0 {
+	fragment@2 {
+		target = <&i2c0if>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+
+	clk_frag: fragment@3 {
+		target = <&cam1_clk>;
+		cam_clk: __overlay__ {
+			clock-frequency = <24000000>;
+			status = "okay";
+		};
+	};
+
+	fragment@4 {
+		target = <&i2c0mux>;
+		__overlay__ {
+			status = "okay";
+		};
+	};
+
+	reg_frag: fragment@5 {
+		target = <&cam1_reg>;
+		cam_reg: __overlay__ {
+			startup-delay-us = <300000>;
+		};
+	};
+
+	i2c_frag: fragment@100 {
 		target = <&i2c_csi_dsi>;
 		__overlay__ {
 			#address-cells = <1>;
@@ -27,7 +56,7 @@
 
 				port {
 					imx477_0: endpoint {
-						remote-endpoint = <&csi1_ep>;
+						remote-endpoint = <&csi_ep>;
 						clock-lanes = <0>;
 						data-lanes = <1 2>;
 						clock-noncontinuous;
@@ -39,13 +68,14 @@
 		};
 	};
 
-	fragment@1 {
+	csi_frag: fragment@101 {
 		target = <&csi1>;
-		__overlay__ {
+		csi: __overlay__ {
 			status = "okay";
+			brcm,media-controller;
 
 			port {
-				csi1_ep: endpoint {
+				csi_ep: endpoint {
 					remote-endpoint = <&imx477_0>;
 					clock-lanes = <0>;
 					data-lanes = <1 2>;
@@ -55,45 +85,15 @@
 		};
 	};
 
-	fragment@2 {
-		target = <&i2c0if>;
-		__overlay__ {
-			status = "okay";
-		};
-	};
-
-	fragment@3 {
-		target = <&cam1_clk>;
-		__overlay__ {
-			clock-frequency = <24000000>;
-			status = "okay";
-		};
-	};
-
-	fragment@4 {
-		target = <&i2c0mux>;
-		__overlay__ {
-			status = "okay";
-		};
-	};
-
-	fragment@5 {
-		target = <&cam1_reg>;
-		__overlay__ {
-			startup-delay-us = <300000>;
-		};
-	};
-
-	fragment@6 {
-		target = <&csi1>;
-		__overlay__ {
-			brcm,media-controller;
-		};
-	};
-
 	__overrides__ {
 		rotation = <&imx477>,"rotation:0";
 		orientation = <&imx477>,"orientation:0";
-		media-controller = <0>,"=6";
+		media-controller = <&csi>,"brcm,media-controller?";
+		cam0 = <&i2c_frag>, "target:0=",<&i2c_vc>,
+		       <&csi_frag>, "target:0=",<&csi0>,
+		       <&clk_frag>, "target:0=",<&cam0_clk>,
+		       <&reg_frag>, "target:0=",<&cam0_reg>,
+		       <&imx477>, "clocks:0=",<&cam0_clk>,
+		       <&imx477>, "vdda-supply:0=",<&cam0_reg>;
 	};
 };
--- a/arch/arm/boot/dts/overlays/imx519-overlay.dts
+++ b/arch/arm/boot/dts/overlays/imx519-overlay.dts
@@ -8,7 +8,7 @@
 /{
 	compatible = "brcm,bcm2835";
 
-	fragment@0 {
+	i2c_frag: fragment@0 {
 		target = <&i2c_csi_dsi>;
 		__overlay__ {
 			#address-cells = <1>;
@@ -44,10 +44,11 @@
 		};
 	};
 
-	fragment@1 {
+	csi_frag: fragment@1 {
 		target = <&csi1>;
-		__overlay__ {
+		csi: __overlay__ {
 			status = "okay";
+			brcm,media-controller;
 
 			port{
 				csi1_ep: endpoint{
@@ -67,7 +68,7 @@
 		};
 	};
 
-	fragment@3 {
+	clk_frag: fragment@3 {
 		target = <&cam1_clk>;
 		__overlay__ {
 			clock-frequency = <24000000>;
@@ -82,16 +83,14 @@
 		};
 	};
 
-	fragment@6 {
-		target = <&csi1>;
-		__overlay__ {
-			brcm,media-controller;
-		};
-	};
-
 	__overrides__ {
 		rotation = <&imx519>,"rotation:0";
 		orientation = <&imx519>,"orientation:0";
-		media-controller = <0>,"=6";
+		media-controller = <&csi>,"brcm,media-controller?";
+		cam0 = <&i2c_frag>, "target:0=",<&i2c_vc>,
+		       <&csi_frag>, "target:0=",<&csi0>,
+		       <&clk_frag>, "target:0=",<&cam0_clk>,
+		       <&imx519>, "clocks:0=",<&cam0_clk>,
+		       <&imx519>, "VANA-supply:0=",<&cam0_reg>;
 	};
 };
--- a/arch/arm/boot/dts/overlays/irs1125-overlay.dts
+++ b/arch/arm/boot/dts/overlays/irs1125-overlay.dts
@@ -6,20 +6,20 @@
 /{
 	compatible = "brcm,bcm2835";
 
-	fragment@0 {
+	i2c_frag: fragment@0 {
 		target = <&i2c_csi_dsi>;
 		__overlay__ {
 			#address-cells = <1>;
 			#size-cells = <0>;
 			status = "okay";
 
-			irs1125: irs1125@3D {
+			irs1125: irs1125@3d {
 				compatible = "infineon,irs1125";
-				reg = <0x3D>;
+				reg = <0x3d>;
 				status = "okay";
 
 				pwdn-gpios = <&gpio 5 0>;
-				clocks = <&irs1125_clk>;
+				clocks = <&cam1_clk>;
 
 				port {
 					irs1125_0: endpoint {
@@ -35,9 +35,9 @@
 		};
 	};
 
-	fragment@1 {
+	csi_frag: fragment@1 {
 		target = <&csi1>;
-		__overlay__ {
+		csi: __overlay__ {
 			status = "okay";
 
 			port {
@@ -72,25 +72,18 @@
 		};
 	};
 
-	fragment@5 {
-		target-path = "/";
+	clk_frag: fragment@5 {
+		target = <&cam1_clk>;
 		__overlay__ {
-			irs1125_clk: camera-clk {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <26000000>;
-			};
-		};
-	};
-
-	fragment@6 {
-		target = <&csi1>;
-		__dormant__ {
-			brcm,media-controller;
+			clock-frequency = <26000000>;
 		};
 	};
 
 	__overrides__ {
-		media-controller = <0>,"=6";
+		media-controller = <&csi>,"brcm,media-controller?";
+		cam0 = <&i2c_frag>, "target:0=",<&i2c_vc>,
+		       <&csi_frag>, "target:0=",<&csi0>,
+		       <&clk_frag>, "target:0=",<&cam0_clk>,
+		       <&irs1125>, "clocks:0=",<&cam0_clk>;
 	};
 };
--- a/arch/arm/boot/dts/overlays/ov5647-overlay.dts
+++ b/arch/arm/boot/dts/overlays/ov5647-overlay.dts
@@ -6,7 +6,7 @@
 /{
 	compatible = "brcm,bcm2835";
 
-	fragment@0 {
+	i2c_frag: fragment@0 {
 		target = <&i2c_csi_dsi>;
 		__overlay__ {
 			#address-cells = <1>;
@@ -41,10 +41,11 @@
 		};
 	};
 
-	fragment@1 {
+	csi_frag: fragment@1 {
 		target = <&csi1>;
-		__overlay__ {
+		csi: __overlay__ {
 			status = "okay";
+			brcm,media-controller;
 
 			port {
 				csi1_ep: endpoint {
@@ -69,14 +70,14 @@
 		};
 	};
 
-	fragment@4 {
+	reg_frag: fragment@4 {
 		target = <&cam1_reg>;
 		__overlay__ {
 			startup-delay-us = <20000>;
 		};
 	};
 
-	fragment@5 {
+	clk_frag: fragment@5 {
 		target = <&cam1_clk>;
 		__overlay__ {
 			status = "okay";
@@ -84,23 +85,15 @@
 		};
 	};
 
-	fragment@6 {
-		target = <&csi1>;
-		__overlay__ {
-			brcm,media-controller;
-		};
-	};
-
-	fragment@7 {
-		target = <&cam1_reg>;
-		__overlay__ {
-			status = "disabled";
-		};
-	};
-
 	__overrides__ {
 		rotation = <&ov5647>,"rotation:0";
 		orientation = <&ov5647>,"orientation:0";
-		media-controller = <0>,"=6";
+		media-controller = <&csi>,"brcm,media-controller?";
+		cam0 = <&i2c_frag>, "target:0=",<&i2c_vc>,
+		       <&csi_frag>, "target:0=",<&csi0>,
+		       <&reg_frag>, "target:0=",<&cam0_reg>,
+		       <&clk_frag>, "target:0=",<&cam0_clk>,
+		       <&ov5647>, "clocks:0=",<&cam0_clk>,
+		       <&ov5647>, "avdd-supply:0=",<&cam0_reg>;
 	};
 };
--- a/arch/arm/boot/dts/overlays/ov7251-overlay.dts
+++ b/arch/arm/boot/dts/overlays/ov7251-overlay.dts
@@ -8,7 +8,7 @@
 /{
 	compatible = "brcm,bcm2835";
 
-	fragment@0 {
+	i2c_frag: fragment@0 {
 		target = <&i2c_csi_dsi>;
 		__overlay__ {
 			#address-cells = <1>;
@@ -45,9 +45,9 @@
 		};
 	};
 
-	fragment@1 {
+	csi_frag: fragment@1 {
 		target = <&csi1>;
-		__overlay__ {
+		csi: __overlay__ {
 			status = "okay";
 
 			port {
@@ -67,30 +67,28 @@
 	};
 
 	fragment@3 {
-		target = <&cam1_clk>;
+		target = <&i2c0mux>;
 		__overlay__ {
 			status = "okay";
-			clock-frequency = <24000000>;
 		};
 	};
 
-	fragment@4 {
-		target = <&i2c0mux>;
+	clk_frag: fragment@4 {
+		target = <&cam1_clk>;
 		__overlay__ {
 			status = "okay";
-		};
-	};
-
-	fragment@6 {
-		target = <&csi1>;
-		__dormant__ {
-			brcm,media-controller;
+			clock-frequency = <24000000>;
 		};
 	};
 
 	__overrides__ {
 		rotation = <&ov7251>,"rotation:0";
 		orientation = <&ov7251>,"orientation:0";
-		media-controller = <0>,"=6";
+		media-controller = <&csi>,"brcm,media-controller?";
+		cam0 = <&i2c_frag>, "target:0=",<&i2c_vc>,
+		       <&csi_frag>, "target:0=",<&csi0>,
+		       <&clk_frag>, "target:0=",<&cam0_clk>,
+		       <&ov7251>, "clocks:0=",<&cam0_clk>,
+		       <&ov7251>, "vdda-supply:0=",<&cam0_reg>;
 	};
 };
--- a/arch/arm/boot/dts/overlays/ov9281-overlay.dts
+++ b/arch/arm/boot/dts/overlays/ov9281-overlay.dts
@@ -8,7 +8,7 @@
 /{
 	compatible = "brcm,bcm2835";
 
-	fragment@0 {
+	i2c_frag: fragment@0 {
 		target = <&i2c_csi_dsi>;
 		__overlay__ {
 			#address-cells = <1>;
@@ -44,10 +44,11 @@
 		};
 	};
 
-	fragment@1 {
+	csi_frag: fragment@1 {
 		target = <&csi1>;
-		__overlay__ {
+		csi: __overlay__ {
 			status = "okay";
+			brcm,media-controller;
 
 			port {
 				csi1_ep: endpoint {
@@ -67,30 +68,28 @@
 	};
 
 	fragment@3 {
-		target = <&cam1_clk>;
-		__overlay__ {
-			status = "okay";
-			clock-frequency = <24000000>;
-		};
-	};
-
-	fragment@4 {
 		target = <&i2c0mux>;
 		__overlay__ {
 			status = "okay";
 		};
 	};
 
-	fragment@5 {
-		target = <&csi1>;
+	clk_frag: fragment@4 {
+		target = <&cam1_clk>;
 		__overlay__ {
-			brcm,media-controller;
+			status = "okay";
+			clock-frequency = <24000000>;
 		};
 	};
 
 	__overrides__ {
 		rotation = <&ov9281>,"rotation:0";
 		orientation = <&ov9281>,"orientation:0";
-		media-controller = <0>,"=5";
+		media-controller = <&csi>,"brcm,media-controller?";
+		cam0 = <&i2c_frag>, "target:0=",<&i2c_vc>,
+		       <&csi_frag>, "target:0=",<&csi0>,
+		       <&clk_frag>, "target:0=",<&cam0_clk>,
+		       <&ov9281>, "clocks:0=",<&cam0_clk>,
+		       <&ov9281>, "avdd-supply:0=",<&cam0_reg>;
 	};
 };
--- a/arch/arm/boot/dts/overlays/tc358743-overlay.dts
+++ b/arch/arm/boot/dts/overlays/tc358743-overlay.dts
@@ -6,23 +6,23 @@
 /{
 	compatible = "brcm,bcm2835";
 
-	fragment@0 {
+	i2c_frag: fragment@0 {
 		target = <&i2c_csi_dsi>;
 		__overlay__ {
 			#address-cells = <1>;
 			#size-cells = <0>;
 			status = "okay";
 
-			tc358743@0f {
+			tc358743: tc358743@f {
 				compatible = "toshiba,tc358743";
 				reg = <0x0f>;
 				status = "okay";
 
-				clocks = <&tc358743_clk>;
+				clocks = <&cam1_clk>;
 				clock-names = "refclk";
 
 				port {
-					tc358743: endpoint {
+					tc358743_0: endpoint {
 						remote-endpoint = <&csi1_ep>;
 						clock-lanes = <0>;
 						clock-noncontinuous;
@@ -34,28 +34,28 @@
 		};
 	};
 
-	fragment@1 {
+	csi_frag: fragment@1 {
 		target = <&csi1>;
-		__overlay__ {
+		csi: __overlay__ {
 			status = "okay";
 
 			port {
 				csi1_ep: endpoint {
-					remote-endpoint = <&tc358743>;
+					remote-endpoint = <&tc358743_0>;
 				};
 			};
 		};
 	};
 
 	fragment@2 {
-		target = <&tc358743>;
+		target = <&tc358743_0>;
 		__overlay__ {
 			data-lanes = <1 2>;
 		};
 	};
 
 	fragment@3 {
-		target = <&tc358743>;
+		target = <&tc358743_0>;
 		__dormant__ {
 			data-lanes = <1 2 3 4>;
 		};
@@ -75,14 +75,10 @@
 		};
 	};
 
-	fragment@6 {
-		target-path = "/";
+	clk_frag: fragment@6 {
+		target = <&cam1_clk>;
 		__overlay__ {
-			tc358743_clk: bridge-clk {
-				compatible = "fixed-clock";
-				#clock-cells = <0>;
-				clock-frequency = <27000000>;
-			};
+			clock-frequency = <27000000>;
 		};
 	};
 
@@ -100,16 +96,13 @@
 		};
 	};
 
-	fragment@9 {
-		target = <&csi1>;
-		__dormant__ {
-			brcm,media-controller;
-		};
-	};
-
 	__overrides__ {
 		4lane = <0>, "-2+3-7+8";
-		link-frequency = <&tc358743>,"link-frequencies#0";
-		media-controller = <0>,"=9";
+		link-frequency = <&tc358743_0>,"link-frequencies#0";
+		media-controller = <&csi>,"brcm,media-controller?";
+		cam0 = <&i2c_frag>, "target:0=",<&i2c_vc>,
+		       <&csi_frag>, "target:0=",<&csi0>,
+		       <&clk_frag>, "target:0=",<&cam0_clk>,
+		       <&tc358743>, "clocks:0=",<&cam0_clk>;
 	};
 };
