| b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From c46a59c99e53ab41096afcf7f7879bb12769346b Mon Sep 17 00:00:00 2001 |
| 2 | From: Maxim Mikityanskiy <maxtram95@gmail.com> |
| 3 | Date: Sat, 27 Jun 2020 13:08:26 +0300 |
| 4 | Subject: [PATCH] ARM: dts: Add Bluetooth nodes for Raspberry Pi |
| 5 | |
| 6 | Add device tree nodes for Bluetooth on supported Raspberry Pi boards. |
| 7 | It's disabled by default and can be enabled by `krnbt=on` dtparam. It's |
| 8 | an alternative way of configuring Bluetooth, as compared to hciattach or |
| 9 | btattach. When the dtparam is enabled, the Bluetooth driver is probed |
| 10 | automatically and doesn't require any additional bring-up scripts. |
| 11 | |
| 12 | Note that Raspberry Pi 3 B rev 1.2 doesn't have the required hardware |
| 13 | flow control pins of UART0 connected to the Bluetooth module, so the |
| 14 | user should decrease the baudrate by passing `krnbt_baudrate=921600` |
| 15 | dtparam to make it more stable. It resembles the behavior of the btuart |
| 16 | script from Raspbian. |
| 17 | |
| 18 | The miniuart-bt overlay was modified to support Bluetooth probing with |
| 19 | device tree, too. It's disabled by default and can be enabled by |
| 20 | `krnbt=on` parameter of the miniuart-bt overlay. |
| 21 | |
| 22 | Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com> |
| 23 | --- |
| 24 | arch/arm/boot/dts/bcm2708-rpi-bt.dtsi | 26 +++++++++++++++++++ |
| 25 | arch/arm/boot/dts/bcm2708-rpi-zero-w.dts | 1 + |
| 26 | arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts | 1 + |
| 27 | arch/arm/boot/dts/bcm2710-rpi-3-b.dts | 1 + |
| 28 | arch/arm/boot/dts/bcm2711-rpi-4-b.dts | 3 +-- |
| 29 | arch/arm/boot/dts/bcm271x-rpi-bt.dtsi | 26 +++++++++++++++++++ |
| 30 | arch/arm/boot/dts/overlays/README | 12 +++++++-- |
| 31 | .../boot/dts/overlays/disable-bt-overlay.dts | 13 ++++++++-- |
| 32 | .../boot/dts/overlays/miniuart-bt-overlay.dts | 21 ++++++++++++--- |
| 33 | 9 files changed, 94 insertions(+), 10 deletions(-) |
| 34 | create mode 100644 arch/arm/boot/dts/bcm2708-rpi-bt.dtsi |
| 35 | create mode 100644 arch/arm/boot/dts/bcm271x-rpi-bt.dtsi |
| 36 | |
| 37 | --- /dev/null |
| 38 | +++ b/arch/arm/boot/dts/bcm2708-rpi-bt.dtsi |
| 39 | @@ -0,0 +1,26 @@ |
| 40 | +// SPDX-License-Identifier: GPL-2.0 |
| 41 | + |
| 42 | +&uart0 { |
| 43 | + bt: bluetooth { |
| 44 | + compatible = "brcm,bcm43438-bt"; |
| 45 | + max-speed = <3000000>; |
| 46 | + shutdown-gpios = <&gpio 45 GPIO_ACTIVE_HIGH>; |
| 47 | + status = "disabled"; |
| 48 | + }; |
| 49 | +}; |
| 50 | + |
| 51 | +&uart1 { |
| 52 | + minibt: bluetooth { |
| 53 | + compatible = "brcm,bcm43438-bt"; |
| 54 | + max-speed = <460800>; |
| 55 | + shutdown-gpios = <&gpio 45 GPIO_ACTIVE_HIGH>; |
| 56 | + status = "disabled"; |
| 57 | + }; |
| 58 | +}; |
| 59 | + |
| 60 | +/ { |
| 61 | + __overrides__ { |
| 62 | + krnbt = <&bt>,"status"; |
| 63 | + krnbt_baudrate = <&bt>,"max-speed:0"; |
| 64 | + }; |
| 65 | +}; |
| 66 | --- a/arch/arm/boot/dts/bcm2708-rpi-zero-w.dts |
| 67 | +++ b/arch/arm/boot/dts/bcm2708-rpi-zero-w.dts |
| 68 | @@ -4,6 +4,7 @@ |
| 69 | #include "bcm2708-rpi.dtsi" |
| 70 | #include "bcm283x-rpi-csi1-2lane.dtsi" |
| 71 | #include "bcm283x-rpi-i2c0mux_0_28.dtsi" |
| 72 | +#include "bcm2708-rpi-bt.dtsi" |
| 73 | |
| 74 | / { |
| 75 | compatible = "raspberrypi,model-zero-w", "brcm,bcm2835"; |
| 76 | --- a/arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts |
| 77 | +++ b/arch/arm/boot/dts/bcm2710-rpi-3-b-plus.dts |
| 78 | @@ -5,6 +5,7 @@ |
| 79 | #include "bcm283x-rpi-lan7515.dtsi" |
| 80 | #include "bcm283x-rpi-csi1-2lane.dtsi" |
| 81 | #include "bcm283x-rpi-i2c0mux_0_44.dtsi" |
| 82 | +#include "bcm271x-rpi-bt.dtsi" |
| 83 | |
| 84 | / { |
| 85 | compatible = "raspberrypi,3-model-b-plus", "brcm,bcm2837"; |
| 86 | --- a/arch/arm/boot/dts/bcm2710-rpi-3-b.dts |
| 87 | +++ b/arch/arm/boot/dts/bcm2710-rpi-3-b.dts |
| 88 | @@ -5,6 +5,7 @@ |
| 89 | #include "bcm283x-rpi-smsc9514.dtsi" |
| 90 | #include "bcm283x-rpi-csi1-2lane.dtsi" |
| 91 | #include "bcm283x-rpi-i2c0mux_0_44.dtsi" |
| 92 | +#include "bcm271x-rpi-bt.dtsi" |
| 93 | |
| 94 | / { |
| 95 | compatible = "raspberrypi,3-model-b", "brcm,bcm2837"; |
| 96 | --- a/arch/arm/boot/dts/bcm2711-rpi-4-b.dts |
| 97 | +++ b/arch/arm/boot/dts/bcm2711-rpi-4-b.dts |
| 98 | @@ -182,6 +182,7 @@ |
| 99 | // Downstream rpi- changes |
| 100 | |
| 101 | #include "bcm270x.dtsi" |
| 102 | +#include "bcm271x-rpi-bt.dtsi" |
| 103 | |
| 104 | / { |
| 105 | soc { |
| 106 | @@ -250,8 +251,6 @@ |
| 107 | &uart0 { |
| 108 | pinctrl-0 = <&uart0_pins &bt_pins>; |
| 109 | status = "okay"; |
| 110 | - |
| 111 | - /delete-node/ bluetooth; |
| 112 | }; |
| 113 | |
| 114 | &uart1 { |
| 115 | --- /dev/null |
| 116 | +++ b/arch/arm/boot/dts/bcm271x-rpi-bt.dtsi |
| 117 | @@ -0,0 +1,26 @@ |
| 118 | +// SPDX-License-Identifier: GPL-2.0 |
| 119 | + |
| 120 | +&uart0 { |
| 121 | + bt: bluetooth { |
| 122 | + compatible = "brcm,bcm43438-bt"; |
| 123 | + max-speed = <3000000>; |
| 124 | + shutdown-gpios = <&expgpio 0 GPIO_ACTIVE_HIGH>; |
| 125 | + status = "disabled"; |
| 126 | + }; |
| 127 | +}; |
| 128 | + |
| 129 | +&uart1 { |
| 130 | + minibt: bluetooth { |
| 131 | + compatible = "brcm,bcm43438-bt"; |
| 132 | + max-speed = <460800>; |
| 133 | + shutdown-gpios = <&expgpio 0 GPIO_ACTIVE_HIGH>; |
| 134 | + status = "disabled"; |
| 135 | + }; |
| 136 | +}; |
| 137 | + |
| 138 | +/ { |
| 139 | + __overrides__ { |
| 140 | + krnbt = <&bt>,"status"; |
| 141 | + krnbt_baudrate = <&bt>,"max-speed:0"; |
| 142 | + }; |
| 143 | +}; |
| 144 | --- a/arch/arm/boot/dts/overlays/README |
| 145 | +++ b/arch/arm/boot/dts/overlays/README |
| 146 | @@ -162,6 +162,13 @@ Params: |
| 147 | i2s Set to "on" to enable the i2s interface |
| 148 | (default "off") |
| 149 | |
| 150 | + krnbt Set to "on" to enable autoprobing of Bluetooth |
| 151 | + driver without need of hciattach/btattach |
| 152 | + (default "off") |
| 153 | + |
| 154 | + krnbt_baudrate Set the baudrate of the PL011 UART when used |
| 155 | + with krnbt=on |
| 156 | + |
| 157 | spi Set to "on" to enable the spi interfaces |
| 158 | (default "off") |
| 159 | |
| 160 | @@ -1764,8 +1771,9 @@ Info: Switch the onboard Bluetooth fun |
| 161 | in which case use /dev/serial1 instead because it will always be |
| 162 | correct. Furthermore, you must also set core_freq and core_freq_min to |
| 163 | the same value in config.txt or the miniuart will not work. |
| 164 | -Load: dtoverlay=miniuart-bt |
| 165 | -Params: <None> |
| 166 | +Load: dtoverlay=miniuart-bt,<param>=<val> |
| 167 | +Params: krnbt Set to "on" to enable autoprobing of Bluetooth |
| 168 | + driver without need of hciattach/btattach |
| 169 | |
| 170 | |
| 171 | Name: mmc |
| 172 | --- a/arch/arm/boot/dts/overlays/disable-bt-overlay.dts |
| 173 | +++ b/arch/arm/boot/dts/overlays/disable-bt-overlay.dts |
| 174 | @@ -8,6 +8,8 @@ |
| 175 | sudo systemctl disable hciuart |
| 176 | */ |
| 177 | |
| 178 | +#include <dt-bindings/gpio/gpio.h> |
| 179 | + |
| 180 | /{ |
| 181 | compatible = "brcm,bcm2835"; |
| 182 | |
| 183 | @@ -28,6 +30,13 @@ |
| 184 | }; |
| 185 | |
| 186 | fragment@2 { |
| 187 | + target = <&bt>; |
| 188 | + __overlay__ { |
| 189 | + status = "disabled"; |
| 190 | + }; |
| 191 | + }; |
| 192 | + |
| 193 | + fragment@3 { |
| 194 | target = <&uart0_pins>; |
| 195 | __overlay__ { |
| 196 | brcm,pins; |
| 197 | @@ -36,7 +45,7 @@ |
| 198 | }; |
| 199 | }; |
| 200 | |
| 201 | - fragment@3 { |
| 202 | + fragment@4 { |
| 203 | target = <&bt_pins>; |
| 204 | __overlay__ { |
| 205 | brcm,pins; |
| 206 | @@ -45,7 +54,7 @@ |
| 207 | }; |
| 208 | }; |
| 209 | |
| 210 | - fragment@4 { |
| 211 | + fragment@5 { |
| 212 | target-path = "/aliases"; |
| 213 | __overlay__ { |
| 214 | serial0 = "/soc/serial@7e201000"; |
| 215 | --- a/arch/arm/boot/dts/overlays/miniuart-bt-overlay.dts |
| 216 | +++ b/arch/arm/boot/dts/overlays/miniuart-bt-overlay.dts |
| 217 | @@ -15,6 +15,8 @@ |
| 218 | this overlay is used. |
| 219 | */ |
| 220 | |
| 221 | +#include <dt-bindings/gpio/gpio.h> |
| 222 | + |
| 223 | /{ |
| 224 | compatible = "brcm,bcm2835"; |
| 225 | |
| 226 | @@ -28,6 +30,13 @@ |
| 227 | }; |
| 228 | |
| 229 | fragment@1 { |
| 230 | + target = <&bt>; |
| 231 | + __overlay__ { |
| 232 | + status = "disabled"; |
| 233 | + }; |
| 234 | + }; |
| 235 | + |
| 236 | + fragment@2 { |
| 237 | target = <&uart1>; |
| 238 | __overlay__ { |
| 239 | pinctrl-names = "default"; |
| 240 | @@ -36,7 +45,7 @@ |
| 241 | }; |
| 242 | }; |
| 243 | |
| 244 | - fragment@2 { |
| 245 | + fragment@3 { |
| 246 | target = <&uart0_pins>; |
| 247 | __overlay__ { |
| 248 | brcm,pins; |
| 249 | @@ -45,7 +54,7 @@ |
| 250 | }; |
| 251 | }; |
| 252 | |
| 253 | - fragment@3 { |
| 254 | + fragment@4 { |
| 255 | target = <&uart1_pins>; |
| 256 | __overlay__ { |
| 257 | brcm,pins = <32 33>; |
| 258 | @@ -54,7 +63,7 @@ |
| 259 | }; |
| 260 | }; |
| 261 | |
| 262 | - fragment@4 { |
| 263 | + fragment@5 { |
| 264 | target = <&gpio>; |
| 265 | __overlay__ { |
| 266 | fake_bt_cts: fake_bt_cts { |
| 267 | @@ -64,11 +73,15 @@ |
| 268 | }; |
| 269 | }; |
| 270 | |
| 271 | - fragment@5 { |
| 272 | + fragment@6 { |
| 273 | target-path = "/aliases"; |
| 274 | __overlay__ { |
| 275 | serial0 = "/soc/serial@7e201000"; |
| 276 | serial1 = "/soc/serial@7e215040"; |
| 277 | }; |
| 278 | }; |
| 279 | + |
| 280 | + __overrides__ { |
| 281 | + krnbt = <&minibt>,"status"; |
| 282 | + }; |
| 283 | }; |