From 8f5ca7f19d75496392309518f20e529e4c3ee3e3 Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Mon, 15 Apr 2024 21:28:11 +0100
Subject: [PATCH 1036/1085] dts: bcm2712: cm5: Add antenna controls

Use the same ant1/ant2/noant controls as CM4.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 .../boot/dts/broadcom/bcm2712-rpi-cm5.dtsi    | 29 +++++++++++++++++++
 arch/arm/boot/dts/overlays/README             |  6 ++--
 2 files changed, 32 insertions(+), 3 deletions(-)

--- a/arch/arm/boot/dts/broadcom/bcm2712-rpi-cm5.dtsi
+++ b/arch/arm/boot/dts/broadcom/bcm2712-rpi-cm5.dtsi
@@ -671,6 +671,22 @@ spi10_cs_pins: &spi10_cs_gpio1 {};
 		output-high;
 		line-name = "RP1 RUN pin";
 	};
+
+	ant1: ant1-hog {
+		gpio-hog;
+		gpios = <5 GPIO_ACTIVE_HIGH>;
+		/* internal antenna enabled */
+		output-high;
+		line-name = "ant1";
+	};
+
+	ant2: ant2-hog {
+		gpio-hog;
+		gpios = <6 GPIO_ACTIVE_HIGH>;
+		/* external antenna disabled */
+		output-low;
+		line-name = "ant2";
+	};
 };
 
 &rp1_gpio {
@@ -841,6 +857,19 @@ spi10_cs_pins: &spi10_cs_gpio1 {};
 		drm_fb2_rp1_dpi = <&aliases>, "drm-fb2=",&dpi;
 		drm_fb2_vc4 = <&aliases>, "drm-fb2=",&vc4;
 
+		ant1 =  <&ant1>,"output-high?=on",
+			<&ant1>, "output-low?=off",
+			<&ant2>, "output-high?=off",
+			<&ant2>, "output-low?=on";
+		ant2 =  <&ant1>,"output-high?=off",
+			<&ant1>, "output-low?=on",
+			<&ant2>, "output-high?=on",
+			<&ant2>, "output-low?=off";
+		noant = <&ant1>,"output-high?=off",
+			<&ant1>, "output-low?=on",
+			<&ant2>, "output-high?=off",
+			<&ant2>, "output-low?=on";
+
 		fan_temp0 = <&cpu_tepid>,"temperature:0";
 		fan_temp1 = <&cpu_warm>,"temperature:0";
 		fan_temp2 = <&cpu_hot>,"temperature:0";
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -130,11 +130,11 @@ Name:   <The base DTB>
 Info:   Configures the base Raspberry Pi hardware
 Load:   <loaded automatically>
 Params:
-        ant1                    Select antenna 1 (default). CM4 only.
+        ant1                    Select antenna 1 (default). CM4/5 only.
 
-        ant2                    Select antenna 2. CM4 only.
+        ant2                    Select antenna 2. CM4/5 only.
 
-        noant                   Disable both antennas. CM4 only.
+        noant                   Disable both antennas. CM4/5 only.
 
         audio                   Set to "on" to enable the onboard ALSA audio
                                 interface (default "off")
