From 9c68ba121ba173dd5711b4537bfcdf82ec731725 Mon Sep 17 00:00:00 2001
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
Date: Wed, 3 Apr 2024 16:08:07 +0100
Subject: [PATCH 1040/1085] dt: Add camX_sync option to configure a GPIO
 following cam FS/FE

Unicam now takes an optional GPIO to expose frame start/end timing,
so add an override to configure that.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
---
 arch/arm/boot/dts/broadcom/bcm270x-rpi.dtsi | 13 +++++++++++++
 arch/arm/boot/dts/overlays/README           | 12 ++++++++++++
 2 files changed, 25 insertions(+)

--- a/arch/arm/boot/dts/broadcom/bcm270x-rpi.dtsi
+++ b/arch/arm/boot/dts/broadcom/bcm270x-rpi.dtsi
@@ -97,6 +97,19 @@
 		drm_fb0_vc4 = <&aliases>, "drm-fb0=",&vc4;
 		drm_fb1_vc4 = <&aliases>, "drm-fb1=",&vc4;
 		drm_fb2_vc4 = <&aliases>, "drm-fb2=",&vc4;
+
+		cam1_sync = <&csi1>, "sync-gpios:0=", <&gpio>,
+			    <&csi1>, "sync-gpios:4",
+			    <&csi1>, "sync-gpios:8=0", <GPIO_ACTIVE_HIGH>;
+		cam1_sync_inverted = <&csi1>, "sync-gpios:0=", <&gpio>,
+			    <&csi1>, "sync-gpios:4",
+			    <&csi1>, "sync-gpios:8=0", <GPIO_ACTIVE_LOW>;
+		cam0_sync = <&csi0>, "sync-gpios:0=", <&gpio>,
+			    <&csi0>, "sync-gpios:4",
+			    <&csi0>, "sync-gpios:8=0", <GPIO_ACTIVE_HIGH>;
+		cam0_sync_inverted = <&csi0>, "sync-gpios:0=", <&gpio>,
+			    <&csi0>, "sync-gpios:4",
+			    <&csi0>, "sync-gpios:8=0", <GPIO_ACTIVE_LOW>;
 	};
 };
 
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -170,6 +170,18 @@ Params:
                                 Default of GPIO expander 5 on CM4, but override
                                 switches to normal GPIO.
 
+        cam0_sync               Enable a GPIO to reflect frame sync from CSI0,
+                                going high on frame start, and low on frame end.
+
+        cam0_sync_inverted      Enable a GPIO to reflect frame sync from CSI0
+                                going low on frame start, and high on frame end.
+
+        cam1_sync               Enable a GPIO to reflect frame sync from CSI1,
+                                going high on frame start, and low on frame end.
+
+        cam1_sync_inverted      Enable a GPIO to reflect frame sync from CSI1
+                                going low on frame start, and high on frame end.
+
         cooling_fan             Enables the Pi 5 cooling fan (enabled
                                 automatically by the firmware)
 
