From patchwork Thu May 26 12:12:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sarthak Garg X-Patchwork-Id: 578012 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B7ADC433F5 for ; Thu, 26 May 2022 12:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345367AbiEZMNp (ORCPT ); Thu, 26 May 2022 08:13:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230487AbiEZMNp (ORCPT ); Thu, 26 May 2022 08:13:45 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B69DB0A5E; Thu, 26 May 2022 05:13:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1653567224; x=1685103224; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=UYtPQVApD7B6CvdbviLsjmzrkXFvYphc+Nw0S1+fXwA=; b=ClHU2Mn/cBEeaFQCIdv82Htowf4MnSb/7Ti6HQJwkPcDMyfqJh1W8c5+ Vpcl6x47vWE3peSsLvUJK61hEh1cPu7qPimjVX+cCDNmDRUhixIyKOBmy kP2+gTTF6c49T5/WwytYAXAsG46/0SLW1sGF8+vyiK8T9pBRt4wmP3k2S I=; Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 26 May 2022 05:13:44 -0700 X-QCInternal: smtphost Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 26 May 2022 05:13:43 -0700 X-QCInternal: smtphost Received: from hu-sartgarg-hyd.qualcomm.com (HELO hu-maiyas-hyd.qualcomm.com) ([10.213.105.147]) by ironmsg01-blr.qualcomm.com with ESMTP; 26 May 2022 17:43:35 +0530 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2339771) id 38B525001B7; Thu, 26 May 2022 17:43:34 +0530 (+0530) From: Sarthak Garg To: adrian.hunter@intel.com, ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, quic_kamasali@quicinc.com, quic_rampraka@quicinc.com, quic_pragalla@quicinc.com, quic_sayalil@quicinc.com, Sarthak Garg , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Thorsten Scherer , Sergey Shtylyov , Dmitry Torokhov , lizhe Subject: [PATCH V2 1/2] mmc: core: Define a new vendor ops to enable wakeup capability Date: Thu, 26 May 2022 17:42:14 +0530 Message-Id: <20220526121215.25947-2-quic_sartgarg@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220526121215.25947-1-quic_sartgarg@quicinc.com> References: <20220526121215.25947-1-quic_sartgarg@quicinc.com> Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Define a new vendor ops to let vendor initialize card as wakeup source and enable wakeup capability specially for SDIO cards which supports waking host from system suspend through external dedicated pins. Signed-off-by: Sarthak Garg --- drivers/mmc/core/bus.c | 3 +++ include/linux/mmc/host.h | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index 58a60afa650b..6192a52288fd 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -364,6 +364,9 @@ int mmc_add_card(struct mmc_card *card) #endif card->dev.of_node = mmc_of_find_child_device(card->host, 0); + if (card->host->ops->card_init_wakeup) + card->host->ops->card_init_wakeup(card); + device_enable_async_suspend(&card->dev); ret = device_add(&card->dev); diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index c193c50ccd78..3bd4374a64b8 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -193,6 +193,13 @@ struct mmc_host_ops { /* Initialize an SD express card, mandatory for MMC_CAP2_SD_EXP. */ int (*init_sd_express)(struct mmc_host *host, struct mmc_ios *ios); + + /* + * Optional for vendor to initialize card as wakeup source and + * enable wakeup capability specially for SDIO cards which supports + * waking host from suspend through external dedicated pins. + */ + void (*card_init_wakeup)(struct mmc_card *card); }; struct mmc_cqe_ops { From patchwork Thu May 26 12:12:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sarthak Garg X-Patchwork-Id: 576391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FECBC433EF for ; Thu, 26 May 2022 12:14:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345648AbiEZMOv (ORCPT ); Thu, 26 May 2022 08:14:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230487AbiEZMOu (ORCPT ); Thu, 26 May 2022 08:14:50 -0400 Received: from alexa-out.qualcomm.com (alexa-out.qualcomm.com [129.46.98.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25A23B0A5E; Thu, 26 May 2022 05:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1653567290; x=1685103290; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=muvrNAbA9KUhGpmb4Y3QN40P7gy4+uJmLvPE+pNb5js=; b=gm26l0gp/eFjQXG1qf0vvX7OWwqbpNsm6G0gBQtizP3mqXWAnZ3HVWG6 5LSuEAMDZFozl3mdunEDDCQRCr6NBKA2OFlgt2qiOYWzzqbY2MQmL2U/o ScbgjU3xlXdqfPwcvHcdtcwcfWDKnXZ+Rc+XTrtj1VTrRjEUzMAXJJYi6 Q=; Received: from ironmsg08-lv.qualcomm.com ([10.47.202.152]) by alexa-out.qualcomm.com with ESMTP; 26 May 2022 05:14:50 -0700 X-QCInternal: smtphost Received: from ironmsg01-blr.qualcomm.com ([10.86.208.130]) by ironmsg08-lv.qualcomm.com with ESMTP/TLS/AES256-SHA; 26 May 2022 05:14:48 -0700 X-QCInternal: smtphost Received: from hu-sartgarg-hyd.qualcomm.com (HELO hu-maiyas-hyd.qualcomm.com) ([10.213.105.147]) by ironmsg01-blr.qualcomm.com with ESMTP; 26 May 2022 17:44:44 +0530 Received: by hu-maiyas-hyd.qualcomm.com (Postfix, from userid 2339771) id 242BA5001B7; Thu, 26 May 2022 17:44:43 +0530 (+0530) From: Sarthak Garg To: adrian.hunter@intel.com, ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, quic_kamasali@quicinc.com, quic_rampraka@quicinc.com, quic_pragalla@quicinc.com, quic_sayalil@quicinc.com, Sarthak Garg , Andy Gross , Bjorn Andersson Subject: [PATCH V2 2/2] mmc: sdhci-msm: Add wakeup functionality to sdio cards Date: Thu, 26 May 2022 17:42:15 +0530 Message-Id: <20220526121215.25947-3-quic_sartgarg@quicinc.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220526121215.25947-1-quic_sartgarg@quicinc.com> References: <20220526121215.25947-1-quic_sartgarg@quicinc.com> Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org This patch initializes wakeup source if the detected card is a sdio card and enables the wakeup capability. Signed-off-by: Sarthak Garg --- drivers/mmc/host/sdhci-msm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index e395411fb6fd..3bfc506e5c45 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -2376,6 +2376,18 @@ static int sdhci_msm_start_signal_voltage_switch(struct mmc_host *mmc, return -EAGAIN; } +static void sdhci_msm_card_init_wakeup(struct mmc_card *card) +{ + int ret; + + if (mmc_card_sdio(card)) { + ret = device_init_wakeup(&card->dev, true); + if (ret) + pr_err("%s: %s: failed to init wakeup: %d\n", + mmc_hostname(card->host), __func__, ret); + } +} + #define DRIVER_NAME "sdhci_msm" #define SDHCI_MSM_DUMP(f, x...) \ pr_err("%s: " DRIVER_NAME ": " f, mmc_hostname(host->mmc), ## x) @@ -2794,6 +2806,8 @@ static int sdhci_msm_probe(struct platform_device *pdev) host->mmc_host_ops.start_signal_voltage_switch = sdhci_msm_start_signal_voltage_switch; host->mmc_host_ops.execute_tuning = sdhci_msm_execute_tuning; + host->mmc_host_ops.card_init_wakeup = sdhci_msm_card_init_wakeup; + if (of_property_read_bool(node, "supports-cqe")) ret = sdhci_msm_cqe_add_host(host, pdev); else