Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8ed024a
ASoC: mediatek: mt8195: update mediatek common driver
wenliangwu Aug 19, 2021
ed20695
ASoC: mediatek: mt8195: support audsys clock control
wenliangwu Aug 19, 2021
36479c7
ASoC: mediatek: mt8195: support etdm in platform driver
wenliangwu Aug 19, 2021
830a096
ASoC: mediatek: mt8195: support adda in platform driver
wenliangwu Aug 19, 2021
cdd32ef
ASoC: mediatek: mt8195: support pcm in platform driver
wenliangwu Aug 19, 2021
1db6b58
ASoC: mediatek: mt8195: add platform driver
wenliangwu Aug 19, 2021
e84ee39
dt-bindings: mediatek: mt8195: add audio afe document
wenliangwu Aug 19, 2021
d6abd2e
ASoC: mediatek: mt8195: add machine driver with mt6359, rt1019 and rt…
wenliangwu Aug 19, 2021
caab8f9
ASoC: mediatek: mt8195: add DPTX audio support
wenliangwu Aug 19, 2021
d4e27ec
ASoC: mediatek: mt8195: add HDMITX audio support
wenliangwu Aug 19, 2021
87b70a9
dt-bindings: mediatek: mt8195: add mt8195-mt6359-rt1019-rt5682 document
wenliangwu Aug 19, 2021
ee0f944
ASoC: SOF: tokens: add token for Mediatek AFE
yaochunhung Aug 27, 2021
2dc101d
ASoC: SOF: topology: Add support for Mediatek AFE DAI
yaochunhung Aug 27, 2021
6c2ce17
ASoC: SOF: pcm: add no ignore machine checking
yaochunhung Aug 27, 2021
248a3d8
ASoC: SOF: mediatek: Add mt8195 hardware support
yaochunhung Aug 27, 2021
488f3d3
ASoC: SOF: mediatek: Add machine driver dsp ops for mt8195 platform
yaochunhung Sep 7, 2021
1659d6d
ASoC: SOF: mediatek: Add dai driver dsp ops callback for mt8195
yaochunhung Sep 7, 2021
a85c74f
ASoC: SOF: mediatek: Add fw loader and mt8195 dsp ops to load firmware
yaochunhung Sep 7, 2021
b4f7aa7
ASoC: SOF: mediatek: Add PCM stream callback for mt8195
yaochunhung Sep 7, 2021
583f14f
ASoC: SOF: mediatek: Add DSP PM callback for mt8195
yaochunhung Sep 7, 2021
2ac0d18
ASoC: SOF: mediatek: Add IPC support for mt8195
yaochunhung Sep 7, 2021
8f38f99
dt-ndings: mediatek: mt8195: add dsp document
yaochunhung Aug 27, 2021
c836c0d
ASoC: SOF: Add mt8195 device descriptor
yaochunhung Aug 27, 2021
46d26ca
ASoC: mediatek: mt8195: add sof to machine driver
yaochunhung Aug 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions Documentation/devicetree/bindings/dsp/mtk,mt8195-dsp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/dsp/mtk,mt8195-dsp.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Mediatek mt8195 DSP core

maintainers:
- YC Hung <yc.hung@mediatek.com>

description: |
Some boards from mt8195 contain a DSP core used for
advanced pre- and post- audio processing.

properties:
compatible:
const: mediatek,mt8195-audio_dsp

reg:
maxItems: 5

reg-names:
maxItems: 5

interrupts:
maxItems: 4

interrupt-names:
maxItems: 4

clocks:
items:
- description: mux for dsp clock
- description: 26M clock
- description: mux for audio dsp local bus
- description: default audio dsp local bus clock source
- description: clock gate for dsp clock
- description: mux for dsp access external bus

clock-names:
items:
- const: dsp_sel
- const: clk26m_ck
- const: audio_local_bus
- const: mainpll_d7_d2
- const: scp_adsp_audiodsp
- const: audio_h_sel

power-domains:
maxItems: 1

mboxes:
maxItems: 3

mbox-names:
items:
- const: adsp 0
- const: adsp 1
- const: adsp 2

"#mbox-cells":
const: 1
description:
The first cell is the client-id, and the second cell is the signal-id.

sound:
maxItems: 3

memory-region:
description:
phandle to a node describing reserved memory (System RAM memory)
used by DSP (see bindings/reserved-memory/reserved-memory.txt)
maxItems: 2

required:
- compatible
- reg
- clocks
- clock-names
- power-domains
- mboxes
- mbox-names
- memory-region
- "#mbox-cells"

additionalProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/interrupt-controller/irq.h>

adsp: adsp@10803000 {
compatible = "mediatek,mt8195-audio_dsp";
reg = <0x10803000 0x1000>,
<0x10840000 0x40000>,
<0x10816000 0x1000>,
<0x10817000 0x1000>,
<0x10818000 0x1000>;
reg-names = "cfg", "sram", "mbox0", "mbox1", "mbox2";
interrupts = <GIC_SPI 694 IRQ_TYPE_LEVEL_HIGH 0>,
<GIC_SPI 702 IRQ_TYPE_LEVEL_HIGH 0>,
<GIC_SPI 703 IRQ_TYPE_LEVEL_HIGH 0>,
<GIC_SPI 704 IRQ_TYPE_LEVEL_HIGH 0>;
interrupt-names = "wdt", "mbox0", "mbox1", "mbox2";
clocks = <&topckgen 10>, //CLK_TOP_DSP_SEL
<&clk26m>,
<&topckgen 107>, //CLK_TOP_AUDIO_LOCAL_BUS_SEL
<&topckgen 136>, //CLK_TOP_MAINPLL_D7_D2
<&scp_adsp 0>, //CLK_SCP_ADSP_AUDIODSP
<&topckgen 34>; //CLK_TOP_AUDIO_H_SEL
clock-names = "dsp_sel",
"clk26m_ck",
"audio_local_bus",
"mainpll_d7_d2",
"scp_adsp_audiodsp",
"audio_h_sel";
memory-region = <&adsp_dma_mem_reserved>,
<&adsp_mem_reserved>;
power-domains = <&spm 6>; //MT8195_POWER_DOMAIN_ADSP
#mbox-cells = <1>;
mboxes = <&adsp 0>, <&adsp 1>, <&adsp 2>;
status = "disabled";

sound {
mediatek,dptx-codec = <&dp_tx>;
mediatek,hdmi-codec = <&hdmi0>;
mediatek,platform = <&afe>;
};
};
184 changes: 184 additions & 0 deletions Documentation/devicetree/bindings/sound/mt8195-afe-pcm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/sound/mt8195-afe-pcm.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Mediatek AFE PCM controller for mt8195

maintainers:
- Trevor Wu <trevor.wu@mediatek.com>

properties:
compatible:
const: mediatek,mt8195-audio

reg:
maxItems: 1

interrupts:
maxItems: 1

mediatek,topckgen:
$ref: "/schemas/types.yaml#/definitions/phandle"
description: The phandle of the mediatek topckgen controller

power-domains:
maxItems: 1

clocks:
items:
- description: 26M clock
- description: audio pll1 clock
- description: audio pll2 clock
- description: clock divider for i2si1_mck
- description: clock divider for i2si2_mck
- description: clock divider for i2so1_mck
- description: clock divider for i2so2_mck
- description: clock divider for dptx_mck
- description: a1sys hoping clock
- description: audio intbus clock
- description: audio hires clock
- description: audio local bus clock
- description: mux for dptx_mck
- description: mux for i2so1_mck
- description: mux for i2so2_mck
- description: mux for i2si1_mck
- description: mux for i2si2_mck
- description: audio infra 26M clock
- description: infra bus clock

clock-names:
items:
- const: clk26m
- const: apll1_ck
- const: apll2_ck
- const: apll12_div0
- const: apll12_div1
- const: apll12_div2
- const: apll12_div3
- const: apll12_div9
- const: a1sys_hp_sel
- const: aud_intbus_sel
- const: audio_h_sel
- const: audio_local_bus_sel
- const: dptx_m_sel
- const: i2so1_m_sel
- const: i2so2_m_sel
- const: i2si1_m_sel
- const: i2si2_m_sel
- const: infra_ao_audio_26m_b
- const: scp_adsp_audiodsp

mediatek,etdm-in1-chn-disabled:
$ref: /schemas/types.yaml#/definitions/uint8-array
maxItems: 24
description: Specify which input channel should be disabled.

mediatek,etdm-in2-chn-disabled:
$ref: /schemas/types.yaml#/definitions/uint8-array
maxItems: 16
description: Specify which input channel should be disabled.

patternProperties:
"^mediatek,etdm-in[1-2]-mclk-always-on-rate-hz$":
description: Specify etdm in mclk output rate for always on case.

"^mediatek,etdm-out[1-3]-mclk-always-on-rate-hz$":
description: Specify etdm out mclk output rate for always on case.

"^mediatek,etdm-in[1-2]-multi-pin-mode$":
type: boolean
description: if present, the etdm data mode is I2S.

"^mediatek,etdm-out[1-3]-multi-pin-mode$":
type: boolean
description: if present, the etdm data mode is I2S.

"^mediatek,etdm-in[1-2]-cowork-source$":
$ref: /schemas/types.yaml#/definitions/uint32
description: |
etdm modules can share the same external clock pin. Specify
which etdm clock source is required by this etdm in moudule.
enum:
- 0 # etdm1_in
- 1 # etdm2_in
- 2 # etdm1_out
- 3 # etdm2_out

"^mediatek,etdm-out[1-2]-cowork-source$":
$ref: /schemas/types.yaml#/definitions/uint32
description: |
etdm modules can share the same external clock pin. Specify
which etdm clock source is required by this etdm out moudule.
enum:
- 0 # etdm1_in
- 1 # etdm2_in
- 2 # etdm1_out
- 3 # etdm2_out

required:
- compatible
- reg
- interrupts
- mediatek,topckgen
- power-domains
- clocks
- clock-names

additionalProperties: false

examples:
- |
#include <dt-bindings/clock/mt8195-clk.h>
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/power/mt8195-power.h>

afe: mt8195-afe-pcm@10890000 {
compatible = "mediatek,mt8195-audio";
reg = <0x10890000 0x10000>;
interrupts = <GIC_SPI 822 IRQ_TYPE_LEVEL_HIGH 0>;
mediatek,topckgen = <&topckgen>;
power-domains = <&spm MT8195_POWER_DOMAIN_AUDIO>;
clocks = <&clk26m>,
<&topckgen CLK_TOP_APLL1>,
<&topckgen CLK_TOP_APLL2>,
<&topckgen CLK_TOP_APLL12_DIV0>,
<&topckgen CLK_TOP_APLL12_DIV1>,
<&topckgen CLK_TOP_APLL12_DIV2>,
<&topckgen CLK_TOP_APLL12_DIV3>,
<&topckgen CLK_TOP_APLL12_DIV9>,
<&topckgen CLK_TOP_A1SYS_HP_SEL>,
<&topckgen CLK_TOP_AUD_INTBUS_SEL>,
<&topckgen CLK_TOP_AUDIO_H_SEL>,
<&topckgen CLK_TOP_AUDIO_LOCAL_BUS_SEL>,
<&topckgen CLK_TOP_DPTX_M_SEL>,
<&topckgen CLK_TOP_I2SO1_M_SEL>,
<&topckgen CLK_TOP_I2SO2_M_SEL>,
<&topckgen CLK_TOP_I2SI1_M_SEL>,
<&topckgen CLK_TOP_I2SI2_M_SEL>,
<&infracfg_ao CLK_INFRA_AO_AUDIO_26M_B>,
<&scp_adsp CLK_SCP_ADSP_AUDIODSP>;
clock-names = "clk26m",
"apll1_ck",
"apll2_ck",
"apll12_div0",
"apll12_div1",
"apll12_div2",
"apll12_div3",
"apll12_div9",
"a1sys_hp_sel",
"aud_intbus_sel",
"audio_h_sel",
"audio_local_bus_sel",
"dptx_m_sel",
"i2so1_m_sel",
"i2so2_m_sel",
"i2si1_m_sel",
"i2si2_m_sel",
"infra_ao_audio_26m_b",
"scp_adsp_audiodsp";
};

...
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/sound/mt8195-mt6359-rt1019-rt5682.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Mediatek MT8195 with MT6359, RT1019 and RT5682 ASoC sound card driver

maintainers:
- Trevor Wu <trevor.wu@mediatek.com>

description:
This binding describes the MT8195 sound card.

properties:
compatible:
const: mediatek,mt8195_mt6359_rt1019_rt5682

mediatek,platform:
$ref: "/schemas/types.yaml#/definitions/phandle"
description: The phandle of MT8195 ASoC platform.

mediatek,dptx-codec:
$ref: "/schemas/types.yaml#/definitions/phandle"
description: The phandle of MT8195 Display Port Tx codec node.

mediatek,hdmi-codec:
$ref: "/schemas/types.yaml#/definitions/phandle"
description: The phandle of MT8195 HDMI codec node.

additionalProperties: false

required:
- compatible
- mediatek,platform

examples:
- |

sound: mt8195-sound {
compatible = "mediatek,mt8195_mt6359_rt1019_rt5682";
mediatek,platform = <&afe>;
pinctrl-names = "default";
pinctrl-0 = <&aud_pins_default>;
};

...
3 changes: 3 additions & 0 deletions include/sound/sof.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ struct sof_dev_desc {

bool use_acpi_target_states;

/*set to 1 to not use ignore_machine and still use the original platform driver*/
bool no_ignore_machine;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unclear why you need this for?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we need to reuse original platform driver in our design, we don't want to overwrite it in the function soc_check_tplg_fes to still use original platform. Then we can route sof link to original(normal sink),
e.g. sof_conn_stream : { "ETDM2_OUT_BE", "AFE_SOF_DL2", SOF_DMA_DL2, SNDRV_PCM_STREAM_PLAYBACK}, to route sof_link : SOF_DMA_DL2 to normal link ETDM2_OUT_BE, then we can use normal link setting for audio hardware.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think going with ignore_machine name here works better.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yaochunhung I totally missed this. ignore_machine has nothing to do with ignoring the machine driver selected in SOF. It is more to do with how the core deals with the FE DAI links in the legacy machine driver. In your case, setting this should have no effect at all because there's no legacy driver to deal with right? @plbossart is my understanding correct?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranj063 We still use legacy driver because some pcm nodes are still controlled by non-sof driver, not move to DSP. And We also want to keep to legacy BE DAI driver because the power and clock of our audio hardware are controlled by AP side. e.g ETDM2_OUT_BE. If no_ignore_machine is set as true, the legacy driver can be keep and reuse. Thanks!

Copy link
Author

@yaochunhung yaochunhung Sep 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart In the machine driver sound/soc/mediatek/mt8195/mt8195-mt6359-rt1019-rt5682.c. we define g_sof_conn_streams about the connection among ETDM2_OUT_BE,SOF_DMA_DL2 and AFE_SOF_DL2.
static const struct sof_conn_stream g_sof_conn_streams[] = {
{ "ETDM2_OUT_BE", "AFE_SOF_DL2", SOF_DMA_DL2, SNDRV_PCM_STREAM_PLAYBACK},
{ "ETDM1_OUT_BE", "AFE_SOF_DL3", SOF_DMA_DL3, SNDRV_PCM_STREAM_PLAYBACK},
{ "UL_SRC1_BE", "AFE_SOF_UL4", SOF_DMA_UL4, SNDRV_PCM_STREAM_CAPTURE},
{ "ETDM2_IN_BE", "AFE_SOF_UL5", SOF_DMA_UL5, SNDRV_PCM_STREAM_CAPTURE},
};
Then we implement .late_probe = mt8195_mt6359_rt1019_rt5682_card_late_probe.
In this function, we search pcm_runtime by sof_link and normal_link then get sof's pcm runtime : sof_rtd and normal pcm runtime : normal_rtd. After that, we search the sof's runtime cpu_dai then check the widget in its path then set dapm route's source and sink then add routes.

for example, ETDM2_OUT_BE is normal_link, AFE_SOF_DL2 is sof_link,SOF_DMA_DL2 is sof_dma, and stream_dir is SNDRV_PCM_STREAM_PLAYBACK.
We will use snd_soc_dapm_widget_for_each_source_path to get the playback_widget is BUFn.x in the diagram above.
then set sink of dpam route as conn->sof_dma(SOF_DMA_DL2 in this case). After that, BUFn.x will be connected to SOF_DMA_DL2.
For SOF_DMA_DL2 to ETDM2_OUT_BE , we define the dapm route path in machine driver.
/* SOF Downlink */
{"I070", NULL, SOF_DMA_DL2},
{"I071", NULL, SOF_DMA_DL2},
And also define dapm route path in mt8195-dai-etdm.c
{"O048", "I070 Switch", "I070"},
{"O049", "I071 Switch", "I071"},
{"ETDM2 Playback", NULL, "O048"},
{"ETDM2 Playback", NULL, "O049"},
I hope this explanation is more clear. Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this explanation is more clear. Thanks.

Humm, no :-(
I am missing the big picture, you just hammered us with details that are probably correct but don't really provide a sense of what the problem statement is, if you considered alternatives and what led you to pick this solution you're asking us to review.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plbossart
We set no_ignore_machine as true to prevent ignoring normal FE in soc_check_tplg_fes.

/* ignore this FE */
if (dai_link->dynamic) {
dai_link->ignore = true;
continue;
})

The reason is that we still need to use normal FE for the paths which don't gothrough DSP. The benifit is that we can offload the process of certain audio data(e.g. speaker/headphone) to dsp and we can reuse normal alsa driver for those audio data which don't need dsp offloading.(e.g. Display port). Thanks.

Copy link
Collaborator

@ranj063 ranj063 Sep 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yaochunhung It makes a bit more sense now. but a naive question. Is there a way for you define the Normal FE-> Normal BE in topology?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ranj063 For normal FE/BE, I think it need to communicate with DSP if defining them in topology(please correct me if my misunderstanding). It takes lower effort to reuse normal FE/BE without topology. Thanks.


/* Platform resource indexes in BAR / ACPI resources. */
/* Must set to -1 if not used - add new items to end */
int resindex_lpe_base;
Expand Down
24 changes: 24 additions & 0 deletions include/sound/sof/dai-mediatek.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
/*
* Copyright(c) 2021 Mediatek Corporation. All rights reserved.
*
* Author: Bo Pan <bo.pan@mediatek.com>
* YC Hung <yc.hung@mediatek.com>
*/

#ifndef __INCLUDE_SOUND_SOF_DAI_MEDIATEK_H__
#define __INCLUDE_SOUND_SOF_DAI_MEDIATEK_H__

#include <sound/sof/header.h>

struct sof_ipc_dai_mtk_afe_params {
struct sof_ipc_hdr hdr;
u32 channels;
u32 rate;
u32 format;
u32 stream_id;
u32 reserved[4]; /* reserve for future */
} __packed;

#endif

Loading