Skip to content

Commit 9402e25

Browse files
plbossartvinodkoul
authored andcommitted
soundwire: cadence: add helpers to access IP_MCP registers
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> Link: https://lore.kernel.org/r/20230314015410.487311-13-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent f117e90 commit 9402e25

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

drivers/soundwire/cadence_master.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,16 @@ static inline void cdns_writel(struct sdw_cdns *cdns, int offset, u32 value)
205205
writel(value, cdns->registers + offset);
206206
}
207207

208+
static inline u32 cdns_ip_readl(struct sdw_cdns *cdns, int offset)
209+
{
210+
return cdns_readl(cdns, cdns->ip_offset + offset);
211+
}
212+
213+
static inline void cdns_ip_writel(struct sdw_cdns *cdns, int offset, u32 value)
214+
{
215+
return cdns_writel(cdns, cdns->ip_offset + offset, value);
216+
}
217+
208218
static inline void cdns_updatel(struct sdw_cdns *cdns,
209219
int offset, u32 mask, u32 val)
210220
{
@@ -215,6 +225,12 @@ static inline void cdns_updatel(struct sdw_cdns *cdns,
215225
cdns_writel(cdns, offset, tmp);
216226
}
217227

228+
static inline void cdns_ip_updatel(struct sdw_cdns *cdns,
229+
int offset, u32 mask, u32 val)
230+
{
231+
cdns_updatel(cdns, cdns->ip_offset + offset, mask, val);
232+
}
233+
218234
static int cdns_set_wait(struct sdw_cdns *cdns, int offset, u32 mask, u32 value)
219235
{
220236
int timeout = 10;

drivers/soundwire/cadence_master.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ struct sdw_cdns_dai_runtime {
107107
* @dev: Linux device
108108
* @bus: Bus handle
109109
* @instance: instance number
110+
* @ip_offset: version-dependent offset to access IP_MCP registers and fields
110111
* @response_buf: SoundWire response buffer
111112
* @tx_complete: Tx completion
112113
* @ports: Data ports
@@ -122,6 +123,8 @@ struct sdw_cdns {
122123
struct sdw_bus bus;
123124
unsigned int instance;
124125

126+
u32 ip_offset;
127+
125128
/*
126129
* The datasheet says the RX FIFO AVAIL can be 2 entries more
127130
* than the FIFO capacity, so allow for this.

0 commit comments

Comments
 (0)