Skip to contentSkip to conversation

Bluetooth: hci_bcm: Autobaud mode support

PATCH Applied Hakan Jansson 4 participants 6 messages May 30, 2022 – Jun 2, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover Bluetooth: hci_bcm: Autobaud mode support

Some devices (e.g. CYW5557x) require autobaud mode to enable FW loading. Autobaud mode can also be required on some boards where the controller device is using a non-standard baud rate when first powered on.

Only a limited subset of HCI commands are supported in autobaud mode.

These patches add a DT property, "brcm,requires-autobaud-mode", to control autobaud mode selection.

Changes v2 -> v3:
- Rename DT property and modify description in binding document

Changes v1 -> v2:
- Modify description in binding document

Hakan Jansson (2):
dt-bindings: net: broadcom-bluetooth: Add property for autobaud mode
Bluetooth: hci_bcm: Add support for FW loading in autobaud mode

 .../bindings/net/broadcom-bluetooth.yaml      |  7 +++++
 drivers/bluetooth/btbcm.c                     | 31 ++++++++++++++-----
 drivers/bluetooth/btbcm.h                     |  8 ++---
 drivers/bluetooth/hci_bcm.c                   | 16 ++++++++--
 4 files changed, 47 insertions(+), 15 deletions(-)

base-commit: 677fb7525331375ba2f90f4bc94a80b9b6e697a3

Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 1/2 dt-bindings: net: broadcom-bluetooth: Add property for autobaud mode

Add property, "brcm,requires-autobaud-mode", to enable autobaud mode selection.

Some devices (e.g. CYW5557x) require autobaud mode to enable FW loading. Autobaud mode can also be required on some boards where the controller device is using a non-standard baud rate when first powered on.

---
V2 -> V3:
- Rename DT property and modify description

    https://lore.kernel.org/linux-devicetree/[email protected]/

V1 -> V2:
- Modify property description

 .../devicetree/bindings/net/broadcom-bluetooth.yaml        | 7 +++++++
 1 file changed, 7 insertions(+)
Documentation/devicetree/bindings/net/broadcom-bluetooth.yaml +7 -0
index 5aac094fd217..0a58d0fbcbc4 100644
@@ -92,6 +92,13 @@ properties:
        pcm-sync-mode: slave, master
        pcm-clock-mode: slave, master
 
+  brcm,requires-autobaud-mode:
+    type: boolean
+    description:
+      Set this property if autobaud mode is required. Autobaud mode is required
+      if the device's initial baud rate in normal mode is not supported by the
+      host or if the device requires autobaud mode startup before loading FW.
+
   interrupts:
     items:
       - description: Handle to the line HOST_WAKE used to wake
Signature · 1 line
2.25.1
#2 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=646037

---Test result---

Test Summary:

CheckPatch                    PASS      2.94 seconds
GitLint                       FAIL      1.47 seconds
SubjectPrefix                 FAIL      0.65 seconds
BuildKernel                   PASS      35.43 seconds
BuildKernel32                 PASS      31.25 seconds
Incremental Build with patchesPASS      48.75 seconds
TestRunner: Setup             PASS      552.97 seconds
TestRunner: l2cap-tester      PASS      18.88 seconds
TestRunner: bnep-tester       PASS      6.90 seconds
TestRunner: mgmt-tester       PASS      114.46 seconds
TestRunner: rfcomm-tester     PASS      11.12 seconds
TestRunner: sco-tester        PASS      11.08 seconds
TestRunner: smp-tester        PASS      11.06 seconds
TestRunner: userchan-tester   PASS      7.66 seconds

Details
##############################
Test: GitLint - FAIL - 1.47 seconds
Run gitlint with rule in .gitlint
[v3,1/2] dt-bindings: net: broadcom-bluetooth: Add property for autobaud mode
14: B1 Line exceeds max length (93>80): " https://lore.kernel.org/linux-devicetree/[email protected]/"

[v3,2/2] Bluetooth: hci_bcm: Add support for FW loading in autobaud mode
21: B1 Line exceeds max length (93>80): " https://lore.kernel.org/linux-devicetree/[email protected]/"

##############################
Test: SubjectPrefix - FAIL - 0.65 seconds Check subject contains "Bluetooth" prefix "Bluetooth: " is not specified in the subject

---
Regards,
Linux Bluetooth

Reviewed-by on v3 1/2
#3 lore raw

Re: [PATCH v3 1/2] dt-bindings: net: broadcom-bluetooth: Add property for autobaud mode

In reply to Hakan Jansson
Quoted 8 lines · Hakan Jansson

Add property, "brcm,requires-autobaud-mode", to enable autobaud mode selection.

Some devices (e.g. CYW5557x) require autobaud mode to enable FW loading. Autobaud mode can also be required on some boards where the controller device is using a non-standard baud rate when first powered on.

Best regards,
Krzysztof

#4 lore raw

PATCH v3 2/2 Bluetooth: hci_bcm: Add support for FW loading in autobaud mode

In reply to Hakan Jansson

Use the presence of a DT property, "brcm,requires-autobaud-mode", to enable startup in autobaud mode. If the property is present, the device is started in autobaud mode by asserting RTS (BT_UART_CTS_N) prior to powering on the device.

Also prevent the use of unsupported commands for devices started in autobaud mode. Only a limited subset of HCI commands are supported in autobaud mode.

Some devices (e.g. CYW5557x) require autobaud mode to enable FW loading. Autobaud mode can also be required on some boards where the controller device is using a non-standard baud rate in normal mode when first powered on.

---
V2 -> V3:
- Rename DT property to "brcm,requires-autobaud-mode"

    https://lore.kernel.org/linux-devicetree/[email protected]/

V1 -> V2:
- No changes, submitted as part of updated patch series

 drivers/bluetooth/btbcm.c   | 31 +++++++++++++++++++++++--------
 drivers/bluetooth/btbcm.h   |  8 ++++----
 drivers/bluetooth/hci_bcm.c | 16 +++++++++++++---
 3 files changed, 40 insertions(+), 15 deletions(-)
drivers/bluetooth/btbcm.c +23 -8
index 76fbb046bdbe..cfe018a6c1fc 100644
@@ -403,6 +403,13 @@ static int btbcm_read_info(struct hci_dev *hdev)
 	bt_dev_info(hdev, "BCM: chip id %u", skb->data[1]);
 	kfree_skb(skb);
 
+	return 0;
+}
+
+static int btbcm_print_controller_features(struct hci_dev *hdev)
+{
+	struct sk_buff *skb;
+
 	/* Read Controller Features */
 	skb = btbcm_read_controller_features(hdev);
 	if (IS_ERR(skb))
@@ -514,7 +521,7 @@ static const char *btbcm_get_board_name(struct device *dev)
 #endif
 }
 
-int btbcm_initialize(struct hci_dev *hdev, bool *fw_load_done)
+int btbcm_initialize(struct hci_dev *hdev, bool *fw_load_done, bool use_autobaud_mode)
 {
 	u16 subver, rev, pid, vid;
 	struct sk_buff *skb;
@@ -551,9 +558,16 @@ int btbcm_initialize(struct hci_dev *hdev, bool *fw_load_done)
 		if (err)
 			return err;
 	}
-	err = btbcm_print_local_name(hdev);
-	if (err)
-		return err;
+
+	if (!use_autobaud_mode) {
+		err = btbcm_print_controller_features(hdev);
+		if (err)
+			return err;
+
+		err = btbcm_print_local_name(hdev);
+		if (err)
+			return err;
+	}
 
 	bcm_subver_table = (hdev->bus == HCI_USB) ? bcm_usb_subver_table :
 						    bcm_uart_subver_table;
@@ -636,13 +650,13 @@ int btbcm_initialize(struct hci_dev *hdev, bool *fw_load_done)
 }
 EXPORT_SYMBOL_GPL(btbcm_initialize);
 
-int btbcm_finalize(struct hci_dev *hdev, bool *fw_load_done)
+int btbcm_finalize(struct hci_dev *hdev, bool *fw_load_done, bool use_autobaud_mode)
 {
 	int err;
 
 	/* Re-initialize if necessary */
 	if (*fw_load_done) {
-		err = btbcm_initialize(hdev, fw_load_done);
+		err = btbcm_initialize(hdev, fw_load_done, use_autobaud_mode);
 		if (err)
 			return err;
 	}
@@ -658,15 +672,16 @@ EXPORT_SYMBOL_GPL(btbcm_finalize);
 int btbcm_setup_patchram(struct hci_dev *hdev)
 {
 	bool fw_load_done = false;
+	bool use_autobaud_mode = false;
 	int err;
 
 	/* Initialize */
-	err = btbcm_initialize(hdev, &fw_load_done);
+	err = btbcm_initialize(hdev, &fw_load_done, use_autobaud_mode);
 	if (err)
 		return err;
 
 	/* Re-initialize after loading Patch */
-	return btbcm_finalize(hdev, &fw_load_done);
+	return btbcm_finalize(hdev, &fw_load_done, use_autobaud_mode);
 }
 EXPORT_SYMBOL_GPL(btbcm_setup_patchram);
 
drivers/bluetooth/btbcm.h +4 -4
index 8bf01565fdfc..b4cb24231a20 100644
@@ -62,8 +62,8 @@ int btbcm_write_pcm_int_params(struct hci_dev *hdev,
 int btbcm_setup_patchram(struct hci_dev *hdev);
 int btbcm_setup_apple(struct hci_dev *hdev);
 
-int btbcm_initialize(struct hci_dev *hdev, bool *fw_load_done);
-int btbcm_finalize(struct hci_dev *hdev, bool *fw_load_done);
+int btbcm_initialize(struct hci_dev *hdev, bool *fw_load_done, bool use_autobaud_mode);
+int btbcm_finalize(struct hci_dev *hdev, bool *fw_load_done, bool use_autobaud_mode);
 
 #else
 
@@ -104,12 +104,12 @@ static inline int btbcm_setup_apple(struct hci_dev *hdev)
 	return 0;
 }
 
-static inline int btbcm_initialize(struct hci_dev *hdev, bool *fw_load_done)
+static inline int btbcm_initialize(struct hci_dev *hdev, bool *fw_load_done, bool use_autobaud_mode)
 {
 	return 0;
 }
 
-static inline int btbcm_finalize(struct hci_dev *hdev, bool *fw_load_done)
+static inline int btbcm_finalize(struct hci_dev *hdev, bool *fw_load_done, bool use_autobaud_mode)
 {
 	return 0;
 }
drivers/bluetooth/hci_bcm.c +13 -3
index 785f445dd60d..4309654f95a5 100644
@@ -99,6 +99,7 @@ struct bcm_device_data {
  * @no_early_set_baudrate: don't set_baudrate before setup()
  * @drive_rts_on_open: drive RTS signal on ->open() when platform requires it
  * @pcm_int_params: keep the initial PCM configuration
+ * @use_autobaud_mode: start Bluetooth device in autobaud mode
  */
 struct bcm_device {
 	/* Must be the first member, hci_serdev.c expects this. */
@@ -136,6 +137,7 @@ struct bcm_device {
 #endif
 	bool			no_early_set_baudrate;
 	bool			drive_rts_on_open;
+	bool			use_autobaud_mode;
 	u8			pcm_int_params[5];
 };
 
@@ -472,7 +474,9 @@ static int bcm_open(struct hci_uart *hu)
 
 out:
 	if (bcm->dev) {
-		if (bcm->dev->drive_rts_on_open)
+		if (bcm->dev->use_autobaud_mode)
+			hci_uart_set_flow_control(hu, false);	/* Assert BT_UART_CTS_N */
+		else if (bcm->dev->drive_rts_on_open)
 			hci_uart_set_flow_control(hu, true);
 
 		hu->init_speed = bcm->dev->init_speed;
@@ -564,6 +568,7 @@ static int bcm_setup(struct hci_uart *hu)
 {
 	struct bcm_data *bcm = hu->priv;
 	bool fw_load_done = false;
+	bool use_autobaud_mode = (bcm->dev ? bcm->dev->use_autobaud_mode : 0);
 	unsigned int speed;
 	int err;
 
@@ -572,7 +577,7 @@ static int bcm_setup(struct hci_uart *hu)
 	hu->hdev->set_diag = bcm_set_diag;
 	hu->hdev->set_bdaddr = btbcm_set_bdaddr;
 
-	err = btbcm_initialize(hu->hdev, &fw_load_done);
+	err = btbcm_initialize(hu->hdev, &fw_load_done, use_autobaud_mode);
 	if (err)
 		return err;
 
@@ -616,7 +621,7 @@ static int bcm_setup(struct hci_uart *hu)
 		btbcm_write_pcm_int_params(hu->hdev, &params);
 	}
 
-	err = btbcm_finalize(hu->hdev, &fw_load_done);
+	err = btbcm_finalize(hu->hdev, &fw_load_done, use_autobaud_mode);
 	if (err)
 		return err;
 
@@ -1197,6 +1202,11 @@ static int bcm_acpi_probe(struct bcm_device *dev)
 
 static int bcm_of_probe(struct bcm_device *bdev)
 {
+	bdev->use_autobaud_mode = device_property_read_bool(bdev->dev,
+							    "brcm,requires-autobaud-mode");
+	if (bdev->use_autobaud_mode)
+		bdev->no_early_set_baudrate = true;
+
 	device_property_read_u32(bdev->dev, "max-speed", &bdev->oper_speed);
 	device_property_read_u8_array(bdev->dev, "brcm,bt-pcm-int-params",
 				      bdev->pcm_int_params, 5);
Signature · 1 line
2.25.1
#5 lore raw
In reply to Hakan Jansson
This series was applied to bluetooth/bluetooth-next.git (master) by Marcel Holtmann <[email protected]>:

Hello:

This series was applied to bluetooth/bluetooth-next.git (master) by Marcel Holtmann <[email protected]>:

Quoted 10 lines · On Mon, 30 May 2022 17:02:16 +0200 you wrote:

Some devices (e.g. CYW5557x) require autobaud mode to enable FW loading. Autobaud mode can also be required on some boards where the controller device is using a non-standard baud rate when first powered on.

Only a limited subset of HCI commands are supported in autobaud mode.

These patches add a DT property, "brcm,requires-autobaud-mode", to control autobaud mode selection.

[...]

Here is the summary with links:
- [v3,1/2] dt-bindings: net: broadcom-bluetooth: Add property for autobaud mode

    https://git.kernel.org/bluetooth/bluetooth-next/c/6d912cc3c21f
  - [v3,2/2] Bluetooth: hci_bcm: Add support for FW loading in autobaud mode
    https://git.kernel.org/bluetooth/bluetooth-next/c/3f125894bed7

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html