Skip to contentSkip to conversation

bluetooth: serdev: hci_ll: Wait for CTS instead of using msleep

PATCH In review David Lechner 2 participants 2 messages Dec 3, 2017 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bluetooth: serdev: hci_ll: Wait for CTS instead of using msleep

When a TI Bluetooth chip is reset, it takes about 100ms for the RTS line of the chip to deassert. For my use case with a TI CC2560A chip, this delay was not long enough and caused the local UART to never transmit at all (TI AM1808 SoC UART2).

We can wait for the CTS signal using serdev_device_wait_for_cts() instead of trying to guess using msleep().

Also changed the comment to be more informative while we are touching this code.

---
 drivers/bluetooth/hci_ll.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/bluetooth/hci_ll.c +6 -2
index 1f6b933..b295cf8 100644
@@ -674,11 +674,15 @@ static int ll_setup(struct hci_uart *hu)
 	serdev_device_set_flow_control(serdev, true);
 
 	do {
-		/* Configure BT_EN to HIGH state */
+		/* Reset the Bluetooth device */
 		gpiod_set_value_cansleep(lldev->enable_gpio, 0);
 		msleep(5);
 		gpiod_set_value_cansleep(lldev->enable_gpio, 1);
-		msleep(100);
+		err = serdev_device_wait_for_cts(serdev, true, 200);
+		if (err) {
+			bt_dev_err(hu->hdev, "Failed to get CTS");
+			return err;
+		}
 
 		err = download_firmware(lldev);
 		if (!err)
Signature · 1 line
2.7.4
maintainer
#1 lore raw

Hi David,

Quoted 8 lines

When a TI Bluetooth chip is reset, it takes about 100ms for the RTS line of the chip to deassert. For my use case with a TI CC2560A chip, this delay was not long enough and caused the local UART to never transmit at all (TI AM1808 SoC UART2).

We can wait for the CTS signal using serdev_device_wait_for_cts() instead of trying to guess using msleep().

Quoted 7 lines

Also changed the comment to be more informative while we are touching this code.

---
drivers/bluetooth/hci_ll.c | 8 ++++++--

1 file changed, 6 insertions(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel