Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1090333rdg; Wed, 11 Oct 2023 14:16:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYlVOgRA6xmGABzMgTg7jXLLtuz2IuSzHcLMehgHA/P1QUSJigTJ09CR8g3Nfbdsr6NbJ3 X-Received: by 2002:a17:90a:e610:b0:27d:8ad:c4e1 with SMTP id j16-20020a17090ae61000b0027d08adc4e1mr2493371pjy.19.1697059013214; Wed, 11 Oct 2023 14:16:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697059013; cv=none; d=google.com; s=arc-20160816; b=m711l92/vpQRzJV3NYKgS1dHIeCWq9cms9wpcw4QJw24cMlerKWta8Krg+bXKYaX6e 2uLNH9ZIr9dtNCqoXGxMixsnCFTQhAegKnooWeg+D0PnyXnjwSiwoZRsb2zSmC9g31fV 1G8VzVSGaQB5EfZ2/APBBQN+5xYMm5anFSnq1fO27wOXrVrFz9Ktag3bxwiRfRSfftYD jEbuEr3owhNrFLqsoDK4c7b7NGa7UhaOFxWSuTnqnBJHwYePdYb1xSu7SwS2Dby/hsPY Csz6FjgyQAwxihbIFjK5cmgaAmUSLJlbRlxNr97FGVyKC4vtfR/in3BKAyDHXImas/ir jecA== 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=YcuMQaLtcq6nfx/dQ1Elat9Q5RmOnuYjnWbVOSjX6f/RdEgx606QGCLzxjwAQ33vW+ 9AmRQgVNQdWj4XS/nKeITetzQX2LRoLOoJN7ET6dsS2GnH/6VG1Q/J9fXz3sr9qPMJOA 4XQx12oD0Wo4pOZCisQZ192PG8rMJWRKoSJhZb+GGuiKIsvxKBfArJTLVBIMh/OZedJ3 3YQXPHHfGtBE4c3TE0GsvO/7uSSilZ2HeN6ODpkWzfoEuwOBbkkFntAPJyxmgTaSmGXe OWjiDrL4kH7HqZwxl1g45UGmzc9bJTuiG3EM3BF7T/olNhzjeMQDkaskEL/IP/S34+72 PdEw== 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-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id hk9-20020a17090b224900b0026b043c8bbesi769515pjb.136.2023.10.11.14.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 14:16:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-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-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-bluetooth-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 AB8748068E14; Wed, 11 Oct 2023 14:16:50 -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 S233527AbjJKVQl (ORCPT + 99 others); Wed, 11 Oct 2023 17:16:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233519AbjJKVQl (ORCPT ); Wed, 11 Oct 2023 17:16:41 -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 63ECBA9 for ; Wed, 11 Oct 2023 14:16:39 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d918aef0d0dso363473276.3 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=s3nddhwdsQvhL56ARUL4K7WegGlKWbX/EeAldhKl4Q1o85SaxNIiuhFCE3jgHMqLmm /B8cfQgEWAtsgmkrL6Y/lAk+arJOzHlFagfwzjragKYf7Oi9AIOuQaKxoLBJ5a9Z3zxr W2e2W1sj05n04WUawBBvXcrOpWybEsOgOV9dZASefLM2jJ2w6qBrGnMLneyg52Xg119M eHx2OS7yrdgfGtU6v8ZwcC3EpJV1EnLCghO3DY4lKsrL1o5LQsahdxZzP2/kKXivul1m wz9oymC8RDG2nRIe5nJXX12GuHnh7ge9kmn0CVvs8VIEg9LU7fo/ziXyercZo09T2pOm vioA== X-Gm-Message-State: AOJu0Yw8r5Ke0jIiv0ZbCC+nWgWnpZEr+quWNIl23EADW16MKW7xGmRj vy9VhgL86m1yexjOzuLrPClhrensqIk64g7Nlu1Tggjw2BJ/lzQhs2X+pkIX+UqjnhNLcnmCJk1 c20UxmK+c0OqqB7m1t1hqw+9CZLcSg64iQZ2n9fJ5at1ng1Kxa+eIjC0lHv0G14IFRB95jwKHYa 9W 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 Content-Type: text/plain; charset="UTF-8" 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-bluetooth@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:50 -0700 (PDT) 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 -- 2.42.0.609.gbb76f46606-goog