Merge tag 'usb-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
[linux-block.git] / drivers / bluetooth / hci_h5.c
index 34286ffe0568fd7033d32f7be86cbb2c70d6032b..c5a0409ef84fd31ff8b9a8fbaf95a0803eab831d 100644 (file)
@@ -629,9 +629,11 @@ static int h5_enqueue(struct hci_uart *hu, struct sk_buff *skb)
                break;
        }
 
-       pm_runtime_get_sync(&hu->serdev->dev);
-       pm_runtime_mark_last_busy(&hu->serdev->dev);
-       pm_runtime_put_autosuspend(&hu->serdev->dev);
+       if (hu->serdev) {
+               pm_runtime_get_sync(&hu->serdev->dev);
+               pm_runtime_mark_last_busy(&hu->serdev->dev);
+               pm_runtime_put_autosuspend(&hu->serdev->dev);
+       }
 
        return 0;
 }
@@ -966,6 +968,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);