Skip to content

Commit 77343b8

Browse files
ChrisCH-LuVudentz
authored andcommitted
Bluetooth: btmtksdio: Add pmctrl handling for BT closed state during reset
This patch adds logic to handle power management control when the Bluetooth function is closed during the SDIO reset sequence. Specifically, if BT is closed before reset, the driver enables the SDIO function and sets driver pmctrl. After reset, if BT remains closed, the driver sets firmware pmctrl and disables the SDIO function. These changes ensure proper power management and device state consistency across the reset flow. Fixes: 8fafe70 ("Bluetooth: mt7921s: support bluetooth reset mechanism") Signed-off-by: Chris Lu <chris.lu@mediatek.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent f0c200a commit 77343b8

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

drivers/bluetooth/btmtksdio.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,12 @@ static void btmtksdio_reset(struct hci_dev *hdev)
12701270

12711271
sdio_claim_host(bdev->func);
12721272

1273+
/* set drv_pmctrl if BT is closed before doing reset */
1274+
if (!test_bit(BTMTKSDIO_FUNC_ENABLED, &bdev->tx_state)) {
1275+
sdio_enable_func(bdev->func);
1276+
btmtksdio_drv_pmctrl(bdev);
1277+
}
1278+
12731279
sdio_writel(bdev->func, C_INT_EN_CLR, MTK_REG_CHLPCR, NULL);
12741280
skb_queue_purge(&bdev->txq);
12751281
cancel_work_sync(&bdev->txrx_work);
@@ -1285,6 +1291,12 @@ static void btmtksdio_reset(struct hci_dev *hdev)
12851291
goto err;
12861292
}
12871293

1294+
/* set fw_pmctrl back if BT is closed after doing reset */
1295+
if (!test_bit(BTMTKSDIO_FUNC_ENABLED, &bdev->tx_state)) {
1296+
btmtksdio_fw_pmctrl(bdev);
1297+
sdio_disable_func(bdev->func);
1298+
}
1299+
12881300
clear_bit(BTMTKSDIO_PATCH_ENABLED, &bdev->tx_state);
12891301
err:
12901302
sdio_release_host(bdev->func);

0 commit comments

Comments
 (0)