]> Gentwo Git Trees - linux/.git/commitdiff
Bluetooth: mediatek: add gpio pin to reset bt
authorZhangchao Zhang <ot_zhangchao.zhang@mediatek.com>
Fri, 26 Sep 2025 10:10:46 +0000 (18:10 +0800)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 1 Dec 2025 20:58:54 +0000 (15:58 -0500)
Support the platform Bluetooth to be reset by hardware pin,
when a Bluetooth exception occurs, attempt to reset the
Bluetooth module using the hardware reset pin, as this
method is generally more stable and reliable than a
software reset. If the hardware reset pin is not specified
in the device tree, fall back to the existing software
reset mechanism to ensure backward compatibility.

Co-developed: Sean Wang <Sean.Wang@mediatek.com>
Co-developed: Hao Qin <hao.qin@mediatek.com>
Co-developed: Chris Lu <chris.lu@mediatek.com>
Signed-off-by: Zhangchao Zhang <ot_zhangchao.zhang@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
drivers/bluetooth/btusb.c

index fa683bb7f0b494e5748537c4f135fe8bc50fa609..9bfa55cb7acf70fb2da2d3ec214f3132c9d67977 100644 (file)
@@ -2808,6 +2808,19 @@ static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data)
        btusb_stop_traffic(data);
        usb_kill_anchored_urbs(&data->tx_anchor);
 
+       /* Toggle the hard reset line. The MediaTek 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 (data->reset_gpio) {
+               gpiod_set_value_cansleep(data->reset_gpio, 1);
+               msleep(200);
+               gpiod_set_value_cansleep(data->reset_gpio, 0);
+               return 0;
+       }
+
        err = btmtk_usb_subsys_reset(hdev, btmtk_data->dev_id);
 
        usb_queue_reset_device(data->intf);