1 From 310ca2954c7cce10d716001ff869bc255494e3df Mon Sep 17 00:00:00 2001
2 From: Ryder Lee <ryder.lee@mediatek.com>
3 Date: Thu, 4 Jan 2018 15:44:08 +0800
4 Subject: [PATCH 185/224] ASoC: mediatek: modify MT2701 AFE driver to adapt mfd
7 As the new MFD parent is in place, modify MT2701 AFE driver to adapt it.
9 Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
10 Signed-off-by: Mark Brown <broonie@kernel.org>
12 sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 45 +++++++++++++-----------------
13 sound/soc/mediatek/mt2701/mt2701-reg.h | 1 -
14 2 files changed, 20 insertions(+), 26 deletions(-)
16 diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
17 index 0edadca12a5e..f0cd08fa5c5d 100644
18 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
19 +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
22 #include <linux/delay.h>
23 #include <linux/module.h>
24 +#include <linux/mfd/syscon.h>
26 #include <linux/of_address.h>
27 #include <linux/pm_runtime.h>
28 @@ -1368,14 +1369,6 @@ static const struct mt2701_i2s_data mt2701_i2s_data[MT2701_I2S_NUM][2] = {
32 -static const struct regmap_config mt2701_afe_regmap_config = {
36 - .max_register = AFE_END_ADDR,
37 - .cache_type = REGCACHE_NONE,
40 static irqreturn_t mt2701_asys_isr(int irq_id, void *dev)
43 @@ -1414,9 +1407,9 @@ static int mt2701_afe_runtime_resume(struct device *dev)
45 static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
47 + struct snd_soc_component *component;
48 struct mtk_base_afe *afe;
49 struct mt2701_afe_private *afe_priv;
50 - struct resource *res;
54 @@ -1446,17 +1439,11 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
58 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
60 - afe->base_addr = devm_ioremap_resource(&pdev->dev, res);
62 - if (IS_ERR(afe->base_addr))
63 - return PTR_ERR(afe->base_addr);
65 - afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr,
66 - &mt2701_afe_regmap_config);
67 - if (IS_ERR(afe->regmap))
68 - return PTR_ERR(afe->regmap);
69 + afe->regmap = syscon_node_to_regmap(dev->parent->of_node);
71 + dev_err(dev, "could not get regmap from parent\n");
75 mutex_init(&afe->irq_alloc_lock);
77 @@ -1490,6 +1477,12 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
78 = &mt2701_i2s_data[i][I2S_IN];
81 + component = kzalloc(sizeof(*component), GFP_KERNEL);
85 + component->regmap = afe->regmap;
87 afe->mtk_afe_hardware = &mt2701_afe_hardware;
88 afe->memif_fs = mt2701_memif_fs;
89 afe->irq_fs = mt2701_irq_fs;
90 @@ -1502,7 +1495,7 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
91 ret = mt2701_init_clock(afe);
93 dev_err(dev, "init clock error\n");
95 + goto err_init_clock;
98 platform_set_drvdata(pdev, afe);
99 @@ -1521,10 +1514,10 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
103 - ret = snd_soc_register_component(&pdev->dev,
104 - &mt2701_afe_pcm_dai_component,
105 - mt2701_afe_pcm_dais,
106 - ARRAY_SIZE(mt2701_afe_pcm_dais));
107 + ret = snd_soc_add_component(dev, component,
108 + &mt2701_afe_pcm_dai_component,
109 + mt2701_afe_pcm_dais,
110 + ARRAY_SIZE(mt2701_afe_pcm_dais));
112 dev_warn(dev, "err_dai_component\n");
113 goto err_dai_component;
114 @@ -1538,6 +1531,8 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
115 pm_runtime_put_sync(dev);
117 pm_runtime_disable(dev);
123 diff --git a/sound/soc/mediatek/mt2701/mt2701-reg.h b/sound/soc/mediatek/mt2701/mt2701-reg.h
124 index f17c76f37b5f..18e676974f22 100644
125 --- a/sound/soc/mediatek/mt2701/mt2701-reg.h
126 +++ b/sound/soc/mediatek/mt2701/mt2701-reg.h
128 #define ASYS_I2S_CON_WIDE_MODE_SET(x) ((x) << 1)
129 #define ASYS_I2S_IN_PHASE_FIX (0x1 << 31)
131 -#define AFE_END_ADDR 0x15e0