From c46a59c99e53ab41096afcf7f7879bb12769346b Mon Sep 17 00:00:00 2001 From: Maxim Mikityanskiy 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 --- 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: +Load: dtoverlay=miniuart-bt,= +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 + /{ 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 + /{ 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"; + }; };