From: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
To: <broonie@kernel.org>, <vkoul@kernel.org>
Cc: <alsa-devel@alsa-project.org>, <yung-chuan.liao@linux.intel.com>,
<pierre-louis.bossart@linux.intel.com>,
<Basavaraj.Hiregoudar@amd.com>, <Sunil-kumar.Dommati@amd.com>,
<vinod.koul@intel.com>, <venkataprasad.potturu@amd.com>,
Vijendar Mukunda <Vijendar.Mukunda@amd.com>,
Sanyog Kale <sanyog.r.kale@intel.com>,
open list <linux-kernel@vger.kernel.org>
Subject: [PATCH V4 05/13] soundwire: amd: refactor soundwire pads enable
Date: Mon, 29 Jan 2024 11:21:39 +0530 [thread overview]
Message-ID: <20240129055147.1493853-6-Vijendar.Mukunda@amd.com> (raw)
In-Reply-To: <20240129055147.1493853-1-Vijendar.Mukunda@amd.com>
As sdw pads enable sequence is executed only once, invoke it from probe
sequence.
Program required pads for both manager instances based on link_mask during
probe sequence. This will avoid acquiring mutex lock.
Remove unnecessary delay after programming ACP_SW_PAD_KEEPER_EN register.
Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
drivers/soundwire/amd_init.c | 45 +++++++++++++++++++++++++++++++++
drivers/soundwire/amd_manager.c | 18 -------------
2 files changed, 45 insertions(+), 18 deletions(-)
diff --git a/drivers/soundwire/amd_init.c b/drivers/soundwire/amd_init.c
index 46a0538d7fc7..e45dc8261ab1 100644
--- a/drivers/soundwire/amd_init.c
+++ b/drivers/soundwire/amd_init.c
@@ -15,6 +15,47 @@
#include "amd_init.h"
+#define ACP_PAD_PULLDOWN_CTRL 0x0001448
+#define ACP_SW_PAD_KEEPER_EN 0x0001454
+#define AMD_SDW_PAD_PULLDOWN_CTRL_ENABLE_MASK 0x7f9a
+#define AMD_SDW0_PAD_PULLDOWN_CTRL_ENABLE_MASK 0x7f9f
+#define AMD_SDW1_PAD_PULLDOWN_CTRL_ENABLE_MASK 0x7ffa
+#define AMD_SDW0_PAD_EN_MASK 1
+#define AMD_SDW1_PAD_EN_MASK 0x10
+#define AMD_SDW_PAD_EN_MASK (AMD_SDW0_PAD_EN_MASK | AMD_SDW1_PAD_EN_MASK)
+
+static int amd_enable_sdw_pads(void __iomem *mmio, u32 link_mask, struct device *dev)
+{
+ u32 val;
+ u32 pad_keeper_en_mask, pad_pulldown_ctrl_mask;
+
+ switch (link_mask) {
+ case 1:
+ pad_keeper_en_mask = AMD_SDW0_PAD_EN_MASK;
+ pad_pulldown_ctrl_mask = AMD_SDW0_PAD_PULLDOWN_CTRL_ENABLE_MASK;
+ break;
+ case 2:
+ pad_keeper_en_mask = AMD_SDW1_PAD_EN_MASK;
+ pad_pulldown_ctrl_mask = AMD_SDW1_PAD_PULLDOWN_CTRL_ENABLE_MASK;
+ break;
+ case 3:
+ pad_keeper_en_mask = AMD_SDW_PAD_EN_MASK;
+ pad_pulldown_ctrl_mask = AMD_SDW_PAD_PULLDOWN_CTRL_ENABLE_MASK;
+ break;
+ default:
+ dev_err(dev, "No SDW Links are enabled\n");
+ return -ENODEV;
+ }
+
+ val = readl(mmio + ACP_SW_PAD_KEEPER_EN);
+ val |= pad_keeper_en_mask;
+ writel(val, mmio + ACP_SW_PAD_KEEPER_EN);
+ val = readl(mmio + ACP_PAD_PULLDOWN_CTRL);
+ val &= pad_pulldown_ctrl_mask;
+ writel(val, mmio + ACP_PAD_PULLDOWN_CTRL);
+ return 0;
+}
+
static int sdw_amd_cleanup(struct sdw_amd_ctx *ctx)
{
int i;
@@ -37,6 +78,7 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res)
struct platform_device_info pdevinfo[2];
u32 link_mask;
int count, index;
+ int ret;
if (!res)
return NULL;
@@ -50,6 +92,9 @@ static struct sdw_amd_ctx *sdw_amd_probe_controller(struct sdw_amd_res *res)
count = res->count;
dev_dbg(&adev->dev, "Creating %d SDW Link devices\n", count);
+ ret = amd_enable_sdw_pads(res->mmio_base, res->link_mask, res->parent);
+ if (ret)
+ return NULL;
/*
* we need to alloc/free memory manually and can't use devm:
diff --git a/drivers/soundwire/amd_manager.c b/drivers/soundwire/amd_manager.c
index efc000334aa0..44d682a83e23 100644
--- a/drivers/soundwire/amd_manager.c
+++ b/drivers/soundwire/amd_manager.c
@@ -26,23 +26,6 @@
#define to_amd_sdw(b) container_of(b, struct amd_sdw_manager, bus)
-static void amd_enable_sdw_pads(struct amd_sdw_manager *amd_manager)
-{
- u32 sw_pad_pulldown_val;
- u32 val;
-
- mutex_lock(amd_manager->acp_sdw_lock);
- val = readl(amd_manager->acp_mmio + ACP_SW_PAD_KEEPER_EN);
- val |= amd_manager->reg_mask->sw_pad_enable_mask;
- writel(val, amd_manager->acp_mmio + ACP_SW_PAD_KEEPER_EN);
- usleep_range(1000, 1500);
-
- sw_pad_pulldown_val = readl(amd_manager->acp_mmio + ACP_PAD_PULLDOWN_CTRL);
- sw_pad_pulldown_val &= amd_manager->reg_mask->sw_pad_pulldown_mask;
- writel(sw_pad_pulldown_val, amd_manager->acp_mmio + ACP_PAD_PULLDOWN_CTRL);
- mutex_unlock(amd_manager->acp_sdw_lock);
-}
-
static int amd_init_sdw_manager(struct amd_sdw_manager *amd_manager)
{
u32 val;
@@ -872,7 +855,6 @@ int amd_sdw_manager_start(struct amd_sdw_manager *amd_manager)
prop = &amd_manager->bus.prop;
if (!prop->hw_disabled) {
- amd_enable_sdw_pads(amd_manager);
ret = amd_init_sdw_manager(amd_manager);
if (ret)
return ret;
--
2.34.1
next prev parent reply other threads:[~2024-01-29 5:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20240129055147.1493853-1-Vijendar.Mukunda@amd.com>
2024-01-29 5:51 ` [PATCH V4 01/13] ASoC/soundwire: implement generic api for scanning amd soundwire controller Vijendar Mukunda
2024-01-29 5:51 ` [PATCH V4 02/13] soundwire: amd: update license Vijendar Mukunda
2024-01-30 15:58 ` Vinod Koul
2024-01-29 5:51 ` [PATCH V4 03/13] soundwire: amd: refactor amd soundwire manager device node creation Vijendar Mukunda
2024-01-30 16:00 ` Vinod Koul
2024-01-29 5:51 ` [PATCH V4 04/13] soundwire: amd: implement function to extract slave information Vijendar Mukunda
2024-01-30 15:59 ` Vinod Koul
2024-01-29 5:51 ` Vijendar Mukunda [this message]
2024-01-30 16:00 ` [PATCH V4 05/13] soundwire: amd: refactor soundwire pads enable Vinod Koul
2024-01-29 5:51 ` [PATCH V4 06/13] soundwire: amd: refactor register mask structure Vijendar Mukunda
2024-01-30 16:00 ` Vinod Koul
2024-01-29 5:51 ` [PATCH V4 07/13] ASoC: SOF: amd: add code for invoking soundwire manager helper functions Vijendar Mukunda
2024-01-29 5:51 ` [PATCH V4 08/13] ASoC: SOF: amd: add interrupt handling for SoundWire manager devices Vijendar Mukunda
2024-01-29 5:51 ` [PATCH V4 09/13] ASoC: SOF: amd: Add Soundwire DAI configuration support for AMD platforms Vijendar Mukunda
2024-01-29 5:51 ` [PATCH V4 10/13] ASoC: SOF: amd: add machine select logic for soundwire based platforms Vijendar Mukunda
2024-01-29 5:51 ` [PATCH V4 11/13] ASoC: SOF: amd: update descriptor fields for acp6.3 based platform Vijendar Mukunda
2024-01-29 5:51 ` [PATCH V4 12/13] ASoC: SOF: amd: select soundwire dependency flag " Vijendar Mukunda
2024-01-29 5:51 ` [PATCH V4 13/13] ASoC: SOF: amd: refactor acp driver pm ops Vijendar Mukunda
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=20240129055147.1493853-6-Vijendar.Mukunda@amd.com \
--to=vijendar.mukunda@amd.com \
--cc=Basavaraj.Hiregoudar@amd.com \
--cc=Sunil-kumar.Dommati@amd.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=venkataprasad.potturu@amd.com \
--cc=vinod.koul@intel.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®