Skip to content

Commit

Permalink
Bluetooth: hci_h5: Add power reset via gpio in h5_btrtl_open
Browse files Browse the repository at this point in the history
Add power reset for bluetooth via enable-gpios in h5_btrtl_open function.

While testing the RTL8822CS SDIO WiFi/BT adapter, it was found that in
some cases the kernel could not initialize BT firmware. However,
manually resetting the adapter via gpio (off/on sequence) allows it to
start correctly.
Apparently, when the system starts, the adapter is in an undefined state
(including unknown gpio state after starting uboot). A forced reset helps
to initialize the adapter in most cases. It has been found experimentally
that 100 ms is sufficient for a reset.

Signed-off-by: Vyacheslav Bocharov <adeep@lexina.in>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Vyacheslav Bocharov authored and Marcel Holtmann committed Jan 26, 2022
1 parent b050c5b commit adce573
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/bluetooth/hci_h5.c
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,11 @@ static void h5_btrtl_open(struct h5 *h5)
pm_runtime_enable(&h5->hu->serdev->dev);
}

/* The controller needs reset to startup */
gpiod_set_value_cansleep(h5->enable_gpio, 0);
gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
msleep(100);

/* The controller needs up to 500ms to wakeup */
gpiod_set_value_cansleep(h5->enable_gpio, 1);
gpiod_set_value_cansleep(h5->device_wake_gpio, 1);
Expand Down

0 comments on commit adce573

Please sign in to comment.