Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+91 -21
+56 -2
sound/soc/sh/rcar/core.c
··· 1125 1125 of_node_put(remote_node); 1126 1126 } 1127 1127 1128 - void rsnd_parse_connect_common(struct rsnd_dai *rdai, 1128 + void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name, 1129 1129 struct rsnd_mod* (*mod_get)(struct rsnd_priv *priv, int id), 1130 1130 struct device_node *node, 1131 1131 struct device_node *playback, ··· 1140 1140 1141 1141 i = 0; 1142 1142 for_each_child_of_node(node, np) { 1143 - struct rsnd_mod *mod = mod_get(priv, i); 1143 + struct rsnd_mod *mod; 1144 + 1145 + i = rsnd_node_fixed_index(np, name, i); 1146 + 1147 + mod = mod_get(priv, i); 1144 1148 1145 1149 if (np == playback) 1146 1150 rsnd_dai_connect(mod, &rdai->playback, mod->type); ··· 1154 1150 } 1155 1151 1156 1152 of_node_put(node); 1153 + } 1154 + 1155 + int rsnd_node_fixed_index(struct device_node *node, char *name, int idx) 1156 + { 1157 + char node_name[16]; 1158 + 1159 + /* 1160 + * rsnd is assuming each device nodes are sequential numbering, 1161 + * but some of them are not. 1162 + * This function adjusts index for it. 1163 + * 1164 + * ex) 1165 + * Normal case, special case 1166 + * ssi-0 1167 + * ssi-1 1168 + * ssi-2 1169 + * ssi-3 ssi-3 1170 + * ssi-4 ssi-4 1171 + * ... 1172 + * 1173 + * assume Max 64 node 1174 + */ 1175 + for (; idx < 64; idx++) { 1176 + snprintf(node_name, sizeof(node_name), "%s-%d", name, idx); 1177 + 1178 + if (strncmp(node_name, of_node_full_name(node), sizeof(node_name)) == 0) 1179 + return idx; 1180 + } 1181 + 1182 + return -EINVAL; 1183 + } 1184 + 1185 + int rsnd_node_count(struct rsnd_priv *priv, struct device_node *node, char *name) 1186 + { 1187 + struct device *dev = rsnd_priv_to_dev(priv); 1188 + struct device_node *np; 1189 + int i; 1190 + 1191 + i = 0; 1192 + for_each_child_of_node(node, np) { 1193 + i = rsnd_node_fixed_index(np, name, i); 1194 + if (i < 0) { 1195 + dev_err(dev, "strange node numbering (%s)", 1196 + of_node_full_name(node)); 1197 + return 0; 1198 + } 1199 + i++; 1200 + } 1201 + 1202 + return i; 1157 1203 } 1158 1204 1159 1205 static struct device_node *rsnd_dai_of_node(struct rsnd_priv *priv,
+5 -3
sound/soc/sh/rcar/dma.c
··· 237 237 return 0; 238 238 } 239 239 240 - struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, 241 - struct rsnd_mod *mod, char *name) 240 + struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, char *name, 241 + struct rsnd_mod *mod, char *x) 242 242 { 243 243 struct dma_chan *chan = NULL; 244 244 struct device_node *np; 245 245 int i = 0; 246 246 247 247 for_each_child_of_node(of_node, np) { 248 + i = rsnd_node_fixed_index(np, name, i); 249 + 248 250 if (i == rsnd_mod_id_raw(mod) && (!chan)) 249 - chan = of_dma_request_slave_channel(np, name); 251 + chan = of_dma_request_slave_channel(np, x); 250 252 i++; 251 253 } 252 254
+1 -1
sound/soc/sh/rcar/dvc.c
··· 282 282 struct rsnd_priv *priv = rsnd_mod_to_priv(mod); 283 283 284 284 return rsnd_dma_request_channel(rsnd_dvc_of_node(priv), 285 - mod, "tx"); 285 + DVC_NAME, mod, "tx"); 286 286 } 287 287 288 288 #ifdef CONFIG_DEBUG_FS
+9 -7
sound/soc/sh/rcar/rsnd.h
··· 269 269 int rsnd_dma_attach(struct rsnd_dai_stream *io, 270 270 struct rsnd_mod *mod, struct rsnd_mod **dma_mod); 271 271 int rsnd_dma_probe(struct rsnd_priv *priv); 272 - struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, 273 - struct rsnd_mod *mod, char *name); 272 + struct dma_chan *rsnd_dma_request_channel(struct device_node *of_node, char *name, 273 + struct rsnd_mod *mod, char *x); 274 274 275 275 /* 276 276 * R-Car sound mod ··· 460 460 #define for_each_rsnd_mod_array(iterator, pos, io, array) \ 461 461 for_each_rsnd_mod_arrays(iterator, pos, io, array, ARRAY_SIZE(array)) 462 462 463 - void rsnd_parse_connect_common(struct rsnd_dai *rdai, 463 + void rsnd_parse_connect_common(struct rsnd_dai *rdai, char *name, 464 464 struct rsnd_mod* (*mod_get)(struct rsnd_priv *priv, int id), 465 465 struct device_node *node, 466 466 struct device_node *playback, 467 467 struct device_node *capture); 468 + int rsnd_node_count(struct rsnd_priv *priv, struct device_node *node, char *name); 469 + int rsnd_node_fixed_index(struct device_node *node, char *name, int idx); 468 470 469 471 int rsnd_channel_normalization(int chan); 470 472 #define rsnd_runtime_channel_original(io) \ ··· 829 827 830 828 #define rsnd_src_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_SRC) 831 829 #define rsnd_parse_connect_src(rdai, playback, capture) \ 832 - rsnd_parse_connect_common(rdai, rsnd_src_mod_get, \ 830 + rsnd_parse_connect_common(rdai, "src", rsnd_src_mod_get, \ 833 831 rsnd_src_of_node(rsnd_rdai_to_priv(rdai)), \ 834 832 playback, capture) 835 833 ··· 841 839 struct rsnd_mod *rsnd_ctu_mod_get(struct rsnd_priv *priv, int id); 842 840 #define rsnd_ctu_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_CTU) 843 841 #define rsnd_parse_connect_ctu(rdai, playback, capture) \ 844 - rsnd_parse_connect_common(rdai, rsnd_ctu_mod_get, \ 842 + rsnd_parse_connect_common(rdai, "ctu", rsnd_ctu_mod_get, \ 845 843 rsnd_ctu_of_node(rsnd_rdai_to_priv(rdai)), \ 846 844 playback, capture) 847 845 ··· 853 851 struct rsnd_mod *rsnd_mix_mod_get(struct rsnd_priv *priv, int id); 854 852 #define rsnd_mix_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_MIX) 855 853 #define rsnd_parse_connect_mix(rdai, playback, capture) \ 856 - rsnd_parse_connect_common(rdai, rsnd_mix_mod_get, \ 854 + rsnd_parse_connect_common(rdai, "mix", rsnd_mix_mod_get, \ 857 855 rsnd_mix_of_node(rsnd_rdai_to_priv(rdai)), \ 858 856 playback, capture) 859 857 ··· 865 863 struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id); 866 864 #define rsnd_dvc_of_node(priv) rsnd_parse_of_node(priv, RSND_NODE_DVC) 867 865 #define rsnd_parse_connect_dvc(rdai, playback, capture) \ 868 - rsnd_parse_connect_common(rdai, rsnd_dvc_mod_get, \ 866 + rsnd_parse_connect_common(rdai, "dvc", rsnd_dvc_mod_get, \ 869 867 rsnd_dvc_of_node(rsnd_rdai_to_priv(rdai)), \ 870 868 playback, capture) 871 869
+4 -2
sound/soc/sh/rcar/src.c
··· 82 82 int is_play = rsnd_io_is_play(io); 83 83 84 84 return rsnd_dma_request_channel(rsnd_src_of_node(priv), 85 - mod, 85 + SRC_NAME, mod, 86 86 is_play ? "rx" : "tx"); 87 87 } 88 88 ··· 656 656 if (!node) 657 657 return 0; /* not used is not error */ 658 658 659 - nr = of_get_child_count(node); 659 + nr = rsnd_node_count(priv, node, SRC_NAME); 660 660 if (!nr) { 661 661 ret = -EINVAL; 662 662 goto rsnd_src_probe_done; ··· 675 675 for_each_child_of_node(node, np) { 676 676 if (!of_device_is_available(np)) 677 677 goto skip; 678 + 679 + i = rsnd_node_fixed_index(np, SRC_NAME, i); 678 680 679 681 src = rsnd_src_get(priv, i); 680 682
+9 -3
sound/soc/sh/rcar/ssi.c
··· 1019 1019 name = is_play ? "rx" : "tx"; 1020 1020 1021 1021 return rsnd_dma_request_channel(rsnd_ssi_of_node(priv), 1022 - mod, name); 1022 + SSI_NAME, mod, name); 1023 1023 } 1024 1024 1025 1025 #ifdef CONFIG_DEBUG_FS ··· 1115 1115 1116 1116 i = 0; 1117 1117 for_each_child_of_node(node, np) { 1118 - struct rsnd_mod *mod = rsnd_ssi_mod_get(priv, i); 1118 + struct rsnd_mod *mod; 1119 + 1120 + i = rsnd_node_fixed_index(np, SSI_NAME, i); 1121 + 1122 + mod = rsnd_ssi_mod_get(priv, i); 1119 1123 1120 1124 if (np == playback) 1121 1125 rsnd_ssi_connect(mod, &rdai->playback); ··· 1162 1158 if (!node) 1163 1159 return -EINVAL; 1164 1160 1165 - nr = of_get_child_count(node); 1161 + nr = rsnd_node_count(priv, node, SSI_NAME); 1166 1162 if (!nr) { 1167 1163 ret = -EINVAL; 1168 1164 goto rsnd_ssi_probe_done; ··· 1181 1177 for_each_child_of_node(node, np) { 1182 1178 if (!of_device_is_available(np)) 1183 1179 goto skip; 1180 + 1181 + i = rsnd_node_fixed_index(np, SSI_NAME, i); 1184 1182 1185 1183 ssi = rsnd_ssi_get(priv, i); 1186 1184
+7 -3
sound/soc/sh/rcar/ssiu.c
··· 395 395 name = is_play ? "rx" : "tx"; 396 396 397 397 return rsnd_dma_request_channel(rsnd_ssiu_of_node(priv), 398 - mod, name); 398 + SSIU_NAME, mod, name); 399 399 } 400 400 401 401 #ifdef CONFIG_DEBUG_FS ··· 470 470 int i = 0; 471 471 472 472 for_each_child_of_node(node, np) { 473 - struct rsnd_mod *mod = rsnd_ssiu_mod_get(priv, i); 473 + struct rsnd_mod *mod; 474 + 475 + i = rsnd_node_fixed_index(np, SSIU_NAME, i); 476 + 477 + mod = rsnd_ssiu_mod_get(priv, i); 474 478 475 479 if (np == playback) 476 480 rsnd_dai_connect(mod, io_p, mod->type); ··· 511 507 */ 512 508 node = rsnd_ssiu_of_node(priv); 513 509 if (node) 514 - nr = of_get_child_count(node); 510 + nr = rsnd_node_count(priv, node, SSIU_NAME); 515 511 else 516 512 nr = priv->ssi_nr; 517 513