From 2da5974313a0580d948c760214a2ea6f4e59bebf Mon Sep 17 00:00:00 2001
From: Phil Elwell <phil@raspberrypi.com>
Date: Wed, 19 Apr 2023 15:13:48 +0100
Subject: [PATCH] overlays: Update miniuart-bt now krnbt is default

Now that the kernel controls the onboard Bluetooth initialisation by
default, the miniuart-bt overlay needs updating to match.

Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 arch/arm/boot/dts/bcm2708-rpi-zero-w.dts           |  6 ++++++
 arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts         |  6 ++++++
 arch/arm/boot/dts/bcm2710-rpi-3-b.dts              |  6 ++++++
 arch/arm/boot/dts/bcm2710-rpi-zero-2-w.dts         |  6 ++++++
 arch/arm/boot/dts/bcm2711-rpi-4-b.dts              |  6 ++++++
 arch/arm/boot/dts/bcm2711-rpi-400.dts              |  6 ++++++
 arch/arm/boot/dts/bcm2711-rpi-cm4.dts              |  6 ++++++
 arch/arm/boot/dts/overlays/README                  | 13 ++++---------
 arch/arm/boot/dts/overlays/miniuart-bt-overlay.dts |  8 +++-----
 9 files changed, 49 insertions(+), 14 deletions(-)

--- a/arch/arm/boot/dts/bcm2708-rpi-zero-w.dts
+++ b/arch/arm/boot/dts/bcm2708-rpi-zero-w.dts
@@ -138,6 +138,12 @@
 		brcm,pull;
 	};
 
+	uart1_bt_pins: uart1_bt_pins {
+		brcm,pins = <32 33 30 31>;
+		brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
+		brcm,pull = <0 2 2 0>;
+	};
+
 	audio_pins: audio_pins {
 		brcm,pins = <>;
 		brcm,function = <>;
--- a/arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts
+++ b/arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts
@@ -140,6 +140,12 @@
 		brcm,pull;
 	};
 
+	uart1_bt_pins: uart1_bt_pins {
+		brcm,pins = <32 33 30 31>;
+		brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
+		brcm,pull = <0 2 2 0>;
+	};
+
 	audio_pins: audio_pins {
 		brcm,pins = <40 41>;
 		brcm,function = <4>;
--- a/arch/arm/boot/dts/bcm2710-rpi-3-b.dts
+++ b/arch/arm/boot/dts/bcm2710-rpi-3-b.dts
@@ -140,6 +140,12 @@
 		brcm,pull;
 	};
 
+	uart1_bt_pins: uart1_bt_pins {
+		brcm,pins = <32 33>;
+		brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
+		brcm,pull = <0 2>;
+	};
+
 	audio_pins: audio_pins {
 		brcm,pins = <40 41>;
 		brcm,function = <4>;
--- a/arch/arm/boot/dts/bcm2710-rpi-zero-2-w.dts
+++ b/arch/arm/boot/dts/bcm2710-rpi-zero-2-w.dts
@@ -138,6 +138,12 @@
 		brcm,pull;
 	};
 
+	uart1_bt_pins: uart1_bt_pins {
+		brcm,pins = <32 33 30 31>;
+		brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
+		brcm,pull = <0 2 2 0>;
+	};
+
 	audio_pins: audio_pins {
 		brcm,pins = <>;
 		brcm,function = <>;
--- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
@@ -445,6 +445,12 @@
 		brcm,pull;
 	};
 
+	uart1_bt_pins: uart1_bt_pins {
+		brcm,pins = <32 33 30 31>;
+		brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
+		brcm,pull = <0 2 2 0>;
+	};
+
 	uart2_pins: uart2_pins {
 		brcm,pins = <0 1>;
 		brcm,function = <BCM2835_FSEL_ALT4>;
--- a/arch/arm/boot/dts/bcm2711-rpi-400.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-400.dts
@@ -445,6 +445,12 @@
 		brcm,pull;
 	};
 
+	uart1_bt_pins: uart1_bt_pins {
+		brcm,pins = <32 33 30 31>;
+		brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
+		brcm,pull = <0 2 2 0>;
+	};
+
 	uart2_pins: uart2_pins {
 		brcm,pins = <0 1>;
 		brcm,function = <BCM2835_FSEL_ALT4>;
--- a/arch/arm/boot/dts/bcm2711-rpi-cm4.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-cm4.dts
@@ -454,6 +454,12 @@
 		brcm,pull;
 	};
 
+	uart1_bt_pins: uart1_bt_pins {
+		brcm,pins = <32 33 30 31>;
+		brcm,function = <BCM2835_FSEL_ALT5>; /* alt5=UART1 */
+		brcm,pull = <0 2 2 0>;
+	};
+
 	uart2_pins: uart2_pins {
 		brcm,pins = <0 1>;
 		brcm,function = <BCM2835_FSEL_ALT4>;
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -2887,17 +2887,12 @@ Params: speed                   SPI bus
 
 
 Name:   miniuart-bt
-Info:   Switch the onboard Bluetooth function on Pi 3B, 3B+, 3A+, 4B and Zero W
+Info:   Switch the onboard Bluetooth function of a BT-equipped Raspberry Pi
         to use the mini-UART (ttyS0) and restore UART0/ttyAMA0 over GPIOs 14 &
-        15. Note that this may reduce the maximum usable baudrate.
-        N.B. It is also necessary to edit /lib/systemd/system/hciuart.service
-        and replace ttyAMA0 with ttyS0, unless using Raspbian or another
-        distribution with udev rules that create /dev/serial0 and /dev/serial1,
-        in which case use /dev/serial1 instead because it will always be
-        correct. Furthermore, you must also set core_freq and core_freq_min to
-        the same value in config.txt or the miniuart will not work.
+        15. Note that this option uses a lower baudrate, and should only be used
+        with low-bandwidth peripherals.
 Load:   dtoverlay=miniuart-bt,<param>=<val>
-Params: krnbt                   Set to "on" to enable autoprobing of Bluetooth
+Params: krnbt                   Set to "off" to disable autoprobing of Bluetooth
                                 driver without need of hciattach/btattach
 
 
--- a/arch/arm/boot/dts/overlays/miniuart-bt-overlay.dts
+++ b/arch/arm/boot/dts/overlays/miniuart-bt-overlay.dts
@@ -55,11 +55,9 @@
 	};
 
 	fragment@4 {
-		target = <&uart1_pins>;
+		target = <&uart1>;
 		__overlay__ {
-			brcm,pins = <32 33 30 31>;
-			brcm,function = <2>; /* alt5=UART1 */
-			brcm,pull = <0 2 2 0>;
+			pinctrl-0 = <&uart1_bt_pins>;
 		};
 	};
 
@@ -68,6 +66,7 @@
 		__overlay__ {
 			serial0 = "/soc/serial@7e201000";
 			serial1 = "/soc/serial@7e215040";
+			bluetooth = "/soc/serial@7e215040/bluetooth";
 		};
 	};
 
@@ -80,6 +79,5 @@
 
 	__overrides__ {
 		krnbt = <&minibt_frag>,"status";
-		krnbt_baudrate = <&minibt_frag>,"max-speed:0";
 	};
 };
