Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1021956pxy; Thu, 22 Apr 2021 20:54:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTUZ33pfPKYldZMTTdp4PPveD/QCqwQ4QdCeBVaXQa2FLJ2Vc6QV1FwB28c+bdyzc3mhDg X-Received: by 2002:a17:90a:f2c5:: with SMTP id gt5mr2132971pjb.67.1619150079850; Thu, 22 Apr 2021 20:54:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619150079; cv=none; d=google.com; s=arc-20160816; b=Ksm+y5Lzzqws68ujTF26Bg9u1evIAm1o1SG3To2n26gwzW5RufWOEth0rUPm+pRiXi 7AmAYZIn3nbvwUWzH1xCdIaRBayeuleE/bvI9ozljCChhcX8XuKR37eggDIzhMc4dtRz vNWheAjIGsEGxV0Wzej5xjBOcP/Ercm6Mj8oCxbPdjhHZgGlnxO5D9Li+/PgQ8gepED8 eNzWr3hGBwUWUckA/kM0tE/HpLDlSVBXTKje3sYwvH+c13NtKmwq6Ems7ZkWMXyizHPs VDBRrgyYXIBC1yPHJ0vE+PsdupL/3hhFrSTzqLmMah+4tI/1zlP152UAeCSuylh8YjKu vtXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:authenticated-by; bh=dphjGnfRwm/Eckf/oo+ODZ54IIMkuUZDcbWrK6ZldtM=; b=XghapCPmu6ddagE4o78unfVtKZcGLFIUfaz75AtCCn/aed0rOd3wZf03e8EWW0jm3G QadVSTQmxpTvMpOFv/ZsCf6FZayQAGydQubTjgVXOFwD5R24dQBmfplzNsEaNoC2VkYu +gYCm6vR/OjOkCy4376gJWuyUkFLwx/gOfKnDShnZ5QdgnUSGwAMEbssIDkYZG5ABQ1O MjApqs/M07ysrhGU0eYYu+IAw7YKAnIZLwJsitrl4XOt2UXzlxFzuVu9o8Bz161jJckK 2AlF6Z9n0F2GaRpUDj6t38GkPOoW2f/7YsQgCIEQVpNMRdI/I24OvCkkKVKSFRFOnFuy SGXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w18si5780701plq.286.2021.04.22.20.54.02; Thu, 22 Apr 2021 20:54:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240355AbhDWDx0 (ORCPT + 99 others); Thu, 22 Apr 2021 23:53:26 -0400 Received: from rtits2.realtek.com ([211.75.126.72]:41284 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240259AbhDWDxY (ORCPT ); Thu, 22 Apr 2021 23:53:24 -0400 Authenticated-By: X-SpamFilter-By: ArmorX SpamTrap 5.73 with qID 13N3qdBrB021907, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtexh36502.realtek.com.tw[172.21.6.25]) by rtits2.realtek.com.tw (8.15.2/2.71/5.88) with ESMTPS id 13N3qdBrB021907 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 23 Apr 2021 11:52:39 +0800 Received: from RTEXMBS04.realtek.com.tw (172.21.6.97) by RTEXH36502.realtek.com.tw (172.21.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Fri, 23 Apr 2021 11:52:39 +0800 Received: from localhost.localdomain (172.21.132.99) by RTEXMBS04.realtek.com.tw (172.21.6.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Fri, 23 Apr 2021 11:52:37 +0800 From: To: CC: , , , , , , , , Subject: [PATCH v3 2/2] Bluetooth: hci_h5: Add flag for keep power during suspend/resume Date: Fri, 23 Apr 2021 11:52:29 +0800 Message-ID: <20210423035229.27513-3-hildawu@realtek.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210423035229.27513-1-hildawu@realtek.com> References: <20210423035229.27513-1-hildawu@realtek.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [172.21.132.99] X-ClientProxiedBy: RTEXMBS01.realtek.com.tw (172.21.6.94) To RTEXMBS04.realtek.com.tw (172.21.6.97) X-KSE-ServerInfo: RTEXMBS04.realtek.com.tw, 9 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: =?big5?B?Q2xlYW4sIGJhc2VzOiAyMDIxLzQvMjMgpFekyCAwMToxMjowMA==?= X-KSE-Attachment-Filter-Triggered-Rules: Clean X-KSE-Attachment-Filter-Triggered-Filters: Clean X-KSE-BulkMessagesFiltering-Scan-Result: protection disabled X-KSE-AntiSpam-Outbound-Interceptor-Info: scan successful X-KSE-AntiSpam-Version: 5.9.20, Database issued on: 04/23/2021 03:40:47 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 10 X-KSE-AntiSpam-Info: Lua profiles 163299 [Apr 22 2021] X-KSE-AntiSpam-Info: Version: 5.9.20.0 X-KSE-AntiSpam-Info: Envelope from: hildawu@realtek.com X-KSE-AntiSpam-Info: LuaCore: 443 443 d64ad0ad6f66abd85f8fb55fe5d831fdcc4c44a0 X-KSE-AntiSpam-Info: {Prob_from_in_msgid} X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;realtek.com:7.1.1;127.0.0.199:7.1.2 X-KSE-AntiSpam-Info: {Track_Chinese_Simplified, headers_charset} X-KSE-AntiSpam-Info: Rate: 10 X-KSE-AntiSpam-Info: Status: not_detected X-KSE-AntiSpam-Info: Method: none X-KSE-AntiSpam-Info: Auth:dkim=none X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Heuristic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 04/23/2021 03:44:00 X-KSE-ServerInfo: RTEXH36502.realtek.com.tw, 9 X-KSE-Attachment-Filter-Triggered-Rules: Clean X-KSE-Attachment-Filter-Triggered-Filters: Clean X-KSE-BulkMessagesFiltering-Scan-Result: protection disabled X-KSE-AntiSpam-Outbound-Interceptor-Info: scan successful X-KSE-AntiSpam-Version: 5.9.20, Database issued on: 04/23/2021 03:40:47 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 10 X-KSE-AntiSpam-Info: Lua profiles 163299 [Apr 22 2021] X-KSE-AntiSpam-Info: Version: 5.9.20.0 X-KSE-AntiSpam-Info: Envelope from: hildawu@realtek.com X-KSE-AntiSpam-Info: LuaCore: 443 443 d64ad0ad6f66abd85f8fb55fe5d831fdcc4c44a0 X-KSE-AntiSpam-Info: {Prob_from_in_msgid} X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: 127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;realtek.com:7.1.1 X-KSE-AntiSpam-Info: Rate: 10 X-KSE-AntiSpam-Info: Status: not_detected X-KSE-AntiSpam-Info: Method: none X-KSE-AntiSpam-Info: Auth:dkim=none X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Heuristic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 04/23/2021 03:44:00 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: hildawu RTL8822C and RTL8852A devices support BT wakeup Host. Add a flag for these specific devices did not power off during suspend and resume. By this change, if the Host support that received BT device signal then it can wake Host up. Signed-off-by: hildawu --- Changed in v3: - Reworked to use UART flag, refer to Maintainer's suggestion. - Split into two patches for different purpose. Changes in v2: - Add the missing struct member - Modify title length --- --- drivers/bluetooth/hci_h5.c | 34 ++++++++++++++++++++++++---------- drivers/bluetooth/hci_ldisc.c | 3 ++- drivers/bluetooth/hci_uart.h | 1 + 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index 27e96681d583..9cacc4cdc928 100644 --- a/drivers/bluetooth/hci_h5.c +++ b/drivers/bluetooth/hci_h5.c @@ -911,6 +911,15 @@ static int h5_btrtl_setup(struct h5 *h5) */ set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &h5->hu->hdev->quirks); + switch (btrtl_dev->project_id) { + case CHIP_ID_8822C: + case CHIP_ID_8852A: + set_bit(HCI_UART_WAKEUP_ENABLE, &h5->hu->hdev_flags); + break; + default: + break; + } + out_free: btrtl_free(btrtl_dev); @@ -945,8 +954,11 @@ static void h5_btrtl_close(struct h5 *h5) static int h5_btrtl_suspend(struct h5 *h5) { serdev_device_set_flow_control(h5->hu->serdev, false); - gpiod_set_value_cansleep(h5->device_wake_gpio, 0); - gpiod_set_value_cansleep(h5->enable_gpio, 0); + + if (!test_bit(HCI_UART_WAKEUP_ENABLE, &h5->hu->hdev_flags)) { + gpiod_set_value_cansleep(h5->device_wake_gpio, 0); + gpiod_set_value_cansleep(h5->enable_gpio, 0); + } return 0; } @@ -972,17 +984,19 @@ static void h5_btrtl_reprobe_worker(struct work_struct *work) static int h5_btrtl_resume(struct h5 *h5) { - struct h5_btrtl_reprobe *reprobe; + if (!test_bit(HCI_UART_WAKEUP_ENABLE, &h5->hu->hdev_flags)) { + struct h5_btrtl_reprobe *reprobe; - reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL); - if (!reprobe) - return -ENOMEM; + reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL); + if (!reprobe) + return -ENOMEM; - __module_get(THIS_MODULE); + __module_get(THIS_MODULE); - INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker); - reprobe->dev = get_device(&h5->hu->serdev->dev); - queue_work(system_long_wq, &reprobe->work); + INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker); + reprobe->dev = get_device(&h5->hu->serdev->dev); + queue_work(system_long_wq, &reprobe->work); + } return 0; } diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 637c5b8c2aa1..3a1038e9dc6a 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c @@ -719,7 +719,8 @@ static int hci_uart_set_flags(struct hci_uart *hu, unsigned long flags) BIT(HCI_UART_CREATE_AMP) | BIT(HCI_UART_INIT_PENDING) | BIT(HCI_UART_EXT_CONFIG) | - BIT(HCI_UART_VND_DETECT); + BIT(HCI_UART_VND_DETECT) | + BIT(HCI_UART_WAKEUP_ENABLE); if (flags & ~valid_flags) return -EINVAL; diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index 4e039d7a16f8..25f5e5c7544c 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h @@ -41,6 +41,7 @@ #define HCI_UART_INIT_PENDING 3 #define HCI_UART_EXT_CONFIG 4 #define HCI_UART_VND_DETECT 5 +#define HCI_UART_WAKEUP_ENABLE 6 struct hci_uart; struct serdev_device; -- 2.17.1