lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 27 Jun 2022 07:27:36 +0800
From:   <sean.wang@...iatek.com>
To:     <marcel@...tmann.org>, <johan.hedberg@...il.com>
CC:     <sean.wang@...iatek.com>, <Soul.Huang@...iatek.com>,
        <YN.Chen@...iatek.com>, <Leon.Yen@...iatek.com>,
        <Eric-SY.Chang@...iatek.com>, <Deren.Wu@...iatek.com>,
        <km.lin@...iatek.com>, <robin.chiu@...iatek.com>,
        <Eddie.Chen@...iatek.com>, <ch.yeh@...iatek.com>,
        <posh.sun@...iatek.com>, <ted.huang@...iatek.com>,
        <Eric.Liang@...iatek.com>, <Stella.Chang@...iatek.com>,
        <Tom.Chou@...iatek.com>, <steve.lee@...iatek.com>,
        <jsiuda@...gle.com>, <frankgor@...gle.com>,
        <abhishekpandit@...gle.com>, <michaelfsun@...gle.com>,
        <mcchou@...omium.org>, <shawnku@...gle.com>,
        <linux-bluetooth@...r.kernel.org>,
        <linux-mediatek@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>,
        "Yake Yang" <yake.yang@...iatek.com>
Subject: [PATCH v3] Bluetooth: btmtksdio: Add in-band wakeup support

From: Sean Wang <sean.wang@...iatek.com>

Commit ce64b3e94919 ("Bluetooth: mt7921s: Support wake on bluetooth")
adds the wake on bluethooth via a dedicated GPIO.

Extend the wake-on-bluetooth to use the SDIO DAT1 pin (in-band wakeup),
when supported by the SDIO host driver.

Co-developed-by: Yake Yang <yake.yang@...iatek.com>
Signed-off-by: Yake Yang <yake.yang@...iatek.com>
Signed-off-by: Sean Wang <sean.wang@...iatek.com>
---
v2: enhance the patch description and comments
v3: add a way suggested by the AngeloGioacchino Del Regno that look
    elegant and can avoid the addition of the BTMTKSDIO_INBAND_WAKEUP
    flag
---
 drivers/bluetooth/btmtksdio.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
index d6700efcfe8c..f9a3444753c2 100644
--- a/drivers/bluetooth/btmtksdio.c
+++ b/drivers/bluetooth/btmtksdio.c
@@ -1282,6 +1282,13 @@ static void btmtksdio_cmd_timeout(struct hci_dev *hdev)
 	hci_reset_dev(hdev);
 }
 
+static bool btmtksdio_sdio_inband_wakeup(struct hci_dev *hdev)
+{
+	struct btmtksdio_dev *bdev = hci_get_drvdata(hdev);
+
+	return device_may_wakeup(bdev->dev);
+}
+
 static bool btmtksdio_sdio_wakeup(struct hci_dev *hdev)
 {
 	struct btmtksdio_dev *bdev = hci_get_drvdata(hdev);
@@ -1349,6 +1356,14 @@ static int btmtksdio_probe(struct sdio_func *func,
 	hdev->shutdown = btmtksdio_shutdown;
 	hdev->send     = btmtksdio_send_frame;
 	hdev->wakeup   = btmtksdio_sdio_wakeup;
+	/*
+	 * If SDIO controller supports wake on Bluetooth, sending a wakeon
+	 * command is not necessary.
+	 */
+	if (device_can_wakeup(func->card->host->parent))
+		hdev->wakeup = btmtksdio_sdio_inband_wakeup;
+	else
+		hdev->wakeup = btmtksdio_sdio_wakeup;
 	hdev->set_bdaddr = btmtk_set_bdaddr;
 
 	SET_HCIDEV_DEV(hdev, &func->dev);
-- 
2.25.1

Powered by blists - more mailing lists