Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1220197rbb; Mon, 26 Feb 2024 02:37:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWPwHf8RWN5O5yIeJhpJxa99U85DzOEXo4bL9NEOmg+RlRO+PB3veK5CcihLs/RCHe3CWfKFUTbCdhYgATdCsnSs2g/ns7ocgVL35v/EA== X-Google-Smtp-Source: AGHT+IF0BhbNnQQiMotmSvCqXgIZisRqeBm+cwretpGvKJAAAyzYBOejzA4k8zAfIvt71jQf1IEm X-Received: by 2002:a05:6870:9589:b0:21f:d09e:b185 with SMTP id k9-20020a056870958900b0021fd09eb185mr6611119oao.42.1708943842703; Mon, 26 Feb 2024 02:37:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708943842; cv=pass; d=google.com; s=arc-20160816; b=qSr7At3pIV0dKX+E1XoGM7S0AT9XSl0FTH+FGovNNtkEKlbsfJO7OaBz0w9B+Hmm4Y +PCtUwUymnNUNmBINez4babXfaWtXZl80VmYEOD0Z+vLku46FCfeHAXFYxvZttmbfVuy SF1lDVJ49WbsfBwFGkDrYCOlF0EyLLsQjvNa5YhpuGGkQUxFOCPeELaaNvdEdhvPi01E TvuwFMNPuWjBWWlab9oextciGbx45RzL4Rm6IcvM6IbZzOYxtHw1KG0ROj7DQCtZ15ro MC+6jPIU926+L/6AGh2ES653QsI1BRB6Bg0dZc2EKWxZ+WFiy5mVMAcDwZCnBQf6/sLS i/8g== 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=PT3rYq5wlLifa1OetliYI6KgIIUCxnn4TmN7Bb6JlgM=; fh=y4FXrSujymOgL1hRR+C3ImzoRkO9ZvGQV32dW03/8NM=; b=x9B0Kwt1g03iLCGu0QA5e4yP9zhNEh8qdIn6X/EaBZF3jgg6Lq+4ff/Fh+P5VwYsu8 dRy8iWR82nRO1JwC/x5xEqVfuTk3aRf1E5lE7IW/GFmBHctW/5GU2lAdoilcYg4RHyzp 0KEhmFBrKme7LpWMpxMK3u6TVHqNFdpUYKIWxJb3V4FMBWONDW1vdXgtVm9b2vZL2jSk FLOwgL4pgv3ZZmRqnHaj25ub4Ztl7GzxkIekfUSyWSnNivw3xaFnkcQLhTZs4bvgswOc c/ikKldiMKSFdoCN7mWijjQCNu8zdjkppE3DDHOQxosxOgzpohq/mdA1oAL9gNnFwugk WKxA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=4Jq7FCFk; 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-81148-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81148-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id i14-20020a63cd0e000000b005dc359d7e93si3436235pgg.806.2024.02.26.02.37.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 02:37:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81148-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=4Jq7FCFk; 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-81148-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81148-linux.lists.archive=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0A86128CF74 for ; Mon, 26 Feb 2024 10:32:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69D82481AD; Mon, 26 Feb 2024 10:16:42 +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="4Jq7FCFk" 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 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: 8bit Content-Type: text/plain 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 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-ebi.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 @@ -1649,6 +1650,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) @@ -1666,10 +1668,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); @@ -1705,8 +1711,6 @@ static int stm32_fmc2_ebi_probe(struct platform_device *pdev) if (ret) goto err_release; - platform_set_drvdata(pdev, ebi); - return 0; err_release: @@ -1714,7 +1718,7 @@ static int stm32_fmc2_ebi_probe(struct platform_device *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); return ret; } @@ -1728,7 +1732,23 @@ static void stm32_fmc2_ebi_remove(struct platform_device *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 *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) @@ -1738,7 +1758,7 @@ static int __maybe_unused stm32_fmc2_ebi_suspend(struct 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); return 0; @@ -1751,8 +1771,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; if (ebi->data->get_sems) @@ -1763,8 +1783,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 = { .child_props = stm32_fmc2_child_props, -- 2.25.1