Subject: [PATCH 0/4] MT8195 Acer Tomato - Audio support

This series enables full support for audio, with DSP, on the Cherry
Chromebooks.
Related ALSA UCM2 configuration was already merged in its upstream
repository [1]: this is fully tested and working as-is since all of
the required fixes for MT8195 SOF drivers were picked and are present
since `next-20220908`.

[1]: https://github.com/alsa-project/alsa-ucm-conf/commit/a59c3b1a57de8eb424c4f754bb031265e856260e

______________________________________
_________ Platform overview: _________

What's still missing?

* Format: feature (location)
*
* MediaTek vcodec enc/dec (mt8195.dtsi only)
* PCI-Express WiFi card (mt8195 and mt8195-cherry)
* VDOSYS1 (mt8195.dtsi and mediatek-drm/mmsys drivers)
* DP/eDP outputs for external/internal display (mt8195 and mt8195-cherry)
* LVTS Thermal Sensors (mt8195.dtsi, driver is missing)
* GPU support (clocks and mtk-regulator-coupler are awaiting for review/pick)

AngeloGioacchino Del Regno (4):
arm64: dts: mediatek: cherry: Add Audio Front End (AFE) support
arm64: dts: mediatek: cherry: Enable the Audio DSP for SOF
arm64: dts: mediatek: cherry: Add external codecs and speaker
amplifier
arm64: dts: mediatek: cherry: Add sound card configuration

.../dts/mediatek/mt8195-cherry-tomato-r1.dts | 10 ++
.../dts/mediatek/mt8195-cherry-tomato-r2.dts | 10 ++
.../dts/mediatek/mt8195-cherry-tomato-r3.dts | 10 ++
.../boot/dts/mediatek/mt8195-cherry.dtsi | 109 ++++++++++++++++++
4 files changed, 139 insertions(+)

--
2.37.2


Subject: [PATCH 3/4] arm64: dts: mediatek: cherry: Add external codecs and speaker amplifier

The entire Cherry family has two digital microphones, for which
we use the generic dmic-codec, linked to the MT6359 PMIC.
Moreover, it uses a Realtek RT1019p amplifier for the speakers
and has either a Realtek RT5682i or RT5682s audio codec on I2C2:
specifically, RT5682i is found on Tomato's rev 1 and rev 2 boards,
while RT5682s is found in rev3 and rev4 boards.

Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
---
.../dts/mediatek/mt8195-cherry-tomato-r1.dts | 5 +++
.../dts/mediatek/mt8195-cherry-tomato-r2.dts | 5 +++
.../dts/mediatek/mt8195-cherry-tomato-r3.dts | 5 +++
.../boot/dts/mediatek/mt8195-cherry.dtsi | 37 +++++++++++++++++++
4 files changed, 52 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r1.dts b/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r1.dts
index 3348ba69ff6c..3767b49ea896 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r1.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r1.dts
@@ -10,6 +10,11 @@ / {
compatible = "google,tomato-rev1", "google,tomato", "mediatek,mt8195";
};

+&audio_codec {
+ compatible = "realtek,rt5682i";
+ realtek,btndet-delay = <16>;
+};
+
&ts_10 {
status = "okay";
};
diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r2.dts b/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r2.dts
index 4669e9d917f8..0ed83a79d680 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r2.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r2.dts
@@ -10,6 +10,11 @@ / {
compatible = "google,tomato-rev2", "google,tomato", "mediatek,mt8195";
};

+&audio_codec {
+ compatible = "realtek,rt5682i";
+ realtek,btndet-delay = <16>;
+};
+
&pio_default {
pins-low-power-hdmi-disable {
pinmux = <PINMUX_GPIO31__FUNC_GPIO31>,
diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r3.dts b/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r3.dts
index 5021edd02f7c..c47b341e98fb 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r3.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r3.dts
@@ -11,6 +11,11 @@ / {
"google,tomato", "mediatek,mt8195";
};

+&audio_codec {
+ compatible = "realtek,rt5682s";
+ realtek,amic-delay-ms = <250>;
+};
+
&pio_default {
pins-low-power-hdmi-disable {
pinmux = <PINMUX_GPIO31__FUNC_GPIO31>,
diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
index 3bc624e6f499..95e93b791432 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
@@ -26,6 +26,12 @@ chosen {
stdout-path = "serial0:115200n8";
};

+ dmic-codec {
+ compatible = "dmic-codec";
+ num-channels = <2>;
+ wakeup-delay-ms = <50>;
+ };
+
memory@40000000 {
device_type = "memory";
reg = <0 0x40000000 0 0x80000000>;
@@ -136,6 +142,14 @@ adsp_device_mem: memory@60e80000 {
no-map;
};
};
+
+ spk_amplifier: rt1019p {
+ compatible = "realtek,rt1019p";
+ label = "rt1019p";
+ pinctrl-names = "default";
+ pinctrl-0 = <&rt1019p_pins_default>;
+ sdb-gpios = <&pio 100 GPIO_ACTIVE_HIGH>;
+ };
};

&adsp {
@@ -185,6 +199,17 @@ &i2c2 {
clock-frequency = <400000>;
pinctrl-names = "default";
pinctrl-0 = <&i2c2_pins>;
+
+ audio_codec: codec@1a {
+ /* Realtek RT5682i or RT5682s, sharing the same configuration */
+ reg = <0x1a>;
+ interrupts-extended = <&pio 89 IRQ_TYPE_EDGE_BOTH>;
+ realtek,jd-src = <1>;
+
+ AVDD-supply = <&mt6359_vio18_ldo_reg>;
+ MICVDD-supply = <&pp3300_z2>;
+ VBAT-supply = <&pp3300_z5>;
+ };
};

&i2c3 {
@@ -289,6 +314,11 @@ &mmc1 {
vqmmc-supply = <&mt_pmic_vmc_ldo_reg>;
};

+&mt6359codec {
+ mediatek,dmic-mode = <1>; /* one-wire */
+ mediatek,mic-type-0 = <2>; /* DMIC */
+};
+
/* for CPU-L */
&mt6359_vcore_buck_reg {
regulator-always-on;
@@ -723,6 +753,13 @@ pins-low-power-pupd {
};
};

+ rt1019p_pins_default: rt1019p-default-pins {
+ pins-amp-sdb {
+ pinmux = <PINMUX_GPIO100__FUNC_GPIO100>;
+ output-low;
+ };
+ };
+
scp_pins: scp-default-pins {
pins-vreq {
pinmux = <PINMUX_GPIO76__FUNC_SCP_VREQ_VAO>;
--
2.37.2

Subject: [PATCH 4/4] arm64: dts: mediatek: cherry: Add sound card configuration

Configure the sound card on all MT8195 Cherry Tomato devices to
enable audio support.

Signed-off-by: AngeloGioacchino Del Regno <[email protected]>
---
.../dts/mediatek/mt8195-cherry-tomato-r1.dts | 5 +++
.../dts/mediatek/mt8195-cherry-tomato-r2.dts | 5 +++
.../dts/mediatek/mt8195-cherry-tomato-r3.dts | 5 +++
.../boot/dts/mediatek/mt8195-cherry.dtsi | 40 +++++++++++++++++++
4 files changed, 55 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r1.dts b/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r1.dts
index 3767b49ea896..2d5e8f371b6d 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r1.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r1.dts
@@ -15,6 +15,11 @@ &audio_codec {
realtek,btndet-delay = <16>;
};

+&sound {
+ compatible = "mediatek,mt8195_mt6359_rt1019_rt5682";
+ model = "mt8195_r1019_5682";
+};
+
&ts_10 {
status = "okay";
};
diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r2.dts b/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r2.dts
index 0ed83a79d680..2586c32ce6e6 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r2.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r2.dts
@@ -35,6 +35,11 @@ pins-low-power-pcie0-disable {
};
};

+&sound {
+ compatible = "mediatek,mt8195_mt6359_rt1019_rt5682";
+ model = "mt8195_r1019_5682";
+};
+
&ts_10 {
status = "okay";
};
diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r3.dts b/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r3.dts
index c47b341e98fb..f54f9477b99d 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r3.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry-tomato-r3.dts
@@ -36,6 +36,11 @@ pins-low-power-pcie0-disable {
};
};

+&sound {
+ compatible = "mediatek,mt8195_mt6359_rt1019_rt5682";
+ model = "m8195_r1019_5682s";
+};
+
&ts_10 {
status = "okay";
};
diff --git a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
index 95e93b791432..3410e16d7e99 100644
--- a/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi
@@ -526,6 +526,34 @@ &pio {
"AP_SPI_FLASH_MOSI",
"AP_SPI_FLASH_MISO";

+ aud_pins_default: audio-default-pins {
+ pins-cmd-dat {
+ pinmux = <PINMUX_GPIO69__FUNC_AUD_CLK_MOSI>,
+ <PINMUX_GPIO70__FUNC_AUD_SYNC_MOSI>,
+ <PINMUX_GPIO71__FUNC_AUD_DAT_MOSI0>,
+ <PINMUX_GPIO72__FUNC_AUD_DAT_MOSI1>,
+ <PINMUX_GPIO73__FUNC_AUD_DAT_MISO0>,
+ <PINMUX_GPIO74__FUNC_AUD_DAT_MISO1>,
+ <PINMUX_GPIO75__FUNC_AUD_DAT_MISO2>,
+ <PINMUX_GPIO0__FUNC_TDMIN_MCK>,
+ <PINMUX_GPIO1__FUNC_TDMIN_DI>,
+ <PINMUX_GPIO2__FUNC_TDMIN_LRCK>,
+ <PINMUX_GPIO3__FUNC_TDMIN_BCK>,
+ <PINMUX_GPIO60__FUNC_I2SO2_D0>,
+ <PINMUX_GPIO49__FUNC_I2SIN_D0>,
+ <PINMUX_GPIO50__FUNC_I2SO1_MCK>,
+ <PINMUX_GPIO51__FUNC_I2SO1_BCK>,
+ <PINMUX_GPIO52__FUNC_I2SO1_WS>,
+ <PINMUX_GPIO53__FUNC_I2SO1_D0>;
+ };
+
+ pins-hp-jack-int-odl {
+ pinmux = <PINMUX_GPIO89__FUNC_GPIO89>;
+ input-enable;
+ bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
+ };
+ };
+
cr50_int: cr50-irq-default-pins {
pins-gsc-ap-int-odl {
pinmux = <PINMUX_GPIO88__FUNC_GPIO88>;
@@ -833,6 +861,18 @@ cros-ec-rpmsg {
};
};

+&sound {
+ status = "okay";
+
+ mediatek,adsp = <&adsp>;
+ mediatek,dai-link =
+ "DL10_FE", "DPTX_BE", "ETDM1_IN_BE", "ETDM2_IN_BE",
+ "ETDM1_OUT_BE", "ETDM2_OUT_BE","UL_SRC1_BE",
+ "AFE_SOF_DL2", "AFE_SOF_DL3", "AFE_SOF_UL4", "AFE_SOF_UL5";
+ pinctrl-names = "default";
+ pinctrl-0 = <&aud_pins_default>;
+};
+
&spi0 {
status = "okay";

--
2.37.2

2022-10-07 09:03:48

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH 0/4] MT8195 Acer Tomato - Audio support

Hi,

On Thu, Sep 22, 2022 at 5:49 PM AngeloGioacchino Del Regno
<[email protected]> wrote:
>
> This series enables full support for audio, with DSP, on the Cherry
> Chromebooks.
> Related ALSA UCM2 configuration was already merged in its upstream
> repository [1]: this is fully tested and working as-is since all of
> the required fixes for MT8195 SOF drivers were picked and are present
> since `next-20220908`.
>
> [1]: https://github.com/alsa-project/alsa-ucm-conf/commit/a59c3b1a57de8eb424c4f754bb031265e856260e

While trying this patch, I get the following error:

# modprobe mt8195-mt6359
[ 44.985107] mt6359-sound mt6359-sound: ASoC: sink widget AIF1TX overwritten
[ 44.994393] dmic-codec dmic-codec: GPIO lookup for consumer dmicen
[ 45.000636] dmic-codec dmic-codec: using device tree for GPIO lookup
[ 45.007165] of_get_named_gpiod_flags: can't parse 'dmicen-gpios'
property of node '/dmic-codec[0]'
[ 45.016177] of_get_named_gpiod_flags: can't parse 'dmicen-gpio'
property of node '/dmic-codec[0]'
[ 45.025084] dmic-codec dmic-codec: using lookup tables for GPIO lookup
[ 45.031666] dmic-codec dmic-codec: No GPIO consumer dmicen found
[ 45.041434] sof-audio-of-mt8195 10803000.dsp: Topology: ABI 3:22:1
Kernel ABI 3:23:0
[ 45.050185] mt8195_mt6359 mt8195-sound: ASoC: Parent card not yet
available, widget card binding deferred
[ 45.060566] sof-audio-of-mt8195 10803000.dsp: ipc tx error for
0x30010000 (msg/reply size: 96/20): -22
[ 45.069965] sof-audio-of-mt8195 10803000.dsp: Failed to setup widget AFE3.IN
[ 45.077575] sof-audio-of-mt8195 10803000.dsp: error: tplg component
load failed -22
[ 45.085291] sof-audio-of-mt8195 10803000.dsp: error: failed to load
DSP topology -22
[ 45.093062] sof-audio-of-mt8195 10803000.dsp: ASoC: error at
snd_soc_component_probe on 10803000.dsp: -22
[ 45.102880] mt8195_mt6359 mt8195-sound: ASoC: failed to instantiate card -22
[ 45.123915] mt8195_mt6359: probe of mt8195-sound failed with error -22

Any ideas?

Subject: Re: [PATCH 0/4] MT8195 Acer Tomato - Audio support

Il 07/10/22 10:42, Chen-Yu Tsai ha scritto:
> Hi,
>
> On Thu, Sep 22, 2022 at 5:49 PM AngeloGioacchino Del Regno
> <[email protected]> wrote:
>>
>> This series enables full support for audio, with DSP, on the Cherry
>> Chromebooks.
>> Related ALSA UCM2 configuration was already merged in its upstream
>> repository [1]: this is fully tested and working as-is since all of
>> the required fixes for MT8195 SOF drivers were picked and are present
>> since `next-20220908`.
>>
>> [1]: https://github.com/alsa-project/alsa-ucm-conf/commit/a59c3b1a57de8eb424c4f754bb031265e856260e
>
> While trying this patch, I get the following error:
>
> # modprobe mt8195-mt6359
> [ 44.985107] mt6359-sound mt6359-sound: ASoC: sink widget AIF1TX overwritten
> [ 44.994393] dmic-codec dmic-codec: GPIO lookup for consumer dmicen
> [ 45.000636] dmic-codec dmic-codec: using device tree for GPIO lookup
> [ 45.007165] of_get_named_gpiod_flags: can't parse 'dmicen-gpios'
> property of node '/dmic-codec[0]'
> [ 45.016177] of_get_named_gpiod_flags: can't parse 'dmicen-gpio'
> property of node '/dmic-codec[0]'
> [ 45.025084] dmic-codec dmic-codec: using lookup tables for GPIO lookup
> [ 45.031666] dmic-codec dmic-codec: No GPIO consumer dmicen found
> [ 45.041434] sof-audio-of-mt8195 10803000.dsp: Topology: ABI 3:22:1
> Kernel ABI 3:23:0
> [ 45.050185] mt8195_mt6359 mt8195-sound: ASoC: Parent card not yet
> available, widget card binding deferred
> [ 45.060566] sof-audio-of-mt8195 10803000.dsp: ipc tx error for
> 0x30010000 (msg/reply size: 96/20): -22
> [ 45.069965] sof-audio-of-mt8195 10803000.dsp: Failed to setup widget AFE3.IN
> [ 45.077575] sof-audio-of-mt8195 10803000.dsp: error: tplg component
> load failed -22
> [ 45.085291] sof-audio-of-mt8195 10803000.dsp: error: failed to load
> DSP topology -22
> [ 45.093062] sof-audio-of-mt8195 10803000.dsp: ASoC: error at
> snd_soc_component_probe on 10803000.dsp: -22
> [ 45.102880] mt8195_mt6359 mt8195-sound: ASoC: failed to instantiate card -22
> [ 45.123915] mt8195_mt6359: probe of mt8195-sound failed with error -22
>
> Any ideas?

We have to recheck if the firmware that was sent upstream is the right one for
Tomato's dts topology variant, I think.
That's surely a firmware issue that you're seeing, anyway.

sof-mt8195.ri

Cheers,
Angelo

Subject: Re: [PATCH 0/4] MT8195 Acer Tomato - Audio support

Il 07/10/22 10:52, AngeloGioacchino Del Regno ha scritto:
> Il 07/10/22 10:42, Chen-Yu Tsai ha scritto:
>> Hi,
>>
>> On Thu, Sep 22, 2022 at 5:49 PM AngeloGioacchino Del Regno
>> <[email protected]> wrote:
>>>
>>> This series enables full support for audio, with DSP, on the Cherry
>>> Chromebooks.
>>> Related ALSA UCM2 configuration was already merged in its upstream
>>> repository [1]: this is fully tested and working as-is since all of
>>> the required fixes for MT8195 SOF drivers were picked and are present
>>> since `next-20220908`.
>>>
>>> [1]:
>>> https://github.com/alsa-project/alsa-ucm-conf/commit/a59c3b1a57de8eb424c4f754bb031265e856260e
>>
>> While trying this patch, I get the following error:
>>
>> # modprobe mt8195-mt6359
>> [   44.985107] mt6359-sound mt6359-sound: ASoC: sink widget AIF1TX overwritten
>> [   44.994393] dmic-codec dmic-codec: GPIO lookup for consumer dmicen
>> [   45.000636] dmic-codec dmic-codec: using device tree for GPIO lookup
>> [   45.007165] of_get_named_gpiod_flags: can't parse 'dmicen-gpios'
>> property of node '/dmic-codec[0]'
>> [   45.016177] of_get_named_gpiod_flags: can't parse 'dmicen-gpio'
>> property of node '/dmic-codec[0]'
>> [   45.025084] dmic-codec dmic-codec: using lookup tables for GPIO lookup
>> [   45.031666] dmic-codec dmic-codec: No GPIO consumer dmicen found
>> [   45.041434] sof-audio-of-mt8195 10803000.dsp: Topology: ABI 3:22:1
>> Kernel ABI 3:23:0
>> [   45.050185] mt8195_mt6359 mt8195-sound: ASoC: Parent card not yet
>> available, widget card binding deferred
>> [   45.060566] sof-audio-of-mt8195 10803000.dsp: ipc tx error for
>> 0x30010000 (msg/reply size: 96/20): -22
>> [   45.069965] sof-audio-of-mt8195 10803000.dsp: Failed to setup widget AFE3.IN
>> [   45.077575] sof-audio-of-mt8195 10803000.dsp: error: tplg component
>> load failed -22
>> [   45.085291] sof-audio-of-mt8195 10803000.dsp: error: failed to load
>> DSP topology -22
>> [   45.093062] sof-audio-of-mt8195 10803000.dsp: ASoC: error at
>> snd_soc_component_probe on 10803000.dsp: -22
>> [   45.102880] mt8195_mt6359 mt8195-sound: ASoC: failed to instantiate card -22
>> [   45.123915] mt8195_mt6359: probe of mt8195-sound failed with error -22
>>
>> Any ideas?
>
> We have to recheck if the firmware that was sent upstream is the right one for
> Tomato's dts topology variant, I think.
> That's surely a firmware issue that you're seeing, anyway.
>
> sof-mt8195.ri
>

Update to this: what you were seeing was not related to this series, which is
entirely correct, but due to an ABI breakage in SoundOpenFirmware.

After I reported that to SOF, a commit [1] was pushed to fix the same - now this
series is fully working, as expected.

[1]:
https://lore.kernel.org/alsa-devel/[email protected]/T/#u

Chen-Yu, would you please test this again with the aforementioned commit?
Works here, should work for you as well now :-)

Cheers!
Angelo


2022-12-16 14:36:55

by Matthias Brugger

[permalink] [raw]
Subject: Re: [PATCH 0/4] MT8195 Acer Tomato - Audio support

Whole series applied, thanks a lot.

Matthias

On 22/09/2022 11:49, AngeloGioacchino Del Regno wrote:
> This series enables full support for audio, with DSP, on the Cherry
> Chromebooks.
> Related ALSA UCM2 configuration was already merged in its upstream
> repository [1]: this is fully tested and working as-is since all of
> the required fixes for MT8195 SOF drivers were picked and are present
> since `next-20220908`.
>
> [1]: https://github.com/alsa-project/alsa-ucm-conf/commit/a59c3b1a57de8eb424c4f754bb031265e856260e
>
> ______________________________________
> _________ Platform overview: _________
>
> What's still missing?
>
> * Format: feature (location)
> *
> * MediaTek vcodec enc/dec (mt8195.dtsi only)
> * PCI-Express WiFi card (mt8195 and mt8195-cherry)
> * VDOSYS1 (mt8195.dtsi and mediatek-drm/mmsys drivers)
> * DP/eDP outputs for external/internal display (mt8195 and mt8195-cherry)
> * LVTS Thermal Sensors (mt8195.dtsi, driver is missing)
> * GPU support (clocks and mtk-regulator-coupler are awaiting for review/pick)
>
> AngeloGioacchino Del Regno (4):
> arm64: dts: mediatek: cherry: Add Audio Front End (AFE) support
> arm64: dts: mediatek: cherry: Enable the Audio DSP for SOF
> arm64: dts: mediatek: cherry: Add external codecs and speaker
> amplifier
> arm64: dts: mediatek: cherry: Add sound card configuration
>
> .../dts/mediatek/mt8195-cherry-tomato-r1.dts | 10 ++
> .../dts/mediatek/mt8195-cherry-tomato-r2.dts | 10 ++
> .../dts/mediatek/mt8195-cherry-tomato-r3.dts | 10 ++
> .../boot/dts/mediatek/mt8195-cherry.dtsi | 109 ++++++++++++++++++
> 4 files changed, 139 insertions(+)
>