aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>2018-01-28 21:51:42 -0500
committerMark Brown <broonie@kernel.org>2018-02-12 06:45:38 -0500
commitf1b5bf07365d4d6599ce90f49ef96dd8833fbd90 (patch)
treecc7c674eaed8e59fe0c1e8a67bb62a34ae037c1d
parente049cf4e6adcb14e34c37123a67158a7e671d000 (diff)
ASoC: mt2701/mt8173: replace platform to component
Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Tested-by: Garlic Tseng <garlic.tseng@mediatek.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/mediatek/common/mtk-afe-fe-dai.c16
-rw-r--r--sound/soc/mediatek/common/mtk-afe-platform-driver.c9
-rw-r--r--sound/soc/mediatek/common/mtk-afe-platform-driver.h3
-rw-r--r--sound/soc/mediatek/mt2701/mt2701-afe-pcm.c50
-rw-r--r--sound/soc/mediatek/mt8173/mt8173-afe-pcm.c42
5 files changed, 73 insertions, 47 deletions
diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c
index ac231d33d8fe..c91e5f4cd902 100644
--- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c
+++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c
@@ -18,6 +18,7 @@
18#include <linux/pm_runtime.h> 18#include <linux/pm_runtime.h>
19#include <linux/regmap.h> 19#include <linux/regmap.h>
20#include <sound/soc.h> 20#include <sound/soc.h>
21#include "mtk-afe-platform-driver.h"
21#include "mtk-afe-fe-dai.h" 22#include "mtk-afe-fe-dai.h"
22#include "mtk-base-afe.h" 23#include "mtk-base-afe.h"
23 24
@@ -43,7 +44,8 @@ int mtk_afe_fe_startup(struct snd_pcm_substream *substream,
43 struct snd_soc_dai *dai) 44 struct snd_soc_dai *dai)
44{ 45{
45 struct snd_soc_pcm_runtime *rtd = substream->private_data; 46 struct snd_soc_pcm_runtime *rtd = substream->private_data;
46 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 47 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
48 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
47 struct snd_pcm_runtime *runtime = substream->runtime; 49 struct snd_pcm_runtime *runtime = substream->runtime;
48 int memif_num = rtd->cpu_dai->id; 50 int memif_num = rtd->cpu_dai->id;
49 struct mtk_base_afe_memif *memif = &afe->memif[memif_num]; 51 struct mtk_base_afe_memif *memif = &afe->memif[memif_num];
@@ -105,7 +107,8 @@ void mtk_afe_fe_shutdown(struct snd_pcm_substream *substream,
105 struct snd_soc_dai *dai) 107 struct snd_soc_dai *dai)
106{ 108{
107 struct snd_soc_pcm_runtime *rtd = substream->private_data; 109 struct snd_soc_pcm_runtime *rtd = substream->private_data;
108 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 110 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
111 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
109 struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; 112 struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id];
110 int irq_id; 113 int irq_id;
111 114
@@ -128,7 +131,8 @@ int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream,
128 struct snd_soc_dai *dai) 131 struct snd_soc_dai *dai)
129{ 132{
130 struct snd_soc_pcm_runtime *rtd = substream->private_data; 133 struct snd_soc_pcm_runtime *rtd = substream->private_data;
131 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 134 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
135 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
132 struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; 136 struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id];
133 int msb_at_bit33 = 0; 137 int msb_at_bit33 = 0;
134 int ret, fs = 0; 138 int ret, fs = 0;
@@ -192,7 +196,8 @@ int mtk_afe_fe_trigger(struct snd_pcm_substream *substream, int cmd,
192{ 196{
193 struct snd_soc_pcm_runtime *rtd = substream->private_data; 197 struct snd_soc_pcm_runtime *rtd = substream->private_data;
194 struct snd_pcm_runtime * const runtime = substream->runtime; 198 struct snd_pcm_runtime * const runtime = substream->runtime;
195 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 199 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
200 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
196 struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; 201 struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id];
197 struct mtk_base_afe_irq *irqs = &afe->irqs[memif->irq_usage]; 202 struct mtk_base_afe_irq *irqs = &afe->irqs[memif->irq_usage];
198 const struct mtk_base_irq_data *irq_data = irqs->irq_data; 203 const struct mtk_base_irq_data *irq_data = irqs->irq_data;
@@ -255,7 +260,8 @@ int mtk_afe_fe_prepare(struct snd_pcm_substream *substream,
255 struct snd_soc_dai *dai) 260 struct snd_soc_dai *dai)
256{ 261{
257 struct snd_soc_pcm_runtime *rtd = substream->private_data; 262 struct snd_soc_pcm_runtime *rtd = substream->private_data;
258 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 263 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
264 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
259 struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; 265 struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id];
260 int hd_audio = 0; 266 int hd_audio = 0;
261 267
diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
index 82d439c15f4e..53215b52e4f2 100644
--- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c
+++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c
@@ -25,7 +25,8 @@ static snd_pcm_uframes_t mtk_afe_pcm_pointer
25 (struct snd_pcm_substream *substream) 25 (struct snd_pcm_substream *substream)
26{ 26{
27 struct snd_soc_pcm_runtime *rtd = substream->private_data; 27 struct snd_soc_pcm_runtime *rtd = substream->private_data;
28 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 28 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
29 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
29 struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; 30 struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id];
30 const struct mtk_base_memif_data *memif_data = memif->data; 31 const struct mtk_base_memif_data *memif_data = memif->data;
31 struct regmap *regmap = afe->regmap; 32 struct regmap *regmap = afe->regmap;
@@ -65,7 +66,8 @@ static int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd)
65 size_t size; 66 size_t size;
66 struct snd_card *card = rtd->card->snd_card; 67 struct snd_card *card = rtd->card->snd_card;
67 struct snd_pcm *pcm = rtd->pcm; 68 struct snd_pcm *pcm = rtd->pcm;
68 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 69 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
70 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
69 71
70 size = afe->mtk_afe_hardware->buffer_bytes_max; 72 size = afe->mtk_afe_hardware->buffer_bytes_max;
71 return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, 73 return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
@@ -77,7 +79,8 @@ static void mtk_afe_pcm_free(struct snd_pcm *pcm)
77 snd_pcm_lib_preallocate_free_for_all(pcm); 79 snd_pcm_lib_preallocate_free_for_all(pcm);
78} 80}
79 81
80const struct snd_soc_platform_driver mtk_afe_pcm_platform = { 82const struct snd_soc_component_driver mtk_afe_pcm_platform = {
83 .name = AFE_PCM_NAME,
81 .ops = &mtk_afe_pcm_ops, 84 .ops = &mtk_afe_pcm_ops,
82 .pcm_new = mtk_afe_pcm_new, 85 .pcm_new = mtk_afe_pcm_new,
83 .pcm_free = mtk_afe_pcm_free, 86 .pcm_free = mtk_afe_pcm_free,
diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.h b/sound/soc/mediatek/common/mtk-afe-platform-driver.h
index a973fc9253b4..8dcdbed959ea 100644
--- a/sound/soc/mediatek/common/mtk-afe-platform-driver.h
+++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.h
@@ -17,7 +17,8 @@
17#ifndef _MTK_AFE_PLATFORM_DRIVER_H_ 17#ifndef _MTK_AFE_PLATFORM_DRIVER_H_
18#define _MTK_AFE_PLATFORM_DRIVER_H_ 18#define _MTK_AFE_PLATFORM_DRIVER_H_
19 19
20extern const struct snd_soc_platform_driver mtk_afe_pcm_platform; 20#define AFE_PCM_NAME "mtk-afe-pcm"
21extern const struct snd_soc_component_driver mtk_afe_pcm_platform;
21 22
22#endif 23#endif
23 24
diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
index d68b53f7cefe..f7e0702d92f8 100644
--- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
+++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
@@ -93,7 +93,8 @@ static int mt2701_afe_i2s_startup(struct snd_pcm_substream *substream,
93 struct snd_soc_dai *dai) 93 struct snd_soc_dai *dai)
94{ 94{
95 struct snd_soc_pcm_runtime *rtd = substream->private_data; 95 struct snd_soc_pcm_runtime *rtd = substream->private_data;
96 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 96 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
97 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
97 int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); 98 int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id);
98 99
99 if (i2s_num < 0) 100 if (i2s_num < 0)
@@ -108,7 +109,8 @@ static int mt2701_afe_i2s_path_shutdown(struct snd_pcm_substream *substream,
108 int dir_invert) 109 int dir_invert)
109{ 110{
110 struct snd_soc_pcm_runtime *rtd = substream->private_data; 111 struct snd_soc_pcm_runtime *rtd = substream->private_data;
111 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 112 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
113 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
112 struct mt2701_afe_private *afe_priv = afe->platform_priv; 114 struct mt2701_afe_private *afe_priv = afe->platform_priv;
113 struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num]; 115 struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num];
114 const struct mt2701_i2s_data *i2s_data; 116 const struct mt2701_i2s_data *i2s_data;
@@ -144,7 +146,8 @@ static void mt2701_afe_i2s_shutdown(struct snd_pcm_substream *substream,
144 struct snd_soc_dai *dai) 146 struct snd_soc_dai *dai)
145{ 147{
146 struct snd_soc_pcm_runtime *rtd = substream->private_data; 148 struct snd_soc_pcm_runtime *rtd = substream->private_data;
147 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 149 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
150 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
148 struct mt2701_afe_private *afe_priv = afe->platform_priv; 151 struct mt2701_afe_private *afe_priv = afe->platform_priv;
149 int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); 152 int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id);
150 struct mt2701_i2s_path *i2s_path; 153 struct mt2701_i2s_path *i2s_path;
@@ -176,7 +179,8 @@ static int mt2701_i2s_path_prepare_enable(struct snd_pcm_substream *substream,
176 int dir_invert) 179 int dir_invert)
177{ 180{
178 struct snd_soc_pcm_runtime *rtd = substream->private_data; 181 struct snd_soc_pcm_runtime *rtd = substream->private_data;
179 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 182 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
183 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
180 struct mt2701_afe_private *afe_priv = afe->platform_priv; 184 struct mt2701_afe_private *afe_priv = afe->platform_priv;
181 struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num]; 185 struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num];
182 const struct mt2701_i2s_data *i2s_data; 186 const struct mt2701_i2s_data *i2s_data;
@@ -247,7 +251,8 @@ static int mt2701_afe_i2s_prepare(struct snd_pcm_substream *substream,
247{ 251{
248 int clk_domain; 252 int clk_domain;
249 struct snd_soc_pcm_runtime *rtd = substream->private_data; 253 struct snd_soc_pcm_runtime *rtd = substream->private_data;
250 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 254 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
255 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
251 struct mt2701_afe_private *afe_priv = afe->platform_priv; 256 struct mt2701_afe_private *afe_priv = afe->platform_priv;
252 int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); 257 int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id);
253 struct mt2701_i2s_path *i2s_path; 258 struct mt2701_i2s_path *i2s_path;
@@ -312,7 +317,8 @@ static int mt2701_btmrg_startup(struct snd_pcm_substream *substream,
312 struct snd_soc_dai *dai) 317 struct snd_soc_dai *dai)
313{ 318{
314 struct snd_soc_pcm_runtime *rtd = substream->private_data; 319 struct snd_soc_pcm_runtime *rtd = substream->private_data;
315 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 320 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
321 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
316 struct mt2701_afe_private *afe_priv = afe->platform_priv; 322 struct mt2701_afe_private *afe_priv = afe->platform_priv;
317 int ret; 323 int ret;
318 324
@@ -329,7 +335,8 @@ static int mt2701_btmrg_hw_params(struct snd_pcm_substream *substream,
329 struct snd_soc_dai *dai) 335 struct snd_soc_dai *dai)
330{ 336{
331 struct snd_soc_pcm_runtime *rtd = substream->private_data; 337 struct snd_soc_pcm_runtime *rtd = substream->private_data;
332 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 338 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
339 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
333 int stream_fs; 340 int stream_fs;
334 u32 val, msk; 341 u32 val, msk;
335 342
@@ -372,7 +379,8 @@ static void mt2701_btmrg_shutdown(struct snd_pcm_substream *substream,
372 struct snd_soc_dai *dai) 379 struct snd_soc_dai *dai)
373{ 380{
374 struct snd_soc_pcm_runtime *rtd = substream->private_data; 381 struct snd_soc_pcm_runtime *rtd = substream->private_data;
375 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 382 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
383 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
376 struct mt2701_afe_private *afe_priv = afe->platform_priv; 384 struct mt2701_afe_private *afe_priv = afe->platform_priv;
377 385
378 /* if the other direction stream is not occupied */ 386 /* if the other direction stream is not occupied */
@@ -392,7 +400,8 @@ static int mt2701_simple_fe_startup(struct snd_pcm_substream *substream,
392 struct snd_soc_dai *dai) 400 struct snd_soc_dai *dai)
393{ 401{
394 struct snd_soc_pcm_runtime *rtd = substream->private_data; 402 struct snd_soc_pcm_runtime *rtd = substream->private_data;
395 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 403 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
404 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
396 int stream_dir = substream->stream; 405 int stream_dir = substream->stream;
397 int memif_num = rtd->cpu_dai->id; 406 int memif_num = rtd->cpu_dai->id;
398 struct mtk_base_afe_memif *memif_tmp; 407 struct mtk_base_afe_memif *memif_tmp;
@@ -414,7 +423,8 @@ static int mt2701_simple_fe_hw_params(struct snd_pcm_substream *substream,
414 struct snd_soc_dai *dai) 423 struct snd_soc_dai *dai)
415{ 424{
416 struct snd_soc_pcm_runtime *rtd = substream->private_data; 425 struct snd_soc_pcm_runtime *rtd = substream->private_data;
417 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 426 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
427 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
418 int stream_dir = substream->stream; 428 int stream_dir = substream->stream;
419 429
420 /* single DL use PAIR_INTERLEAVE */ 430 /* single DL use PAIR_INTERLEAVE */
@@ -431,7 +441,8 @@ static int mt2701_dlm_fe_startup(struct snd_pcm_substream *substream,
431 struct snd_soc_dai *dai) 441 struct snd_soc_dai *dai)
432{ 442{
433 struct snd_soc_pcm_runtime *rtd = substream->private_data; 443 struct snd_soc_pcm_runtime *rtd = substream->private_data;
434 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 444 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
445 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
435 struct mtk_base_afe_memif *memif_tmp; 446 struct mtk_base_afe_memif *memif_tmp;
436 const struct mtk_base_memif_data *memif_data; 447 const struct mtk_base_memif_data *memif_data;
437 int i; 448 int i;
@@ -458,7 +469,8 @@ static void mt2701_dlm_fe_shutdown(struct snd_pcm_substream *substream,
458 struct snd_soc_dai *dai) 469 struct snd_soc_dai *dai)
459{ 470{
460 struct snd_soc_pcm_runtime *rtd = substream->private_data; 471 struct snd_soc_pcm_runtime *rtd = substream->private_data;
461 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 472 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
473 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
462 const struct mtk_base_memif_data *memif_data; 474 const struct mtk_base_memif_data *memif_data;
463 int i; 475 int i;
464 476
@@ -477,7 +489,8 @@ static int mt2701_dlm_fe_hw_params(struct snd_pcm_substream *substream,
477 struct snd_soc_dai *dai) 489 struct snd_soc_dai *dai)
478{ 490{
479 struct snd_soc_pcm_runtime *rtd = substream->private_data; 491 struct snd_soc_pcm_runtime *rtd = substream->private_data;
480 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 492 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
493 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
481 int channels = params_channels(params); 494 int channels = params_channels(params);
482 495
483 regmap_update_bits(afe->regmap, 496 regmap_update_bits(afe->regmap,
@@ -500,7 +513,8 @@ static int mt2701_dlm_fe_trigger(struct snd_pcm_substream *substream,
500 int cmd, struct snd_soc_dai *dai) 513 int cmd, struct snd_soc_dai *dai)
501{ 514{
502 struct snd_soc_pcm_runtime *rtd = substream->private_data; 515 struct snd_soc_pcm_runtime *rtd = substream->private_data;
503 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 516 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
517 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
504 struct mtk_base_afe_memif *memif_tmp = &afe->memif[MT2701_MEMIF_DL1]; 518 struct mtk_base_afe_memif *memif_tmp = &afe->memif[MT2701_MEMIF_DL1];
505 519
506 switch (cmd) { 520 switch (cmd) {
@@ -1517,7 +1531,8 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
1517 } 1531 }
1518 pm_runtime_get_sync(dev); 1532 pm_runtime_get_sync(dev);
1519 1533
1520 ret = snd_soc_register_platform(dev, &mtk_afe_pcm_platform); 1534 ret = devm_snd_soc_register_component(&pdev->dev, &mtk_afe_pcm_platform,
1535 NULL, 0);
1521 if (ret) { 1536 if (ret) {
1522 dev_warn(dev, "err_platform\n"); 1537 dev_warn(dev, "err_platform\n");
1523 goto err_platform; 1538 goto err_platform;
@@ -1526,13 +1541,11 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
1526 ret = mt2701_afe_add_component(afe); 1541 ret = mt2701_afe_add_component(afe);
1527 if (ret) { 1542 if (ret) {
1528 dev_warn(dev, "err_dai_component\n"); 1543 dev_warn(dev, "err_dai_component\n");
1529 goto err_dai_component; 1544 goto err_platform;
1530 } 1545 }
1531 1546
1532 return 0; 1547 return 0;
1533 1548
1534err_dai_component:
1535 snd_soc_unregister_platform(dev);
1536err_platform: 1549err_platform:
1537 pm_runtime_put_sync(dev); 1550 pm_runtime_put_sync(dev);
1538err_pm_disable: 1551err_pm_disable:
@@ -1549,7 +1562,6 @@ static int mt2701_afe_pcm_dev_remove(struct platform_device *pdev)
1549 mt2701_afe_runtime_suspend(&pdev->dev); 1562 mt2701_afe_runtime_suspend(&pdev->dev);
1550 1563
1551 snd_soc_unregister_component(&pdev->dev); 1564 snd_soc_unregister_component(&pdev->dev);
1552 snd_soc_unregister_platform(&pdev->dev);
1553 1565
1554 return 0; 1566 return 0;
1555} 1567}
diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
index c7f7f8add5d9..65d1433a0944 100644
--- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
+++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c
@@ -304,7 +304,8 @@ static int mt8173_afe_i2s_startup(struct snd_pcm_substream *substream,
304 struct snd_soc_dai *dai) 304 struct snd_soc_dai *dai)
305{ 305{
306 struct snd_soc_pcm_runtime *rtd = substream->private_data; 306 struct snd_soc_pcm_runtime *rtd = substream->private_data;
307 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 307 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
308 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
308 309
309 if (dai->active) 310 if (dai->active)
310 return 0; 311 return 0;
@@ -318,7 +319,8 @@ static void mt8173_afe_i2s_shutdown(struct snd_pcm_substream *substream,
318 struct snd_soc_dai *dai) 319 struct snd_soc_dai *dai)
319{ 320{
320 struct snd_soc_pcm_runtime *rtd = substream->private_data; 321 struct snd_soc_pcm_runtime *rtd = substream->private_data;
321 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 322 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
323 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
322 324
323 if (dai->active) 325 if (dai->active)
324 return; 326 return;
@@ -334,7 +336,8 @@ static int mt8173_afe_i2s_prepare(struct snd_pcm_substream *substream,
334{ 336{
335 struct snd_soc_pcm_runtime *rtd = substream->private_data; 337 struct snd_soc_pcm_runtime *rtd = substream->private_data;
336 struct snd_pcm_runtime * const runtime = substream->runtime; 338 struct snd_pcm_runtime * const runtime = substream->runtime;
337 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 339 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
340 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
338 struct mt8173_afe_private *afe_priv = afe->platform_priv; 341 struct mt8173_afe_private *afe_priv = afe->platform_priv;
339 int ret; 342 int ret;
340 343
@@ -356,7 +359,8 @@ static int mt8173_afe_hdmi_startup(struct snd_pcm_substream *substream,
356 struct snd_soc_dai *dai) 359 struct snd_soc_dai *dai)
357{ 360{
358 struct snd_soc_pcm_runtime *rtd = substream->private_data; 361 struct snd_soc_pcm_runtime *rtd = substream->private_data;
359 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 362 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
363 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
360 struct mt8173_afe_private *afe_priv = afe->platform_priv; 364 struct mt8173_afe_private *afe_priv = afe->platform_priv;
361 365
362 if (dai->active) 366 if (dai->active)
@@ -371,7 +375,8 @@ static void mt8173_afe_hdmi_shutdown(struct snd_pcm_substream *substream,
371 struct snd_soc_dai *dai) 375 struct snd_soc_dai *dai)
372{ 376{
373 struct snd_soc_pcm_runtime *rtd = substream->private_data; 377 struct snd_soc_pcm_runtime *rtd = substream->private_data;
374 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 378 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
379 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
375 struct mt8173_afe_private *afe_priv = afe->platform_priv; 380 struct mt8173_afe_private *afe_priv = afe->platform_priv;
376 381
377 if (dai->active) 382 if (dai->active)
@@ -386,7 +391,8 @@ static int mt8173_afe_hdmi_prepare(struct snd_pcm_substream *substream,
386{ 391{
387 struct snd_soc_pcm_runtime *rtd = substream->private_data; 392 struct snd_soc_pcm_runtime *rtd = substream->private_data;
388 struct snd_pcm_runtime * const runtime = substream->runtime; 393 struct snd_pcm_runtime * const runtime = substream->runtime;
389 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 394 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
395 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
390 struct mt8173_afe_private *afe_priv = afe->platform_priv; 396 struct mt8173_afe_private *afe_priv = afe->platform_priv;
391 397
392 unsigned int val; 398 unsigned int val;
@@ -449,7 +455,8 @@ static int mt8173_afe_hdmi_trigger(struct snd_pcm_substream *substream, int cmd,
449 struct snd_soc_dai *dai) 455 struct snd_soc_dai *dai)
450{ 456{
451 struct snd_soc_pcm_runtime *rtd = substream->private_data; 457 struct snd_soc_pcm_runtime *rtd = substream->private_data;
452 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 458 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
459 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
453 460
454 dev_info(afe->dev, "%s cmd=%d %s\n", __func__, cmd, dai->name); 461 dev_info(afe->dev, "%s cmd=%d %s\n", __func__, cmd, dai->name);
455 462
@@ -498,7 +505,8 @@ static int mt8173_memif_fs(struct snd_pcm_substream *substream,
498 unsigned int rate) 505 unsigned int rate)
499{ 506{
500 struct snd_soc_pcm_runtime *rtd = substream->private_data; 507 struct snd_soc_pcm_runtime *rtd = substream->private_data;
501 struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); 508 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME);
509 struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component);
502 struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; 510 struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id];
503 int fs; 511 int fs;
504 512
@@ -1172,31 +1180,29 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev)
1172 afe->runtime_resume = mt8173_afe_runtime_resume; 1180 afe->runtime_resume = mt8173_afe_runtime_resume;
1173 afe->runtime_suspend = mt8173_afe_runtime_suspend; 1181 afe->runtime_suspend = mt8173_afe_runtime_suspend;
1174 1182
1175 ret = snd_soc_register_platform(&pdev->dev, &mtk_afe_pcm_platform); 1183 ret = devm_snd_soc_register_component(&pdev->dev,
1184 &mtk_afe_pcm_platform,
1185 NULL, 0);
1176 if (ret) 1186 if (ret)
1177 goto err_pm_disable; 1187 goto err_pm_disable;
1178 1188
1179 ret = snd_soc_register_component(&pdev->dev, 1189 ret = devm_snd_soc_register_component(&pdev->dev,
1180 &mt8173_afe_pcm_dai_component, 1190 &mt8173_afe_pcm_dai_component,
1181 mt8173_afe_pcm_dais, 1191 mt8173_afe_pcm_dais,
1182 ARRAY_SIZE(mt8173_afe_pcm_dais)); 1192 ARRAY_SIZE(mt8173_afe_pcm_dais));
1183 if (ret) 1193 if (ret)
1184 goto err_platform; 1194 goto err_pm_disable;
1185 1195
1186 ret = snd_soc_register_component(&pdev->dev, 1196 ret = devm_snd_soc_register_component(&pdev->dev,
1187 &mt8173_afe_hdmi_dai_component, 1197 &mt8173_afe_hdmi_dai_component,
1188 mt8173_afe_hdmi_dais, 1198 mt8173_afe_hdmi_dais,
1189 ARRAY_SIZE(mt8173_afe_hdmi_dais)); 1199 ARRAY_SIZE(mt8173_afe_hdmi_dais));
1190 if (ret) 1200 if (ret)
1191 goto err_comp; 1201 goto err_pm_disable;
1192 1202
1193 dev_info(&pdev->dev, "MT8173 AFE driver initialized.\n"); 1203 dev_info(&pdev->dev, "MT8173 AFE driver initialized.\n");
1194 return 0; 1204 return 0;
1195 1205
1196err_comp:
1197 snd_soc_unregister_component(&pdev->dev);
1198err_platform:
1199 snd_soc_unregister_platform(&pdev->dev);
1200err_pm_disable: 1206err_pm_disable:
1201 pm_runtime_disable(&pdev->dev); 1207 pm_runtime_disable(&pdev->dev);
1202 return ret; 1208 return ret;
@@ -1207,8 +1213,6 @@ static int mt8173_afe_pcm_dev_remove(struct platform_device *pdev)
1207 pm_runtime_disable(&pdev->dev); 1213 pm_runtime_disable(&pdev->dev);
1208 if (!pm_runtime_status_suspended(&pdev->dev)) 1214 if (!pm_runtime_status_suspended(&pdev->dev))
1209 mt8173_afe_runtime_suspend(&pdev->dev); 1215 mt8173_afe_runtime_suspend(&pdev->dev);
1210 snd_soc_unregister_component(&pdev->dev);
1211 snd_soc_unregister_platform(&pdev->dev);
1212 return 0; 1216 return 0;
1213} 1217}
1214 1218