* [PATCH v2 1/2] dt-bindings: sound: simple-card: add system-clock-id property
2026-05-15 16:13 [PATCH v2 0/2] ASoC: simple-card-utils: support system-clock-id DT property Sen Wang
@ 2026-05-15 16:13 ` Sen Wang
2026-05-15 16:13 ` [PATCH v2 2/2] ASoC: simple-card-utils: support system-clock-id DT property Sen Wang
2026-05-15 19:32 ` [PATCH v2 0/2] " Wang, Sen
2 siblings, 0 replies; 5+ messages in thread
From: Sen Wang @ 2026-05-15 16:13 UTC (permalink / raw)
To: Mark Brown, Kuninori Morimoto, Liam Girdwood, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai
Cc: linux-sound, devicetree, linux-kernel, Sen Wang
Document the new optional "system-clock-id" u32 property for cpu/codec
sub-nodes in simple-audio-card and audio-graph-card.
The property maps directly to the clk_id argument of
snd_soc_dai_set_sysclk(). When absent the existing default of 0 is
used, so no existing DT is affected. CPU and codec sub-nodes are
parsed independently; each side may carry a different value to select
different clock sources on the two DAIs within the same dai-link.
Signed-off-by: Sen Wang <sen@ti.com>
---
changes in V2:
- Newly added (V1 is RFC)
diff --git a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
index d1cbfc5edd3a..8094a76b9b4a 100644
--- a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
+++ b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
@@ -67,6 +67,8 @@ definitions:
$ref: simple-card.yaml#/definitions/system-clock-direction-out
system-clock-fixed:
$ref: simple-card.yaml#/definitions/system-clock-fixed
+ system-clock-id:
+ $ref: simple-card.yaml#/definitions/system-clock-id
dai-format:
description: audio format.
diff --git a/Documentation/devicetree/bindings/sound/simple-card.yaml b/Documentation/devicetree/bindings/sound/simple-card.yaml
index a14716b2732f..47a02d340d5e 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.yaml
+++ b/Documentation/devicetree/bindings/sound/simple-card.yaml
@@ -49,6 +49,14 @@ definitions:
single fixed sampling rate.
$ref: /schemas/types.yaml#/definitions/flag
+ system-clock-id:
+ description:
+ Selects which system clock to configure via set_sysclk(). Corresponds
+ to the clk_id argument of snd_soc_dai_set_sysclk(). When absent the
+ driver default (0) is used. CPU and codec sub-nodes are parsed
+ independently so each side may carry a different value.
+ $ref: /schemas/types.yaml#/definitions/uint32
+
mclk-fs:
description: |
Multiplication factor between stream rate and codec mclk.
@@ -135,6 +143,8 @@ definitions:
$ref: "#/definitions/system-clock-direction-out"
system-clock-fixed:
$ref: "#/definitions/system-clock-fixed"
+ system-clock-id:
+ $ref: "#/definitions/system-clock-id"
required:
- sound-dai
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH v2 2/2] ASoC: simple-card-utils: support system-clock-id DT property
2026-05-15 16:13 [PATCH v2 0/2] ASoC: simple-card-utils: support system-clock-id DT property Sen Wang
2026-05-15 16:13 ` [PATCH v2 1/2] dt-bindings: sound: simple-card: add system-clock-id property Sen Wang
@ 2026-05-15 16:13 ` Sen Wang
2026-05-15 16:37 ` sashiko-bot
2026-05-15 19:32 ` [PATCH v2 0/2] " Wang, Sen
2 siblings, 1 reply; 5+ messages in thread
From: Sen Wang @ 2026-05-15 16:13 UTC (permalink / raw)
To: Mark Brown, Kuninori Morimoto, Liam Girdwood, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai
Cc: linux-sound, devicetree, linux-kernel, Sen Wang
The generic machine driver never had a mechanism to adjust for various
clk_ids that is tailored for individual codec & cpu peripheral driver.
simple_util_dai_init() has hardcoded 0, thus making non-default clock IDs
unreachable from DTS. Boards needing a specific clk_id have had no choice
but to write dedicated machine drivers.
Add an optional "system-clock-id" u32 property to the cpu/codec
sub-node and use it in all three set_sysclk() call sites. When absent
clk_id stays 0, preserving identical behavior for all existing boards.
And since simple_util_parse_clk() is invoked once per sub-node, per-DAI
independence can be preserved as cpu and codec sub-nodes carry independent
clk_id values.
E.g., the following dts topology would be supported:
cpu { system-clock-id = <6>; }
codec { system-clock-id = <1>; }
Signed-off-by: Sen Wang <sen@ti.com>
---
Apologies Morimoto-san, when finalizing the patch I realize a few more
places need to be changed, can you kindly re-review and give your
acked-by?
Changes in v2:
- Adopted sysclk func changes for mclk cases
- Links to v1 (RFC):
https://lore.kernel.org/all/20260514212802.3569643-1-sen@ti.com/
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index 915e6ae5f68d..f221fba92e5e 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -26,6 +26,7 @@ struct simple_util_dai {
const char *name;
unsigned int sysclk;
int clk_direction;
+ int clk_id;
int slots;
int slot_width;
unsigned int tx_slot_mask;
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 4cf3a5395763..ce7e960db5e9 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -290,6 +290,9 @@ int simple_util_parse_clk(struct device *dev,
if (of_property_read_bool(node, "system-clock-direction-out"))
simple_dai->clk_direction = SND_SOC_CLOCK_OUT;
+ if (!of_property_read_u32(node, "system-clock-id", &val))
+ simple_dai->clk_id = val;
+
return 0;
}
EXPORT_SYMBOL_GPL(simple_util_parse_clk);
@@ -506,14 +509,16 @@ int simple_util_hw_params(struct snd_pcm_substream *substream,
/* CPU first */
for_each_rtd_cpu_dais(rtd, i, sdai) {
pdai = simple_props_to_dai_cpu(props, i);
- ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, pdai->clk_direction);
+ ret = snd_soc_dai_set_sysclk(sdai, pdai->clk_id,
+ mclk, pdai->clk_direction);
if (ret && ret != -ENOTSUPP)
goto end;
}
for_each_rtd_codec_dais(rtd, i, sdai) {
pdai = simple_props_to_dai_codec(props, i);
- ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, pdai->clk_direction);
+ ret = snd_soc_dai_set_sysclk(sdai, pdai->clk_id,
+ mclk, pdai->clk_direction);
if (ret && ret != -ENOTSUPP)
goto end;
}
@@ -521,14 +526,16 @@ int simple_util_hw_params(struct snd_pcm_substream *substream,
/* default: codec first */
for_each_rtd_codec_dais(rtd, i, sdai) {
pdai = simple_props_to_dai_codec(props, i);
- ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, pdai->clk_direction);
+ ret = snd_soc_dai_set_sysclk(sdai, pdai->clk_id,
+ mclk, pdai->clk_direction);
if (ret && ret != -ENOTSUPP)
goto end;
}
for_each_rtd_cpu_dais(rtd, i, sdai) {
pdai = simple_props_to_dai_cpu(props, i);
- ret = snd_soc_dai_set_sysclk(sdai, 0, mclk, pdai->clk_direction);
+ ret = snd_soc_dai_set_sysclk(sdai, pdai->clk_id,
+ mclk, pdai->clk_direction);
if (ret && ret != -ENOTSUPP)
goto end;
}
@@ -587,7 +594,8 @@ static int simple_init_dai(struct simple_util_priv *priv,
return 0;
if (simple_dai->sysclk) {
- ret = snd_soc_dai_set_sysclk(dai, 0, simple_dai->sysclk,
+ ret = snd_soc_dai_set_sysclk(dai, simple_dai->clk_id,
+ simple_dai->sysclk,
simple_dai->clk_direction);
if (ret && ret != -ENOTSUPP) {
dev_err(dai->dev, "simple-card: set_sysclk error\n");
^ permalink raw reply related [flat|nested] 5+ messages in thread