All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bard Liao <yung-chuan.liao@linux.intel.com>
To: alsa-devel@alsa-project.org, vkoul@kernel.org, broonie@kernel.org
Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org,
	pierre-louis.bossart@linux.intel.com, bard.liao@intel.com,
	tiwai@suse.de
Subject: [PATCH 12/20] soundwire: intel_ace2x: set SYNCPRD before powering-up
Date: Thu, 23 Mar 2023 13:44:44 +0800	[thread overview]
Message-ID: <20230323054452.1543233-13-yung-chuan.liao@linux.intel.com> (raw)
In-Reply-To: <20230323054452.1543233-1-yung-chuan.liao@linux.intel.com>

From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

The registers used for multi-link synchronization are no longer in the
SHIM but in the HDaudio multi-link capability space. Use helpers to
configure the SYNCPRD value, and wait for SYNCPU to change after
powering-up.

Note that the SYNCPRD value is shared between all sublinks, for
obvious reasons if those links are supposed to be synchronized. The
value of SYNCPRD is programmed only once for all sublinks.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
 drivers/soundwire/intel_ace2x.c | 42 +++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/soundwire/intel_ace2x.c b/drivers/soundwire/intel_ace2x.c
index 5b6a608e63ba..01668246b7ba 100644
--- a/drivers/soundwire/intel_ace2x.c
+++ b/drivers/soundwire/intel_ace2x.c
@@ -17,17 +17,51 @@
 
 static int intel_link_power_up(struct sdw_intel *sdw)
 {
+	struct sdw_bus *bus = &sdw->cdns.bus;
+	struct sdw_master_prop *prop = &bus->prop;
+	u32 *shim_mask = sdw->link_res->shim_mask;
+	unsigned int link_id = sdw->instance;
+	u32 syncprd;
 	int ret;
 
 	mutex_lock(sdw->link_res->shim_lock);
 
-	ret = hdac_bus_eml_sdw_power_up_unlocked(sdw->link_res->hbus, sdw->instance);
+	if (!*shim_mask) {
+		/* we first need to program the SyncPRD/CPU registers */
+		dev_dbg(sdw->cdns.dev, "first link up, programming SYNCPRD\n");
+
+		if (prop->mclk_freq % 6000000)
+			syncprd = SDW_SHIM_SYNC_SYNCPRD_VAL_38_4;
+		else
+			syncprd = SDW_SHIM_SYNC_SYNCPRD_VAL_24;
+
+		ret =  hdac_bus_eml_sdw_set_syncprd_unlocked(sdw->link_res->hbus, syncprd);
+		if (ret < 0) {
+			dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_set_syncprd failed: %d\n",
+				__func__, ret);
+			goto out;
+		}
+	}
+
+	ret = hdac_bus_eml_sdw_power_up_unlocked(sdw->link_res->hbus, link_id);
 	if (ret < 0) {
 		dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_power_up failed: %d\n",
 			__func__, ret);
 		goto out;
 	}
 
+	if (!*shim_mask) {
+		/* SYNCPU will change once link is active */
+		ret =  hdac_bus_eml_sdw_wait_syncpu_unlocked(sdw->link_res->hbus);
+		if (ret < 0) {
+			dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_wait_syncpu failed: %d\n",
+				__func__, ret);
+			goto out;
+		}
+	}
+
+	*shim_mask |= BIT(link_id);
+
 	sdw->cdns.link_up = true;
 out:
 	mutex_unlock(sdw->link_res->shim_lock);
@@ -37,13 +71,17 @@ static int intel_link_power_up(struct sdw_intel *sdw)
 
 static int intel_link_power_down(struct sdw_intel *sdw)
 {
+	u32 *shim_mask = sdw->link_res->shim_mask;
+	unsigned int link_id = sdw->instance;
 	int ret;
 
 	mutex_lock(sdw->link_res->shim_lock);
 
 	sdw->cdns.link_up = false;
 
-	ret = hdac_bus_eml_sdw_power_down_unlocked(sdw->link_res->hbus, sdw->instance);
+	*shim_mask &= ~BIT(link_id);
+
+	ret = hdac_bus_eml_sdw_power_down_unlocked(sdw->link_res->hbus, link_id);
 	if (ret < 0) {
 		dev_err(sdw->cdns.dev, "%s: hdac_bus_eml_sdw_power_down failed: %d\n",
 			__func__, ret);
-- 
2.25.1


  parent reply	other threads:[~2023-03-23  5:31 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23  5:44 [PATCH 00/20] ASoC/soundwire: add support for ACE2.x Bard Liao
2023-03-23  5:44 ` [PATCH 01/20] ASoC: SOF: Intel: shim: add enum for ACE 2.0 IP used in LunarLake Bard Liao
2023-03-23 14:18   ` Mark Brown
2023-03-23  5:44 ` [PATCH 02/20] soundwire: intel: add ACE2.x SHIM definitions Bard Liao
2023-03-23  5:44 ` [PATCH 03/20] soundwire: intel_ace2x: add empty new ops for LunarLake Bard Liao
2023-03-23  5:44 ` [PATCH 04/20] soundwire/ASOC: Intel: update offsets " Bard Liao
2023-03-23 14:18   ` Mark Brown
2023-03-23  5:44 ` [PATCH 05/20] soundwire: intel/cadence: set ip_offset at run-time Bard Liao
2023-03-23  5:44 ` [PATCH 06/20] ASoC/soundwire: intel: pass hdac_bus pointer for link management Bard Liao
2023-03-23 14:19   ` Mark Brown
2023-03-23  5:44 ` [PATCH 07/20] soundwire: intel: add eml_lock in the interface for new platforms Bard Liao
2023-03-23  5:44 ` [PATCH 08/20] ASoC: SOF: Intel: hda: retrieve SoundWire eml_lock and pass pointer Bard Liao
2023-03-23 14:20   ` Mark Brown
2023-03-23  5:44 ` [PATCH 09/20] soundwire: intel_init: use eml_lock parameter Bard Liao
2023-03-23  5:44 ` [PATCH 10/20] soundwire: intel_ace2x: add debugfs support Bard Liao
2023-03-23  5:44 ` [PATCH 11/20] soundwire: intel_ace2x: add link power-up/down helpers Bard Liao
2023-03-23  5:44 ` Bard Liao [this message]
2023-03-23  5:44 ` [PATCH 13/20] soundwire: intel_ace2x: configure link PHY Bard Liao
2023-03-23  5:44 ` [PATCH 14/20] soundwire: intel_ace2x: add DAI registration Bard Liao
2023-03-23  5:44 ` [PATCH 15/20] soundwire: intel_ace2x: add sync_arm/sync_go helpers Bard Liao
2023-03-23  5:44 ` [PATCH 16/20] soundwire: intel_ace2x: use common helpers for bus start/stop Bard Liao
2023-03-23  5:44 ` [PATCH 17/20] soundwire: intel_ace2x: enable wake support Bard Liao
2023-03-23  5:44 ` [PATCH 18/20] soundwire: intel_ace2x: add check_cmdsync_unlocked helper Bard Liao
2023-03-23  5:44 ` [PATCH 19/20] soundwire: bus: add new manager callback to deal with peripheral enumeration Bard Liao
2023-03-23  5:44 ` [PATCH 20/20] soundwire: intel_ace2x: add new_peripheral_assigned callback Bard Liao
2023-03-23 14:15 ` [PATCH 00/20] ASoC/soundwire: add support for ACE2.x Liao, Bard
2023-04-12 10:07 ` Vinod Koul
2023-04-12 14:11   ` Pierre-Louis Bossart
2023-04-12 15:22     ` Vinod Koul
2023-04-12 16:06       ` Pierre-Louis Bossart

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=20230323054452.1543233-13-yung-chuan.liao@linux.intel.com \
    --to=yung-chuan.liao@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bard.liao@intel.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.de \
    --cc=vinod.koul@linaro.org \
    --cc=vkoul@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.