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

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: mt8188-mt6359: add SOF support

Merge series from Trevor Wu <trevor.wu@mediatek.com>:

This series introduces dynamic pinctrl and adds support for the SOF on
the mt8188-mt6359 machine driver.

+332 -28
+98 -15
sound/soc/mediatek/common/mtk-dsp-sof-common.c
··· 54 54 { 55 55 int i; 56 56 struct snd_soc_dai_link *dai_link; 57 + struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card); 58 + struct mtk_sof_priv *sof_priv = soc_card_data->sof_priv; 57 59 58 60 /* Set stream_name to help sof bind widgets */ 59 61 for_each_card_prelinks(card, i, dai_link) { ··· 63 61 dai_link->stream_name = dai_link->name; 64 62 } 65 63 64 + INIT_LIST_HEAD(&sof_priv->dai_link_list); 65 + 66 66 return 0; 67 67 } 68 68 EXPORT_SYMBOL_GPL(mtk_sof_card_probe); 69 + 70 + static struct snd_soc_pcm_runtime *mtk_sof_find_tplg_be(struct snd_soc_pcm_runtime *rtd) 71 + { 72 + struct snd_soc_card *card = rtd->card; 73 + struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card); 74 + struct mtk_sof_priv *sof_priv = soc_card_data->sof_priv; 75 + struct snd_soc_pcm_runtime *fe; 76 + struct snd_soc_pcm_runtime *be; 77 + struct snd_soc_dpcm *dpcm; 78 + int i, stream; 79 + 80 + for_each_pcm_streams(stream) { 81 + fe = NULL; 82 + for_each_dpcm_fe(rtd, stream, dpcm) { 83 + fe = dpcm->fe; 84 + if (fe) 85 + break; 86 + } 87 + 88 + if (!fe) 89 + continue; 90 + 91 + for_each_dpcm_be(fe, stream, dpcm) { 92 + be = dpcm->be; 93 + if (be == rtd) 94 + continue; 95 + 96 + for (i = 0; i < sof_priv->num_streams; i++) { 97 + const struct sof_conn_stream *conn = &sof_priv->conn_streams[i]; 98 + 99 + if (!strcmp(be->dai_link->name, conn->sof_link)) 100 + return be; 101 + } 102 + } 103 + } 104 + 105 + return NULL; 106 + } 107 + 108 + /* fixup the BE DAI link to match any values from topology */ 109 + static int mtk_sof_check_tplg_be_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, 110 + struct snd_pcm_hw_params *params) 111 + { 112 + struct snd_soc_card *card = rtd->card; 113 + struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card); 114 + struct mtk_sof_priv *sof_priv = soc_card_data->sof_priv; 115 + struct snd_soc_pcm_runtime *sof_be; 116 + struct mtk_dai_link *dai_link; 117 + int ret = 0; 118 + 119 + sof_be = mtk_sof_find_tplg_be(rtd); 120 + if (sof_be) { 121 + if (sof_priv->sof_dai_link_fixup) 122 + ret = sof_priv->sof_dai_link_fixup(rtd, params); 123 + else if (sof_be->dai_link->be_hw_params_fixup) 124 + ret = sof_be->dai_link->be_hw_params_fixup(sof_be, params); 125 + } else { 126 + list_for_each_entry(dai_link, &sof_priv->dai_link_list, list) { 127 + if (strcmp(dai_link->name, rtd->dai_link->name) == 0) { 128 + if (dai_link->be_hw_params_fixup) 129 + ret = dai_link->be_hw_params_fixup(rtd, params); 130 + 131 + break; 132 + } 133 + } 134 + } 135 + 136 + return ret; 137 + } 69 138 70 139 int mtk_sof_card_late_probe(struct snd_soc_card *card) 71 140 { ··· 145 72 struct mtk_soc_card_data *soc_card_data = 146 73 snd_soc_card_get_drvdata(card); 147 74 struct mtk_sof_priv *sof_priv = soc_card_data->sof_priv; 75 + struct snd_soc_dai_link *dai_link; 76 + struct mtk_dai_link *mtk_dai_link; 148 77 int i; 149 78 150 79 /* 1. find sof component */ ··· 161 86 return 0; 162 87 } 163 88 164 - /* 2. add route path and fixup callback */ 89 + /* 2. overwrite all BE fixups, and backup the existing fixup */ 90 + for_each_card_prelinks(card, i, dai_link) { 91 + if (dai_link->be_hw_params_fixup) { 92 + mtk_dai_link = devm_kzalloc(card->dev, 93 + sizeof(*mtk_dai_link), 94 + GFP_KERNEL); 95 + if (!mtk_dai_link) 96 + return -ENOMEM; 97 + 98 + mtk_dai_link->be_hw_params_fixup = dai_link->be_hw_params_fixup; 99 + mtk_dai_link->name = dai_link->name; 100 + 101 + list_add(&mtk_dai_link->list, &sof_priv->dai_link_list); 102 + } 103 + 104 + if (dai_link->no_pcm) 105 + dai_link->be_hw_params_fixup = mtk_sof_check_tplg_be_dai_link_fixup; 106 + } 107 + 108 + /* 3. add route path and SOF_BE fixup callback */ 165 109 for (i = 0; i < sof_priv->num_streams; i++) { 166 110 const struct sof_conn_stream *conn = &sof_priv->conn_streams[i]; 167 111 struct snd_soc_pcm_runtime *sof_rtd = NULL; 168 - struct snd_soc_pcm_runtime *normal_rtd = NULL; 169 112 170 113 for_each_card_rtds(card, rtd) { 171 114 if (!strcmp(rtd->dai_link->name, conn->sof_link)) { 172 115 sof_rtd = rtd; 173 - continue; 174 - } 175 - if (!strcmp(rtd->dai_link->name, conn->normal_link)) { 176 - normal_rtd = rtd; 177 - continue; 178 - } 179 - if (normal_rtd && sof_rtd) 180 116 break; 117 + } 181 118 } 182 - if (normal_rtd && sof_rtd) { 119 + if (sof_rtd) { 183 120 int j; 184 121 struct snd_soc_dai *cpu_dai; 185 122 ··· 218 131 } 219 132 } 220 133 134 + /* overwrite SOF BE fixup */ 221 135 sof_rtd->dai_link->be_hw_params_fixup = 222 136 sof_comp->driver->be_hw_params_fixup; 223 - if (sof_priv->sof_dai_link_fixup) 224 - normal_rtd->dai_link->be_hw_params_fixup = 225 - sof_priv->sof_dai_link_fixup; 226 - else 227 - normal_rtd->dai_link->be_hw_params_fixup = mtk_sof_dai_link_fixup; 228 137 } 229 138 } 230 139
+8
sound/soc/mediatek/common/mtk-dsp-sof-common.h
··· 18 18 int stream_dir; 19 19 }; 20 20 21 + struct mtk_dai_link { 22 + const char *name; 23 + int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd, 24 + struct snd_pcm_hw_params *params); 25 + struct list_head list; 26 + }; 27 + 21 28 struct mtk_sof_priv { 22 29 const struct sof_conn_stream *conn_streams; 23 30 int num_streams; 24 31 int (*sof_dai_link_fixup)(struct snd_soc_pcm_runtime *rtd, 25 32 struct snd_pcm_hw_params *params); 33 + struct list_head dai_link_list; 26 34 }; 27 35 28 36 int mtk_sof_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
+226 -13
sound/soc/mediatek/mt8188/mt8188-mt6359.c
··· 19 19 #include "../../codecs/mt6359.h" 20 20 #include "../common/mtk-afe-platform-driver.h" 21 21 #include "../common/mtk-soundcard-driver.h" 22 + #include "../common/mtk-dsp-sof-common.h" 23 + #include "../common/mtk-soc-card.h" 22 24 23 25 #define CKSYS_AUD_TOP_CFG 0x032c 24 26 #define RG_TEST_ON BIT(0) ··· 46 44 * Nau88l25 47 45 */ 48 46 #define NAU8825_CODEC_DAI "nau8825-hifi" 47 + 48 + #define SOF_DMA_DL2 "SOF_DMA_DL2" 49 + #define SOF_DMA_DL3 "SOF_DMA_DL3" 50 + #define SOF_DMA_UL4 "SOF_DMA_UL4" 51 + #define SOF_DMA_UL5 "SOF_DMA_UL5" 49 52 50 53 /* FE */ 51 54 SND_SOC_DAILINK_DEFS(playback2, ··· 183 176 "dmic-hifi")), 184 177 DAILINK_COMP_ARRAY(COMP_EMPTY())); 185 178 179 + SND_SOC_DAILINK_DEFS(AFE_SOF_DL2, 180 + DAILINK_COMP_ARRAY(COMP_CPU("SOF_DL2")), 181 + DAILINK_COMP_ARRAY(COMP_DUMMY()), 182 + DAILINK_COMP_ARRAY(COMP_EMPTY())); 183 + 184 + SND_SOC_DAILINK_DEFS(AFE_SOF_DL3, 185 + DAILINK_COMP_ARRAY(COMP_CPU("SOF_DL3")), 186 + DAILINK_COMP_ARRAY(COMP_DUMMY()), 187 + DAILINK_COMP_ARRAY(COMP_EMPTY())); 188 + 189 + SND_SOC_DAILINK_DEFS(AFE_SOF_UL4, 190 + DAILINK_COMP_ARRAY(COMP_CPU("SOF_UL4")), 191 + DAILINK_COMP_ARRAY(COMP_DUMMY()), 192 + DAILINK_COMP_ARRAY(COMP_EMPTY())); 193 + 194 + SND_SOC_DAILINK_DEFS(AFE_SOF_UL5, 195 + DAILINK_COMP_ARRAY(COMP_CPU("SOF_UL5")), 196 + DAILINK_COMP_ARRAY(COMP_DUMMY()), 197 + DAILINK_COMP_ARRAY(COMP_EMPTY())); 198 + 199 + static const struct sof_conn_stream g_sof_conn_streams[] = { 200 + { 201 + .sof_link = "AFE_SOF_DL2", 202 + .sof_dma = SOF_DMA_DL2, 203 + .stream_dir = SNDRV_PCM_STREAM_PLAYBACK 204 + }, 205 + { 206 + .sof_link = "AFE_SOF_DL3", 207 + .sof_dma = SOF_DMA_DL3, 208 + .stream_dir = SNDRV_PCM_STREAM_PLAYBACK 209 + }, 210 + { 211 + .sof_link = "AFE_SOF_UL4", 212 + .sof_dma = SOF_DMA_UL4, 213 + .stream_dir = SNDRV_PCM_STREAM_CAPTURE 214 + }, 215 + { 216 + .sof_link = "AFE_SOF_UL5", 217 + .sof_dma = SOF_DMA_UL5, 218 + .stream_dir = SNDRV_PCM_STREAM_CAPTURE 219 + }, 220 + }; 221 + 186 222 struct mt8188_mt6359_priv { 187 223 struct snd_soc_jack dp_jack; 188 224 struct snd_soc_jack hdmi_jack; ··· 296 246 SND_SOC_DAPM_MIC("Headset Mic", NULL), 297 247 SND_SOC_DAPM_SINK("HDMI"), 298 248 SND_SOC_DAPM_SINK("DP"), 249 + SND_SOC_DAPM_MIXER(SOF_DMA_DL2, SND_SOC_NOPM, 0, 0, NULL, 0), 250 + SND_SOC_DAPM_MIXER(SOF_DMA_DL3, SND_SOC_NOPM, 0, 0, NULL, 0), 251 + SND_SOC_DAPM_MIXER(SOF_DMA_UL4, SND_SOC_NOPM, 0, 0, NULL, 0), 252 + SND_SOC_DAPM_MIXER(SOF_DMA_UL5, SND_SOC_NOPM, 0, 0, NULL, 0), 253 + 254 + /* dynamic pinctrl */ 255 + SND_SOC_DAPM_PINCTRL("ETDM_SPK_PIN", "aud_etdm_spk_on", "aud_etdm_spk_off"), 256 + SND_SOC_DAPM_PINCTRL("ETDM_HP_PIN", "aud_etdm_hp_on", "aud_etdm_hp_off"), 257 + SND_SOC_DAPM_PINCTRL("MTKAIF_PIN", "aud_mtkaif_on", "aud_mtkaif_off"), 299 258 }; 300 259 301 260 static const struct snd_kcontrol_new mt8188_mt6359_controls[] = { ··· 320 261 SOC_DAPM_PIN_SWITCH("Headphone Jack"), 321 262 }; 322 263 264 + static const struct snd_soc_dapm_route mt8188_mt6359_routes[] = { 265 + /* SOF Uplink */ 266 + {SOF_DMA_UL4, NULL, "O034"}, 267 + {SOF_DMA_UL4, NULL, "O035"}, 268 + {SOF_DMA_UL5, NULL, "O036"}, 269 + {SOF_DMA_UL5, NULL, "O037"}, 270 + /* SOF Downlink */ 271 + {"I070", NULL, SOF_DMA_DL2}, 272 + {"I071", NULL, SOF_DMA_DL2}, 273 + {"I020", NULL, SOF_DMA_DL3}, 274 + {"I021", NULL, SOF_DMA_DL3}, 275 + }; 276 + 323 277 static int mt8188_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd) 324 278 { 325 279 struct snd_soc_component *cmpnt_afe = 326 280 snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); 327 281 struct snd_soc_component *cmpnt_codec = 328 282 asoc_rtd_to_codec(rtd, 0)->component; 283 + struct snd_soc_dapm_widget *pin_w = NULL, *w; 329 284 struct mtk_base_afe *afe; 330 285 struct mt8188_afe_private *afe_priv; 331 286 struct mtkaif_param *param; ··· 378 305 __func__); 379 306 return 0; 380 307 } 308 + 309 + for_each_card_widgets(rtd->card, w) { 310 + if (!strcmp(w->name, "MTKAIF_PIN")) { 311 + pin_w = w; 312 + break; 313 + } 314 + } 315 + 316 + if (pin_w) 317 + dapm_pinctrl_event(pin_w, NULL, SND_SOC_DAPM_PRE_PMU); 318 + else 319 + dev_dbg(afe->dev, "%s(), no pinmux widget, please check if default on\n", __func__); 381 320 382 321 pm_runtime_get_sync(afe->dev); 383 322 mt6359_mtkaif_calibration_enable(cmpnt_codec); ··· 488 403 for (i = 0; i < MT8188_MTKAIF_MISO_NUM; i++) 489 404 param->mtkaif_phase_cycle[i] = mtkaif_phase_cycle[i]; 490 405 406 + if (pin_w) 407 + dapm_pinctrl_event(pin_w, NULL, SND_SOC_DAPM_POST_PMD); 408 + 491 409 dev_dbg(afe->dev, "%s(), end, calibration ok %d\n", 492 410 __func__, param->mtkaif_calibration_ok); 493 411 ··· 538 450 DAI_LINK_ETDM3_OUT_BE, 539 451 DAI_LINK_PCM1_BE, 540 452 DAI_LINK_UL_SRC_BE, 453 + DAI_LINK_REGULAR_LAST = DAI_LINK_UL_SRC_BE, 454 + DAI_LINK_SOF_START, 455 + DAI_LINK_SOF_DL2_BE = DAI_LINK_SOF_START, 456 + DAI_LINK_SOF_DL3_BE, 457 + DAI_LINK_SOF_UL4_BE, 458 + DAI_LINK_SOF_UL5_BE, 459 + DAI_LINK_SOF_END = DAI_LINK_SOF_UL5_BE, 541 460 }; 461 + 462 + #define DAI_LINK_REGULAR_NUM (DAI_LINK_REGULAR_LAST + 1) 542 463 543 464 static int mt8188_dptx_hw_params(struct snd_pcm_substream *substream, 544 465 struct snd_pcm_hw_params *params) ··· 579 482 580 483 static int mt8188_hdmi_codec_init(struct snd_soc_pcm_runtime *rtd) 581 484 { 582 - struct mt8188_mt6359_priv *priv = snd_soc_card_get_drvdata(rtd->card); 485 + struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(rtd->card); 486 + struct mt8188_mt6359_priv *priv = soc_card_data->mach_priv; 583 487 struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; 584 488 int ret = 0; 585 489 ··· 605 507 606 508 static int mt8188_dptx_codec_init(struct snd_soc_pcm_runtime *rtd) 607 509 { 608 - struct mt8188_mt6359_priv *priv = snd_soc_card_get_drvdata(rtd->card); 510 + struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(rtd->card); 511 + struct mt8188_mt6359_priv *priv = soc_card_data->mach_priv; 609 512 struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; 610 513 int ret = 0; 611 514 ··· 726 627 static int mt8188_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) 727 628 { 728 629 struct snd_soc_card *card = rtd->card; 729 - struct mt8188_mt6359_priv *priv = snd_soc_card_get_drvdata(card); 630 + struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card); 631 + struct mt8188_mt6359_priv *priv = soc_card_data->mach_priv; 730 632 struct snd_soc_component *component = asoc_rtd_to_codec(rtd, 0)->component; 731 633 struct snd_soc_jack *jack = &priv->headset_jack; 732 634 int ret; ··· 812 712 static const struct snd_soc_ops mt8188_nau8825_ops = { 813 713 .hw_params = mt8188_nau8825_hw_params, 814 714 }; 715 + 716 + static int mt8188_sof_be_hw_params(struct snd_pcm_substream *substream, 717 + struct snd_pcm_hw_params *params) 718 + { 719 + struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 720 + struct snd_soc_component *cmpnt_afe = NULL; 721 + struct snd_soc_pcm_runtime *runtime; 722 + 723 + /* find afe component */ 724 + for_each_card_rtds(rtd->card, runtime) { 725 + cmpnt_afe = snd_soc_rtdcom_lookup(runtime, AFE_PCM_NAME); 726 + if (cmpnt_afe) 727 + break; 728 + } 729 + 730 + if (cmpnt_afe && !pm_runtime_active(cmpnt_afe->dev)) { 731 + dev_err(rtd->dev, "afe pm runtime is not active!!\n"); 732 + return -EINVAL; 733 + } 734 + 735 + return 0; 736 + } 737 + 738 + static const struct snd_soc_ops mt8188_sof_be_ops = { 739 + .hw_params = mt8188_sof_be_hw_params, 740 + }; 741 + 815 742 static struct snd_soc_dai_link mt8188_mt6359_dai_links[] = { 816 743 /* FE */ 817 744 [DAI_LINK_DL2_FE] = { ··· 1109 982 .dpcm_capture = 1, 1110 983 SND_SOC_DAILINK_REG(ul_src), 1111 984 }, 985 + 986 + /* SOF BE */ 987 + [DAI_LINK_SOF_DL2_BE] = { 988 + .name = "AFE_SOF_DL2", 989 + .no_pcm = 1, 990 + .dpcm_playback = 1, 991 + .ops = &mt8188_sof_be_ops, 992 + SND_SOC_DAILINK_REG(AFE_SOF_DL2), 993 + }, 994 + [DAI_LINK_SOF_DL3_BE] = { 995 + .name = "AFE_SOF_DL3", 996 + .no_pcm = 1, 997 + .dpcm_playback = 1, 998 + .ops = &mt8188_sof_be_ops, 999 + SND_SOC_DAILINK_REG(AFE_SOF_DL3), 1000 + }, 1001 + [DAI_LINK_SOF_UL4_BE] = { 1002 + .name = "AFE_SOF_UL4", 1003 + .no_pcm = 1, 1004 + .dpcm_capture = 1, 1005 + .ops = &mt8188_sof_be_ops, 1006 + SND_SOC_DAILINK_REG(AFE_SOF_UL4), 1007 + }, 1008 + [DAI_LINK_SOF_UL5_BE] = { 1009 + .name = "AFE_SOF_UL5", 1010 + .no_pcm = 1, 1011 + .dpcm_capture = 1, 1012 + .ops = &mt8188_sof_be_ops, 1013 + SND_SOC_DAILINK_REG(AFE_SOF_UL5), 1014 + }, 1112 1015 }; 1113 1016 1114 1017 static void mt8188_fixup_controls(struct snd_soc_card *card) 1115 1018 { 1116 - struct mt8188_mt6359_priv *priv = snd_soc_card_get_drvdata(card); 1019 + struct mtk_soc_card_data *soc_card_data = snd_soc_card_get_drvdata(card); 1020 + struct mt8188_mt6359_priv *priv = soc_card_data->mach_priv; 1117 1021 struct mt8188_card_data *card_data = (struct mt8188_card_data *)priv->private_data; 1118 1022 struct snd_kcontrol *kctl; 1119 1023 ··· 1172 1014 .num_links = ARRAY_SIZE(mt8188_mt6359_dai_links), 1173 1015 .dapm_widgets = mt8188_mt6359_widgets, 1174 1016 .num_dapm_widgets = ARRAY_SIZE(mt8188_mt6359_widgets), 1017 + .dapm_routes = mt8188_mt6359_routes, 1018 + .num_dapm_routes = ARRAY_SIZE(mt8188_mt6359_routes), 1175 1019 .controls = mt8188_mt6359_controls, 1176 1020 .num_controls = ARRAY_SIZE(mt8188_mt6359_controls), 1177 1021 .fixup_controls = mt8188_fixup_controls, ··· 1183 1023 { 1184 1024 struct snd_soc_card *card = &mt8188_mt6359_soc_card; 1185 1025 struct device_node *platform_node; 1026 + struct device_node *adsp_node; 1027 + struct mtk_soc_card_data *soc_card_data; 1186 1028 struct mt8188_mt6359_priv *priv; 1187 1029 struct mt8188_card_data *card_data; 1188 1030 struct snd_soc_dai_link *dai_link; ··· 1205 1043 if (!card->name) 1206 1044 card->name = card_data->name; 1207 1045 1208 - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 1209 - if (!priv) 1210 - return -ENOMEM; 1211 - 1212 1046 if (of_property_read_bool(pdev->dev.of_node, "audio-routing")) { 1213 1047 ret = snd_soc_of_parse_audio_routing(card, "audio-routing"); 1214 1048 if (ret) 1215 1049 return ret; 1216 1050 } 1217 1051 1052 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 1053 + if (!priv) 1054 + return -ENOMEM; 1055 + 1056 + soc_card_data = devm_kzalloc(&pdev->dev, sizeof(*card_data), GFP_KERNEL); 1057 + if (!soc_card_data) 1058 + return -ENOMEM; 1059 + 1060 + soc_card_data->mach_priv = priv; 1061 + 1062 + adsp_node = of_parse_phandle(pdev->dev.of_node, "mediatek,adsp", 0); 1063 + if (adsp_node) { 1064 + struct mtk_sof_priv *sof_priv; 1065 + 1066 + sof_priv = devm_kzalloc(&pdev->dev, sizeof(*sof_priv), GFP_KERNEL); 1067 + if (!sof_priv) { 1068 + ret = -ENOMEM; 1069 + goto err_adsp_node; 1070 + } 1071 + sof_priv->conn_streams = g_sof_conn_streams; 1072 + sof_priv->num_streams = ARRAY_SIZE(g_sof_conn_streams); 1073 + soc_card_data->sof_priv = sof_priv; 1074 + card->probe = mtk_sof_card_probe; 1075 + card->late_probe = mtk_sof_card_late_probe; 1076 + if (!card->topology_shortname_created) { 1077 + snprintf(card->topology_shortname, 32, "sof-%s", card->name); 1078 + card->topology_shortname_created = true; 1079 + } 1080 + card->name = card->topology_shortname; 1081 + } 1082 + 1083 + if (of_property_read_bool(pdev->dev.of_node, "mediatek,dai-link")) { 1084 + ret = mtk_sof_dailink_parse_of(card, pdev->dev.of_node, 1085 + "mediatek,dai-link", 1086 + mt8188_mt6359_dai_links, 1087 + ARRAY_SIZE(mt8188_mt6359_dai_links)); 1088 + if (ret) { 1089 + dev_err_probe(&pdev->dev, ret, "Parse dai-link fail\n"); 1090 + goto err_adsp_node; 1091 + } 1092 + } else { 1093 + if (!adsp_node) 1094 + card->num_links = DAI_LINK_REGULAR_NUM; 1095 + } 1096 + 1218 1097 platform_node = of_parse_phandle(pdev->dev.of_node, 1219 1098 "mediatek,platform", 0); 1220 1099 if (!platform_node) { 1221 - ret = -EINVAL; 1222 - return dev_err_probe(&pdev->dev, ret, "Property 'platform' missing or invalid\n"); 1100 + ret = dev_err_probe(&pdev->dev, -EINVAL, 1101 + "Property 'platform' missing or invalid\n"); 1102 + goto err_adsp_node; 1103 + 1223 1104 } 1224 1105 1225 1106 ret = parse_dai_link_info(card); ··· 1270 1065 goto err; 1271 1066 1272 1067 for_each_card_prelinks(card, i, dai_link) { 1273 - if (!dai_link->platforms->name) 1274 - dai_link->platforms->of_node = platform_node; 1068 + if (!dai_link->platforms->name) { 1069 + if (!strncmp(dai_link->name, "AFE_SOF", strlen("AFE_SOF")) && adsp_node) 1070 + dai_link->platforms->of_node = adsp_node; 1071 + else 1072 + dai_link->platforms->of_node = platform_node; 1073 + } 1275 1074 1276 1075 if (strcmp(dai_link->name, "DPTX_BE") == 0) { 1277 1076 if (strcmp(dai_link->codecs->dai_name, "snd-soc-dummy-dai")) ··· 1318 1109 } 1319 1110 1320 1111 priv->private_data = card_data; 1321 - snd_soc_card_set_drvdata(card, priv); 1112 + snd_soc_card_set_drvdata(card, soc_card_data); 1322 1113 1323 1114 ret = devm_snd_soc_register_card(&pdev->dev, card); 1324 1115 if (ret) ··· 1327 1118 err: 1328 1119 of_node_put(platform_node); 1329 1120 clean_card_reference(card); 1121 + 1122 + err_adsp_node: 1123 + of_node_put(adsp_node); 1124 + 1330 1125 return ret; 1331 1126 } 1332 1127