Commit d7ef0d1e authored by Alex Lu's avatar Alex Lu Committed by Marcel Holtmann

Bluetooth: btusb: Use cmd_timeout to reset Realtek device

Realtek Bluetooth controller provides a BT_DIS reset pin for hardware
reset of it. The cmd_timeout is helpful on Realtek bluetooth controller
where the firmware gets stuck.
Signed-off-by: default avatarAlex Lu <alex_lu@realsil.com.cn>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent cf0d9a70
...@@ -524,6 +524,36 @@ static void btusb_intel_cmd_timeout(struct hci_dev *hdev) ...@@ -524,6 +524,36 @@ static void btusb_intel_cmd_timeout(struct hci_dev *hdev)
gpiod_set_value_cansleep(reset_gpio, 0); gpiod_set_value_cansleep(reset_gpio, 0);
} }
static void btusb_rtl_cmd_timeout(struct hci_dev *hdev)
{
struct btusb_data *data = hci_get_drvdata(hdev);
struct gpio_desc *reset_gpio = data->reset_gpio;
if (++data->cmd_timeout_cnt < 5)
return;
if (!reset_gpio) {
bt_dev_err(hdev, "No gpio to reset Realtek device, ignoring");
return;
}
/* Toggle the hard reset line. The Realtek 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;
}
bt_dev_err(hdev, "Reset Realtek device via gpio");
gpiod_set_value_cansleep(reset_gpio, 0);
msleep(200);
gpiod_set_value_cansleep(reset_gpio, 1);
}
static inline void btusb_free_frags(struct btusb_data *data) static inline void btusb_free_frags(struct btusb_data *data)
{ {
unsigned long flags; unsigned long flags;
...@@ -3783,6 +3813,7 @@ static int btusb_probe(struct usb_interface *intf, ...@@ -3783,6 +3813,7 @@ static int btusb_probe(struct usb_interface *intf,
if (id->driver_info & BTUSB_REALTEK) { if (id->driver_info & BTUSB_REALTEK) {
hdev->setup = btrtl_setup_realtek; hdev->setup = btrtl_setup_realtek;
hdev->shutdown = btrtl_shutdown_realtek; hdev->shutdown = btrtl_shutdown_realtek;
hdev->cmd_timeout = btusb_rtl_cmd_timeout;
/* Realtek devices lose their updated firmware over global /* Realtek devices lose their updated firmware over global
* suspend that means host doesn't send SET_FEATURE * suspend that means host doesn't send SET_FEATURE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment