forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/sound/soc/atmel/sam9g20_wm8731.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * sam9g20_wm8731 -- SoC audio for AT91SAM9G20-based
34 * ATMEL AT91SAM9G20ek board.
....@@ -13,20 +14,6 @@
1314 * Based on corgi.c by:
1415 * Copyright 2005 Wolfson Microelectronics PLC.
1516 * Copyright 2005 Openedhand Ltd.
16
- *
17
- * This program is free software; you can redistribute it and/or modify
18
- * it under the terms of the GNU General Public License as published by
19
- * the Free Software Foundation; either version 2 of the License, or
20
- * (at your option) any later version.
21
- *
22
- * This program is distributed in the hope that it will be useful,
23
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
- * GNU General Public License for more details.
26
- *
27
- * You should have received a copy of the GNU General Public License
28
- * along with this program; if not, write to the Free Software
29
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3017 */
3118
3219 #include <linux/module.h>
....@@ -59,35 +46,6 @@
5946 */
6047 #undef ENABLE_MIC_INPUT
6148
62
-static struct clk *mclk;
63
-
64
-static int at91sam9g20ek_set_bias_level(struct snd_soc_card *card,
65
- struct snd_soc_dapm_context *dapm,
66
- enum snd_soc_bias_level level)
67
-{
68
- static int mclk_on;
69
- int ret = 0;
70
-
71
- switch (level) {
72
- case SND_SOC_BIAS_ON:
73
- case SND_SOC_BIAS_PREPARE:
74
- if (!mclk_on)
75
- ret = clk_enable(mclk);
76
- if (ret == 0)
77
- mclk_on = 1;
78
- break;
79
-
80
- case SND_SOC_BIAS_OFF:
81
- case SND_SOC_BIAS_STANDBY:
82
- if (mclk_on)
83
- clk_disable(mclk);
84
- mclk_on = 0;
85
- break;
86
- }
87
-
88
- return ret;
89
-}
90
-
9149 static const struct snd_soc_dapm_widget at91sam9g20ek_dapm_widgets[] = {
9250 SND_SOC_DAPM_MIC("Int Mic", NULL),
9351 SND_SOC_DAPM_SPK("Ext Spk", NULL),
....@@ -109,7 +67,7 @@
10967 */
11068 static int at91sam9g20ek_wm8731_init(struct snd_soc_pcm_runtime *rtd)
11169 {
112
- struct snd_soc_dai *codec_dai = rtd->codec_dai;
70
+ struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
11371 struct device *dev = rtd->dev;
11472 int ret;
11573
....@@ -129,16 +87,18 @@
12987 return 0;
13088 }
13189
90
+SND_SOC_DAILINK_DEFS(pcm,
91
+ DAILINK_COMP_ARRAY(COMP_CPU("at91rm9200_ssc.0")),
92
+ DAILINK_COMP_ARRAY(COMP_CODEC("wm8731.0-001b", "wm8731-hifi")),
93
+ DAILINK_COMP_ARRAY(COMP_PLATFORM("at91rm9200_ssc.0")));
94
+
13295 static struct snd_soc_dai_link at91sam9g20ek_dai = {
13396 .name = "WM8731",
13497 .stream_name = "WM8731 PCM",
135
- .cpu_dai_name = "at91rm9200_ssc.0",
136
- .codec_dai_name = "wm8731-hifi",
13798 .init = at91sam9g20ek_wm8731_init,
138
- .platform_name = "at91rm9200_ssc.0",
139
- .codec_name = "wm8731.0-001b",
14099 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
141100 SND_SOC_DAIFMT_CBM_CFM,
101
+ SND_SOC_DAILINK_REG(pcm),
142102 };
143103
144104 static struct snd_soc_card snd_soc_at91sam9g20ek = {
....@@ -146,7 +106,6 @@
146106 .owner = THIS_MODULE,
147107 .dai_link = &at91sam9g20ek_dai,
148108 .num_links = 1,
149
- .set_bias_level = at91sam9g20ek_set_bias_level,
150109
151110 .dapm_widgets = at91sam9g20ek_dapm_widgets,
152111 .num_dapm_widgets = ARRAY_SIZE(at91sam9g20ek_dapm_widgets),
....@@ -159,7 +118,6 @@
159118 {
160119 struct device_node *np = pdev->dev.of_node;
161120 struct device_node *codec_np, *cpu_np;
162
- struct clk *pllb;
163121 struct snd_soc_card *card = &snd_soc_at91sam9g20ek;
164122 int ret;
165123
....@@ -172,31 +130,6 @@
172130 dev_err(&pdev->dev, "ssc channel is not valid\n");
173131 return -EINVAL;
174132 }
175
-
176
- /*
177
- * Codec MCLK is supplied by PCK0 - set it up.
178
- */
179
- mclk = clk_get(NULL, "pck0");
180
- if (IS_ERR(mclk)) {
181
- dev_err(&pdev->dev, "Failed to get MCLK\n");
182
- ret = PTR_ERR(mclk);
183
- goto err;
184
- }
185
-
186
- pllb = clk_get(NULL, "pllb");
187
- if (IS_ERR(pllb)) {
188
- dev_err(&pdev->dev, "Failed to get PLLB\n");
189
- ret = PTR_ERR(pllb);
190
- goto err_mclk;
191
- }
192
- ret = clk_set_parent(mclk, pllb);
193
- clk_put(pllb);
194
- if (ret != 0) {
195
- dev_err(&pdev->dev, "Failed to set MCLK parent\n");
196
- goto err_mclk;
197
- }
198
-
199
- clk_set_rate(mclk, MCLK_RATE);
200133
201134 card->dev = &pdev->dev;
202135
....@@ -211,24 +144,25 @@
211144 goto err;
212145
213146 /* Parse codec info */
214
- at91sam9g20ek_dai.codec_name = NULL;
147
+ at91sam9g20ek_dai.codecs->name = NULL;
215148 codec_np = of_parse_phandle(np, "atmel,audio-codec", 0);
216149 if (!codec_np) {
217150 dev_err(&pdev->dev, "codec info missing\n");
218151 return -EINVAL;
219152 }
220
- at91sam9g20ek_dai.codec_of_node = codec_np;
153
+ at91sam9g20ek_dai.codecs->of_node = codec_np;
221154
222155 /* Parse dai and platform info */
223
- at91sam9g20ek_dai.cpu_dai_name = NULL;
224
- at91sam9g20ek_dai.platform_name = NULL;
156
+ at91sam9g20ek_dai.cpus->dai_name = NULL;
157
+ at91sam9g20ek_dai.platforms->name = NULL;
225158 cpu_np = of_parse_phandle(np, "atmel,ssc-controller", 0);
226159 if (!cpu_np) {
227160 dev_err(&pdev->dev, "dai and pcm info missing\n");
161
+ of_node_put(codec_np);
228162 return -EINVAL;
229163 }
230
- at91sam9g20ek_dai.cpu_of_node = cpu_np;
231
- at91sam9g20ek_dai.platform_of_node = cpu_np;
164
+ at91sam9g20ek_dai.cpus->of_node = cpu_np;
165
+ at91sam9g20ek_dai.platforms->of_node = cpu_np;
232166
233167 of_node_put(codec_np);
234168 of_node_put(cpu_np);
....@@ -240,9 +174,6 @@
240174
241175 return ret;
242176
243
-err_mclk:
244
- clk_put(mclk);
245
- mclk = NULL;
246177 err:
247178 atmel_ssc_put_audio(0);
248179 return ret;
....@@ -252,8 +183,6 @@
252183 {
253184 struct snd_soc_card *card = platform_get_drvdata(pdev);
254185
255
- clk_disable(mclk);
256
- mclk = NULL;
257186 snd_soc_unregister_card(card);
258187 atmel_ssc_put_audio(0);
259188