Skip to content

Commit 88939e7

Browse files
committed
Merge series "ASoC: mediatek: Add support for MT8195 SoC" from Trevor Wu <[email protected]>:
This series of patches adds support for Mediatek AFE of MT8195 SoC. Patches are based on broonie tree "for-next" branch. Changes since v4: - removed sof related code Changes since v3: - fixed warnings found by kernel test robot - removed unused critical section - corrected the lock protected sections on etdm driver - added DPTX and HDMITX audio support Changes since v2: - added audio clock gate control - added 'mediatek' prefix to private dts properties - added consumed clocks to dt-bindins and adopted suggestions from Rob - refined clock usage and remove unused clock and control code - fixed typos Changes since v1: - fixed some problems related to dt-bindings - added some missing properties to dt-bindings - added depency declaration on dt-bindings - fixed some warnings found by kernel test robot Trevor Wu (11): ASoC: mediatek: mt8195: update mediatek common driver ASoC: mediatek: mt8195: support audsys clock control ASoC: mediatek: mt8195: support etdm in platform driver ASoC: mediatek: mt8195: support adda in platform driver ASoC: mediatek: mt8195: support pcm in platform driver ASoC: mediatek: mt8195: add platform driver dt-bindings: mediatek: mt8195: add audio afe document ASoC: mediatek: mt8195: add machine driver with mt6359, rt1019 and rt5682 ASoC: mediatek: mt8195: add DPTX audio support ASoC: mediatek: mt8195: add HDMITX audio support dt-bindings: mediatek: mt8195: add mt8195-mt6359-rt1019-rt5682 document .../bindings/sound/mt8195-afe-pcm.yaml | 184 + .../sound/mt8195-mt6359-rt1019-rt5682.yaml | 47 + sound/soc/mediatek/Kconfig | 24 + sound/soc/mediatek/Makefile | 1 + sound/soc/mediatek/common/mtk-afe-fe-dai.c | 22 +- sound/soc/mediatek/common/mtk-base-afe.h | 10 +- sound/soc/mediatek/mt8195/Makefile | 15 + sound/soc/mediatek/mt8195/mt8195-afe-clk.c | 441 +++ sound/soc/mediatek/mt8195/mt8195-afe-clk.h | 109 + sound/soc/mediatek/mt8195/mt8195-afe-common.h | 158 + sound/soc/mediatek/mt8195/mt8195-afe-pcm.c | 3281 +++++++++++++++++ sound/soc/mediatek/mt8195/mt8195-audsys-clk.c | 214 ++ sound/soc/mediatek/mt8195/mt8195-audsys-clk.h | 15 + .../soc/mediatek/mt8195/mt8195-audsys-clkid.h | 93 + sound/soc/mediatek/mt8195/mt8195-dai-adda.c | 830 +++++ sound/soc/mediatek/mt8195/mt8195-dai-etdm.c | 2639 +++++++++++++ sound/soc/mediatek/mt8195/mt8195-dai-pcm.c | 389 ++ .../mt8195/mt8195-mt6359-rt1019-rt5682.c | 1087 ++++++ sound/soc/mediatek/mt8195/mt8195-reg.h | 2796 ++++++++++++++ 19 files changed, 12350 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/mt8195-afe-pcm.yaml create mode 100644 Documentation/devicetree/bindings/sound/mt8195-mt6359-rt1019-rt5682.yaml create mode 100644 sound/soc/mediatek/mt8195/Makefile create mode 100644 sound/soc/mediatek/mt8195/mt8195-afe-clk.c create mode 100644 sound/soc/mediatek/mt8195/mt8195-afe-clk.h create mode 100644 sound/soc/mediatek/mt8195/mt8195-afe-common.h create mode 100644 sound/soc/mediatek/mt8195/mt8195-afe-pcm.c create mode 100644 sound/soc/mediatek/mt8195/mt8195-audsys-clk.c create mode 100644 sound/soc/mediatek/mt8195/mt8195-audsys-clk.h create mode 100644 sound/soc/mediatek/mt8195/mt8195-audsys-clkid.h create mode 100644 sound/soc/mediatek/mt8195/mt8195-dai-adda.c create mode 100644 sound/soc/mediatek/mt8195/mt8195-dai-etdm.c create mode 100644 sound/soc/mediatek/mt8195/mt8195-dai-pcm.c create mode 100644 sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c create mode 100644 sound/soc/mediatek/mt8195/mt8195-reg.h -- 2.18.0
2 parents 0be10d7 + 5f8c991 commit 88939e7

19 files changed

+12350
-5
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/sound/mt8195-afe-pcm.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Mediatek AFE PCM controller for mt8195
8+
9+
maintainers:
10+
- Trevor Wu <[email protected]>
11+
12+
properties:
13+
compatible:
14+
const: mediatek,mt8195-audio
15+
16+
reg:
17+
maxItems: 1
18+
19+
interrupts:
20+
maxItems: 1
21+
22+
mediatek,topckgen:
23+
$ref: "/schemas/types.yaml#/definitions/phandle"
24+
description: The phandle of the mediatek topckgen controller
25+
26+
power-domains:
27+
maxItems: 1
28+
29+
clocks:
30+
items:
31+
- description: 26M clock
32+
- description: audio pll1 clock
33+
- description: audio pll2 clock
34+
- description: clock divider for i2si1_mck
35+
- description: clock divider for i2si2_mck
36+
- description: clock divider for i2so1_mck
37+
- description: clock divider for i2so2_mck
38+
- description: clock divider for dptx_mck
39+
- description: a1sys hoping clock
40+
- description: audio intbus clock
41+
- description: audio hires clock
42+
- description: audio local bus clock
43+
- description: mux for dptx_mck
44+
- description: mux for i2so1_mck
45+
- description: mux for i2so2_mck
46+
- description: mux for i2si1_mck
47+
- description: mux for i2si2_mck
48+
- description: audio infra 26M clock
49+
- description: infra bus clock
50+
51+
clock-names:
52+
items:
53+
- const: clk26m
54+
- const: apll1_ck
55+
- const: apll2_ck
56+
- const: apll12_div0
57+
- const: apll12_div1
58+
- const: apll12_div2
59+
- const: apll12_div3
60+
- const: apll12_div9
61+
- const: a1sys_hp_sel
62+
- const: aud_intbus_sel
63+
- const: audio_h_sel
64+
- const: audio_local_bus_sel
65+
- const: dptx_m_sel
66+
- const: i2so1_m_sel
67+
- const: i2so2_m_sel
68+
- const: i2si1_m_sel
69+
- const: i2si2_m_sel
70+
- const: infra_ao_audio_26m_b
71+
- const: scp_adsp_audiodsp
72+
73+
mediatek,etdm-in1-chn-disabled:
74+
$ref: /schemas/types.yaml#/definitions/uint8-array
75+
maxItems: 24
76+
description: Specify which input channel should be disabled.
77+
78+
mediatek,etdm-in2-chn-disabled:
79+
$ref: /schemas/types.yaml#/definitions/uint8-array
80+
maxItems: 16
81+
description: Specify which input channel should be disabled.
82+
83+
patternProperties:
84+
"^mediatek,etdm-in[1-2]-mclk-always-on-rate-hz$":
85+
description: Specify etdm in mclk output rate for always on case.
86+
87+
"^mediatek,etdm-out[1-3]-mclk-always-on-rate-hz$":
88+
description: Specify etdm out mclk output rate for always on case.
89+
90+
"^mediatek,etdm-in[1-2]-multi-pin-mode$":
91+
type: boolean
92+
description: if present, the etdm data mode is I2S.
93+
94+
"^mediatek,etdm-out[1-3]-multi-pin-mode$":
95+
type: boolean
96+
description: if present, the etdm data mode is I2S.
97+
98+
"^mediatek,etdm-in[1-2]-cowork-source$":
99+
$ref: /schemas/types.yaml#/definitions/uint32
100+
description: |
101+
etdm modules can share the same external clock pin. Specify
102+
which etdm clock source is required by this etdm in moudule.
103+
enum:
104+
- 0 # etdm1_in
105+
- 1 # etdm2_in
106+
- 2 # etdm1_out
107+
- 3 # etdm2_out
108+
109+
"^mediatek,etdm-out[1-2]-cowork-source$":
110+
$ref: /schemas/types.yaml#/definitions/uint32
111+
description: |
112+
etdm modules can share the same external clock pin. Specify
113+
which etdm clock source is required by this etdm out moudule.
114+
enum:
115+
- 0 # etdm1_in
116+
- 1 # etdm2_in
117+
- 2 # etdm1_out
118+
- 3 # etdm2_out
119+
120+
required:
121+
- compatible
122+
- reg
123+
- interrupts
124+
- mediatek,topckgen
125+
- power-domains
126+
- clocks
127+
- clock-names
128+
129+
additionalProperties: false
130+
131+
examples:
132+
- |
133+
#include <dt-bindings/clock/mt8195-clk.h>
134+
#include <dt-bindings/interrupt-controller/arm-gic.h>
135+
#include <dt-bindings/interrupt-controller/irq.h>
136+
#include <dt-bindings/power/mt8195-power.h>
137+
138+
afe: mt8195-afe-pcm@10890000 {
139+
compatible = "mediatek,mt8195-audio";
140+
reg = <0x10890000 0x10000>;
141+
interrupts = <GIC_SPI 822 IRQ_TYPE_LEVEL_HIGH 0>;
142+
mediatek,topckgen = <&topckgen>;
143+
power-domains = <&spm MT8195_POWER_DOMAIN_AUDIO>;
144+
clocks = <&clk26m>,
145+
<&topckgen CLK_TOP_APLL1>,
146+
<&topckgen CLK_TOP_APLL2>,
147+
<&topckgen CLK_TOP_APLL12_DIV0>,
148+
<&topckgen CLK_TOP_APLL12_DIV1>,
149+
<&topckgen CLK_TOP_APLL12_DIV2>,
150+
<&topckgen CLK_TOP_APLL12_DIV3>,
151+
<&topckgen CLK_TOP_APLL12_DIV9>,
152+
<&topckgen CLK_TOP_A1SYS_HP_SEL>,
153+
<&topckgen CLK_TOP_AUD_INTBUS_SEL>,
154+
<&topckgen CLK_TOP_AUDIO_H_SEL>,
155+
<&topckgen CLK_TOP_AUDIO_LOCAL_BUS_SEL>,
156+
<&topckgen CLK_TOP_DPTX_M_SEL>,
157+
<&topckgen CLK_TOP_I2SO1_M_SEL>,
158+
<&topckgen CLK_TOP_I2SO2_M_SEL>,
159+
<&topckgen CLK_TOP_I2SI1_M_SEL>,
160+
<&topckgen CLK_TOP_I2SI2_M_SEL>,
161+
<&infracfg_ao CLK_INFRA_AO_AUDIO_26M_B>,
162+
<&scp_adsp CLK_SCP_ADSP_AUDIODSP>;
163+
clock-names = "clk26m",
164+
"apll1_ck",
165+
"apll2_ck",
166+
"apll12_div0",
167+
"apll12_div1",
168+
"apll12_div2",
169+
"apll12_div3",
170+
"apll12_div9",
171+
"a1sys_hp_sel",
172+
"aud_intbus_sel",
173+
"audio_h_sel",
174+
"audio_local_bus_sel",
175+
"dptx_m_sel",
176+
"i2so1_m_sel",
177+
"i2so2_m_sel",
178+
"i2si1_m_sel",
179+
"i2si2_m_sel",
180+
"infra_ao_audio_26m_b",
181+
"scp_adsp_audiodsp";
182+
};
183+
184+
...
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/sound/mt8195-mt6359-rt1019-rt5682.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Mediatek MT8195 with MT6359, RT1019 and RT5682 ASoC sound card driver
8+
9+
maintainers:
10+
- Trevor Wu <[email protected]>
11+
12+
description:
13+
This binding describes the MT8195 sound card.
14+
15+
properties:
16+
compatible:
17+
const: mediatek,mt8195_mt6359_rt1019_rt5682
18+
19+
mediatek,platform:
20+
$ref: "/schemas/types.yaml#/definitions/phandle"
21+
description: The phandle of MT8195 ASoC platform.
22+
23+
mediatek,dptx-codec:
24+
$ref: "/schemas/types.yaml#/definitions/phandle"
25+
description: The phandle of MT8195 Display Port Tx codec node.
26+
27+
mediatek,hdmi-codec:
28+
$ref: "/schemas/types.yaml#/definitions/phandle"
29+
description: The phandle of MT8195 HDMI codec node.
30+
31+
additionalProperties: false
32+
33+
required:
34+
- compatible
35+
- mediatek,platform
36+
37+
examples:
38+
- |
39+
40+
sound: mt8195-sound {
41+
compatible = "mediatek,mt8195_mt6359_rt1019_rt5682";
42+
mediatek,platform = <&afe>;
43+
pinctrl-names = "default";
44+
pinctrl-0 = <&aud_pins_default>;
45+
};
46+
47+
...

sound/soc/mediatek/Kconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,27 @@ config SND_SOC_MT8192_MT6359_RT1015_RT5682
184184
with the MT6359 RT1015 RT5682 audio codec.
185185
Select Y if you have such device.
186186
If unsure select "N".
187+
188+
config SND_SOC_MT8195
189+
tristate "ASoC support for Mediatek MT8195 chip"
190+
select SND_SOC_MEDIATEK
191+
help
192+
This adds ASoC platform driver support for Mediatek MT8195 chip
193+
that can be used with other codecs.
194+
Select Y if you have such device.
195+
If unsure select "N".
196+
197+
config SND_SOC_MT8195_MT6359_RT1019_RT5682
198+
tristate "ASoC Audio driver for MT8195 with MT6359 RT1019 RT5682 codec"
199+
depends on I2C
200+
depends on SND_SOC_MT8195
201+
select SND_SOC_MT6359
202+
select SND_SOC_RT1015P
203+
select SND_SOC_RT5682_I2C
204+
select SND_SOC_DMIC
205+
select SND_SOC_HDMI_CODEC
206+
help
207+
This adds ASoC driver for Mediatek MT8195 boards
208+
with the MT6359 RT1019 RT5682 audio codec.
209+
Select Y if you have such device.
210+
If unsure select "N".

sound/soc/mediatek/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ obj-$(CONFIG_SND_SOC_MT6797) += mt6797/
55
obj-$(CONFIG_SND_SOC_MT8173) += mt8173/
66
obj-$(CONFIG_SND_SOC_MT8183) += mt8183/
77
obj-$(CONFIG_SND_SOC_MT8192) += mt8192/
8+
obj-$(CONFIG_SND_SOC_MT8195) += mt8195/

sound/soc/mediatek/common/mtk-afe-fe-dai.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream,
139139
substream->runtime->dma_area,
140140
substream->runtime->dma_bytes);
141141

142-
memset_io(substream->runtime->dma_area, 0,
142+
memset_io((void __force __iomem *)substream->runtime->dma_area, 0,
143143
substream->runtime->dma_bytes);
144144

145145
/* set addr */
@@ -433,11 +433,20 @@ int mtk_memif_set_addr(struct mtk_base_afe *afe, int id,
433433
phys_buf_addr_upper_32);
434434
}
435435

436-
/* set MSB to 33-bit */
437-
if (memif->data->msb_reg >= 0)
436+
/*
437+
* set MSB to 33-bit, for memif address
438+
* only for memif base address, if msb_end_reg exists
439+
*/
440+
if (memif->data->msb_reg)
438441
mtk_regmap_update_bits(afe->regmap, memif->data->msb_reg,
439442
1, msb_at_bit33, memif->data->msb_shift);
440443

444+
/* set MSB to 33-bit, for memif end address */
445+
if (memif->data->msb_end_reg)
446+
mtk_regmap_update_bits(afe->regmap, memif->data->msb_end_reg,
447+
1, msb_at_bit33,
448+
memif->data->msb_end_shift);
449+
441450
return 0;
442451
}
443452
EXPORT_SYMBOL_GPL(mtk_memif_set_addr);
@@ -464,6 +473,13 @@ int mtk_memif_set_channel(struct mtk_base_afe *afe,
464473
else
465474
mono = (channel == 1) ? 1 : 0;
466475

476+
/* for specific configuration of memif mono mode */
477+
if (memif->data->int_odd_flag_reg)
478+
mtk_regmap_update_bits(afe->regmap,
479+
memif->data->int_odd_flag_reg,
480+
1, mono,
481+
memif->data->int_odd_flag_shift);
482+
467483
return mtk_regmap_update_bits(afe->regmap, memif->data->mono_reg,
468484
1, mono, memif->data->mono_shift);
469485
}

sound/soc/mediatek/common/mtk-base-afe.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ struct mtk_base_memif_data {
2929
int quad_ch_reg;
3030
int quad_ch_mask;
3131
int quad_ch_shift;
32+
int int_odd_flag_reg;
33+
int int_odd_flag_shift;
3234
int enable_reg;
3335
int enable_shift;
3436
int hd_reg;
@@ -37,10 +39,13 @@ struct mtk_base_memif_data {
3739
int hd_align_mshift;
3840
int msb_reg;
3941
int msb_shift;
40-
int msb2_reg;
41-
int msb2_shift;
42+
int msb_end_reg;
43+
int msb_end_shift;
4244
int agent_disable_reg;
4345
int agent_disable_shift;
46+
int ch_num_reg;
47+
int ch_num_shift;
48+
int ch_num_maskbit;
4449
/* playback memif only */
4550
int pbuf_reg;
4651
int pbuf_mask;
@@ -62,6 +67,7 @@ struct mtk_base_irq_data {
6267
int irq_en_shift;
6368
int irq_clr_reg;
6469
int irq_clr_shift;
70+
int irq_status_shift;
6571
};
6672

6773
struct device;

sound/soc/mediatek/mt8195/Makefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
# platform driver
4+
snd-soc-mt8195-afe-objs := \
5+
mt8195-audsys-clk.o \
6+
mt8195-afe-clk.o \
7+
mt8195-afe-pcm.o \
8+
mt8195-dai-adda.o \
9+
mt8195-dai-etdm.o \
10+
mt8195-dai-pcm.o
11+
12+
obj-$(CONFIG_SND_SOC_MT8195) += snd-soc-mt8195-afe.o
13+
14+
# machine driver
15+
obj-$(CONFIG_SND_SOC_MT8195_MT6359_RT1019_RT5682) += mt8195-mt6359-rt1019-rt5682.o

0 commit comments

Comments
 (0)