From patchwork Mon Feb 12 17:48:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Kerello X-Patchwork-Id: 199975 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp89338dyb; Mon, 12 Feb 2024 10:18:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVZp5lzYYDc/8PuYKrOqqinz0JWD4UpSynMwXfVYsg+6ZPAZt8jxDZdcAjmbhezrSWpZyKLd+NGZ+sd56o/zDgz/BW7Bg== X-Google-Smtp-Source: AGHT+IHS4xoep95xdJIlRzxCiPwXpgtgRxsrBj4xWmf2XuwUHRtMjL/IxLhUAqa/tAooOI+Z0qGX X-Received: by 2002:a05:6a21:8cc9:b0:19e:ca6a:118e with SMTP id ta9-20020a056a218cc900b0019eca6a118emr4616326pzb.36.1707761882517; Mon, 12 Feb 2024 10:18:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707761882; cv=pass; d=google.com; s=arc-20160816; b=J+eYG68MP6UW9LqAi0W4xKaVwpI+GX/tEp3ECbGDC7oq4qHD0zcBMS05VwGGoIALit XLc55mF2AYVE96tqNF+XtbM/Oi5hDjoXUTTno0zdfeSsd6/NajprqKpC8gaxsvFra11U jS9qBnMVo50VfUyS8Zm9CzmnhD1MEcCqoXmzEoz62/FS9RsCYud7Jzxb4XN3cxFu+mem x3PPqGd2m0PX/9y9ao94bjVnMSz2nZAfetS+AhAf5VS7YTf/I8DgxgDxJYO6KHb9sqtf Ae7WFXg0+kezioKdkbGSukINgoDW8KZb+HpZesQcHhumTL2MTUGUoic4bw2r6LTBz3yq pi3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yBt3J1JvC9JWaK1tn/1K6Z3tKSfz+E4rgFKGPurOxBY=; fh=Txg9wzQSMH2QEwQAqGrgwO4AEbL3azBFV274xDnK9Js=; b=AN36AA3z7ijYY/k7pHb0XN4d7sTCRM0cYCuLLMrtSyZNCDsxxh3wQiPKJ/x1QEMeTe gMW3VBFWsDRa8Bovrpoa2S180GTcrbb2hn1uh8tWRfW3LBqgXgSKs7Wi/yBvmAxMdgWn r1n7XwRi6TFgDcdk/MsMC+odxTuzaNombnFWelM004RXArdTlTZzX1BekKJQ8JQ2A/qM gXrIzdQJVXBF5j9eLY8N3avc4feY+syiTTzXK6yVk9rE+a0h8Hf8EyA+ndskipNjL9Gm 3QHm0xciPB39A2FM1WtspoFg/MK83SkXsPGyqnVSm2RYy3v25jBZps74XHBnKZyRED1G xy4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=xZx3E2ww; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-kernel+bounces-62138-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62138-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com X-Forwarded-Encrypted: i=2; AJvYcCVb5yn+VAXzXSnMOAemEEZWyzBO1xVEGcPGh0k3CGjR/P8Sl7NNGHq+Qq0FVeGJ/nmO1XSPYq5Y0zuj/ZoyjE62yGSgCg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id x66-20020a636345000000b005dc15abdad3si572214pgb.291.2024.02.12.10.18.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 10:18:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-62138-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=xZx3E2ww; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-kernel+bounces-62138-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-62138-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 655DCB288A6 for ; Mon, 12 Feb 2024 17:53:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2695E45BFE; Mon, 12 Feb 2024 17:51:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="xZx3E2ww" Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) (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 479A73FB2F; Mon, 12 Feb 2024 17:51:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.182.106 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707760285; cv=none; b=gSrMY5wn2UzFL6NsEwOXqqwEPb8ZRglkSRON3sA6wURkATpfq4Lh/P7lknqi8S2Ae+F55hshYbmAHvlVBJkSjSEe0hQwzKRgHBNwe/ogu0zp7+hGdUBmjTbJDR93k1UI5FiIwzoOkO8TEHFrj0JI+Tn+Gw89QUVjJs/XhuSrlRY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707760285; c=relaxed/simple; bh=BirkVWS+mSl3fX1O0cWUQWmo13pH6fBvp3WBZIckfaI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iPnKtVbd1bs17CqycQb4lLr/sPjW47lGKwPnVUMRk0+i6b9RxJwdK8S0tK9yJMPwJQdvPIBUuourkDzC3SEEji37wPX8YehD/FSSsIzbSRaIKfS+57cPM6IZDWfKijanfBaSyrlQdhnQJFlKbK/GV23pr7UoRnlBaC+mrvHg+2c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b=xZx3E2ww; arc=none smtp.client-ip=185.132.182.106 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41CFLrBU012118; Mon, 12 Feb 2024 18:51:10 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= selector1; bh=yBt3J1JvC9JWaK1tn/1K6Z3tKSfz+E4rgFKGPurOxBY=; b=xZ x3E2wwN4kEMq39WrPmVwFEDW1B6Fddppyfll/2jFmRLCGh5NB7tkU0x5A482/pEE ZXMIHanjrTw/RdTfl/IpKwIySG9HQlvt39JXzgvxWoysu5OR+87MqPDZd6DAH+qP MjionM8pOk8HXk5x3uYhh55FfatkPuwaAtvdBfEQE/8XI5A4I1VWkOJsfUQmwEPm 2EGk8a/5oadfOjS7fXFUjzCbTDFSqAShhsRS77VFdqfCQR7TdD31N7ET8pTSIPTk JkMriE1G81O2EZs7sd2IaeXXCuWunz7FzRUujzIRtWV3ShZs5KFhSV7y42tJIkS9 0/WaGLDduM5ZnFjVCBsA== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3w62h0qkux-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 12 Feb 2024 18:51:10 +0100 (CET) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 669B740044; Mon, 12 Feb 2024 18:51:07 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 15F5927F261; Mon, 12 Feb 2024 18:50:22 +0100 (CET) Received: from localhost (10.201.22.200) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 12 Feb 2024 18:50:21 +0100 From: Christophe Kerello To: , , , , , , CC: , , , , Christophe Kerello Subject: [PATCH 07/12] memory: stm32-fmc2-ebi: add runtime PM support Date: Mon, 12 Feb 2024 18:48:17 +0100 Message-ID: <20240212174822.77734-8-christophe.kerello@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240212174822.77734-1-christophe.kerello@foss.st.com> References: <20240212174822.77734-1-christophe.kerello@foss.st.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SHFCAS1NODE1.st.com (10.75.129.72) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-12_15,2024-02-12_03,2023-05-22_02 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790718123476412252 X-GMAIL-MSGID: 1790718123476412252 Add runtime PM support in FMC2 ebi driver to be able to manage GENPD support when it will be enabled. Signed-off-by: Christophe Kerello --- drivers/memory/stm32-fmc2-ebi.c | 40 ++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/drivers/memory/stm32-fmc2-ebi.c b/drivers/memory/stm32-fmc2-ebi.c index 04248c15832f..8c30e56be3b0 100644 --- a/drivers/memory/stm32-fmc2-ebi.c +++ b/drivers/memory/stm32-fmc2-ebi.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -1381,6 +1382,7 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev) return -ENOMEM; ebi->dev = dev; + platform_set_drvdata(pdev, ebi); ebi->data = of_device_get_match_data(dev); if (!ebi->data) @@ -1398,10 +1400,14 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev) if (PTR_ERR(rstc) == -EPROBE_DEFER) return -EPROBE_DEFER; - ret = clk_prepare_enable(ebi->clk); + ret = devm_pm_runtime_enable(dev); if (ret) return ret; + ret = pm_runtime_resume_and_get(dev); + if (ret < 0) + return ret; + if (!IS_ERR(rstc)) { reset_control_assert(rstc); reset_control_deassert(rstc); @@ -1432,7 +1438,6 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev) goto err_release; stm32_fmc2_ebi_save_setup(ebi); - platform_set_drvdata(pdev, ebi); return 0; @@ -1440,7 +1445,7 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev) stm32_fmc2_ebi_disable_banks(ebi); stm32_fmc2_ebi_disable(ebi); stm32_fmc2_ebi_put_sems(ebi); - clk_disable_unprepare(ebi->clk); + pm_runtime_put_sync_suspend(dev); return ret; } @@ -1453,7 +1458,23 @@ static void stm32_fmc2_ebi_remove(struct platform_device *pdev) stm32_fmc2_ebi_disable_banks(ebi); stm32_fmc2_ebi_disable(ebi); stm32_fmc2_ebi_put_sems(ebi); + pm_runtime_put_sync_suspend(&pdev->dev); +} + +static int __maybe_unused stm32_fmc2_ebi_runtime_suspend(struct device *dev) +{ + struct stm32_fmc2_ebi *ebi = dev_get_drvdata(dev); + clk_disable_unprepare(ebi->clk); + + return 0; +} + +static int __maybe_unused stm32_fmc2_ebi_runtime_resume(struct device *dev) +{ + struct stm32_fmc2_ebi *ebi = dev_get_drvdata(dev); + + return clk_prepare_enable(ebi->clk); } static int __maybe_unused stm32_fmc2_ebi_suspend(struct device *dev) @@ -1462,7 +1483,7 @@ static int __maybe_unused stm32_fmc2_ebi_suspend(struct device *dev) stm32_fmc2_ebi_disable(ebi); stm32_fmc2_ebi_put_sems(ebi); - clk_disable_unprepare(ebi->clk); + pm_runtime_put_sync_suspend(dev); pinctrl_pm_select_sleep_state(dev); return 0; @@ -1475,8 +1496,8 @@ static int __maybe_unused stm32_fmc2_ebi_resume(struct device *dev) pinctrl_pm_select_default_state(dev); - ret = clk_prepare_enable(ebi->clk); - if (ret) + ret = pm_runtime_resume_and_get(dev); + if (ret < 0) return ret; stm32_fmc2_ebi_get_sems(ebi); @@ -1486,8 +1507,11 @@ static int __maybe_unused stm32_fmc2_ebi_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(stm32_fmc2_ebi_pm_ops, stm32_fmc2_ebi_suspend, - stm32_fmc2_ebi_resume); +static const struct dev_pm_ops stm32_fmc2_ebi_pm_ops = { + SET_RUNTIME_PM_OPS(stm32_fmc2_ebi_runtime_suspend, + stm32_fmc2_ebi_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(stm32_fmc2_ebi_suspend, stm32_fmc2_ebi_resume) +}; static const struct stm32_fmc2_ebi_data stm32_fmc2_ebi_mp1_data = { .rnb_for_nand = false,