kernel: bump 4.14 to 4.14.52 for 18.06
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.14 / 0185-ASoC-mediatek-modify-MT2701-AFE-driver-to-adapt-mfd-.patch
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
5 device
6
7 As the new MFD parent is in place, modify MT2701 AFE driver to adapt it.
8
9 Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
10 Signed-off-by: Mark Brown <broonie@kernel.org>
11 ---
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(-)
15
16 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
17 +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
18 @@ -17,6 +17,7 @@
19
20 #include <linux/delay.h>
21 #include <linux/module.h>
22 +#include <linux/mfd/syscon.h>
23 #include <linux/of.h>
24 #include <linux/of_address.h>
25 #include <linux/pm_runtime.h>
26 @@ -1368,14 +1369,6 @@ static const struct mt2701_i2s_data mt27
27 },
28 };
29
30 -static const struct regmap_config mt2701_afe_regmap_config = {
31 - .reg_bits = 32,
32 - .reg_stride = 4,
33 - .val_bits = 32,
34 - .max_register = AFE_END_ADDR,
35 - .cache_type = REGCACHE_NONE,
36 -};
37 -
38 static irqreturn_t mt2701_asys_isr(int irq_id, void *dev)
39 {
40 int id;
41 @@ -1414,9 +1407,9 @@ static int mt2701_afe_runtime_resume(str
42
43 static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
44 {
45 + struct snd_soc_component *component;
46 struct mtk_base_afe *afe;
47 struct mt2701_afe_private *afe_priv;
48 - struct resource *res;
49 struct device *dev;
50 int i, irq_id, ret;
51
52 @@ -1446,17 +1439,11 @@ static int mt2701_afe_pcm_dev_probe(stru
53 return ret;
54 }
55
56 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
57 -
58 - afe->base_addr = devm_ioremap_resource(&pdev->dev, res);
59 -
60 - if (IS_ERR(afe->base_addr))
61 - return PTR_ERR(afe->base_addr);
62 -
63 - afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr,
64 - &mt2701_afe_regmap_config);
65 - if (IS_ERR(afe->regmap))
66 - return PTR_ERR(afe->regmap);
67 + afe->regmap = syscon_node_to_regmap(dev->parent->of_node);
68 + if (!afe->regmap) {
69 + dev_err(dev, "could not get regmap from parent\n");
70 + return -ENODEV;
71 + }
72
73 mutex_init(&afe->irq_alloc_lock);
74
75 @@ -1490,6 +1477,12 @@ static int mt2701_afe_pcm_dev_probe(stru
76 = &mt2701_i2s_data[i][I2S_IN];
77 }
78
79 + component = kzalloc(sizeof(*component), GFP_KERNEL);
80 + if (!component)
81 + return -ENOMEM;
82 +
83 + component->regmap = afe->regmap;
84 +
85 afe->mtk_afe_hardware = &mt2701_afe_hardware;
86 afe->memif_fs = mt2701_memif_fs;
87 afe->irq_fs = mt2701_irq_fs;
88 @@ -1502,7 +1495,7 @@ static int mt2701_afe_pcm_dev_probe(stru
89 ret = mt2701_init_clock(afe);
90 if (ret) {
91 dev_err(dev, "init clock error\n");
92 - return ret;
93 + goto err_init_clock;
94 }
95
96 platform_set_drvdata(pdev, afe);
97 @@ -1521,10 +1514,10 @@ static int mt2701_afe_pcm_dev_probe(stru
98 goto err_platform;
99 }
100
101 - ret = snd_soc_register_component(&pdev->dev,
102 - &mt2701_afe_pcm_dai_component,
103 - mt2701_afe_pcm_dais,
104 - ARRAY_SIZE(mt2701_afe_pcm_dais));
105 + ret = snd_soc_add_component(dev, component,
106 + &mt2701_afe_pcm_dai_component,
107 + mt2701_afe_pcm_dais,
108 + ARRAY_SIZE(mt2701_afe_pcm_dais));
109 if (ret) {
110 dev_warn(dev, "err_dai_component\n");
111 goto err_dai_component;
112 @@ -1538,6 +1531,8 @@ err_platform:
113 pm_runtime_put_sync(dev);
114 err_pm_disable:
115 pm_runtime_disable(dev);
116 +err_init_clock:
117 + kfree(component);
118
119 return ret;
120 }
121 --- a/sound/soc/mediatek/mt2701/mt2701-reg.h
122 +++ b/sound/soc/mediatek/mt2701/mt2701-reg.h
123 @@ -145,5 +145,4 @@
124 #define ASYS_I2S_CON_WIDE_MODE_SET(x) ((x) << 1)
125 #define ASYS_I2S_IN_PHASE_FIX (0x1 << 31)
126
127 -#define AFE_END_ADDR 0x15e0
128 #endif