mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
To: <vkoul@kernel.org>
Cc: <yung-chuan.liao@linux.intel.com>,
	<pierre-louis.bossart@linux.dev>, <Basavaraj.Hiregoudar@amd.com>,
	<Sunil-kumar.Dommati@amd.com>, <venkataprasad.potturu@amd.com>,
	<Syed.SabaKareem@amd.com>, <Mario.Limonciello@amd.com>,
	<Richard.Gong@amd.com>, <Poojitha.N@amd.com>,
	<linux-sound@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	"Vijendar Mukunda" <Vijendar.Mukunda@amd.com>
Subject: [PATCH v4 11/11] soundwire: amd: guard clock-stop register access by acp_rev
Date: Tue, 17 Nov 2026 12:48:20 +0530	[thread overview]
Message-ID: <20261117071927.830373-12-Vijendar.Mukunda@amd.com> (raw)
In-Reply-To: <20261117071927.830373-1-Vijendar.Mukunda@amd.com>

Wrap the readl_poll_timeout call in amd_sdw_clock_stop() in an explicit
switch/case block on acp_rev covering ACP63, ACP70, ACP71, and ACP72,
selecting the register offset via clk_resume_ctrl.
An unrecognised revision returns -EINVAL before clk_stopped is set.

The wake-enable writel follows unconditionally under wake_en_mask since
the revision check above already guarantees a known acp_rev at that point,
avoiding a second switch that would leave clk_stopped = true on an
unexpected default branch.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
 drivers/soundwire/amd_manager_common.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/soundwire/amd_manager_common.c b/drivers/soundwire/amd_manager_common.c
index 987283d06cb9..7712469d6ce7 100644
--- a/drivers/soundwire/amd_manager_common.c
+++ b/drivers/soundwire/amd_manager_common.c
@@ -520,7 +520,7 @@ int amd_sdw_manager_start(struct amd_sdw_manager *amd_manager)
  */
 int amd_sdw_clock_stop(struct amd_sdw_manager *amd_manager)
 {
-	u32 val;
+	u32 clk_resume_ctrl, val;
 	int ret;
 
 	ret = sdw_bus_prep_clk_stop(&amd_manager->bus);
@@ -534,8 +534,21 @@ int amd_sdw_clock_stop(struct amd_sdw_manager *amd_manager)
 		return 0;
 	}
 
-	ret = readl_poll_timeout(amd_manager->mmio + ACP_SW_CLK_RESUME_CTRL, val,
-				 (val & AMD_SDW_CLK_STOP_DONE), ACP_DELAY_US, AMD_SDW_TIMEOUT);
+	switch (amd_manager->acp_rev) {
+	case ACP63_PCI_REV_ID:
+	case ACP70_PCI_REV_ID:
+	case ACP71_PCI_REV_ID:
+	case ACP72_PCI_REV_ID:
+		clk_resume_ctrl = ACP_SW_CLK_RESUME_CTRL;
+		break;
+	default:
+		dev_err(amd_manager->dev, "unexpected acp_rev 0x%x\n", amd_manager->acp_rev);
+		return -EINVAL;
+	}
+
+	ret = readl_poll_timeout(amd_manager->mmio + clk_resume_ctrl, val,
+				 (val & AMD_SDW_CLK_STOP_DONE),
+				 ACP_DELAY_US, AMD_SDW_TIMEOUT);
 	if (ret) {
 		dev_err(amd_manager->dev, "SDW%x clock stop failed\n", amd_manager->instance);
 		return 0;
-- 
2.53.0


      parent reply	other threads:[~2026-11-17  7:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  7:18 [PATCH v4 00/11] soundwire: amd: introduce hw_ops dispatch and split driver into revision-specific files Vijendar Mukunda
2026-11-17  7:18 ` [PATCH v4 01/11] soundwire: amd: rename AMD_SDW_MAX_MANAGER_COUNT macro Vijendar Mukunda
2026-11-17  7:18 ` [PATCH v4 02/11] soundwire: amd: allocate pdevinfo and sdw_pdata by ACP revision in probe Vijendar Mukunda
2026-11-17  7:18 ` [PATCH v4 03/11] soundwire: amd: allocate sdw_amd_ctx pdev array dynamically Vijendar Mukunda
2026-11-17  7:18 ` [PATCH v4 04/11] soundwire: amd: rename hardware backend symbols to amd_acp63_*() prefix Vijendar Mukunda
2026-11-17  7:18 ` [PATCH v4 05/11] soundwire: amd: remove unused AMD_SDW_MAX_FREQ_NUM define Vijendar Mukunda
2026-11-17  7:18 ` [PATCH v4 06/11] soundwire: amd: introduce struct amd_sdw_hw_ops dispatch framework Vijendar Mukunda
2026-11-17  7:18 ` [PATCH v4 07/11] soundwire: amd: dispatch irq/work handlers to per-revision functions Vijendar Mukunda
2026-11-17  7:18 ` [PATCH v4 08/11] soundwire: amd: populate hw_ops and wire all call sites through acp_*() helpers Vijendar Mukunda
2026-11-17  7:18 ` [PATCH v4 09/11] soundwire: amd: extract shared functions into amd_manager_common.c Vijendar Mukunda
2026-11-17  7:18 ` [PATCH v4 10/11] soundwire: amd: guard DAI PCM caps by acp_rev in register_dais() Vijendar Mukunda
2026-11-17  7:18 ` Vijendar Mukunda [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261117071927.830373-12-Vijendar.Mukunda@amd.com \
    --to=vijendar.mukunda@amd.com \
    --cc=Basavaraj.Hiregoudar@amd.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=Poojitha.N@amd.com \
    --cc=Richard.Gong@amd.com \
    --cc=Sunil-kumar.Dommati@amd.com \
    --cc=Syed.SabaKareem@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=venkataprasad.potturu@amd.com \
    --cc=vkoul@kernel.org \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®