Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] soundwire: qcom: add SCP address paging support
@ 2026-07-06 19:21 Jorijn van der Graaf
  2026-07-06 20:57 ` Srinivas Kandagatla
  0 siblings, 1 reply; 2+ messages in thread
From: Jorijn van der Graaf @ 2026-07-06 19:21 UTC (permalink / raw)
  To: Vinod Koul, Bard Liao, Srinivas Kandagatla
  Cc: Jorijn van der Graaf, Pierre-Louis Bossart, Luca Weiss,
	Mohammad Rafi Shaik, linux-sound, linux-arm-msm, linux-kernel

The Qualcomm controller driver ignores the paging fields of struct
sdw_msg. For a paged access (register address >= 0x8000 on a
paging-capable peripheral, e.g. the SDCA control space at
0x40000000+) the core sets BIT(15) in the wire address and splits the
upper bits into addr_page1/addr_page2, but since the controller never
programmed the SCP_AddrPage registers the peripheral resolved every
such command against their reset value: reads and writes were
silently redirected to addr[14:0] in page 0.

Write the two SCP_AddrPage registers through the command FIFO before
the transfer, as cadence_master.c (cdns_program_scp_addr) and
amd_manager.c (amd_program_scp_addr) do. Like those controllers the
pages are programmed on every paged message rather than cached per
device; a cache can be a follow-up if the two extra FIFO commands
ever matter.

No peripheral on a Qualcomm bus sets prop.paging_support in mainline
today; the first user is the WCD9378 codec, whose driver is being
upstreamed separately - its entire register map, the
wcd937x-compatible analog core included, lives in the SDCA address
space.

Verified on the Fairphone 6 (SM7635): WCD9378 SDCA registers read
back their documented reset defaults and audio capture through the
codec works end-to-end; without this change every paged access landed
in page 0.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Jorijn van der Graaf <jorijnvdgraaf@catcrafts.net>
---
 drivers/soundwire/qcom.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index 603f228f46b5..3562802f4204 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -975,6 +975,20 @@ static enum sdw_command_response qcom_swrm_xfer_msg(struct sdw_bus *bus,
 	struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus);
 	int ret, i, len;
 
+	if (msg->page) {
+		ret = qcom_swrm_cmd_fifo_wr_cmd(ctrl, msg->addr_page1,
+						msg->dev_num,
+						SDW_SCP_ADDRPAGE1);
+		if (ret)
+			return ret;
+
+		ret = qcom_swrm_cmd_fifo_wr_cmd(ctrl, msg->addr_page2,
+						msg->dev_num,
+						SDW_SCP_ADDRPAGE2);
+		if (ret)
+			return ret;
+	}
+
 	if (msg->flags == SDW_MSG_FLAG_READ) {
 		for (i = 0; i < msg->len;) {
 			len = min(msg->len - i, QCOM_SWRM_MAX_RD_LEN);
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] soundwire: qcom: add SCP address paging support
  2026-07-06 19:21 [PATCH] soundwire: qcom: add SCP address paging support Jorijn van der Graaf
@ 2026-07-06 20:57 ` Srinivas Kandagatla
  0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Kandagatla @ 2026-07-06 20:57 UTC (permalink / raw)
  To: Jorijn van der Graaf, Vinod Koul, Bard Liao, Srinivas Kandagatla
  Cc: Pierre-Louis Bossart, Luca Weiss, Mohammad Rafi Shaik,
	linux-sound, linux-arm-msm, linux-kernel



On 7/6/26 8:21 PM, Jorijn van der Graaf wrote:
> The Qualcomm controller driver ignores the paging fields of struct
> sdw_msg. For a paged access (register address >= 0x8000 on a
> paging-capable peripheral, e.g. the SDCA control space at
> 0x40000000+) the core sets BIT(15) in the wire address and splits the
> upper bits into addr_page1/addr_page2, but since the controller never
> programmed the SCP_AddrPage registers the peripheral resolved every
> such command against their reset value: reads and writes were
> silently redirected to addr[14:0] in page 0.
> 
> Write the two SCP_AddrPage registers through the command FIFO before
> the transfer, as cadence_master.c (cdns_program_scp_addr) and
> amd_manager.c (amd_program_scp_addr) do. Like those controllers the
> pages are programmed on every paged message rather than cached per
> device; a cache can be a follow-up if the two extra FIFO commands
> ever matter.
> 
> No peripheral on a Qualcomm bus sets prop.paging_support in mainline
> today; the first user is the WCD9378 codec, whose driver is being
> upstreamed separately - its entire register map, the
> wcd937x-compatible analog core included, lives in the SDCA address
> space.
> 
> Verified on the Fairphone 6 (SM7635): WCD9378 SDCA registers read
> back their documented reset defaults and audio capture through the
> codec works end-to-end; without this change every paged access landed
> in page 0.
> 
> Assisted-by: Claude:claude-fable-5
> Signed-off-by: Jorijn van der Graaf <jorijnvdgraaf@catcrafts.net>
> ---
Thanks Jorjin for the patch, I have pretty much identical patch that I
was about to send.

LGTM,

Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com>

--srini
>  drivers/soundwire/qcom.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index 603f228f46b5..3562802f4204 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
> @@ -975,6 +975,20 @@ static enum sdw_command_response qcom_swrm_xfer_msg(struct sdw_bus *bus,
>  	struct qcom_swrm_ctrl *ctrl = to_qcom_sdw(bus);
>  	int ret, i, len;
>  
> +	if (msg->page) {
> +		ret = qcom_swrm_cmd_fifo_wr_cmd(ctrl, msg->addr_page1,
> +						msg->dev_num,
> +						SDW_SCP_ADDRPAGE1);
> +		if (ret)
> +			return ret;
> +
> +		ret = qcom_swrm_cmd_fifo_wr_cmd(ctrl, msg->addr_page2,
> +						msg->dev_num,
> +						SDW_SCP_ADDRPAGE2);
> +		if (ret)
> +			return ret;
> +	}
> +
>  	if (msg->flags == SDW_MSG_FLAG_READ) {
>  		for (i = 0; i < msg->len;) {
>  			len = min(msg->len - i, QCOM_SWRM_MAX_RD_LEN);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-06 20:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 19:21 [PATCH] soundwire: qcom: add SCP address paging support Jorijn van der Graaf
2026-07-06 20:57 ` Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox