diff options
author | Mark Brown <broonie@kernel.org> | 2021-06-01 18:10:39 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-06-01 18:10:39 +0100 |
commit | d86eb3349b4000c87dabc3c0d676a3d0bec4a3d9 (patch) | |
tree | 08eb6a2a775206e2f0648687c0849ccda969b51a /sound | |
parent | 1f763d0388af6f6cffcdb1080ce112c63d766809 (diff) | |
parent | c413983eb66a0f6de37c13f7da3dd5fa488e5967 (diff) |
Merge series "ASoC: rsnd: adjust disabled module for R-Car D3" from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:
Hi Mark, Geert
Renesas Sound driver is assuming that all SSI/SRC
are connected.
But some SSI/SRC are not connected on Some Renesas SoC.
ex)
H2 E2
SRC0 <=
SRC1 SRC1
SRC2 SRC2
... ...
We accepted it by using "status = disabled" on DT before.
ex)
rcar_sound,src {
src-0 {
=> status = "disabled";
};
src1: src-1 {
...
};
...
But R-Car D3 have many disabled modules (It has SSI3/SSI4, SRC5/SRC6),
and Renesas SoC maintainer don't want above style on DT.
ex)
rcar_sound,src {
=> src0: src-0 { status = "disabled"; };
=> src1: src-1 { status = "disabled"; };
=> src2: src-2 { status = "disabled"; };
=> src3: src-3 { status = "disabled"; };
=> src4: src-4 { status = "disabled"; };
src5: src-5 {
...
};
...
This patch-set adjust to this situation, and enables to intuitive DT settings.
rcar_sound,src {
src5: src-5 {
...
};
src6: src-6 {
...
};
};
Kuninori Morimoto (4):
ASoC: rsnd: tidyup rsnd_parse_connect_common()
ASoC: rsnd: tidyup rsnd_dma_request_channel()
ASoC: rsnd: tidyup rsnd_parse_connect_xxx()
ASoC: rsnd: adjust disabled module
sound/soc/sh/rcar/core.c | 58 ++++++++++++++++++++++++++++++++++++++--
sound/soc/sh/rcar/dma.c | 8 +++---
sound/soc/sh/rcar/dvc.c | 2 +-
sound/soc/sh/rcar/rsnd.h | 16 ++++++-----
sound/soc/sh/rcar/src.c | 6 +++--
sound/soc/sh/rcar/ssi.c | 12 ++++++---
sound/soc/sh/rcar/ssiu.c | 10 ++++---
7 files changed, 91 insertions(+), 21 deletions(-)
--
2.25.1
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/sh/rcar/core.c | 58 | ||||
-rw-r--r-- | sound/soc/sh/rcar/dma.c | 8 | ||||
-rw-r--r-- | sound/soc/sh/rcar/dvc.c | 2 | ||||
-rw-r--r-- | sound/soc/sh/rcar/rsnd.h | 16 | ||||
-rw-r--r-- | sound/soc/sh/rcar/src.c | 6 | ||||
-rw-r--r-- | sound/soc/sh/rcar/ssi.c | 12 | ||||
-rw-r--r-- | sound/soc/sh/rcar/ssiu.c | 10 |
7 files changed, 91 insertions, 21 deletions
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 2dc8aee4ac12..a4ed9d8f022a 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1125,7 +1125,7 @@ static void rsnd_parse_connect_graph(struct rsnd_priv *priv, of_node_put(remote_node); } -void rsnd_parse_connect_common(struct rsnd_dai *rdai, +void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name, struct rsnd_mod* (*mod_get)(struct rsnd_priv *priv, int id), struct device_node *node, struct device_node *playback, @@ -1140,7 +1140,11 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, i = 0; for_each_child_of_node(node, np) { - struct rsnd_mod *mod = mod_get(priv, i); + struct rsnd_mod *mod; + + i = rsnd_node_fixed_index(np, name, i); + + mod = mod_get(priv, i); if (np == playback) rsnd_dai_connect(mod, &rdai->playback, mod->type); @@ -1152,6 +1156,56 @@ void rsnd_parse_connect_common(struct rsnd_dai *rdai, of_node_put(node); } +int rsnd_node_fixed_index(struct device_node *node, char *name, int idx) +{ + char node_name[16]; + + /* + * rsnd is assuming each device nodes are sequential numbering, + * but some of them are not. + * This function adjusts index for it. + * + * ex) + * Normal case, special case + * ssi-0 + * ssi-1 + * ssi-2 + * ssi-3 ssi-3 + * ssi-4 ssi-4 + * ... + * + * assume Max 64 node + */ + for (; idx < 64; idx++) { + snprintf(node_name, sizeof(node_name), "%s-%d", name, idx); + + if (strncmp(node_name, of_node_full_name(node), sizeof(node_name)) == 0) + return idx; + } + + return -EINVAL; +} + +int rsnd_node_count(struct rsnd_priv *priv, struct device_node *node, char *name) +{ + struct device *dev = rsnd_priv_to_dev(priv); + struct device_node *np; + int i; + + i = 0; + for_each_child_of_node(node, np) { + i = rsnd_node_fixed_index(np, name, i); + if (i < 0) { + dev_err(dev, "strange node numbering (%s)", + of_node_full_name(node)); + return 0; + } + i++; + } + + return i; +} + static struct device_node *rsnd_dai_of_node(struct rsnd_priv *priv, int *is_graph) { diff --git a/sound/soc/sh/rcar/dma.c b/sound/soc/sh/rcar/dma.c index 44519929a28b..82d16e037d9a 100644 --- a/sound/soc/sh/rcar/dma.c +++ b/sound/soc/sh/rcar/dma.c @@ -237,16 +237,18 @@ static int rsnd_dmaen_start(struct rsnd_mod *mod, return 0; } -struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, - struct rsnd_mod *mod, char *name) +struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, char *name, + struct rsnd_mod *mod, char *x) { struct dma_chan *chan = NULL; struct device_node *np; int i = 0; for_each_child_of_node(of_node, np) { + i = rsnd_node_fixed_index(np, name, i); + if (i == rsnd_mod_id_raw(mod) && (!chan)) - chan = of_dma_request_slave_channel(np, name); + chan = of_dma_request_slave_channel(np, x); i++; } diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 1943ac1ff803..5137e03a9d7c 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -282,7 +282,7 @@ static struct dma_chan *rsnd_dvc_dma_req(struct rsnd_dai_stream *io, struct rsnd_priv *priv = rsnd_mod_to_priv(mod); return rsnd_dma_request_channel(rsnd_dvc_of_node(priv), - mod, "tx"); + DVC_NAME, mod, "tx"); } #ifdef CONFIG_DEBUG_FS diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index d712615c9c9f..b2fbe3bbaabd 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -269,8 +269,8 @@ u32 rsnd_get_busif_shift(struct rsnd_dai_stream *io, struct rsnd_mod *mod); int rsnd_dma_attach(struct rsnd_dai_stream *io, struct rsnd_mod *mod, struct rsnd_mod **dma_mod); int rsnd_dma_probe(struct rsnd_priv *priv); -struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, - struct rsnd_mod *mod, char *name); +struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, char *name, + struct rsnd_mod *mod, char *x); /* * R-Car sound mod @@ -460,11 +460,13 @@ struct rsnd_mod *rsnd_mod_next(int *iterator, #define for_each_rsnd_mod_array(iterator, pos, io, array) \ for_each_rsnd_mod_arrays(iterator, pos, io, array, ARRAY_SIZE(array)) -void rsnd_parse_connect_common(struct rsnd_dai *rdai, +void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name, struct rsnd_mod* (*mod_get)(struct rsnd_priv *priv, int id), struct device_node *node, struct device_node *playback, struct device_node *capture); +int rsnd_node_count(struct rsnd_priv *priv, struct device_node *node, char *name); +int rsnd_node_fixed_index(struct device_node *node, char *name, int idx); int rsnd_channel_normalization(int chan); #define rsnd_runtime_channel_original(io) \ @@ -827,7 +829,7 @@ unsigned int rsnd_src_get_rate(struct rsnd_priv *priv, #define rsnd_src_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_SRC) #define rsnd_parse_connect_src(rdai, playback, capture) \ - rsnd_parse_connect_common(rdai, rsnd_src_mod_get, \ + rsnd_parse_connect_common(rdai, "src", rsnd_src_mod_get, \ rsnd_src_of_node(rsnd_rdai_to_priv(rdai)), \ playback, capture) @@ -839,7 +841,7 @@ void rsnd_ctu_remove(struct rsnd_priv *priv); struct rsnd_mod *rsnd_ctu_mod_get(struct rsnd_priv *priv, int id); #define rsnd_ctu_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_CTU) #define rsnd_parse_connect_ctu(rdai, playback, capture) \ - rsnd_parse_connect_common(rdai, rsnd_ctu_mod_get, \ + rsnd_parse_connect_common(rdai, "ctu", rsnd_ctu_mod_get, \ rsnd_ctu_of_node(rsnd_rdai_to_priv(rdai)), \ playback, capture) @@ -851,7 +853,7 @@ void rsnd_mix_remove(struct rsnd_priv *priv); struct rsnd_mod *rsnd_mix_mod_get(struct rsnd_priv *priv, int id); #define rsnd_mix_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_MIX) #define rsnd_parse_connect_mix(rdai, playback, capture) \ - rsnd_parse_connect_common(rdai, rsnd_mix_mod_get, \ + rsnd_parse_connect_common(rdai, "mix", rsnd_mix_mod_get, \ rsnd_mix_of_node(rsnd_rdai_to_priv(rdai)), \ playback, capture) @@ -863,7 +865,7 @@ void rsnd_dvc_remove(struct rsnd_priv *priv); struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id); #define rsnd_dvc_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_DVC) #define rsnd_parse_connect_dvc(rdai, playback, capture) \ - rsnd_parse_connect_common(rdai, rsnd_dvc_mod_get, \ + rsnd_parse_connect_common(rdai, "dvc", rsnd_dvc_mod_get, \ rsnd_dvc_of_node(rsnd_rdai_to_priv(rdai)), \ playback, capture) diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 8f7af3e3a1cd..42a100c6303d 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -82,7 +82,7 @@ static struct dma_chan *rsnd_src_dma_req(struct rsnd_dai_stream *io, int is_play = rsnd_io_is_play(io); return rsnd_dma_request_channel(rsnd_src_of_node(priv), - mod, + SRC_NAME, mod, is_play ? "rx" : "tx"); } @@ -656,7 +656,7 @@ int rsnd_src_probe(struct rsnd_priv *priv) if (!node) return 0; /* not used is not error */ - nr = of_get_child_count(node); + nr = rsnd_node_count(priv, node, SRC_NAME); if (!nr) { ret = -EINVAL; goto rsnd_src_probe_done; @@ -676,6 +676,8 @@ int rsnd_src_probe(struct rsnd_priv *priv) if (!of_device_is_available(np)) goto skip; + i = rsnd_node_fixed_index(np, SRC_NAME, i); + src = rsnd_src_get(priv, i); snprintf(name, RSND_SRC_NAME_SIZE, "%s.%d", diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index facdd8c0d419..27f34ca6059d 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -1019,7 +1019,7 @@ static struct dma_chan *rsnd_ssi_dma_req(struct rsnd_dai_stream *io, name = is_play ? "rx" : "tx"; return rsnd_dma_request_channel(rsnd_ssi_of_node(priv), - mod, name); + SSI_NAME, mod, name); } #ifdef CONFIG_DEBUG_FS @@ -1115,7 +1115,11 @@ void rsnd_parse_connect_ssi(struct rsnd_dai *rdai, i = 0; for_each_child_of_node(node, np) { - struct rsnd_mod *mod = rsnd_ssi_mod_get(priv, i); + struct rsnd_mod *mod; + + i = rsnd_node_fixed_index(np, SSI_NAME, i); + + mod = rsnd_ssi_mod_get(priv, i); if (np == playback) rsnd_ssi_connect(mod, &rdai->playback); @@ -1158,7 +1162,7 @@ int rsnd_ssi_probe(struct rsnd_priv *priv) if (!node) return -EINVAL; - nr = of_get_child_count(node); + nr = rsnd_node_count(priv, node, SSI_NAME); if (!nr) { ret = -EINVAL; goto rsnd_ssi_probe_done; @@ -1178,6 +1182,8 @@ int rsnd_ssi_probe(struct rsnd_priv *priv) if (!of_device_is_available(np)) goto skip; + i = rsnd_node_fixed_index(np, SSI_NAME, i); + ssi = rsnd_ssi_get(priv, i); snprintf(name, RSND_SSI_NAME_SIZE, "%s.%d", diff --git a/sound/soc/sh/rcar/ssiu.c b/sound/soc/sh/rcar/ssiu.c index 4363508e8250..5682c74bb7ff 100644 --- a/sound/soc/sh/rcar/ssiu.c +++ b/sound/soc/sh/rcar/ssiu.c @@ -395,7 +395,7 @@ static struct dma_chan *rsnd_ssiu_dma_req(struct rsnd_dai_stream *io, name = is_play ? "rx" : "tx"; return rsnd_dma_request_channel(rsnd_ssiu_of_node(priv), - mod, name); + SSIU_NAME, mod, name); } #ifdef CONFIG_DEBUG_FS @@ -470,7 +470,11 @@ void rsnd_parse_connect_ssiu(struct rsnd_dai *rdai, int i = 0; for_each_child_of_node(node, np) { - struct rsnd_mod *mod = rsnd_ssiu_mod_get(priv, i); + struct rsnd_mod *mod; + + i = rsnd_node_fixed_index(np, SSIU_NAME, i); + + mod = rsnd_ssiu_mod_get(priv, i); if (np == playback) rsnd_dai_connect(mod, io_p, mod->type); @@ -507,7 +511,7 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv) */ node = rsnd_ssiu_of_node(priv); if (node) - nr = of_get_child_count(node); + nr = rsnd_node_count(priv, node, SSIU_NAME); else nr = priv->ssi_nr; |