linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bluetooth: serdev: hci_ll: Wait for CTS instead of using msleep
@ 2017-12-03  2:43 David Lechner
  2017-12-03 19:24 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: David Lechner @ 2017-12-03  2:43 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: David Lechner, Marcel Holtmann, Gustavo Padovan, Johan Hedberg,
	linux-kernel

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.

Signed-off-by: David Lechner <david@lechnology.com>
---
 drivers/bluetooth/hci_ll.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c
index 1f6b933..b295cf8 100644
--- a/drivers/bluetooth/hci_ll.c
+++ b/drivers/bluetooth/hci_ll.c
@@ -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)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bluetooth: serdev: hci_ll: Wait for CTS instead of using msleep
  2017-12-03  2:43 [PATCH] bluetooth: serdev: hci_ll: Wait for CTS instead of using msleep David Lechner
@ 2017-12-03 19:24 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2017-12-03 19:24 UTC (permalink / raw)
  To: David Lechner
  Cc: open list:BLUETOOTH DRIVERS, Gustavo F. Padovan, Johan Hedberg,
	linux-kernel

Hi David,

> 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.
> 
> Signed-off-by: David Lechner <david@lechnology.com>
> ---
> drivers/bluetooth/hci_ll.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-03 19:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-03  2:43 [PATCH] bluetooth: serdev: hci_ll: Wait for CTS instead of using msleep David Lechner
2017-12-03 19:24 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).