aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.4/950-0841-ARM-dts-Add-Bluetooth-nodes-for-Raspberry-Pi.patch
blob: fd66e6590dc60655e6e3ac6a72efd1c8a6a32ba6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
From c46a59c99e53ab41096afcf7f7879bb12769346b Mon Sep 17 00:00:00 2001
From: Maxim Mikityanskiy <maxtram95@gmail.com>
Date: Sat, 27 Jun 2020 13:08:26 +0300
Subject: [PATCH] ARM: dts: Add Bluetooth nodes for Raspberry Pi

Add device tree nodes for Bluetooth on supported Raspberry Pi boards.
It's disabled by default and can be enabled by `krnbt=on` dtparam. It's
an alternative way of configuring Bluetooth, as compared to hciattach or
btattach. When the dtparam is enabled, the Bluetooth driver is probed
automatically and doesn't require any additional bring-up scripts.

Note that Raspberry Pi 3 B rev 1.2 doesn't have the required hardware
flow control pins of UART0 connected to the Bluetooth module, so the
user should decrease the baudrate by passing `krnbt_baudrate=921600`
dtparam to make it more stable. It resembles the behavior of the btuart
script from Raspbian.

The miniuart-bt overlay was modified to support Bluetooth probing with
device tree, too. It's disabled by default and can be enabled by
`krnbt=on` parameter of the miniuart-bt overlay.

Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
---
 arch/arm/boot/dts/bcm2708-rpi-bt.dtsi         | 26 +++++++++++++++++++
 arch/arm/boot/dts/bcm2708-rpi-zero-w.dts      |  1 +
 arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts    |  1 +
 arch/arm/boot/dts/bcm2710-rpi-3-b.dts         |  1 +
 arch/arm/boot/dts/bcm2711-rpi-4-b.dts         |  3 +--
 arch/arm/boot/dts/bcm271x-rpi-bt.dtsi         | 26 +++++++++++++++++++
 arch/arm/boot/dts/overlays/README             | 12 +++++++--
 .../boot/dts/overlays/disable-bt-overlay.dts  | 13 ++++++++--
 .../boot/dts/overlays/miniuart-bt-overlay.dts | 21 ++++++++++++---
 9 files changed, 94 insertions(+), 10 deletions(-)
 create mode 100644 arch/arm/boot/dts/bcm2708-rpi-bt.dtsi
 create mode 100644 arch/arm/boot/dts/bcm271x-rpi-bt.dtsi

--- /dev/null
+++ b/arch/arm/boot/dts/bcm2708-rpi-bt.dtsi
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+
+&uart0 {
+	bt: bluetooth {
+		compatible = "brcm,bcm43438-bt";
+		max-speed = <3000000>;
+		shutdown-gpios = <&gpio 45 GPIO_ACTIVE_HIGH>;
+		status = "disabled";
+	};
+};
+
+&uart1 {
+	minibt: bluetooth {
+		compatible = "brcm,bcm43438-bt";
+		max-speed = <460800>;
+		shutdown-gpios = <&gpio 45 GPIO_ACTIVE_HIGH>;
+		status = "disabled";
+	};
+};
+
+/ {
+	__overrides__ {
+		krnbt = <&bt>,"status";
+		krnbt_baudrate = <&bt>,"max-speed:0";
+	};
+};
--- a/arch/arm/boot/dts/bcm2708-rpi-zero-w.dts
+++ b/arch/arm/boot/dts/bcm2708-rpi-zero-w.dts
@@ -4,6 +4,7 @@
 #include "bcm2708-rpi.dtsi"
 #include "bcm283x-rpi-csi1-2lane.dtsi"
 #include "bcm283x-rpi-i2c0mux_0_28.dtsi"
+#include "bcm2708-rpi-bt.dtsi"
 
 / {
 	compatible = "raspberrypi,model-zero-w", "brcm,bcm2835";
--- a/arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts
+++ b/arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts
@@ -5,6 +5,7 @@
 #include "bcm283x-rpi-lan7515.dtsi"
 #include "bcm283x-rpi-csi1-2lane.dtsi"
 #include "bcm283x-rpi-i2c0mux_0_44.dtsi"
+#include "bcm271x-rpi-bt.dtsi"
 
 / {
 	compatible = "raspberrypi,3-model-b-plus", "brcm,bcm2837";
--- a/arch/arm/boot/dts/bcm2710-rpi-3-b.dts
+++ b/arch/arm/boot/dts/bcm2710-rpi-3-b.dts
@@ -5,6 +5,7 @@
 #include "bcm283x-rpi-smsc9514.dtsi"
 #include "bcm283x-rpi-csi1-2lane.dtsi"
 #include "bcm283x-rpi-i2c0mux_0_44.dtsi"
+#include "bcm271x-rpi-bt.dtsi"
 
 / {
 	compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
--- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
+++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts
@@ -182,6 +182,7 @@
 // Downstream rpi- changes
 
 #include "bcm270x.dtsi"
+#include "bcm271x-rpi-bt.dtsi"
 
 / {
 	soc {
@@ -250,8 +251,6 @@
 &uart0 {
 	pinctrl-0 = <&uart0_pins &bt_pins>;
 	status = "okay";
-
-	/delete-node/ bluetooth;
 };
 
 &uart1 {
--- /dev/null
+++ b/arch/arm/boot/dts/bcm271x-rpi-bt.dtsi
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0
+
+&uart0 {
+	bt: bluetooth {
+		compatible = "brcm,bcm43438-bt";
+		max-speed = <3000000>;
+		shutdown-gpios = <&expgpio 0 GPIO_ACTIVE_HIGH>;
+		status = "disabled";
+	};
+};
+
+&uart1 {
+	minibt: bluetooth {
+		compatible = "brcm,bcm43438-bt";
+		max-speed = <460800>;
+		shutdown-gpios = <&expgpio 0 GPIO_ACTIVE_HIGH>;
+		status = "disabled";
+	};
+};
+
+/ {
+	__overrides__ {
+		krnbt = <&bt>,"status";
+		krnbt_baudrate = <&bt>,"max-speed:0";
+	};
+};
--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -162,6 +162,13 @@ Params:
         i2s                     Set to "on" to enable the i2s interface
                                 (default "off")
 
+        krnbt                   Set to "on" to enable autoprobing of Bluetooth
+                                driver without need of hciattach/btattach
+                                (default "off")
+
+        krnbt_baudrate          Set the baudrate of the PL011 UART when used
+                                with krnbt=on
+
         spi                     Set to "on" to enable the spi interfaces
                                 (default "off")
 
@@ -1764,8 +1771,9 @@ Info:   Switch the onboard Bluetooth fun
         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.
-Load:   dtoverlay=miniuart-bt
-Params: <None>
+Load:   dtoverlay=miniuart-bt,<param>=<val>
+Params: krnbt                   Set to "on" to enable autoprobing of Bluetooth
+                                driver without need of hciattach/btattach
 
 
 Name:   mmc
--- a/arch/arm/boot/dts/overlays/disable-bt-overlay.dts
+++ b/arch/arm/boot/dts/overlays/disable-bt-overlay.dts
@@ -8,6 +8,8 @@
        sudo systemctl disable hciuart
 */
 
+#include <dt-bindings/gpio/gpio.h>
+
 /{
 	compatible = "brcm,bcm2835";
 
@@ -28,6 +30,13 @@
 	};
 
 	fragment@2 {
+		target = <&bt>;
+		__overlay__ {
+			status = "disabled";
+		};
+	};
+
+	fragment@3 {
 		target = <&uart0_pins>;
 		__overlay__ {
 			brcm,pins;
@@ -36,7 +45,7 @@
 		};
 	};
 
-	fragment@3 {
+	fragment@4 {
 		target = <&bt_pins>;
 		__overlay__ {
 			brcm,pins;
@@ -45,7 +54,7 @@
 		};
 	};
 
-	fragment@4 {
+	fragment@5 {
 		target-path = "/aliases";
 		__overlay__ {
 			serial0 = "/soc/serial@7e201000";
--- a/arch/arm/boot/dts/overlays/miniuart-bt-overlay.dts
+++ b/arch/arm/boot/dts/overlays/miniuart-bt-overlay.dts
@@ -15,6 +15,8 @@
    this overlay is used.
 */
 
+#include <dt-bindings/gpio/gpio.h>
+
 /{
 	compatible = "brcm,bcm2835";
 
@@ -28,6 +30,13 @@
 	};
 
 	fragment@1 {
+		target = <&bt>;
+		__overlay__ {
+			status = "disabled";
+		};
+	};
+
+	fragment@2 {
 		target = <&uart1>;
 		__overlay__ {
 			pinctrl-names = "default";
@@ -36,7 +45,7 @@
 		};
 	};
 
-	fragment@2 {
+	fragment@3 {
 		target = <&uart0_pins>;
 		__overlay__ {
 			brcm,pins;
@@ -45,7 +54,7 @@
 		};
 	};
 
-	fragment@3 {
+	fragment@4 {
 		target = <&uart1_pins>;
 		__overlay__ {
 			brcm,pins = <32 33>;
@@ -54,7 +63,7 @@
 		};
 	};
 
-	fragment@4 {
+	fragment@5 {
 		target = <&gpio>;
 		__overlay__ {
 			fake_bt_cts: fake_bt_cts {
@@ -64,11 +73,15 @@
 		};
 	};
 
-	fragment@5 {
+	fragment@6 {
 		target-path = "/aliases";
 		__overlay__ {
 			serial0 = "/soc/serial@7e201000";
 			serial1 = "/soc/serial@7e215040";
 		};
 	};
+
+	__overrides__ {
+		krnbt = <&minibt>,"status";
+	};
 };