diff options
author | tjiang@codeaurora.org <tjiang@codeaurora.org> | 2021-09-16 11:41:06 +0300 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2021-09-21 11:47:17 +0300 |
commit | 24ff62ae383f776ab0285f2996de6bd9bb2d2e4b (patch) | |
tree | 885f0928246596672b6f2dd1572938662fc80de0 /drivers/bluetooth | |
parent | 037ce005af6b8a3e40ee07c6e9266c8997e6a4d6 (diff) | |
download | linux-24ff62ae383f776ab0285f2996de6bd9bb2d2e4b.tar.xz |
Bluetooth: btusb: Add gpio reset way for qca btsoc in cmd_timeout
if platform provide gpio connect to BT_EN reset pin of qca btsoc chip,
we can do hardware reset instead of usb port reset.
Signed-off-by: Tim Jiang <tjiang@codeaurora.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r-- | drivers/bluetooth/btusb.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 8ef4e0f6e0bb..da85cc14f931 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -657,11 +657,33 @@ static void btusb_rtl_cmd_timeout(struct hci_dev *hdev) static void btusb_qca_cmd_timeout(struct hci_dev *hdev) { struct btusb_data *data = hci_get_drvdata(hdev); + struct gpio_desc *reset_gpio = data->reset_gpio; int err; if (++data->cmd_timeout_cnt < 5) return; + if (reset_gpio) { + bt_dev_err(hdev, "Reset qca device via bt_en gpio"); + + /* Toggle the hard reset line. The qca bt device is going to + * yank itself off the USB and then replug. The cleanup is handled + * correctly on the way out (standard USB disconnect), and the new + * device is detected cleanly and bound to the driver again like + * it should be. + */ + if (test_and_set_bit(BTUSB_HW_RESET_ACTIVE, &data->flags)) { + bt_dev_err(hdev, "last reset failed? Not resetting again"); + return; + } + + gpiod_set_value_cansleep(reset_gpio, 0); + msleep(200); + gpiod_set_value_cansleep(reset_gpio, 1); + + return; + } + bt_dev_err(hdev, "Multiple cmd timeouts seen. Resetting usb device."); /* This is not an unbalanced PM reference since the device will reset */ err = usb_autopm_get_interface(data->intf); |