Skip to content

Commit 94319ba

Browse files
korochenbroonie
authored andcommitted
ASoC: mediatek: Use platform_of_node for machine drivers
This replaces the platform_name in snd_soc_dai_link by device tree node. Signed-off-by: Koro Chen <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 4623a61 commit 94319ba

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

Documentation/devicetree/bindings/sound/mt8173-max98090.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ MT8173 with MAX98090 CODEC
33
Required properties:
44
- compatible : "mediatek,mt8173-max98090"
55
- mediatek,audio-codec: the phandle of the MAX98090 audio codec
6+
- mediatek,platform: the phandle of MT8173 ASoC platform
67

78
Example:
89

910
sound {
1011
compatible = "mediatek,mt8173-max98090";
1112
mediatek,audio-codec = <&max98090>;
13+
mediatek,platform = <&afe>;
1214
};
1315

Documentation/devicetree/bindings/sound/mt8173-rt5650-rt5676.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ MT8173 with RT5650 RT5676 CODECS
33
Required properties:
44
- compatible : "mediatek,mt8173-rt5650-rt5676"
55
- mediatek,audio-codec: the phandles of rt5650 and rt5676 codecs
6+
- mediatek,platform: the phandle of MT8173 ASoC platform
67

78
Example:
89

910
sound {
1011
compatible = "mediatek,mt8173-rt5650-rt5676";
1112
mediatek,audio-codec = <&rt5650 &rt5676>;
13+
mediatek,platform = <&afe>;
1214
};
1315

sound/soc/mediatek/mt8173-max98090.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ static struct snd_soc_dai_link mt8173_max98090_dais[] = {
103103
.name = "MAX98090 Playback",
104104
.stream_name = "MAX98090 Playback",
105105
.cpu_dai_name = "DL1",
106-
.platform_name = "11220000.mt8173-afe-pcm",
107106
.codec_name = "snd-soc-dummy",
108107
.codec_dai_name = "snd-soc-dummy-dai",
109108
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
@@ -114,7 +113,6 @@ static struct snd_soc_dai_link mt8173_max98090_dais[] = {
114113
.name = "MAX98090 Capture",
115114
.stream_name = "MAX98090 Capture",
116115
.cpu_dai_name = "VUL",
117-
.platform_name = "11220000.mt8173-afe-pcm",
118116
.codec_name = "snd-soc-dummy",
119117
.codec_dai_name = "snd-soc-dummy-dai",
120118
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
@@ -125,7 +123,6 @@ static struct snd_soc_dai_link mt8173_max98090_dais[] = {
125123
{
126124
.name = "Codec",
127125
.cpu_dai_name = "I2S",
128-
.platform_name = "11220000.mt8173-afe-pcm",
129126
.no_pcm = 1,
130127
.codec_dai_name = "HiFi",
131128
.init = mt8173_max98090_init,
@@ -152,9 +149,21 @@ static struct snd_soc_card mt8173_max98090_card = {
152149
static int mt8173_max98090_dev_probe(struct platform_device *pdev)
153150
{
154151
struct snd_soc_card *card = &mt8173_max98090_card;
155-
struct device_node *codec_node;
152+
struct device_node *codec_node, *platform_node;
156153
int ret, i;
157154

155+
platform_node = of_parse_phandle(pdev->dev.of_node,
156+
"mediatek,platform", 0);
157+
if (!platform_node) {
158+
dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
159+
return -EINVAL;
160+
}
161+
for (i = 0; i < card->num_links; i++) {
162+
if (mt8173_max98090_dais[i].platform_name)
163+
continue;
164+
mt8173_max98090_dais[i].platform_of_node = platform_node;
165+
}
166+
158167
codec_node = of_parse_phandle(pdev->dev.of_node,
159168
"mediatek,audio-codec", 0);
160169
if (!codec_node) {

sound/soc/mediatek/mt8173-rt5650-rt5676.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ static struct snd_soc_dai_link mt8173_rt5650_rt5676_dais[] = {
138138
.name = "rt5650_rt5676 Playback",
139139
.stream_name = "rt5650_rt5676 Playback",
140140
.cpu_dai_name = "DL1",
141-
.platform_name = "11220000.mt8173-afe-pcm",
142141
.codec_name = "snd-soc-dummy",
143142
.codec_dai_name = "snd-soc-dummy-dai",
144143
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
@@ -149,7 +148,6 @@ static struct snd_soc_dai_link mt8173_rt5650_rt5676_dais[] = {
149148
.name = "rt5650_rt5676 Capture",
150149
.stream_name = "rt5650_rt5676 Capture",
151150
.cpu_dai_name = "VUL",
152-
.platform_name = "11220000.mt8173-afe-pcm",
153151
.codec_name = "snd-soc-dummy",
154152
.codec_dai_name = "snd-soc-dummy-dai",
155153
.trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
@@ -161,7 +159,6 @@ static struct snd_soc_dai_link mt8173_rt5650_rt5676_dais[] = {
161159
{
162160
.name = "Codec",
163161
.cpu_dai_name = "I2S",
164-
.platform_name = "11220000.mt8173-afe-pcm",
165162
.no_pcm = 1,
166163
.codecs = mt8173_rt5650_rt5676_codecs,
167164
.num_codecs = 2,
@@ -209,7 +206,21 @@ static struct snd_soc_card mt8173_rt5650_rt5676_card = {
209206
static int mt8173_rt5650_rt5676_dev_probe(struct platform_device *pdev)
210207
{
211208
struct snd_soc_card *card = &mt8173_rt5650_rt5676_card;
212-
int ret;
209+
struct device_node *platform_node;
210+
int i, ret;
211+
212+
platform_node = of_parse_phandle(pdev->dev.of_node,
213+
"mediatek,platform", 0);
214+
if (!platform_node) {
215+
dev_err(&pdev->dev, "Property 'platform' missing or invalid\n");
216+
return -EINVAL;
217+
}
218+
219+
for (i = 0; i < card->num_links; i++) {
220+
if (mt8173_rt5650_rt5676_dais[i].platform_name)
221+
continue;
222+
mt8173_rt5650_rt5676_dais[i].platform_of_node = platform_node;
223+
}
213224

214225
mt8173_rt5650_rt5676_codecs[0].of_node =
215226
of_parse_phandle(pdev->dev.of_node, "mediatek,audio-codec", 0);

0 commit comments

Comments
 (0)