From nobody Mon Feb 9 08:55:53 2026 Received: from mx08-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (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 16AA02D610; Mon, 19 Feb 2024 14:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.207.212.93 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708351511; cv=none; b=t2rZM1cdePg5f1Dg+MRA/bY3jtGgTOJr3zibt5DWjqC7azmhyM49BWgC48djxeXSxtSF9LHyc5D+CoXl7WdZ9wU+zjXw6/zKhv44kmzNKcBlC17KRsoKODXrEXmxivpQxlq49ouvHqYfyVZyBeDsXupx2pQsF+3nkWQZEcryHug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708351511; c=relaxed/simple; bh=+LBu4n1zxPhBosXlNDQSx93UUlGPNq4g+6hLLcKMSGY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eYjY3egxz5vbXnte65jdj2PN1Sscp5KOd0QaDJLI+TnU9ehf3Zq1eox5Mj4s/hyGBkpYnOqJzK73edlrqLC4ldv1ARS43+88Rdyr6kLdKBZcC09x/JjfhnitsenoMGQMPdeAx85TK/YZOtngAa6h4oVh+2BcEajceTbOu803RHQ= 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=54XofLlV; arc=none smtp.client-ip=91.207.212.93 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="54XofLlV" Received: from pps.filterd (m0369457.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41JBPV6C011678; Mon, 19 Feb 2024 15:05:02 +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=UpwsTRqMb0U8hGwknl8QF8zKrhGPawmi4ZB0T5+Hy+k=; b=54 XofLlVEw3qgAjOXP/xHF+gEjTv38ebHK8qUc2numPUM+beL7wNneXcnkk4td0qfW DGMwLmH01cicZMoNOTetpf+I324UDFiDCwGiM/KcfCMFRSlFobdCjCjlwqoDlJj5 sICRps6PEtCs55JF1ScQkSPXqVXT4YYU4xaOL7Ei4h8B9oO2bcNxSgiuMRxEmW/L +O/Yxo6Nwb0+s+tdUFnj0NxIev4qzN5VKb1Bmjl76jXr1Tn/sRxBVy5T8C8PYsOD oz9edawnGQ3ShS4/eKCypBnoVwTCgB5OqmFHiSdeJ9Q/Xo3RWATOrrTOfquLaTi6 qQVSE+jxX7NSThLEQjWQ== 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 3wb8mnmn8j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 19 Feb 2024 15:05:02 +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 1ADDA4002D; Mon, 19 Feb 2024 15:04:59 +0100 (CET) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 7BD1926A990; Mon, 19 Feb 2024 15:04:29 +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, 19 Feb 2024 15:04:29 +0100 From: Christophe Kerello To: , , , CC: , , , Christophe Kerello Subject: [PATCH v2 5/5] memory: stm32-fmc2-ebi: keep power domain on Date: Mon, 19 Feb 2024 15:02:02 +0100 Message-ID: <20240219140202.85680-6-christophe.kerello@foss.st.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240219140202.85680-1-christophe.kerello@foss.st.com> References: <20240219140202.85680-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-19_10,2024-02-19_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 b1d5e61c2434..e32d2a24af8c 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 @@ -1655,6 +1656,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) @@ -1672,10 +1674,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); @@ -1713,8 +1719,6 @@ static int stm32_fmc2_ebi_probe(struct platform_devic= e *pdev) goto err_release; } =20 - platform_set_drvdata(pdev, ebi); - return 0; =20 err_release: @@ -1722,7 +1726,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; } @@ -1736,7 +1740,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) @@ -1746,7 +1766,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; @@ -1759,8 +1779,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) @@ -1773,8 +1793,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