From nobody Mon Feb 9 14:14:36 2026 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 AE281605A6; Mon, 26 Feb 2024 10:16:39 +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=1708942601; cv=none; b=N8Ch3Aia/fslCvfC+VDZpXVqDllANeK427SQLSP4Fi3ZfP07JX7JjOvz3St3SUbBJD/XofrE55Xo4iLpYVtuAgzHwWDERBSJXtfJ4RgE32Bl5Xg62OlH8iwhu+mG7g4bzgM4o9+riwqowHL2OEXm1qyiVIrL1g4iVaeJQlgwc1M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708942601; c=relaxed/simple; bh=BBLXVljoZZOO7u++4ebU0cnPhwZGz3QMObnaaqrDBB0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=np4cNm4f3uNom01IpYyMMBA+rglwGknB0cHTMGmFqHb8D+zhbtnH7gv3TLtlYmdZG+lKDoPzoE75Lr89T8VMT5pvDQCH8YLN6TpPF54a2VAwKbQSWatVTG5fPkDayc7fX3fKJxbkw6Qqg2+Vg8zENVkweWtt0opTR5zJE9xod8c= 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=4Jq7FCFk; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="4Jq7FCFk" Received: from pps.filterd (m0369458.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41QAFlbT008172; Mon, 26 Feb 2024 11:16:32 +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=PT3rYq5wlLifa1OetliYI6KgIIUCxnn4TmN7Bb6JlgM=; b=4J q7FCFkxxDiPjkA38ACbqL8dIcdiM7qa9nM4FFO55DvREPOjTty845/9D4tnatVOA TS6/JqIlOBdfel12QFGvCFk4om/yOPceAgnMZ2+Xc+0bRVnWfTwVVq9Ur+h4SQvM G99cXqzYZDkg6KRX/kTxAcqF+WipLhFXqO2yiO0KbE70l7U9Lh0xFzZgCLMo6jqi OQTVFZH1/Q4RGY2lsNKvZ6YfcnlhJkVuI23/xr62A1EwSN3j5VBq7DX043HXwMRK w7/80lXYO4nfLfqggLaZxpurUxuPFwu3evdKHpnlFenqdpM57YBB4tL+G4H+CBfz Yejvl5bbyTbaKCjqX2XQ== 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 3wftw4mh2e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 11:16:32 +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 2BA4F40045; Mon, 26 Feb 2024 11:16:29 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 74A71259106; Mon, 26 Feb 2024 11:16:02 +0100 (CET) Received: from localhost (10.201.21.177) 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, 26 Feb 2024 11:16:02 +0100 From: Christophe Kerello To: , , , CC: , , , Christophe Kerello Subject: [PATCH v3 5/5] memory: stm32-fmc2-ebi: keep power domain on Date: Mon, 26 Feb 2024 11:14:28 +0100 Message-ID: <20240226101428.37791-6-christophe.kerello@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240226101428.37791-1-christophe.kerello@foss.st.com> References: <20240226101428.37791-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 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: EQNCAS1NODE3.st.com (10.75.129.80) 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-26_07,2024-02-23_01,2023-05-22_02 Content-Type: text/plain; charset="utf-8" MP25 FMC2 domain has to be kept on. To handle it throw PSCI OS-initiated, basic PM for keeping domain on is introduced. Signed-off-by: Christophe Kerello --- Changes in v2: - Patch has been renamed and associated commit message has been updated. drivers/memory/stm32-fmc2-ebi.c | 41 +++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/drivers/memory/stm32-fmc2-ebi.c b/drivers/memory/stm32-fmc2-eb= i.c index 45c658af613d..1c63eeacd071 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 =20 @@ -1649,6 +1650,7 @@ static int stm32_fmc2_ebi_probe(struct platform_devic= e *pdev) return -ENOMEM; =20 ebi->dev =3D dev; + platform_set_drvdata(pdev, ebi); =20 ebi->data =3D of_device_get_match_data(dev); if (!ebi->data) @@ -1666,10 +1668,14 @@ static int stm32_fmc2_ebi_probe(struct platform_dev= ice *pdev) if (PTR_ERR(rstc) =3D=3D -EPROBE_DEFER) return -EPROBE_DEFER; =20 - ret =3D clk_prepare_enable(ebi->clk); + ret =3D devm_pm_runtime_enable(dev); if (ret) return ret; =20 + ret =3D pm_runtime_resume_and_get(dev); + if (ret < 0) + return ret; + if (!IS_ERR(rstc)) { reset_control_assert(rstc); reset_control_deassert(rstc); @@ -1705,8 +1711,6 @@ static int stm32_fmc2_ebi_probe(struct platform_devic= e *pdev) if (ret) goto err_release; =20 - platform_set_drvdata(pdev, ebi); - return 0; =20 err_release: @@ -1714,7 +1718,7 @@ static int stm32_fmc2_ebi_probe(struct platform_devic= e *pdev) stm32_fmc2_ebi_disable(ebi); if (ebi->data->put_sems) ebi->data->put_sems(ebi); - clk_disable_unprepare(ebi->clk); + pm_runtime_put_sync_suspend(dev); =20 return ret; } @@ -1728,7 +1732,23 @@ static void stm32_fmc2_ebi_remove(struct platform_de= vice *pdev) stm32_fmc2_ebi_disable(ebi); if (ebi->data->put_sems) ebi->data->put_sems(ebi); + pm_runtime_put_sync_suspend(&pdev->dev); +} + +static int __maybe_unused stm32_fmc2_ebi_runtime_suspend(struct device *de= v) +{ + struct stm32_fmc2_ebi *ebi =3D 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 =3D dev_get_drvdata(dev); + + return clk_prepare_enable(ebi->clk); } =20 static int __maybe_unused stm32_fmc2_ebi_suspend(struct device *dev) @@ -1738,7 +1758,7 @@ static int __maybe_unused stm32_fmc2_ebi_suspend(stru= ct device *dev) stm32_fmc2_ebi_disable(ebi); if (ebi->data->put_sems) ebi->data->put_sems(ebi); - clk_disable_unprepare(ebi->clk); + pm_runtime_put_sync_suspend(dev); pinctrl_pm_select_sleep_state(dev); =20 return 0; @@ -1751,8 +1771,8 @@ static int __maybe_unused stm32_fmc2_ebi_resume(struc= t device *dev) =20 pinctrl_pm_select_default_state(dev); =20 - ret =3D clk_prepare_enable(ebi->clk); - if (ret) + ret =3D pm_runtime_resume_and_get(dev); + if (ret < 0) return ret; =20 if (ebi->data->get_sems) @@ -1763,8 +1783,11 @@ static int __maybe_unused stm32_fmc2_ebi_resume(stru= ct device *dev) return 0; } =20 -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 =3D { + 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) +}; =20 static const struct stm32_fmc2_ebi_data stm32_fmc2_ebi_mp1_data =3D { .child_props =3D stm32_fmc2_child_props, --=20 2.25.1