From patchwork Mon Oct 14 06:01:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 836499 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2084.outbound.protection.outlook.com [40.107.103.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63F9A4436E; Mon, 14 Oct 2024 06:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728885641; cv=fail; b=NLRhuGSvWWaeljQd7V518uyD2YWind0Tc6xJw6MB1z/FrsJ7nrwExf/6t94ZKYjuhzG55YE5PqIo/cytMpgjmjGEjLlQyxw0rX8BFX/EdijiOb6MlC10T10mRiki3uIKcGc6FSpz4sbiYlvIeERbV36aBcRwnGIc0yzI6+6Znww= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728885641; c=relaxed/simple; bh=H4F5ZZDvDlIaoo6y7hdT1AxnPJpDfEh0S/NhPBB+tiY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=cawldexwnH7+D8gMdlLwWbxbooxw566eLZuF/b4T42Ynhte66wBQn0jzcw9PXyCJWtwXSCsxSJE6CtkxbbktAzHqVD5pQTidV5X+GntCReCTs2HNDyzi+HapuBCX8nwncZf/VeenFcO4IArZAk6JxUnzpim1BJiLR8QRkuJTvnk= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=OSVrhjDH; arc=fail smtp.client-ip=40.107.103.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="OSVrhjDH" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=yotc6oxnbC+0EX1jLPPndWyB2slHV/sgXp+nK3i8/a0RJG3lxaetrEUObbMuVM3Myp6Da1e7wKVRpYL5PV7IwUwJdik8UMdNJFDkYrFJ4MLM4o6utXGKzi2L/qBhvyalIUsqUiQzhs6xZ9mvFb8U1TPcpZRJ5h+7HPVk7LciVMN1IivfFh8qAigDncLilShB0bVoHtIN+Da9z/9HMFr60tRrXARWQzc/uOOxi6VY8m9bTet/S4el/eh/3jHsUThcuLdqIz4EnfyhT4JQKKKbn1jVij6mk3rnGXRlY/M4DGoM8NGSMOcDkCo9WInuTdiCtyLhhKrClnqILc4ii3hVQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c5JJ7KTa6A17Sn75TWE7cPxLnU+thl6qePZUrJ5fI1g=; b=YQNBPcMByZi0jJtd8GZi2Q//tPqIk4zDufHZWK4DhuofMvTXjjTZctbN2l4AvvdikZ//p9tDYzApoxfhdpsnfu6gsc2UjNE1LjO8SOF4aOtYCx5AiE+RYz4s//TF0HhTDEojhy9IcgEYfI+on1Bv9Js7RvZpkV7skEVonxrDf0AtyntCBnMNA5+6FiN6Pdcol+gw3c+8wo8ILDOZ2LTsKEURp3WtExVTjBxdYDiqCY4jHACLOuzGd6ic/Zbgoytp5s4R5peMpze177ZyAZ7VbojUzwJmqHGn98aAR69Ov+Khh1MEVYb2cmFrs/GtKX7zEBdNtjHWA9n5lFcVD1tVlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c5JJ7KTa6A17Sn75TWE7cPxLnU+thl6qePZUrJ5fI1g=; b=OSVrhjDHAJ5tXAJVQzfWFPcpNGVP5+P1YuPJ/bD4PmegIlEXiuZLfEoF9Epg1vhyUg3dTaSM3i8a+ckG2bb4SF/sQy8UmAnVS7Gj2pwIKVwDPjp8W76IcJMrx5Qi8AvEawNd33iSEBDyIZ749fAvHsFwdVckU6lNaIWPfGM/n0EkXXBtbMf8Z9oz2wV0rknezbJnZrc9FsOaSej9xqlpV4TpPQXwWzFc7erHkfNg3gLIHuOzc9bWPxo3JjHVXnmrJVH3LEIRZlO2inBFgFdus7IAP/iKm/xhagO/clT/KGxBAcHjb2ILhZ0XV/+2GVkR3YXeV1JUF4RnPgCbuW52gA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU0PR04MB9496.eurprd04.prod.outlook.com (2603:10a6:10:32d::19) by AS4PR04MB9459.eurprd04.prod.outlook.com (2603:10a6:20b:4eb::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.25; Mon, 14 Oct 2024 06:00:35 +0000 Received: from DU0PR04MB9496.eurprd04.prod.outlook.com ([fe80::4fa3:7420:14ed:5334]) by DU0PR04MB9496.eurprd04.prod.outlook.com ([fe80::4fa3:7420:14ed:5334%7]) with mapi id 15.20.8048.020; Mon, 14 Oct 2024 06:00:29 +0000 From: haibo.chen@nxp.com To: adrian.hunter@intel.com, ulf.hansson@linaro.org, linux-mmc@vger.kernel.org Cc: imx@lists.linux.dev, haibo.chen@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, s32@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] mmc: sdhci: export APIs for sdhci irq wakeup Date: Mon, 14 Oct 2024 14:01:27 +0800 Message-Id: <20241014060130.1162629-2-haibo.chen@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014060130.1162629-1-haibo.chen@nxp.com> References: <20241014060130.1162629-1-haibo.chen@nxp.com> X-ClientProxiedBy: SI2PR06CA0011.apcprd06.prod.outlook.com (2603:1096:4:186::16) To DU0PR04MB9496.eurprd04.prod.outlook.com (2603:10a6:10:32d::19) Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9496:EE_|AS4PR04MB9459:EE_ X-MS-Office365-Filtering-Correlation-Id: d2775155-40a9-4eca-d5f0-08dcec15814d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: qRIZX3N8LnwuBAfsTQ3fKaGqYnbFrVithA0prd7826m+6TZIN04QixgWda5V/vfZO8X/dHCnNegrjPZ8Luj1VNSjhzlEhNtrF2Mi1X8u8ocTqih11bXU36udaO8QvZqK+F+jKGBtcL/3V0pXnNbYmBmZ+zzhuFB344CD/PmnVXFethXVdpBKmqQUxxV7aPHA+dg+fcTkO5aIaOn+uOuQLH934nf7uZRkxMlaBKPkkxe4JNf+CBzkqNfBuviI9FZRqCT/Kr2SzjMOMxSxr1NAg9neNisXwO1PkzJnY9MjITJB2Z187m/J8SrpFVTxzOUPLQglB3EJD78d+VXjzNkzdizTTikLQ6zeAgHX7hPwJiWHO1Y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496.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dbsjVyXUlhx1okXEiENK/hyaJxnZfGGGvtgCC0DZ4rg+3Utu7i35bthSy3v7maicZOpcCGMScX72ulm3toS6KbUNh5J/sg8MiQMpuoctIqOB20lKRbu2S//yZe8diLXbLi3r8Ad+R1ZsfyuenNsPzeHg5m+omOyCKI8rKi/BEX8p8zVvbydtx83MOihNUrPI/KzuOX+jjdluvOKmVKdPk9uVa75wouP/gPVki0VM0XkOxr9LdMzRsV2+ml7QQCpTSEZiHz7guKz2QHljztHrEfX71AnnhDTI6ATKcwgA9siSRExlrHI2o27MbBf9YMDYXajLCW1IIm+/HR7Gs+Rcn2amQZcA+Li3s6+z7a2tZzfLtNd2iglMCG634clFrDFUo+QynQi1P3WaBsrod6Bxv033zmTqOnMzvh6D1/O6Y4CrMzirUOTj8lct6PLb66MxHeKkGye33/2NrVt2MtIt5Rdw6WpQ9Fh8OAhfR+HV74QCEv8pl+DWRUSr4xCx9UdmuumMomTnYS5fucqPQDETRYhcmVhszG9Ftsu3r/Hj2iSjGtlUKdC+NKyfJdKeHdRgKLohj+Iu7tHtlzyeIXbGcu7LawQWTzvt3DoWdis7qN9EC/iBOYGrHTgg7XFklpEi1GuXbq2U1+c4daui0MRRFgu2AMPg37ibUVofUWPK9EIfSzvBhsbEtDIHhT4Xun8eNbPiAE00ixp5QishCE2HCJxeFQEXAewGlsjM8seiTBO4pUQ5lHy9nS/VoVVr8aT0xjYbd95AyDjeEocsaWXSy+1dO+6RwFATxkVtPLT5F8TWHQ87uenVXoNUNdzDjT55DcrHZj0F7EGfVeoDg7HkhEhkXx0JMH20Oo69LmLGbBNIBb+kjdLEFaUerXC57G1/d/ftXJezq4NqPkFiK01hp05KA/Mi+n2F3o9ZC9oQbURMWZbjXzDPyD+VnMu0BKKiJuXgHGnKkJsUCOwQZZK6x75exz12lBtJxq6LJUPGy7FXxB+fN9HEeA9uxcgygl98esnsBJsSWaQXI1gt+0gZ3DKo0etsPPJPBj+qkxWWBXeMUXHacVTLeREA0xeOXmeBdFBsc3WgnyBm7cIHY8+FpKH/6lT/TBIfDwyerEwviM6vwLxhFfwhIZNQhnKS1icUya5sFkdGxwacwIC7gs1B7lqRDZg2ofeCQj0yfUfZlN9/6dtG2qkNnMsPj5EHLxJveM5ONYSkiO/74kkLb8rI6Ydt6t/pecBmwcCic81OaIaSF9aiH7/UGdkB42VfeKNBe1j2v8MOblJGN7pU2dw+Emir/7zrcSqVO4Qg5lVm9QAw7rEQLyO2LZ1lihLIS3fJKlFRyPfBqDIjydor5Q+iS4U6q5CujpvMCraqMXYfd7i9qi9iB6bNPLcZezgidW5/QvrZPjmowzGY56VN5PUV9TaeAjZjAazpTrbYTrK20RUwph7YJHvJJRuy/DL8LrK4Mh6x9fHj+C3TA9dTDSWpMokljriM16nQScP10JlLefCZRBvNG9tjQ/GrE2Z+82QtyPHs6s/CRMMl2fSOCH+8ky9QSJsLeVEDQsmEkIK12uCsDLo1U8711f125Sap2mzc X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2775155-40a9-4eca-d5f0-08dcec15814d X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9496.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 06:00:29.0056 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tK8GaNoim7R4rX5VnnbEFzu9Kca+F4Ajqz6dr5N0+TjaAjuHwMsHUMG0MrChkR8RDFiqk+1ek0p4Jj/Y2Wwv7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9459 From: Haibo Chen Export the sdhci_enable_irq_wakeups() and sdhci_disable_irq_wakeups, so other driver can use them. Signed-off-by: Haibo Chen --- drivers/mmc/host/sdhci.c | 6 ++++-- drivers/mmc/host/sdhci.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 4b91c9e96635..b3df3e7653af 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -3698,7 +3698,7 @@ static bool sdhci_cd_irq_can_wakeup(struct sdhci_host *host) * sdhci_disable_irq_wakeups() since it will be set by * sdhci_enable_card_detection() or sdhci_init(). */ -static bool sdhci_enable_irq_wakeups(struct sdhci_host *host) +bool sdhci_enable_irq_wakeups(struct sdhci_host *host) { u8 mask = SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE | SDHCI_WAKE_ON_INT; @@ -3730,8 +3730,9 @@ static bool sdhci_enable_irq_wakeups(struct sdhci_host *host) return host->irq_wake_enabled; } +EXPORT_SYMBOL_GPL(sdhci_enable_irq_wakeups); -static void sdhci_disable_irq_wakeups(struct sdhci_host *host) +void sdhci_disable_irq_wakeups(struct sdhci_host *host) { u8 val; u8 mask = SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE @@ -3745,6 +3746,7 @@ static void sdhci_disable_irq_wakeups(struct sdhci_host *host) host->irq_wake_enabled = false; } +EXPORT_SYMBOL_GPL(sdhci_disable_irq_wakeups); int sdhci_suspend_host(struct sdhci_host *host) { diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index f531b617f28d..bc303fe7f87b 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -802,6 +802,8 @@ void sdhci_adma_write_desc(struct sdhci_host *host, void **desc, dma_addr_t addr, int len, unsigned int cmd); #ifdef CONFIG_PM +bool sdhci_enable_irq_wakeups(struct sdhci_host *host); +void sdhci_disable_irq_wakeups(struct sdhci_host *host); int sdhci_suspend_host(struct sdhci_host *host); int sdhci_resume_host(struct sdhci_host *host); int sdhci_runtime_suspend_host(struct sdhci_host *host); From patchwork Mon Oct 14 06:01:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 836498 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2084.outbound.protection.outlook.com [40.107.103.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4D3513D62B; Mon, 14 Oct 2024 06:00:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728885647; cv=fail; b=Yba/WTIVaQ5h7oGJm0qAjfqTxwrjOCM6BhWqgVF2pAOwuUY2ItsbSQFi1HkYpREu5spo3WypZlsoKtCGux/0kFWg/0ILYdZsq9Kij0E+a0+vfKdfFfJ1kAeEBPj/PhtKu0+Nv+KGDVayVlnLxRS1tA+ta9dcCFUy6GSderwnRqY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728885647; c=relaxed/simple; bh=t2bFtiuTbusH+vdzOAdjZ0c0c7pZPCiLqng8RmEPVAo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=GaUtc4n97cAL3Jax/+k2hQisb0mLfdJNjsNfN69FrFsEK1UoPGMRB0CNc0xs7muUvV0xgxDWJvl3eDJcLlhg3mwf7pn6le1U+KPkNrcaUOAZ6+ywMpGjOlCfjIot7XBDbeekiwZV3Mj8SY25PZ0wgjfwHDMzsi46R8YuHGCBdeo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=iMCurIfj; arc=fail smtp.client-ip=40.107.103.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="iMCurIfj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o6mw7vlT58KA6/Ch/7fa+sJq7wkLHpWcFyt+j4oeiESy3KVCbM1hwW3G0/QAkDt9nm1pdvU7bGcOHHmKBS52cS8dTTtUw6zYFAD8goQyAMKOGE96YNo6xYGxkgQpQJIzSYoDxVubKovJVXzVZcGdzVxId7A6WqbCIOvDNx8dlpD8uGicSenbXkxYhQyh5I2QQC4JdTzFQqhfXgMNzm6VpvAIZHlcmcPQa+Uf6ASKMJm8QL4/57/32/CBizH/geaVdN27e58B8rPGSGHCS6XyAn8YW4DlLbF4nEBnjEG4jkvbYJkd5T8K1ZZQw148J5Tu/t6Pty6/vvDPf5l+v0t9Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CGxyknLbtIalQ3GMBGRDohcnpTs4FNczYpD4DizUtno=; b=YW2ZvfqZ+YfsmjoK5zcWTGwsZohjYZqNdoxmHJnT8vCtHaCPTEe2L4M8yl3d4Y+lQNbTO3iULcXnQ9Myctoe7QGzRg0GSa8T3jFffiuOFMGinmlI33jtvWwPIBKDWRqimEUFV86hP1dGIJIrQIDA8kZi41WBZXyYIHXrduTDBZ/FO25scDxrki9DyvsjgagRQ+3ZIuHwQNjKnCArAu5PiKXMdGPgYQDRP6WHGHYy8vUs0QarKgpaGKsdHb8+TasarRaVcm0P9GcHi649+34X8ZYRvYkXrtr5qM+gklxc2i7FgJXcdN/QCpY4quc/DC8xqlcS535i1yO4Z/XILCDHaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CGxyknLbtIalQ3GMBGRDohcnpTs4FNczYpD4DizUtno=; b=iMCurIfjTXoJ0DgX8ywU1WqjN1Ty2agy+Ufvw6kd1UNvt2//nH4GwG84AzeQ8oiO5y1J2nZ/uZ8BT+Woq3ew1WtzOVsCSZT5NkqKnj3FcgSZDN2nA/vVf0klAPci7RiruAj1JiDk3DT/155tJgDsPK7WJL+YlRIzKyclQmZeoJQ+PMts09zRBkMpAzEI5qhkKC23iwnD3yk/+j1qHqKwtoPu+UZFrmT6EE6LQkbq41I145OH74VM22eth2VqGJApjRd1XU+JaWPFLIDTuXwJMNX7evOptMSPDqfnEXnamOzydFU6xX54i0hCqSLZPx/w0XUz6zjmh4rh2huF16Idxw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU0PR04MB9496.eurprd04.prod.outlook.com (2603:10a6:10:32d::19) by AS4PR04MB9459.eurprd04.prod.outlook.com (2603:10a6:20b:4eb::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.25; Mon, 14 Oct 2024 06:00:35 +0000 Received: from DU0PR04MB9496.eurprd04.prod.outlook.com ([fe80::4fa3:7420:14ed:5334]) by DU0PR04MB9496.eurprd04.prod.outlook.com ([fe80::4fa3:7420:14ed:5334%7]) with mapi id 15.20.8048.020; Mon, 14 Oct 2024 06:00:35 +0000 From: haibo.chen@nxp.com To: adrian.hunter@intel.com, ulf.hansson@linaro.org, linux-mmc@vger.kernel.org Cc: imx@lists.linux.dev, haibo.chen@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, s32@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] mmc: host: sdhci-esdhc-imx: refactor the system PM logic Date: Mon, 14 Oct 2024 14:01:28 +0800 Message-Id: <20241014060130.1162629-3-haibo.chen@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014060130.1162629-1-haibo.chen@nxp.com> References: <20241014060130.1162629-1-haibo.chen@nxp.com> X-ClientProxiedBy: SI2PR06CA0011.apcprd06.prod.outlook.com (2603:1096:4:186::16) To DU0PR04MB9496.eurprd04.prod.outlook.com (2603:10a6:10:32d::19) Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9496:EE_|AS4PR04MB9459:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c2ba417-598e-48e8-230d-08dcec1583a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: 2PbW+4voim9758/eiejHVfiJtMpfAEVtgQESzbn8WQlnN5sILTFEZ36V9zfFWoMOK+qpdxWB9J6RQbPukn+96XyiwEeWRhxrtcCEfvEuDHSV6B7arh1atnItMKm4DDxmQHRsp2NUSp2Him2lEwA/oKAuq8/WUAc4Rn1Wd9NM0VlIvkVXzixzejYrNCMTw+s5N4j0lWI5TLsYzKhTkuO+9N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8iSgw2K+giV6waT3KsICbhUvwy9/qwodMQVWdP9qQ655DVPFGyCa7mptkrQHZegAy5A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9496.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 63klnFseGE0ZYzOAKC+DzHQdxBCtv6ZLUoH2pZMaO1HNcO6sNDNSs/A47dlX0HEauOhHnKdmhj4w9V87ZUitfzaIqqr/PyQ6KjJBSCUkWKE5Da4rxwmABj7NaIKv9zhasC3zs1FVeDYlE2fpDBiNSYMpy3zNgwfigDi7TZD9xYnFwassrd/3yenRoQEPGBq4GgpfA259tvCG6F353hAP1/DtPwuJNP48jug6O1Go/YpMc5Vkv+/C5pkMgs8+YzDeD3IeXsefr8wtgDqPTGwHa8sxO8fYVuBRNZn6PK2l3mrNLMaXrcUnZCLmrZSZgm6jBaQbHl+neyzhsCl8KVsmpTeXbfXKN31WeiMAOEV85U8KDT1tycIh7vgXu29MRMcVxcnIpEN/7SYGfbd9fv7k3syytKHWvWaoN+pB4xdeJapd8hsSdyXWgZfXirF9yy6/DmaIqXwFAgXKPz6sOvUbKjZiFpg+JZfALuLadBMSO4AoPTR0Fl//eWvvTE/GUPDVPn7Jm296y+dVaZeA6sdvTYYHu+TR7RNh/KY7obV5JR7Wc7INZssf1bNixdxbLJd70OpVT9b8n3EhWA1C+L/Rznw8HdL4M7zw+DuYA+UmjO0cYoZxQuD6wS5uVOhqWgxk69VHsjeY4kUFLv7CU031NmrO9ARzfmPFBnL2k1DrBGvemoCSbmoLZ/eD7hhkcyjUdNq9vVCceSWK/1482ZsxngVu1/npJGGK75t2Yvlu8Dvtnn85V1q1iy4mJ6DsrAcARRojMb/yr/+sb69Em9PFnS/Zhm+Y+Ez5gYKT4sI7EWEzHM1ktZwi/5Di9OUtOmyGgs0Is4KYxt0db06izdlWBTaHxRKgSDBgLGmPSS6F6QiaXj+YESylUCIiYpx/ViLC6zGpC85/avw5G3KEXMpurFRYDYzeBUcSizCH3j6hoZRV0hADGvSHFVXbAF/GZ+An4z4hgDbmuEpoUVrAWPuvXOZowRT7nQDlSKPQRwGWCbq4arJfdSnpuHJmkYb9LXLTqWIctdj5pjwQwSO5SFMgevRxSBugNfx0GfUfuJXrqWJUAZ6T2wqvsyR0BraKMxeplHzoAM4xkU0suegEhQgqx6J+34rC4sUNqWeDh2fZDaomPyz1jyDOnpfU4+GLXrLx3lMhdHeBqyD4bhCAJSSDTE0Z08ijm4vxWI8/cX33PXwknWyWP9VGvmxGO+QkiLvfWukjxvuQ+9LW1Bc7vmVmT4QMWH14meirxXVENO2udEI6l0o9nG2VDCQWWUraqYo1YMbo0u8iihLP1VaYhXD2/uhPg9EpuNClIO15+E7vIcOF8a65rZ3mWCn0p+UoN0BplyBEHQaDVdko+ThPv5L8KdypPjwVzfX+yMAgGuo7CYMdTClfLzlapiMcosUJh0mehE5HonEm9AVic4ekSpihxsnKSbYNhDUW5WHLJbdikX4q91u2wp9AKkifpR6qlgR9zEkV5yI8RYd/RcpyXHZJPGr2v+RKLNjBF8vXwKaB0S4bsGb07s5YPMfzXrfdqOIxUJTDFlOxcm+JNvz5948Hqh6dhjXo0JZ8BB8DmVWSiRbfxmcrGBVEwiXn1qg6p2v/ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c2ba417-598e-48e8-230d-08dcec1583a4 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9496.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 06:00:32.8318 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZhZF0yz3ZfqKGOAFUNK/RcQ/Px78vLU3J+gxy0pipC7WnoKgaRp/UzmsHq1g9C66b7nRoWC9HiVMVorN3DmEvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9459 From: Haibo Chen Current suspend/resume logic has one issue. in suspend, will config register when call sdhci_suspend_host(), but at this time, can't guarantee host in runtime resume state. if not, the per clock is gate off, access register will hung. Now use pm_runtime_force_suspend/resume() in NOIRQ_SYSTEM_SLEEP_PM, add in NOIRQ stage can cover SDIO wakeup feature, because in interrupt handler, there is register access, need the per clock on. In sdhci_esdhc_suspend/sdhci_esdhc_resume, remove sdhci_suspend_host() and sdhci_resume_host(), all are handled in runtime PM callbacks except the wakeup irq setting. Remove pinctrl_pm_select_default_state() in sdhci_esdhc_resume, because pm_runtime_force_resume() already config the pinctrl state according to ios timing, and here config the default pinctrl state again is wrong for SDIO3.0 device if it keep power in suspend. Signed-off-by: Haibo Chen --- drivers/mmc/host/sdhci-esdhc-imx.c | 39 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index c7582ad45123..18febfeb60cf 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -1871,11 +1871,13 @@ static int sdhci_esdhc_suspend(struct device *dev) struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); int ret; - if (host->mmc->caps2 & MMC_CAP2_CQE) { - ret = cqhci_suspend(host->mmc); - if (ret) - return ret; - } + /* + * Switch to runtime resume for two reasons: + * 1, there is register access, so need to make sure gate on ipg clock. + * 2, make sure the pm_runtime_force_suspend() in NOIRQ stage really + * invoke its ->runtime_suspend callback. + */ + pm_runtime_get_sync(dev); if ((imx_data->socdata->flags & ESDHC_FLAG_STATE_LOST_IN_LPMODE) && (host->tuning_mode != SDHCI_TUNING_MODE_1)) { @@ -1883,12 +1885,11 @@ static int sdhci_esdhc_suspend(struct device *dev) mmc_retune_needed(host->mmc); } - if (host->tuning_mode != SDHCI_TUNING_MODE_3) - mmc_retune_needed(host->mmc); - - ret = sdhci_suspend_host(host); - if (ret) - return ret; + if (device_may_wakeup(dev)) { + ret = sdhci_enable_irq_wakeups(host); + if (!ret) + dev_warn(dev, "Failed to enable irq wakeup\n"); + } ret = pinctrl_pm_select_sleep_state(dev); if (ret) @@ -1904,22 +1905,18 @@ static int sdhci_esdhc_resume(struct device *dev) struct sdhci_host *host = dev_get_drvdata(dev); int ret; - ret = pinctrl_pm_select_default_state(dev); + ret = mmc_gpio_set_cd_wake(host->mmc, false); if (ret) return ret; /* re-initialize hw state in case it's lost in low power mode */ sdhci_esdhc_imx_hwinit(host); - ret = sdhci_resume_host(host); - if (ret) - return ret; - - if (host->mmc->caps2 & MMC_CAP2_CQE) - ret = cqhci_resume(host->mmc); + if (host->irq_wake_enabled) + sdhci_disable_irq_wakeups(host); - if (!ret) - ret = mmc_gpio_set_cd_wake(host->mmc, false); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return ret; } @@ -2011,6 +2008,8 @@ static const struct dev_pm_ops sdhci_esdhc_pmops = { SET_SYSTEM_SLEEP_PM_OPS(sdhci_esdhc_suspend, sdhci_esdhc_resume) SET_RUNTIME_PM_OPS(sdhci_esdhc_runtime_suspend, sdhci_esdhc_runtime_resume, NULL) + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) }; static struct platform_driver sdhci_esdhc_imx_driver = { From patchwork Mon Oct 14 06:01:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 835344 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2084.outbound.protection.outlook.com [40.107.103.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DFF61428F1; Mon, 14 Oct 2024 06:00:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.103.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728885649; cv=fail; b=qA4XvpnvSTlzDKN80/pQST1jd4GDXpMk2Cupboo9Uf6o+5rf3uq7vx16DjsWNRMRTRx2nUMNl9MVlUPWu1dx7nwH+3D27N2rBqavtXpjziu4GCMeH+UB9P51s5MrP1VtSicm5bDRzg7gdbYr0RJk4ghKZMuUrovKme2NB/QdmBk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728885649; c=relaxed/simple; bh=XpzPxDFynOBgTh84+8z0cvsZTJyltgVl6OAlCQgIV7Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=BWaCbx23XeXUn2VmLA3TJFfUTs3US/V+2rK/hfPnlRIstPzwI0yE1SGjUUdKgpujwAKmqBhfsZxcoaoSncTkYMqFwIbhASMWN1HgIflEU8IYuufTNGygzaR2fgubInXJwvWxcacmD1pCVgauXRaYJO3n4xiy5DROQYLDe8XjUAU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=jTYDPl1u; arc=fail smtp.client-ip=40.107.103.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="jTYDPl1u" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Po7s5Biu6c/jpaaoUN6XIMwgRonvWYXwVNUDA+W4KWhOaIzXX/Pc7dAK8rCROe4HAFz9SJPdFIF+fnVRCoHZJaMNEnnmGv5iwRU8fQB+IDaNPwsncxafW1dmYICrMX8Q2tEGT96mj/5Yz9FdJpSnnOxHLTHpeCcxE8EkoGOpCTGJCkQZQdsDhzslB7OXG+ZqgWU+t/u+Jzzggubife8LhRkJ3OtsboBfx72mr/O9rpRmUIvsXZboYTrIyVWpyivJTme+nGgme0Ml+Kvigv3w90tAizS51garL9m03uhZf+DLevGriJkrrzy1flPzbm90mvjoSWvEgAsFPU2Y4cZeSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2uvylZoVj2f5wE9XylQPvz8SlUsXond/T1pZkE8NnEU=; b=SeWF1C3ntLjU0BbC2lTxDQFjSI8XSjMoFkYVLb64y9GFNYG5GVb8l5jYnI+xMiNOBCTzBQJcWMT/GDod1P3CLw7K+LurThUandtTEmGIAsSJ3q14GjDD8pxMkJ2SccHqJMWDNTi1YxnXp7MyumDLNHwOE2FjRfZ10Yk1OhKUBQwZ5UMmiwUVhe4/IywXzlrJKtSMyZ/bPXt6yoRRzqXsqharVzhzUwX9AYNDnuE1wiNafmAbN7uBVUtunO+JFqHRMWBiDxEG4lFN2JDigEEph2elLb7VY6KaD29wuC2Sd6+hkwNbvXsU1dZxpY2l6IEyR4huuryVvCTukeMeZPhXoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2uvylZoVj2f5wE9XylQPvz8SlUsXond/T1pZkE8NnEU=; b=jTYDPl1ucQc5LTCVZDB+Jyjro806LzzuUletKtL6EPifohRakbrDHf6Pas6Ys92QvrZ5t1Cc9SPVExnKT6pmJA7mzEyEjZYRHf8iheuLU7a+K6eePXKNgKssiVZS7BAlzzqyy+C5MLw+o/w3Xvql7Gr7VyjfzhyEoMMlvJIEj+aOWN2o4qL4f1/eOQRZ+jdtF23SUL7JAHojm5KCfZlwUyre6JRwtWF899HG9YUVKDn5wMUKsmCEG0RIT3gC8sEu+C0D0T9Ts1fczSNFYXXC2B8bxIEI1zTqQg6g8NG1SOAtXTaJoLcBnVLXrebIQKWazo4YE2E4TZC5g+/p38TRvQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU0PR04MB9496.eurprd04.prod.outlook.com (2603:10a6:10:32d::19) by AS4PR04MB9459.eurprd04.prod.outlook.com (2603:10a6:20b:4eb::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.25; Mon, 14 Oct 2024 06:00:37 +0000 Received: from DU0PR04MB9496.eurprd04.prod.outlook.com ([fe80::4fa3:7420:14ed:5334]) by DU0PR04MB9496.eurprd04.prod.outlook.com ([fe80::4fa3:7420:14ed:5334%7]) with mapi id 15.20.8048.020; Mon, 14 Oct 2024 06:00:36 +0000 From: haibo.chen@nxp.com To: adrian.hunter@intel.com, ulf.hansson@linaro.org, linux-mmc@vger.kernel.org Cc: imx@lists.linux.dev, haibo.chen@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, s32@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] mmc: host: sdhci-esdhc-imx: save tuning value for the SDIO card as wakeup source Date: Mon, 14 Oct 2024 14:01:29 +0800 Message-Id: <20241014060130.1162629-4-haibo.chen@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014060130.1162629-1-haibo.chen@nxp.com> References: <20241014060130.1162629-1-haibo.chen@nxp.com> X-ClientProxiedBy: SI2PR06CA0011.apcprd06.prod.outlook.com (2603:1096:4:186::16) To DU0PR04MB9496.eurprd04.prod.outlook.com (2603:10a6:10:32d::19) Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9496:EE_|AS4PR04MB9459:EE_ X-MS-Office365-Filtering-Correlation-Id: 1bc3322d-c3a0-4a93-dc40-08dcec1585ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|7416014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: j3ymP+Xqp+YDWj99DEORqBH8cNLRoJO760AzB8ZSsqtFk2CUI6wGHYhd6ed8b4Q9AqQxqROcCy8oFwNzTMIaiZe3eUwDyVJ1twsNl/2jDdXNxNQosLAU4OkBNrCviyrPr2/FtTnxug7zUK6psYISQNxGD/5ihS3HBGUe3v0I/nt7tbZrEi+VS+eGMAFsDbtkvFhOZ6UsnkoVGYcJHY1Tj7s4nfLAWKGokNHPgPE5yyqJCHq7fYWjvvAuOgmDkzARaWWFW92YCjfpLarcGhunn0AKNmChKbFfIpHrjfO3trKhAa8MgRoSuygLfLaT32RIpaFKSXPKCmbZGrrXPvn1KxB1hfUpiLiiyBvFAbXwRE2q6Eo2m0M5vCy+3lAZAL9uhvXfG4WFJIFPvSWPvezATCfVYHs6K7EVhwuPn1ATwPodWVg/J0NEj9VAdWjcU9eGSJfP7wx5xxfYzv4o/wL1mMueE0q+QmNYJZtLZ1WuE83ALi9eFe3dgqFw2Ad6ozTKWSsKxBhIm5MejUnjW7ihXoqjkGkYz+9RF1+5jAxdWOCvlajjDNjD333AyM0BWFK0erD6eL5hfclZdi7fNMTYnnA8drhb6E/pPfsenvsmXmyRrDSI1rxlptHxZXNQ02viJHuRqr5STWOKrEHaqL1/JNByTbpvSv+DeHMT2Y8++RNTpYMqw1xKlbuvQcYIsTQ9NueVmCXWjp4ZUUR3M5TsFbOFz4IQGsN5F8eT02G9MYwoQOUehud/otGW+rgMTIioTfh9Cx2m9BLQ2PCkiOoGWlaGi7lZFJNWFi2dKfK5JpywPyiih7O+ceSrYDW1E1xp2awtCvt7BMTXSliDeEz0a/dGsIu23bKvSja3bWkPzLtnrqXVl/CZaZoGxcH8YVSDjHo0GucuG4mC9PVxkTF2ANoRnPyTnsSuetsnznSSDPX7UOoZDNlZgxwVEYTEVNWykly+YzUS+kFWyBClQQlLav5PHgqrB0nyyXA1jkzYmXwm/q/Zhh7J0ejq4GHTw8SJpFhNCuiwFtyShWC7NPCdOx9Lgu5WSRDNRbykKW+dtfbvrdxT+/jqDS0zGR6xq7v8euv7WbCIp0Jtjh8TVQeORySCr8lZEEN3a5n/OTaJ1Ta71Z95E48pZIjlzqRDLnBOM8focl7gFqAaYhLD1b5LMXv9jn9IrTUv7FxIxqrDfXaVBXLPvybgquPAgbRkP/5FyqNNn9hOy8tkNAfXlya70o4H+DInbrnMBGcUBspNto9Y9FbsbbeRirg/m+uZeK7UQLG9WpuA2r60cejfH0EZ7pFJGRbF4D4ahKD3lBg7+h8yHIbAz/mQ8fnUgMPlLdgY473KUwP0ANws46ItOy0RlA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9496.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(7416014)(52116014)(366016)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-A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TaOU+/5MXMdE1UvQuisDWRmBHPijpA3w4Ibx7tK+hottV5vwa2kaglsQm8ozy7qOlAJF9MsZyqPaID+D5mT4awyswE6jpeTp0A6dE7mBIo5IR3uDmczHFf3KVgbpqdVGuwguqtkOYLOYg4R97n/Co6nKFvUYenM3Iu09s8gqMug9qzjY99O7TrpZrhAvwrIg2G+xUPDviMBvSnQ+Xr/dy/xxHR3ZhE8CPybuXsXemudFnO22w+zTscy5mMSgimZjqaebpVcdqSVhgoP6v5SVtto0Sav3PLHwLIIvNm2zUORbuGjXD5fEFX33ar05iaBQx9fY/GaABgfG59B/oO48iYKZpVxtcunVbSEPhRU67EyUbIC60ktCZCFrG+3AS2psG8SrBMIXmKgUbmUBw3pykj4t3KHMConG3ufOjHuDR2Ws97/k0/yNHzofav6H2Y8jwwaZCYEHk/O1rzrlREpki0AZDCvkzVpaRwy8cElWplssm2nubPmSLvpc6vn1JKYGNOqoyZpi9KMqtMrKByke3r0YSvvvKVPYObODQc10q51612LR0me0mV X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1bc3322d-c3a0-4a93-dc40-08dcec1585ea X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9496.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 06:00:36.6587 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BxO6PDx2qFYkSGYm133fXJ7tCmCz59C+kOlyHLB9B2+xOL+NJbQNfv9gf1rHyZi9G0eQttuoEiUZdIawwlXdBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9459 From: Haibo Chen For some SoCs like imx6ul(l/z)/imx7d/imx93, during system PM, usdhc will totally power off, so the internal tuning status will lost. Here add save/restore the tuning value for any command after system resume back when re-tuning hold. The tipical case is for the SDIO which contain flag MMC_PM_KEEP_POWER, and contain pm_flags MMC_PM_WAKE_SDIO_IRQ. in mmc_sdio_suspend(), SDIO will switch to 1 bit mode, and switch back to 4 bit mode when resume back. According to spec, tuning command do not support in 1 bit mode. So when send cmd52 to switch back to 4 bit mode, need to hold re-tuning. But this cmd52 still need a correct sample point, otherwise will meet command CRC error, so need to keep the previous tuning value. Signed-off-by: Haibo Chen --- drivers/mmc/host/sdhci-esdhc-imx.c | 94 +++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 18febfeb60cf..4173967022d0 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -80,6 +80,9 @@ #define ESDHC_TUNE_CTRL_STEP 1 #define ESDHC_TUNE_CTRL_MIN 0 #define ESDHC_TUNE_CTRL_MAX ((1 << 7) - 1) +#define ESDHC_TUNE_CTRL_STATUS_TAP_SEL_PRE_MASK 0x7f000000 +#define ESDHC_TUNE_CTRL_STATUS_TAP_SEL_PRE_SHIFT 24 +#define ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_SHIFT 8 /* strobe dll register */ #define ESDHC_STROBE_DLL_CTRL 0x70 @@ -234,6 +237,7 @@ struct esdhc_platform_data { unsigned int tuning_step; /* The delay cell steps in tuning procedure */ unsigned int tuning_start_tap; /* The start delay cell point in tuning procedure */ unsigned int strobe_dll_delay_target; /* The delay cell for strobe pad (read clock) */ + unsigned int saved_tuning_delay_cell; /* save the value of tuning delay cell */ }; struct esdhc_soc_data { @@ -1055,7 +1059,7 @@ static void esdhc_reset_tuning(struct sdhci_host *host) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); - u32 ctrl; + u32 ctrl, tuning_ctrl; int ret; /* Reset the tuning circuit */ @@ -1069,6 +1073,17 @@ static void esdhc_reset_tuning(struct sdhci_host *host) writel(0, host->ioaddr + ESDHC_TUNE_CTRL_STATUS); } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) { writel(ctrl, host->ioaddr + ESDHC_MIX_CTRL); + + /* + * enable the std tuning just in case it cleared in + * sdhc_esdhc_tuning_restore. + */ + tuning_ctrl = readl(host->ioaddr + ESDHC_TUNING_CTRL); + if (!(tuning_ctrl & ESDHC_STD_TUNING_EN)) { + tuning_ctrl |= ESDHC_STD_TUNING_EN; + writel(tuning_ctrl, host->ioaddr + ESDHC_TUNING_CTRL); + } + ctrl = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS); ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL; ctrl &= ~ESDHC_MIX_CTRL_EXE_TUNE; @@ -1147,7 +1162,8 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val) reg |= ESDHC_MIX_CTRL_EXE_TUNE | ESDHC_MIX_CTRL_SMPCLK_SEL | ESDHC_MIX_CTRL_FBCLK_SEL; writel(reg, host->ioaddr + ESDHC_MIX_CTRL); - writel(val << 8, host->ioaddr + ESDHC_TUNE_CTRL_STATUS); + writel(val << ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_SHIFT, + host->ioaddr + ESDHC_TUNE_CTRL_STATUS); dev_dbg(mmc_dev(host->mmc), "tuning with delay 0x%x ESDHC_TUNE_CTRL_STATUS 0x%x\n", val, readl(host->ioaddr + ESDHC_TUNE_CTRL_STATUS)); @@ -1555,6 +1571,58 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host *host) } } +static void sdhc_esdhc_tuning_save(struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); + u32 reg; + + /* + * SD/eMMC do not need this tuning save because it will re-init + * after system resume back. + * Here save the tuning delay value for SDIO device since it may + * keep power during system PM. And for usdhc, only SDR50 and + * SDR104 mode for SDIO devide need to do tuning, and need to + * save/restore. + */ + if ((host->timing == MMC_TIMING_UHS_SDR50) | + (host->timing == MMC_TIMING_UHS_SDR104)) { + reg = readl(host->ioaddr + ESDHC_TUNE_CTRL_STATUS); + reg = (reg & ESDHC_TUNE_CTRL_STATUS_TAP_SEL_PRE_MASK) >> + ESDHC_TUNE_CTRL_STATUS_TAP_SEL_PRE_SHIFT; + imx_data->boarddata.saved_tuning_delay_cell = reg; + } +} + +static void sdhc_esdhc_tuning_restore(struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); + u32 reg; + + if ((host->timing == MMC_TIMING_UHS_SDR50) | + (host->timing == MMC_TIMING_UHS_SDR104)) { + /* + * restore the tuning delay value actually is a + * manual tuning method, so clear the standard + * tuning enable bit here. Will set back this + * ESDHC_STD_TUNING_EN in esdhc_reset_tuning() + * when trigger re-tuning. + */ + reg = readl(host->ioaddr + ESDHC_TUNING_CTRL); + reg &= ~ESDHC_STD_TUNING_EN; + writel(reg, host->ioaddr + ESDHC_TUNING_CTRL); + + reg = readl(host->ioaddr + ESDHC_MIX_CTRL); + reg |= ESDHC_MIX_CTRL_SMPCLK_SEL | ESDHC_MIX_CTRL_FBCLK_SEL; + writel(reg, host->ioaddr + ESDHC_MIX_CTRL); + + writel(imx_data->boarddata.saved_tuning_delay_cell << + ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_SHIFT, + host->ioaddr + ESDHC_TUNE_CTRL_STATUS); + } +} + static void esdhc_cqe_enable(struct mmc_host *mmc) { struct sdhci_host *host = mmc_priv(mmc); @@ -1883,7 +1951,17 @@ static int sdhci_esdhc_suspend(struct device *dev) (host->tuning_mode != SDHCI_TUNING_MODE_1)) { mmc_retune_timer_stop(host->mmc); mmc_retune_needed(host->mmc); - } + + /* + * For the SDIO device need to keep power during system PM, and enable + * wakeup, need to save the tuning delay value just in case the retuning + * is hold when SDIO resume, but still need to switch to 4 bit bus width. + */ + if (host->mmc->sdio_irqs && mmc_card_keep_power(host->mmc) && + (esdhc_is_usdhc(imx_data))) + sdhc_esdhc_tuning_save(host); + + } if (device_may_wakeup(dev)) { ret = sdhci_enable_irq_wakeups(host); @@ -1903,6 +1981,8 @@ static int sdhci_esdhc_suspend(struct device *dev) static int sdhci_esdhc_resume(struct device *dev) { struct sdhci_host *host = dev_get_drvdata(dev); + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); int ret; ret = mmc_gpio_set_cd_wake(host->mmc, false); @@ -1915,6 +1995,14 @@ static int sdhci_esdhc_resume(struct device *dev) if (host->irq_wake_enabled) sdhci_disable_irq_wakeups(host); + /* + * Restore the saved tuning delay value for the SDIO device + * which enabled wakeup and keep power during system PM. + */ + if ((imx_data->socdata->flags & ESDHC_FLAG_STATE_LOST_IN_LPMODE) && + mmc_card_keep_power(host->mmc) && mmc_card_wake_sdio_irq(host->mmc)) + sdhc_esdhc_tuning_restore(host); + pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); From patchwork Mon Oct 14 06:01:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 835345 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2048.outbound.protection.outlook.com [40.107.22.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF9F713EFF3; Mon, 14 Oct 2024 06:00:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.22.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728885646; cv=fail; b=ex0GZbm7/bn4uKqDSHfPU/TGnaWlTD//kOK9i5t5uy3mKaMqwr3VFUhOjHpmJvj8awsFYZYHl1s32EppmFd4CG6T2n8eXygM7UZy9nQvlZ5BZdfU5wZk7zNf/DyvSHKNAs8kMmWnaBr2Np9IZp66FD9eCJ4MeFaeYnsx28Yj960= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728885646; c=relaxed/simple; bh=rOOwKzF71V2MHYYPif9n4eDxZEf3Z1fTWh5YQIIjav4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Dg8CkCkF2hjD/t1x1OtsW6w236bmjlqlLE9O0AT7TJU46/UP88ymhfhWRi76AS9UhRD55EdXxDNAtz7ODtEeAipM+AAdGAYQNtFNdeqWWifl449Lz7NyaakE/iJz5zWqcnSdsdMXk3LaPtld0x/aW3NIVBUz1weQIGe0Qu5vixM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=DrXeqW4y; arc=fail smtp.client-ip=40.107.22.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="DrXeqW4y" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g9DKM2PAGoc5EH2GdnHRh++0qG33L42K06XGYjHIkL/rp3ktuIxX5abyLCDVx+lbRkjxKOLVxr1ZLtPw3nO+bfE0wtE35z6yMPWaYlAj8VN3Gv/zmSNO7759+RLaQKbnrbo4kfrqyL4BqVx/+DaitZCJzwFgwbAagtBkH2/u+OqXtq1nxQn6nlMrg6Xxoc7BrEUVPpcOgy+JM7VxIE+GKsq9g4l8sKC1StvlG4BPWAAWkJXAAb+D0fkjozhPOLO8LflALzeZ49s3ClltaI1tOXKBOgIQGa8Qcm6uszw7jvPlXqCfzdz7ep6UAu3JgJUmZqUwcQoyZleBKSLiuiUPlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MEW+ck023C1R0wEnHSWTj2drmMrl5/32Ipeta6xg2yI=; b=I3pLm0aunJeFADpFkZOYyWPvPpUss9Ric9fK5PTJdwM6DCjtqVlQmZ0QaDWKnw4LDwxvujKSSlyThZNmPu4sNJE1GQbm0cTUbCGbDhOVBCdJKgY+Nr9C3L9Njo9cACNvWGaOShdp17MpwAn6L8Pbbsou0nhPQqkaoJHAY7ObU+9p+vPRNVyM7oh8eolaykD9BGtJ4zuWj0ad4EKIi77m2h5vb71PP5zzZXkzxwfER3mrUsaZddX9fVIWEcX/Rcw6Dfe/1SdEe30ua9YQm/gV0s2GjHlo9GZvpG3+uqWDJUwe+Uqov6PspIpzvVBE0qbd+cZQionGGSpNqL9OUCMjnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MEW+ck023C1R0wEnHSWTj2drmMrl5/32Ipeta6xg2yI=; b=DrXeqW4yozTMksFF1jwxVdPOjw2QEiRxybyWmi0SBk2In/IWcJsmwttCQi2rzrxQREuzezLYuhSuyxfGcSpfJ2E80HQvBL7OIhTSxCSf3cEOlXuqx5K08QpCkx24UG63uFmbUN2Xt+wMmbOmwItmC0V/84GTMnyPuNBNNg3CFNYgUVyalDN4RGay1DtIcwp068DLNHzjJrmntVeUfllQlhcRrQUoKj85fe071VF5MCx5GWRY6sWU6BJ0YF71vJ1LEZKxiIFvN3DAeqYb1R3OIC1+3aOyhkymbgcU8ZzTfglVGFcsHIzPWk/MBBzrfip0Zel10+Y9ERmiS+9t56RV0A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU0PR04MB9496.eurprd04.prod.outlook.com (2603:10a6:10:32d::19) by PAXPR04MB8224.eurprd04.prod.outlook.com (2603:10a6:102:1cb::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.26; Mon, 14 Oct 2024 06:00:40 +0000 Received: from DU0PR04MB9496.eurprd04.prod.outlook.com ([fe80::4fa3:7420:14ed:5334]) by DU0PR04MB9496.eurprd04.prod.outlook.com ([fe80::4fa3:7420:14ed:5334%7]) with mapi id 15.20.8048.020; Mon, 14 Oct 2024 06:00:40 +0000 From: haibo.chen@nxp.com To: adrian.hunter@intel.com, ulf.hansson@linaro.org, linux-mmc@vger.kernel.org Cc: imx@lists.linux.dev, haibo.chen@nxp.com, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, s32@nxp.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] mmc: sdhci-esdhc-imx: do not change to sleep pinctrl state in suspend if enable wakeup Date: Mon, 14 Oct 2024 14:01:30 +0800 Message-Id: <20241014060130.1162629-5-haibo.chen@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241014060130.1162629-1-haibo.chen@nxp.com> References: <20241014060130.1162629-1-haibo.chen@nxp.com> X-ClientProxiedBy: SI2PR06CA0011.apcprd06.prod.outlook.com (2603:1096:4:186::16) To DU0PR04MB9496.eurprd04.prod.outlook.com (2603:10a6:10:32d::19) Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9496:EE_|PAXPR04MB8224:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c41fabc-9305-4897-0918-08dcec158834 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|7416014|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: Aur5Owf93diMl1B6fs2wMDiqVo0+auyMxnjQj4qZkxBRLlx0OftoPXMX2unLqri1ijeDEZscN3sIgnJ4P9ws47SySOXNKc7Tw8970f7X9R8F3g+9SpbgMoM314KhzY/J7hGq44gfRmnL28F+nQDBTtNjcSJf5b3QHNOAXPI832W8b8drRlCiG1l8gR87KbBzc3QP8+GXDTZpXBt+HPJhZAxAkWUtR3+WjKBJQClVG+Mq3NPVR5isI+aij3nEo4hkADIQiEiUjg2USra8M+UPNeeJb1fiBePXt6+gKvPedaWShI2ORTSilZWueSwIE2QfRqnhmA3sTfn3RAhrL5D25POe4nr4IDWOfPINUYqaYdRl/rh1kV0VYsg8ebxVi6d52wbpvlKVXjyeVH3anxF3H7FQ8BK5xl8KSNrwBzqRK0nX6lBGBaBPDtznPb6vKQYEowHT4eRl2vXNFaLPOgsj+LYLg8KQXZp915MOjRqUsigBP4+zjF8a4ZTXZpPN2Qo+BzrYn3H6tUpDQurBkjAMwcFVgCAncspmEEk0fduW8T3Z7Et9L9JkLt+Tqpx/rw/0HBXJBcWl2WxMethSbuGuT6DvrF44car+6sghVdagd25R3glh5PeScMGv+BgbykMMmB8n8siiOJTCI9FZucK90kDDkWpIqRi046Fhco8puY8zNTFX5c10HwRdBDY2BT+Zyq+XFSxW92R/JukYdstQUFuMgEqRWd5t6AJVd4M1JE6l++htLuNDXjc1UltVxP+dykCxLGEKjilh7Sq0dq/dUSaA/CaBiqW1IARu3jq8n80k9F6rZddnYGHr6XeABB1k8W78QiBV8mWJwe2xtZ08pYB/uUJKWOiJ3i/56Y6X+nQ1AjRqHyb7Va3Ak31rUeRuQhQ05WOe7PAqW0Wn6Hehn6/2noFDiFhqoZ0lpuupyuh1GCvKh7vr86kDBaxFFnGdtwCOrDg2wekZmsdiGRmnAtM20JttaIt5JB2H0wnNlm4zAyTnIgSHSBipbN7ch5WohBKKvvRsLZOfun+nh9kgW26TAMn5G69ZcePFtHR4M8Bu4AoTupnIf6Ism0x1Jv8LLxmoWNTIiA3fIoulXD6n6HSPCl1DX+aBW6N+A/sqzExzqUth2Wx9tVFY39Gnux67CyIz5VoqLvktNnUN259mwfN204ZRM9j6O+/X8hzx2I6fburyk66gUxzN6z3KTQ9Oj47z4H16OTeK7KQakoTwwQX36FXH4ywcMgge8SC0jeCspDpBaGpWM6hLxJcfTCJWFnCtcVJqkgZ7vBkPxDMzSL5UvAceuLvPxvvt32S18D/SuWGDL20mxxk2gH/hwhvKE4d2dICauEK5MeZQLFDOZw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9496.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(7416014)(376014)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PSG/rGY0w7+oR5llUDC3VTE8odkeM8GeP1+fjaTR9yyyGi2JrPl5fnOHj9u4hfT6Tm9NUWZiQQQnOSBG82B9caSoKH0YoKuuhy2guFYJrsKtJfyvQbw5+0JEOTJexn19k5S0FrBQNiDTd5cfNQ2euQaP8UudWXvkbgb60qlVZd+XI1dn7llGa5nUNRBaMW7x1iuie/GtaeL3ooOF0EnlJdMIOcEVV6wDJ5w/5WG+Rc8e3ruARO4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5wizOfzRhi16QyrLboZ7uhH3iIFPIkSLLg3ayzDVnIkzWe9Te7ITivxFAGowkp0Kv0q1KaH0O2Ppw93hwRRxfi+8bClUrDWKYycl3gGQBTJ3wKZ8wFC/xQJq1tN4X24Tan7SY4O5GFbkFScJ7fH8Dp92gI0kajyY+0Ec0kw2oyr1YsJouUpWGUubg0YFwqKjXfzRdeWhwJuHYTetQ+bNOofyRQFEB6DlSp4RZCvLumvgrQ52SNC28gpAZ0MSyzQ+PA5u8DAHuuneJhlvgyKgjgdws+0Sur5KWDOp X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c41fabc-9305-4897-0918-08dcec158834 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9496.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2024 06:00:40.5857 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r875Lh6Zi/vchDxp8itrWhJp+w3WXoEybP1vBuwk08AMJm6DNr7oCDN1A/kMFiP0M8EYVvsKIOGtHQLpkX/pYA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8224 From: Haibo Chen pinctrl sleep state may config the pin mux to certain function to save power in system PM. But if usdhc is setting as wakeup source, like the card interrupt(SDIO) or card insert interrupt, it depends on the related pin mux configured to usdhc function pad. e.g. To support card interrupt(SDIO interrupt), it need the pin is configured as usdhc DATA[1] function pin. Find the issue on imx93-11x11-evk board, SDIO WiFi in band interrupt can't wakeup system because the pinctrl sleep state config the DATA[1] pin as GPIO function. Signed-off-by: Haibo Chen --- drivers/mmc/host/sdhci-esdhc-imx.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index 4173967022d0..d4bb23c9e866 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -1969,9 +1969,19 @@ static int sdhci_esdhc_suspend(struct device *dev) dev_warn(dev, "Failed to enable irq wakeup\n"); } - ret = pinctrl_pm_select_sleep_state(dev); - if (ret) - return ret; + /* + * For the device which works as wakeup source, no need + * to change the pinctrl to sleep state. + * e.g. For SDIO device, the interrupt share with data pin, + * but the pinctrl sleep state may config the data pin to + * other function like GPIO function to save power in PM, + * which finally block the SDIO wakeup function. + */ + if (!device_may_wakeup(dev) || !host->irq_wake_enabled) { + ret = pinctrl_pm_select_sleep_state(dev); + if (ret) + return ret; + } ret = mmc_gpio_set_cd_wake(host->mmc, true);