From nobody Mon Feb 9 14:15:22 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 349773009EE for ; Fri, 30 Jan 2026 13:34:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769780102; cv=none; b=KI9K49QyB4/GjcyLfnw5x8FxvDUcLWWQL4MCXdmBg/FdK6S1icPkOIERUX4DdJ3m8VnEIj0xEfmWc7g3F3BOso3qw/vIhqVGdFsoL2kcrf3qLM+rfymlPCPNdAwCx68GW83R/5KowRbKDFDSVZ9lsnzu53nb8tpCiw9kSKYg/Zw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769780102; c=relaxed/simple; bh=D2udKOIgRxYLN++wJlYNmDyuzLLhyWkSNCE7NFH6d+E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VtCuftF4gMyauHs6eqKM5+6wWb+S1x/kaVk97dL+czms9v/5P3u3GxwlsI9goXoreuh7N59W/SI2P1ot4zx7TFVPeIAx8wZGzxryG4o6yfiiCE+iwIKAbwmAQBqUKEPMUT3q7Lxd5jAOLyvEIN43WBlQvvmgR4IObbJzEp+vMpA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=eJnK2kNm; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eJnK2kNm" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-435a11957f6so1792340f8f.0 for ; Fri, 30 Jan 2026 05:34:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769780096; x=1770384896; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lKvxKGZ/wM7it4bTsO0Z3rMS2mHTFWTEN2O02PyhYlQ=; b=eJnK2kNmw3iqt/rG3pKu3Kgb1Pjsgc2LnOWPktXTT0SCHFcqEdpIX1JfxSwGs3nNoM YZZvWqnGqO4zHbJ/jbHE8NCWyd2lEqpEimm8Nv4LVnxDulyBtqScBMkgOtatrfiHd9yh Xy3EgcXUHqQuTkmXL6u1mtd7CsnmFv9VC49Y/F9XQFKYwTHOvXSFBwkHLyz2ZL49LLUN Lc+4oXBW+APm4gl24uitdYnywYvuYe3zAc09Rl3a/Ai44qKC1dsQY0FN1HEm+3vhsyp2 PBhkzMv75fgTiwXnDr1a0UxBE2zGMSSMw5YooEk3nLDXOKvkwpfmt0KPNxtK2iM3vSDh oMsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769780096; x=1770384896; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lKvxKGZ/wM7it4bTsO0Z3rMS2mHTFWTEN2O02PyhYlQ=; b=IwXs04r1SjhOHtxhiC/7T+YaJHJQFq3nSMghEJJOszS940aWQxWSMg0cOXpZqZMPYZ Lk7ytDtv3b1Kh8RrnY6hNur5pI/kfx5zIuiWyU0jCjGHYtU/wTiWR0qLsHAewolexjeR 5OWRI72x4sePW8fpSABrz4cA7JU8QLNIveQIFWuHsMgPfp3AMe+vuSlQ/n9JC+wDEE6P bLNBdV+LD+0tvb88uaS3ireFXzKEY2FsdaUDsEzPe+D+ObufA2Kv1PSzh7qTArXwwyQo xHmm67ymK3lLq0DqnQMNk+w2Vu+g5a+v6KoAx+QIMmC0h6GhDSyRKgSnW4KXGk9MEILE CbFQ== X-Forwarded-Encrypted: i=1; AJvYcCXLrKCAdu8xMccCcVs4ndiuT7ieKIY1BKotnsnAduM5JK3cV1pmMbGXXREkApW6uGR+KLpJuAxXfTmHRag=@vger.kernel.org X-Gm-Message-State: AOJu0Yzlmsr345M5nCDPAkzEGPbiuSNA1/F3tYKRGAyY+wbl8/w5CDuh cO7+/9CgdVCBtvp/HYoBt6D7nV1ilrt60vxA9JONavS19kZhXx4elj1W X-Gm-Gg: AZuq6aLXFX0C4GgVIKpNbZILnoieuTsta+nLeu4oWig8F+U2ivTjHP9X618EZQGwFtl f/TX9GllNY/Vd48hqHGDZY2LAbsBoxGXXD+94UTrCH2BmnJxaOqo4StB5TRWLA7wlGYykWtc8Mp cC5fY5ahTPGkAhqC/iVgLMk9JgT5QNW5XPnf4fQDiTJi7VNtJvJnMFd7qP+KDsBni+LZnC7ojR8 DjPoaaRNEv/f2LB+mUSjsOIAVBLewXiSdZ7Zt1wCPeRe+zaK7gXGoPCIRH4ueXnzsDahQZvLWlm yJfEzewAmBNmsa5eiGAsZfASKzgJ+ETHq/XpUw0QqfcBmfabQB+w2qrTVBSB2wFF0giiegV/GfR /IcyPm/LL0C0JSEYh3gti17rOEW/ef4ygqXtGG5fuhBXBBg1KQ5Zq4QJbAblBl0Bhweniz926YX OC X-Received: by 2002:a05:6000:184d:b0:432:da3b:5941 with SMTP id ffacd0b85a97d-435f3a7b8camr4494369f8f.21.1769780096189; Fri, 30 Jan 2026 05:34:56 -0800 (PST) Received: from xeon ([188.163.112.49]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435e131ce93sm21536837f8f.24.2026.01.30.05.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jan 2026 05:34:55 -0800 (PST) From: Svyatoslav Ryhel To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thierry Reding , Jonathan Hunter , Jaroslav Kysela , Takashi Iwai , Svyatoslav Ryhel , =?UTF-8?q?Jonas=20Schw=C3=B6bel?= Cc: linux-sound@vger.kernel.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 4/4] ASoC: tegra: Support WM8962 by machine driver Date: Fri, 30 Jan 2026 15:34:34 +0200 Message-ID: <20260130133434.353353-5-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260130133434.353353-1-clamor95@gmail.com> References: <20260130133434.353353-1-clamor95@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Jonas Schw=C3=B6bel Add Wolfson Microelectronics WM8962 codec support to the Tegra ASoC machine driver. The WM8962 codec is found on devices like Microsoft Surface RT and Microsoft Surface 2 Windows RT based tablets. Co-developed-by: Svyatoslav Ryhel Signed-off-by: Svyatoslav Ryhel Signed-off-by: Jonas Schw=C3=B6bel --- sound/soc/tegra/Kconfig | 10 ++ sound/soc/tegra/Makefile | 2 + sound/soc/tegra/tegra_wm8962.c | 165 +++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 sound/soc/tegra/tegra_wm8962.c diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig index f9257830daa1..56a2f53df2c1 100644 --- a/sound/soc/tegra/Kconfig +++ b/sound/soc/tegra/Kconfig @@ -229,6 +229,16 @@ config SND_SOC_TEGRA_WM8903 boards using the WM8093 codec. Currently, the supported boards are Harmony, Ventana, Seaboard, Kaen, and Aebl. =20 +config SND_SOC_TEGRA_WM8962 + tristate "SoC Audio support for Tegra boards using a WM8962 codec" + depends on I2C && GPIOLIB + select SND_SOC_TEGRA_MACHINE_DRV + select SND_SOC_WM8962 + help + Say Y or M here if you want to add support for SoC audio on Tegra + boards using the WM8962 codec. Currently, the supported boards are + Microsoft Surface RT. + config SND_SOC_TEGRA_WM9712 tristate "SoC Audio support for Tegra boards using a WM9712 codec" depends on GPIOLIB diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile index defea7f53f11..3f396c87802e 100644 --- a/sound/soc/tegra/Makefile +++ b/sound/soc/tegra/Makefile @@ -43,9 +43,11 @@ obj-$(CONFIG_SND_SOC_TEGRA210_OPE) +=3D snd-soc-tegra210= -ope.o =20 # Tegra machine Support snd-soc-tegra-wm8903-y :=3D tegra_wm8903.o +snd-soc-tegra-wm8962-y :=3D tegra_wm8962.o snd-soc-tegra-machine-y :=3D tegra_asoc_machine.o snd-soc-tegra-audio-graph-card-y :=3D tegra_audio_graph_card.o =20 obj-$(CONFIG_SND_SOC_TEGRA_WM8903) +=3D snd-soc-tegra-wm8903.o +obj-$(CONFIG_SND_SOC_TEGRA_WM8962) +=3D snd-soc-tegra-wm8962.o obj-$(CONFIG_SND_SOC_TEGRA_MACHINE_DRV) +=3D snd-soc-tegra-machine.o obj-$(CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD) +=3D snd-soc-tegra-audio-grap= h-card.o diff --git a/sound/soc/tegra/tegra_wm8962.c b/sound/soc/tegra/tegra_wm8962.c new file mode 100644 index 000000000000..31f9d9181595 --- /dev/null +++ b/sound/soc/tegra/tegra_wm8962.c @@ -0,0 +1,165 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * tegra_wm8962.c - Tegra machine ASoC driver for boards using WM8962 code= c. + * + * Copyright (C) 2021-2024 Jonas Schw=C3=B6bel + * Svyatoslav Ryhel + * + * Based on tegra_wm8903 code copyright/by: + * + * Author: Stephen Warren + * Copyright (C) 2010-2012 - NVIDIA, Inc. + * + * Based on code copyright/by: + * + * (c) 2009, 2010 Nvidia Graphics Pvt. Ltd. + * + * Copyright 2007 Wolfson Microelectronics PLC. + * Author: Graeme Gregory + * graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include "../codecs/wm8962.h" + +#include "tegra_asoc_machine.h" + +static struct snd_soc_jack_pin tegra_wm8962_mic_jack_pins[] =3D { + { .pin =3D "Mic Jack", .mask =3D SND_JACK_MICROPHONE }, +}; + +static unsigned int tegra_wm8962_mclk_rate(unsigned int srate) +{ + unsigned int mclk; + + switch (srate) { + case 8000: + case 16000: + case 24000: + case 32000: + case 48000: + case 64000: + case 96000: + mclk =3D 12288000; + break; + case 11025: + case 22050: + case 44100: + case 88200: + mclk =3D 11289600; + break; + default: + mclk =3D 12000000; + break; + } + + return mclk; +} + +static int tegra_wm8962_init(struct snd_soc_pcm_runtime *rtd) +{ + struct tegra_machine *machine =3D snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_card *card =3D rtd->card; + struct snd_soc_dapm_context *dapm =3D snd_soc_card_to_dapm(card); + int err; + + err =3D tegra_asoc_machine_init(rtd); + if (err) + return err; + + if (!machine->gpiod_mic_det && machine->asoc->add_mic_jack) { + struct snd_soc_dai *codec_dai =3D snd_soc_rtd_to_codec(rtd, 0); + struct snd_soc_component *component =3D codec_dai->component; + + err =3D snd_soc_card_jack_new_pins(rtd->card, "Mic Jack", + SND_JACK_MICROPHONE, + machine->mic_jack, + tegra_wm8962_mic_jack_pins, + ARRAY_SIZE(tegra_wm8962_mic_jack_pins)); + if (err) { + dev_err(rtd->dev, "Mic Jack creation failed: %d\n", err); + return err; + } + + wm8962_mic_detect(component, machine->mic_jack); + } + + snd_soc_dapm_force_enable_pin(dapm, "MICBIAS"); + + return 0; +} + +static int tegra_wm8962_remove(struct snd_soc_card *card) +{ + struct snd_soc_dai_link *link =3D &card->dai_link[0]; + struct snd_soc_pcm_runtime *rtd =3D snd_soc_get_pcm_runtime(card, link); + struct snd_soc_dai *codec_dai =3D snd_soc_rtd_to_codec(rtd, 0); + struct snd_soc_component *component =3D codec_dai->component; + + wm8962_mic_detect(component, NULL); + + return 0; +} + +SND_SOC_DAILINK_DEFS(wm8962_hifi, + DAILINK_COMP_ARRAY(COMP_EMPTY()), + DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8962")), + DAILINK_COMP_ARRAY(COMP_EMPTY())); + +static struct snd_soc_dai_link tegra_wm8962_dai =3D { + .name =3D "WM8962", + .stream_name =3D "WM8962 PCM", + .init =3D tegra_wm8962_init, + .dai_fmt =3D SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBC_CFC, + SND_SOC_DAILINK_REG(wm8962_hifi), +}; + +static struct snd_soc_card snd_soc_tegra_wm8962 =3D { + .components =3D "codec:wm8962", + .owner =3D THIS_MODULE, + .dai_link =3D &tegra_wm8962_dai, + .num_links =3D 1, + .remove =3D tegra_wm8962_remove, + .fully_routed =3D true, +}; + +static const struct tegra_asoc_data tegra_wm8962_data =3D { + .mclk_rate =3D tegra_wm8962_mclk_rate, + .card =3D &snd_soc_tegra_wm8962, + .add_common_dapm_widgets =3D true, + .add_common_controls =3D true, + .add_common_snd_ops =3D true, + .add_mic_jack =3D true, + .add_hp_jack =3D true, +}; + +static const struct of_device_id tegra_wm8962_of_match[] =3D { + { .compatible =3D "nvidia,tegra-audio-wm8962", .data =3D &tegra_wm8962_da= ta }, + {}, +}; +MODULE_DEVICE_TABLE(of, tegra_wm8962_of_match); + +static struct platform_driver tegra_wm8962_driver =3D { + .driver =3D { + .name =3D "tegra-wm8962", + .of_match_table =3D tegra_wm8962_of_match, + .pm =3D &snd_soc_pm_ops, + }, + .probe =3D tegra_asoc_machine_probe, +}; +module_platform_driver(tegra_wm8962_driver); + +MODULE_AUTHOR("Jonas Schw=C3=B6bel "); +MODULE_AUTHOR("Svyatoslav Ryhel "); +MODULE_DESCRIPTION("Tegra+WM8962 machine ASoC driver"); +MODULE_LICENSE("GPL"); --=20 2.51.0