From patchwork Mon Feb 26 10:14:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Kerello X-Patchwork-Id: 206547 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1984118dyb; Mon, 26 Feb 2024 02:33:49 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVztH9kiU/atk31kv2FowEllX/Jk7hmrGdz42Xq0XBLrTWx9PFEEVbl7ggY3eB/xGRngVvnRB/RAmyE+SAaFSbr0brqbA== X-Google-Smtp-Source: AGHT+IGs4g79NRtgNgyRpttshuhw54WBl+rjqdlB4f8cIt/HFiTm1ey6mp7J7nyN5iHGglJ28Kbb X-Received: by 2002:a05:620a:136c:b0:785:d8a1:dfbd with SMTP id d12-20020a05620a136c00b00785d8a1dfbdmr7592778qkl.68.1708943628922; Mon, 26 Feb 2024 02:33:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708943628; cv=pass; d=google.com; s=arc-20160816; b=BDtG0Jtm5JEj13YjgJDvERvelNY5ZSsSMHewf+A/ZboXpCHJuDVzZPErTtUHnfSQBs WDAoIFQsdZMZ3mFwVStGQz+0+LoDnZH7cq5XVhL1ZAV98U7Fs648+Z/lRtmUWqNp3ft+ yqHo0ar5MzsuXArTfcNlF0vO3HE2FOFRGy8oUX4gQGpldVX1dP1ivyMIGo4geS+puWh7 FRrG8RAicOgfVZkYhtbzctnvQekxgKtPT4s0rxKSBl1UBqp3yKn9Cx+JpeN98KG88aWJ bQfb/T7kF2IfccBoBk3WTidpGnF5ZoVPMMVxv+DNvdAfKLu6M0FcMGG1udUrsVaqsPo5 1vAg== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81148-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ye4-20020a05620a3b8400b00787c0bac683si4617163qkn.191.2024.02.26.02.33.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 02:33:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81148-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81148-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id CD8051C25AA3 for ; Mon, 26 Feb 2024 10:32:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6D6A5481BD; Mon, 26 Feb 2024 10:16:44 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791957274525767107 X-GMAIL-MSGID: 1791957274525767107 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,