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
Cc: vinod.koul@linaro.org, linux-kernel@vger.kernel.org,
	pierre-louis.bossart@linux.intel.com, bard.liao@intel.com
Subject: [PATCH 12/16] soundwire: cadence: add helpers to access IP_MCP registers
Date: Tue, 14 Mar 2023 09:54:06 +0800	[thread overview]
Message-ID: <20230314015410.487311-13-yung-chuan.liao@linux.intel.com> (raw)
In-Reply-To: <20230314015410.487311-1-yung-chuan.liao@linux.intel.com>

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

The latest Cadence IP splits some of the existing registers into two,
separated by a fixed offset. The bitfields themselves remain at the
same position, so we can use new helpers to dynamically add the fixed
offset.

For example, the existing MCP_CONFIG is now split in two with
MCP_CONFIG and IP_MCP_CONFIG (the naming comes directly from the
design document).

This patch adds helpers to access registers with the IP_ prefix. The
addition of the 'ip' prefix for helpers, registers and bitfields is
intentional to help reviewers spot any mistake.

For existing solutions, the offset is exactly zero so there's no
functional change - the MCP_CONFIG and IP_MCP_CONFIG are aliased to
the same address.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
 drivers/soundwire/cadence_master.c | 16 ++++++++++++++++
 drivers/soundwire/cadence_master.h |  3 +++
 2 files changed, 19 insertions(+)

diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c
index 4f34fc72dbd5..4461a7fa4124 100644
--- a/drivers/soundwire/cadence_master.c
+++ b/drivers/soundwire/cadence_master.c
@@ -205,6 +205,16 @@ static inline void cdns_writel(struct sdw_cdns *cdns, int offset, u32 value)
 	writel(value, cdns->registers + offset);
 }
 
+static inline u32 cdns_ip_readl(struct sdw_cdns *cdns, int offset)
+{
+	return cdns_readl(cdns, cdns->ip_offset + offset);
+}
+
+static inline void cdns_ip_writel(struct sdw_cdns *cdns, int offset, u32 value)
+{
+	return cdns_writel(cdns, cdns->ip_offset + offset, value);
+}
+
 static inline void cdns_updatel(struct sdw_cdns *cdns,
 				int offset, u32 mask, u32 val)
 {
@@ -215,6 +225,12 @@ static inline void cdns_updatel(struct sdw_cdns *cdns,
 	cdns_writel(cdns, offset, tmp);
 }
 
+static inline void cdns_ip_updatel(struct sdw_cdns *cdns,
+				   int offset, u32 mask, u32 val)
+{
+	cdns_updatel(cdns, cdns->ip_offset + offset, mask, val);
+}
+
 static int cdns_set_wait(struct sdw_cdns *cdns, int offset, u32 mask, u32 value)
 {
 	int timeout = 10;
diff --git a/drivers/soundwire/cadence_master.h b/drivers/soundwire/cadence_master.h
index dec0b4f993c1..b653734085d9 100644
--- a/drivers/soundwire/cadence_master.h
+++ b/drivers/soundwire/cadence_master.h
@@ -107,6 +107,7 @@ struct sdw_cdns_dai_runtime {
  * @dev: Linux device
  * @bus: Bus handle
  * @instance: instance number
+ * @ip_offset: version-dependent offset to access IP_MCP registers and fields
  * @response_buf: SoundWire response buffer
  * @tx_complete: Tx completion
  * @ports: Data ports
@@ -122,6 +123,8 @@ struct sdw_cdns {
 	struct sdw_bus bus;
 	unsigned int instance;
 
+	u32 ip_offset;
+
 	/*
 	 * The datasheet says the RX FIFO AVAIL can be 2 entries more
 	 * than the FIFO capacity, so allow for this.
-- 
2.25.1


  parent reply	other threads:[~2023-03-14  1:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14  1:53 [PATCH 00/16] soundwire: updates before LunarLake introduction Bard Liao
2023-03-14  1:53 ` [PATCH 01/16] soundwire: intel: move common definitions to header file Bard Liao
2023-03-14  1:53 ` [PATCH 02/16] soundwire: intel: remove stale/misleading comment Bard Liao
2023-03-14  1:53 ` [PATCH 03/16] soundwire: intel: remove PDI-level restrictions on rates and formats Bard Liao
2023-03-14  1:53 ` [PATCH 04/16] soundwire: intel: remove useless abstraction Bard Liao
2023-03-14  1:53 ` [PATCH 05/16] soundwire: intel: simplify sync_go sequence Bard Liao
2023-03-14  1:54 ` [PATCH 06/16] soundwire: intel: add sync_arm/sync_go to ops Bard Liao
2023-03-14  1:54 ` [PATCH 07/16] soundwire: intel: use indirection before moving bus start/stop sequences Bard Liao
2023-03-14  1:54 ` [PATCH 08/16] soundwire: intel: move bus common sequences to different file Bard Liao
2023-03-14  1:54 ` [PATCH 09/16] soundwire: intel: add abstraction for cmdsync check Bard Liao
2023-03-14  1:54 ` [PATCH 10/16] soundwire: intel: move bank switch routine to common intel_bus_common.c Bard Liao
2023-03-14  1:54 ` [PATCH 11/16] soundwire: cadence: remove CDNS_MCP_CONFIG_SSPMOD Bard Liao
2023-03-14  1:54 ` Bard Liao [this message]
2023-03-14  1:54 ` [PATCH 13/16] soundwire: cadence: split access to IP_MCP_CONFIG fields Bard Liao
2023-03-14  1:54 ` [PATCH 14/16] soundwire: cadence: split access to IP_MCP_CONTROL fields Bard Liao
2023-03-14  1:54 ` [PATCH 15/16] soundwire: cadence: split access to IP_MCP_CMDCTRL fields Bard Liao
2023-03-14  1:54 ` [PATCH 16/16] soundwire: cadence: change access to IP_MCP_CMD_BASE Bard Liao
2023-03-15 13:54 ` [PATCH 00/16] soundwire: updates before LunarLake introduction Vinod Koul

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=20230314015410.487311-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=linux-kernel@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --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.