From patchwork Wed Oct 11 21:16:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhengping Jiang X-Patchwork-Id: 151557 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp819914vqb; Wed, 11 Oct 2023 14:16:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFeDG14mksEWsG8nehHDgOZbsslkoH1s4ravzIPWiGDMveYXGRKauy4d1BZ5cA6AxdoN81b X-Received: by 2002:a05:6830:3109:b0:6b9:db20:4d25 with SMTP id b9-20020a056830310900b006b9db204d25mr32229863ots.1.1697059011198; Wed, 11 Oct 2023 14:16:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697059011; cv=none; d=google.com; s=arc-20160816; b=RGGWzqHyQsLbsD6uWU+odWAIGxVJQk5nF3NLrO3ojQaO3gSBEId80u9GVLJDQHDM8D voLjooORvu1HrkOzDzJJx90K7CSw6A+iQ7lVMex1O19NJjhWRLpazzjzfOjH5uIlH8bX yo0hC93oPU8JWBMjMsEmyzMfjtIAspRTfDWkpAzyAsukiFu+eUsI0XW7N7qxUKIgcEpH kBcF5EyzZ1wNPkDo0qdCrm7/DxhSWoBl5n8BgqYaQ+fWK6af/a4BXFRlkAKhK9itusI+ hQQIwekA+Rc9SlDkBBftXinthpRKWnNPBwM36CI3dPOh9ha+E1j9g4JIAXscjt7G80u4 CoRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=AkMbkjU0vEq64RoxC9mx2kutRLIWzBPilt+kMErOBXk=; fh=8O/T8yO2An2gDr6hpf39SWXAF9j8g22xX2o08V+kF20=; b=rRViHWALRYmiGntoY5r8heAYyw2VH1W9EFCPq5quqxXLVNZDT05hF0/I3MK3q9nc6s zDLbL4qrOtHEcDEQGS8BJvGXF2dNpmAqvx8TbY+yQxWjNh4jer/DAIXCX4UTKeHjZriQ YOlk1JBNmbjjEJn/V/1nOpxSiB5NcV/2QlXUo0OFhpC95geigvkTpvfkWxE4qO+t5YmG wuDOIoZu5v6XVM4+79wAMNIi5wWdsH5aPe8rDmOWZ9wDTRc9yUqScsN7oE/9f5npbW9M vSybnqYWwKc9EQvfi6YIxfS7x/Mjv7lSdoLj4ahVwCRYy85oQjxkIV5k/MiD5+NGBdWR pC9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=viwZ6khh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id ea23-20020a056a004c1700b00690d79b95f7si12764053pfb.288.2023.10.11.14.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 14:16:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=viwZ6khh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 358D6807C868; Wed, 11 Oct 2023 14:16:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233496AbjJKVQl (ORCPT + 18 others); Wed, 11 Oct 2023 17:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233441AbjJKVQk (ORCPT ); Wed, 11 Oct 2023 17:16:40 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 304369E for ; Wed, 11 Oct 2023 14:16:39 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d9a3e5f1742so386501276.0 for ; Wed, 11 Oct 2023 14:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697058998; x=1697663798; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=AkMbkjU0vEq64RoxC9mx2kutRLIWzBPilt+kMErOBXk=; b=viwZ6khh+pCy12HXp+3i4C2faf8ibwIfdTcWmQp9SYSsN1/Og84W5amWj/g/L+6Xxp Jhz/bvk+NqhIHvb13OiY+MCvx/yLnAUdvWVe1oKQQdnPITCmJcCGrnQuQNOcXkxTJd0x mpOg2HZjEuz9xUsh/PwD1IIKzEm54xgZDzXfa4uEuUzmTNLf8e7ApnEA72oJVJVieU63 GHdyFgPk+J87teZ4yIBUQjNdkXVsFMwbb+tMgBbWWg7aWTEcveut7KLxqnb8sdA84OgL +Mvz7rOnFau1cjNwdeW8VEioeObD0cwri3E/vs1c8Q6ICaM/uvoz9JuJs6JMzXD3xPHY O7lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697058998; x=1697663798; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=AkMbkjU0vEq64RoxC9mx2kutRLIWzBPilt+kMErOBXk=; b=uaV2ZHSzMrbkYSD4zXbblDryZSkjo0E9DWdoOM/QpgnMChM4RxRxnLL700yO7R2Hq3 CqmM1gHDyRmjXU0xhvjDM+G3XEiQ+/XwZc4fZ2zK9ExyYnGNzprpH2b591uGTZ59e2s5 Hmb546189TvrqP59xegL3hiWAoMmljYgAEQ1mpbX4EbvFBnTDaTYOs9ZcNj3Gs5HH8Kx uUfVjdEnIqC5n/ZfrnAWZ8RRo+kxDx63Jx4HM1er5NHGlmeJfsZ9a3NeNFqPFQEITjd/ yj1DlzsItfHHz0lcOjJeAmfYlFTxb6jfHy4LiMh7Lxz6nz0qMjiTG8ZwDXIcI5kuMSyf M4JA== X-Gm-Message-State: AOJu0YxF9CeKckXGyrMzflS0qQppwb/G6QBFZGVzLzo0g4zIWWvHn+Vz aT27OUsnyqaEcjrjylPExOBUCVkY/ax5 X-Received: from jiangzp-glinux-dev.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:38e4]) (user=jiangzp job=sendgmr) by 2002:a25:828c:0:b0:d9a:bc5a:737c with SMTP id r12-20020a25828c000000b00d9abc5a737cmr10169ybk.4.1697058998406; Wed, 11 Oct 2023 14:16:38 -0700 (PDT) Date: Wed, 11 Oct 2023 14:16:31 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.609.gbb76f46606-goog Message-ID: <20231011141631.kernel.v1.1.I6dbfc1fedddf0633b55ce7e7a10ef7f3929a9bdc@changeid> Subject: [kernel PATCH v1] btmtksdio: enable bluetooth wakeup in system suspend From: Zhengping Jiang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org, luiz.dentz@gmail.com Cc: chromeos-bluetooth-upstreaming@chromium.org, Zhengping Jiang , AngeloGioacchino Del Regno , Johan Hedberg , Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 11 Oct 2023 14:16:49 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779495349794237710 X-GMAIL-MSGID: 1779495349794237710 The BTMTKSDIO_BT_WAKE_ENABLED flag is set for bluetooth interrupt during system suspend and increases wakeup count for bluetooth event. Signed-off-by: Zhengping Jiang --- Changes in v1: - Add BTMTKSDIO_BT_WAKE_ENABLED flag - Call pm_wakeup_event in btmtksdio_interrupt drivers/bluetooth/btmtksdio.c | 36 +++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c index f9a3444753c2..ddc04ce5c6d4 100644 --- a/drivers/bluetooth/btmtksdio.c +++ b/drivers/bluetooth/btmtksdio.c @@ -118,6 +118,7 @@ MODULE_DEVICE_TABLE(sdio, btmtksdio_table); #define BTMTKSDIO_FUNC_ENABLED 3 #define BTMTKSDIO_PATCH_ENABLED 4 #define BTMTKSDIO_HW_RESET_ACTIVE 5 +#define BTMTKSDIO_BT_WAKE_ENABLED 6 struct mtkbtsdio_hdr { __le16 len; @@ -620,6 +621,12 @@ static void btmtksdio_interrupt(struct sdio_func *func) { struct btmtksdio_dev *bdev = sdio_get_drvdata(func); + if (test_bit(BTMTKSDIO_BT_WAKE_ENABLED, &bdev->tx_state)) { + if (bdev->hdev->suspended) + pm_wakeup_event(bdev->dev, 0); + clear_bit(BTMTKSDIO_BT_WAKE_ENABLED, &bdev->tx_state); + } + /* Disable interrupt */ sdio_writel(bdev->func, C_INT_EN_CLR, MTK_REG_CHLPCR, 0); @@ -1454,6 +1461,23 @@ static int btmtksdio_runtime_suspend(struct device *dev) return err; } +static int btmtksdio_system_suspend(struct device *dev) +{ + struct sdio_func *func = dev_to_sdio_func(dev); + struct btmtksdio_dev *bdev; + + bdev = sdio_get_drvdata(func); + if (!bdev) + return 0; + + if (!test_bit(BTMTKSDIO_FUNC_ENABLED, &bdev->tx_state)) + return 0; + + set_bit(BTMTKSDIO_BT_WAKE_ENABLED, &bdev->tx_state); + + return btmtksdio_runtime_suspend(dev); +} + static int btmtksdio_runtime_resume(struct device *dev) { struct sdio_func *func = dev_to_sdio_func(dev); @@ -1474,8 +1498,16 @@ static int btmtksdio_runtime_resume(struct device *dev) return err; } -static UNIVERSAL_DEV_PM_OPS(btmtksdio_pm_ops, btmtksdio_runtime_suspend, - btmtksdio_runtime_resume, NULL); +static int btmtksdio_system_resume(struct device *dev) +{ + return btmtksdio_runtime_resume(dev); +} + +const struct dev_pm_ops __maybe_unused btmtksdio_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(btmtksdio_system_suspend, btmtksdio_system_resume) + SET_RUNTIME_PM_OPS(btmtksdio_runtime_suspend, btmtksdio_runtime_resume, NULL) +}; + #define BTMTKSDIO_PM_OPS (&btmtksdio_pm_ops) #else /* CONFIG_PM */ #define BTMTKSDIO_PM_OPS NULL