mbox series

[v9,0/8] ASoC: mediatek: Add support for MT8186 SoC

Message ID 20220712150442.32504-1-jiaxin.yu@mediatek.com (mailing list archive)
Headers show
Series ASoC: mediatek: Add support for MT8186 SoC | expand

Message

Jiaxin Yu July 12, 2022, 3:04 p.m. UTC
This series of patches adds support for Mediatek AFE of MT8186 Soc.
Patches are based on broonie tree "for-next" branch.

Changes since v8:
  - Remove unnecessary comments and blank line.
  - Use devm_add_action_or_reset to ease error handling when dev probe.
  - Remove .remove callback in plaform driver.

Changes since v7:
  - Optimize the code logic, such as the return value and position of a
    function.
  - Use devm_pm_runtime_enable() instead of pm_runtime_enable().
  - Use pm_runtime_resume_and_get() instead of pm_runtime_get_sync().

Changes since v6:
  - The Makefile and Kconfig updates are moved into the driver patches so that can
    keep independence of each patch.

Changes since v5:
  - fix build error about function snd_soc_card_jack_new that modified by:
    Link: https://lore.kernel.org/r/20220408041114.6024-1-akihiko.odaki@gmail.com
  - some have been accepted, details are in the link below:
    Link: https://lore.kernel.org/all/165459931885.399031.2621579592368573898.b4-ty@kernel.org/

Changes since v4:
  - [v5 07/20]
    - remove unsusd controls
  - [v5 09/20]
    - correct indent error
  - [v5 10/20]
  - [v5 13/20]
  - [v5 14/20]
    - fix the return value if the value is different from the previous
      value in mixer controls
  - [v5 17/20]
  - [v5 19/20]
    - correct the compatible name with '_' instead of '-'
  - [v5 18/20]
  - [v5 20/20]
    - correct the yaml after 'pip3 install dtschema --upgrade'

Changes since v3:
  - [v4 09/18]
    - remove DEBUG_COEFF debugging code
  - [v4 10/18]
    - simplify the logic of the code
  - [v4 13/18]
    - split out the MT6366 bits into mt8186-mt6366-commom.c
    - fix build error of "error: 'struct dev_pm_info' has no member named 'runtime_error'"
    - fix bug of adda dai driver
    - add route for pcm interface channel 2.
  - [v4 15/18]
  - [v4 17/18]
    - commonize the configuration of the codec
    - move MT6366 common bits into mt8186-mt6366-common.c

Changes since v2:
  - add a new compatible string "mediatek,mt6366-sound"
  - modify the log level for simplicity
  - use dev_err_probe(...) instead of dev_err(...) in dev probe()
  - optimized the logic of some code
  - use BIT() and GENMASK() macros to descript the registers

  Thanks for AngeloGioacchino's careful reviews.

Changes since v1:
  [v2 01/17]
    - add a new ID to the existing mt6358 codec driver
  [v2 03/17]
    - modify log level in DAPM events
    - use standard numeric control with name ending in Switch
    - return 1 when the value changed in mixer control's .get callback
  [v2 05/17]
    - ending in Switch to the standard on/off controls
    - change to "HW Gain 1 Volume" and "HW Gain 2 Volume"
  [v2 09/17]
    - return an error in the default case rather than just picking one of
      the behaviours when do .set_fmt
    - use the new defines that are _PROVIDER_MASK, _DAIFMT_CBP_CFP and
      _DAIFMT_CBC_CFC
  [v2 10/17]
  [v2 11/17]
    - the clock and gpio are aplit out into separate  patches

  The source file's GPL comment use c++ style, and the header fils's GPL
  comment use c style. We have added "Switch" after the names of all the
  controls that just are simple on/off.

Jiaxin Yu (8):
  dt-bindings: mediatek: mt6358: add new compatible for using mt6366
  ASoC: mediatek: mt8186: add platform driver
  ASoC: mediatek: mt8186: add mt8186-mt6366 common driver
  dt-bindings: mediatek: mt8186: add audio afe document
  ASoC: mediatek: mt8186: add machine driver with mt6366, da7219 and
    max98357
  dt-bindings: mediatek: mt8186: add mt8186-mt6366-da7219-max98357
    document
  ASoC: mediatek: mt8186: add machine driver with mt6366, rt1019 and
    rt5682s
  dt-bindings: mediatek: mt8186: add mt8186-mt6366-rt1019-rt5682s
    document

 .../devicetree/bindings/sound/mt6358.txt      |    4 +-
 .../bindings/sound/mt8186-afe-pcm.yaml        |  175 +
 .../sound/mt8186-mt6366-da7219-max98357.yaml  |   75 +
 .../sound/mt8186-mt6366-rt1019-rt5682s.yaml   |   75 +
 sound/soc/mediatek/Kconfig                    |   44 +
 sound/soc/mediatek/Makefile                   |    1 +
 sound/soc/mediatek/mt8186/Makefile            |   22 +
 sound/soc/mediatek/mt8186/mt8186-afe-clk.c    |    3 +-
 sound/soc/mediatek/mt8186/mt8186-afe-clk.h    |    2 +-
 sound/soc/mediatek/mt8186/mt8186-afe-common.h |  235 ++
 .../soc/mediatek/mt8186/mt8186-afe-control.c  |  255 ++
 sound/soc/mediatek/mt8186/mt8186-afe-pcm.c    | 3000 +++++++++++++++++
 .../mediatek/mt8186/mt8186-mt6366-common.c    |   57 +
 .../mediatek/mt8186/mt8186-mt6366-common.h    |   17 +
 .../mt8186/mt8186-mt6366-da7219-max98357.c    | 1002 ++++++
 .../mt8186/mt8186-mt6366-rt1019-rt5682s.c     |  978 ++++++
 16 files changed, 5942 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/mt8186-afe-pcm.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/mt8186-mt6366-da7219-max98357.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/mt8186-mt6366-rt1019-rt5682s.yaml
 create mode 100644 sound/soc/mediatek/mt8186/Makefile
 create mode 100644 sound/soc/mediatek/mt8186/mt8186-afe-common.h
 create mode 100644 sound/soc/mediatek/mt8186/mt8186-afe-control.c
 create mode 100644 sound/soc/mediatek/mt8186/mt8186-afe-pcm.c
 create mode 100644 sound/soc/mediatek/mt8186/mt8186-mt6366-common.c
 create mode 100644 sound/soc/mediatek/mt8186/mt8186-mt6366-common.h
 create mode 100644 sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c
 create mode 100644 sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c

Comments

AngeloGioacchino Del Regno July 14, 2022, 2:08 p.m. UTC | #1
Il 12/07/22 17:04, Jiaxin Yu ha scritto:
> Add mt8186 platform and affiliated driver.
> 
> Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
> ---
>   sound/soc/mediatek/Kconfig                    |   12 +
>   sound/soc/mediatek/Makefile                   |    1 +
>   sound/soc/mediatek/mt8186/Makefile            |   19 +
>   sound/soc/mediatek/mt8186/mt8186-afe-clk.c    |    3 +-
>   sound/soc/mediatek/mt8186/mt8186-afe-clk.h    |    2 +-
>   sound/soc/mediatek/mt8186/mt8186-afe-common.h |  235 ++
>   .../soc/mediatek/mt8186/mt8186-afe-control.c  |  255 ++
>   sound/soc/mediatek/mt8186/mt8186-afe-pcm.c    | 3000 +++++++++++++++++
>   8 files changed, 3525 insertions(+), 2 deletions(-)
>   create mode 100644 sound/soc/mediatek/mt8186/Makefile
>   create mode 100644 sound/soc/mediatek/mt8186/mt8186-afe-common.h
>   create mode 100644 sound/soc/mediatek/mt8186/mt8186-afe-control.c
>   create mode 100644 sound/soc/mediatek/mt8186/mt8186-afe-pcm.c
> 
> diff --git a/sound/soc/mediatek/Kconfig b/sound/soc/mediatek/Kconfig
> index 3b1ddea26a9e..f3c3b93226e4 100644
> --- a/sound/soc/mediatek/Kconfig
> +++ b/sound/soc/mediatek/Kconfig
> @@ -152,6 +152,18 @@ config SND_SOC_MT8183_DA7219_MAX98357A
>   	  Select Y if you have such device.
>   	  If unsure select "N".
>   
> +config SND_SOC_MT8186
> +	tristate "ASoC support for Mediatek MT8186 chip"
> +	depends on ARCH_MEDIATEK || COMPILE_TEST
> +	depends on COMMON_CLK
> +	select SND_SOC_MEDIATEK
> +	select MFD_SYSCON if SND_SOC_MT6358
> +	help
> +	  This adds ASoC driver for Mediatek MT8186 boards
> +	  that can be used with other codecs.
> +	  Select Y if you have such device.
> +	  If unsure select "N".
> +
>   config SND_SOC_MTK_BTCVSD
>   	tristate "ALSA BT SCO CVSD/MSBC Driver"
>   	help
> diff --git a/sound/soc/mediatek/Makefile b/sound/soc/mediatek/Makefile
> index 34778ca12106..5571c640a288 100644
> --- a/sound/soc/mediatek/Makefile
> +++ b/sound/soc/mediatek/Makefile
> @@ -4,5 +4,6 @@ obj-$(CONFIG_SND_SOC_MT2701) += mt2701/
>   obj-$(CONFIG_SND_SOC_MT6797) += mt6797/
>   obj-$(CONFIG_SND_SOC_MT8173) += mt8173/
>   obj-$(CONFIG_SND_SOC_MT8183) += mt8183/
> +obj-$(CONFIG_SND_SOC_MT8186) += mt8186/
>   obj-$(CONFIG_SND_SOC_MT8192) += mt8192/
>   obj-$(CONFIG_SND_SOC_MT8195) += mt8195/
> diff --git a/sound/soc/mediatek/mt8186/Makefile b/sound/soc/mediatek/mt8186/Makefile
> new file mode 100644
> index 000000000000..7626bb3499dd
> --- /dev/null
> +++ b/sound/soc/mediatek/mt8186/Makefile
> @@ -0,0 +1,19 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +# platform driver
> +snd-soc-mt8186-afe-objs := \
> +	mt8186-afe-pcm.o \
> +	mt8186-audsys-clk.o \
> +	mt8186-afe-clk.o \
> +	mt8186-afe-gpio.o \
> +	mt8186-dai-adda.o \
> +	mt8186-afe-control.o \
> +	mt8186-dai-i2s.o \
> +	mt8186-dai-hw-gain.o \
> +	mt8186-dai-pcm.o \
> +	mt8186-dai-src.o \
> +	mt8186-dai-hostless.o \
> +	mt8186-dai-tdm.o \
> +	mt8186-misc-control.o \
> +
> +obj-$(CONFIG_SND_SOC_MT8186) += snd-soc-mt8186-afe.o
> diff --git a/sound/soc/mediatek/mt8186/mt8186-afe-clk.c b/sound/soc/mediatek/mt8186/mt8186-afe-clk.c
> index 0275f66ddc18..a6b4f29049bb 100644
> --- a/sound/soc/mediatek/mt8186/mt8186-afe-clk.c
> +++ b/sound/soc/mediatek/mt8186/mt8186-afe-clk.c
> @@ -645,7 +645,8 @@ int mt8186_init_clock(struct mtk_base_afe *afe)
>   	return 0;
>   }
>   
> -void mt8186_deinit_clock(struct mtk_base_afe *afe)
> +void mt8186_deinit_clock(void *priv)
>   {
> +	struct mtk_base_afe *afe = priv;
>   	mt8186_audsys_clk_unregister(afe);
>   }
> diff --git a/sound/soc/mediatek/mt8186/mt8186-afe-clk.h b/sound/soc/mediatek/mt8186/mt8186-afe-clk.h
> index c539557d7c78..d5988717d8f2 100644
> --- a/sound/soc/mediatek/mt8186/mt8186-afe-clk.h
> +++ b/sound/soc/mediatek/mt8186/mt8186-afe-clk.h
> @@ -81,7 +81,7 @@ enum {
>   struct mtk_base_afe;
>   int mt8186_set_audio_int_bus_parent(struct mtk_base_afe *afe, int clk_id);
>   int mt8186_init_clock(struct mtk_base_afe *afe);
> -void mt8186_deinit_clock(struct mtk_base_afe *afe);
> +void mt8186_deinit_clock(void *priv);
>   int mt8186_afe_enable_cgs(struct mtk_base_afe *afe);
>   void mt8186_afe_disable_cgs(struct mtk_base_afe *afe);
>   int mt8186_afe_enable_clock(struct mtk_base_afe *afe);
> diff --git a/sound/soc/mediatek/mt8186/mt8186-afe-common.h b/sound/soc/mediatek/mt8186/mt8186-afe-common.h
> new file mode 100644
> index 000000000000..7e9e71783468
> --- /dev/null
> +++ b/sound/soc/mediatek/mt8186/mt8186-afe-common.h
> @@ -0,0 +1,235 @@
> +/* SPDX-License-Identifier: GPL-2.0
> + *
> + * mt8186-afe-common.h  --  Mediatek 8186 audio driver definitions
> + *
> + * Copyright (c) 2022 MediaTek Inc.
> + * Author: Jiaxin Yu <jiaxin.yu@mediatek.com>
> + */
> +

..snip..

> +
> +#define MT8186_RECORD_MEMIF MT8186_MEMIF_VUL12
> +#define MT8186_ECHO_REF_MEMIF MT8186_MEMIF_AWB
> +#define MT8186_PRIMARY_MEMIF MT8186_MEMIF_DL1
> +#define MT8186_FAST_MEMIF MT8186_MEMIF_DL2
> +#define MT8186_DEEP_MEMIF MT8186_MEMIF_DL3
> +#define MT8186_VOIP_MEMIF MT8186_MEMIF_DL12
> +#define MT8186_MMAP_DL_MEMIF MT8186_MEMIF_DL5
> +#define MT8186_MMAP_UL_MEMIF MT8186_MEMIF_VUL5
> +#define MT8186_BARGEIN_MEMIF MT8186_MEMIF_AWB
> +
> +enum {
> +	MT8186_IRQ_0,
> +	MT8186_IRQ_1,
> +	MT8186_IRQ_2,
> +	MT8186_IRQ_3,
> +	MT8186_IRQ_4,
> +	MT8186_IRQ_5,
> +	MT8186_IRQ_6,
> +	MT8186_IRQ_7,
> +	MT8186_IRQ_8,
> +	MT8186_IRQ_9,
> +	MT8186_IRQ_10,
> +	MT8186_IRQ_11,
> +	MT8186_IRQ_12,
> +	MT8186_IRQ_13,
> +	MT8186_IRQ_14,
> +	MT8186_IRQ_15,
> +	MT8186_IRQ_16,
> +	MT8186_IRQ_17,
> +	MT8186_IRQ_18,
> +	MT8186_IRQ_19,
> +	MT8186_IRQ_20,
> +	MT8186_IRQ_21,
> +	MT8186_IRQ_22,
> +	MT8186_IRQ_23,
> +	MT8186_IRQ_24,
> +	MT8186_IRQ_25,
> +	MT8186_IRQ_26,
> +	MT8186_IRQ_NUM,
> +};
> +
> +enum {
> +	MT8186_AFE_IRQ_DIR_MCU = 0,
> +	MT8186_AFE_IRQ_DIR_DSP,
> +	MT8186_AFE_IRQ_DIR_BOTH,
> +};
> +
> +enum {
> +	MTKAIF_PROTOCOL_1 = 0,
> +	MTKAIF_PROTOCOL_2,
> +	MTKAIF_PROTOCOL_2_CLK_P2,
> +};
> +
> +enum {
> +	MTK_AFE_ADDA_DL_GAIN_MUTE = 0,
> +	MTK_AFE_ADDA_DL_GAIN_NORMAL = 0xf74f,
> +	/* SA suggest apply -0.3db to audio/speech path */
> +};
> +
> +#define MTK_SPK_NOT_SMARTPA_STR "MTK_SPK_NOT_SMARTPA"
> +#define MTK_SPK_RICHTEK_RT5509_STR "MTK_SPK_RICHTEK_RT5509"
> +#define MTK_SPK_MEDIATEK_MT6660_STR "MTK_SPK_MEDIATEK_MT6660"
> +#define MTK_SPK_GOODIX_TFA9874_STR "MTK_SPK_GOODIX_TFA9874"
> +
> +#define MTK_SPK_I2S_0_STR "MTK_SPK_I2S_0"
> +#define MTK_SPK_I2S_1_STR "MTK_SPK_I2S_1"
> +#define MTK_SPK_I2S_2_STR "MTK_SPK_I2S_2"
> +#define MTK_SPK_I2S_3_STR "MTK_SPK_I2S_3"
> +#define MTK_SPK_I2S_5_STR "MTK_SPK_I2S_5"
> +#define MTK_SPK_I2S_6_STR "MTK_SPK_I2S_6"
> +#define MTK_SPK_I2S_7_STR "MTK_SPK_I2S_7"
> +#define MTK_SPK_I2S_8_STR "MTK_SPK_I2S_8"
> +#define MTK_SPK_I2S_9_STR "MTK_SPK_I2S_9"

These definitions (and some more) are unused. Please drop.

Everything else looks ok to me.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>