From nobody Mon Feb 9 16:01:03 2026 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 4379141C2FA for ; Fri, 6 Feb 2026 17:34:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770399283; cv=none; b=qEPrtAOiLRJ3VR6sO0jQEB/rY5Bf3mNIasRqSWd/uFbHvQCFWxhBfS8O7eA33s+44MkYutsl7H7/kca7wRQV+wGyXvqV/xypGDUlETD25oPPDjMzmA/6+Im/IyX+jb5O2+77s+rvtdMoA05yl5Ka1RzshX+wxkaNPyBx/hGg8FA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770399283; c=relaxed/simple; bh=yQseu6gM2haEIm/ayUoG3639fNPMyxWFXUHZI+hw/MA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jKZNlB3OB6cYFmeyWOWOS28Qd6LPB2O66lms9m/76cYVCf3beCxdnWZs7TC+w9FBGijzrXZXuylj9eZwMyOJbw/5nXFhmIyD/fQLjql9C1gyeii6OVoAUWsn3srklHWhbd/6+SmgybtQcsm8h4Tm+x3fCqW/WrwTh/IBufyiZco= 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=htxHN6H2; arc=none smtp.client-ip=209.85.221.50 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="htxHN6H2" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-4359a302794so679655f8f.1 for ; Fri, 06 Feb 2026 09:34:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770399282; x=1771004082; 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=htXBvNPgxXNOHZBCLFJRJ5Aq3ZtCWpOxvSqLp1RXyrk=; b=htxHN6H22fQr/tKGomUm5OBCFkj9D12sMw6/K965cBZryy/B5OEPN7H9Dmq0Ve42Ek gszRnMchhmdmi33NNEH+JFdEFc/4/EDmbroQ80++H1ad2blP0jRX6RAMUI1uJ3a9kWsU ABS24H7qx/9RTAhoVb9KyuL6hh+cjyq5XmFUAVvE3B8dPfb5sGtZhAxMrLzddX9gF0DB Mr2ES0zKHByOtK9SHdgL6/cJGm4+NvSw4cl0IXruJeN+lnSjLDFP9NGYT/7HLFF9soXE 1lioujO79aWT46UO5c88A4P7znIo1v+jTZlhwQSrvBY96xSQ1mezIJVdZVQ0fJKZhKHm Oywg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770399282; x=1771004082; 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=htXBvNPgxXNOHZBCLFJRJ5Aq3ZtCWpOxvSqLp1RXyrk=; b=H+u8w9K0BL7r1n8tMEo8tzzZx7E5C86UQMhMxneIypfpU+WfOOPmcuuhxrWZWQ+rSJ Z7kJ7gGQ15bZVWNXgEUTDObQnNhpH1bEQJ9CSXEA3mPtUjyNl2BDyEhLyFMV3S+9NLNM SnUxvgZX4XR0Pyfl98oIFK4CYDQYc3rZoJbVkaTz9YtGxcMZ8SPsB82Nul97Ua0DmCD/ hcoMuNUtSV/9weRGxC2cjQKdFREIwP08L/mB68hKLex2Y22fZy/+M3HsJ/pJkOnZRwhw W0xfmjmlJgW3F6B5JDubmuI4k3dB03yxXej4dGwbJTNOEOZrY0oJZXjP5yZV5ehx0uqw 7ddw== X-Forwarded-Encrypted: i=1; AJvYcCXm6HELSvYk95hl5+K12NQDC+H3B6PpfSAuvXRrOd5TXVXBfjK+B7u75b1IENoUcQru0iocEwZ9rmthGdc=@vger.kernel.org X-Gm-Message-State: AOJu0YwSSh7oLbITpvcHsZFqgSL8FCDk1ACHqCyj4pMiHjdos4L2NPuB erR5VIdBDoWa9aO8+dQXY6iGZlNfD1Y8EIdPgTPjeuIZPWpXkW5CNRDO X-Gm-Gg: AZuq6aIRVL+HZggL7TKHbMu6thB7PpFZfvv8Gf3JFQdW+YpC8jm7KW05PpcqkEphXPl 1m5X99Jkr49hYIB8j3DJwvY4O5rRvLYSIYrzCZeKEwl7jIY88nGu+Ij1RoMt1u65AAwI93MEqsC paa+YOozuRTc1zssyFRWx8xVbOgWdDVtrWi+ARVCFTAQXqideaGxlVIjMnl0GGOoXXA+mrsuRTM sGX30c5vL5RIbYzjq0JouVW6s+BpQedL7wh3WbnjtMrvCSn/05RoLxrq8JZaDGXq4egQBW9k+cX +jtfNbI+2zevS31o6VgiQIFS/AqFCDWMywflDM/1cfg48tLVI8y1/geV/VTL3ewuOx/zfaJ+X9G STARrVPYQRMr2r2XCOvpDLoOBVujzIXeoVhXj/xPEjUu/sY53a5Uv0l1tchLJNGFew4MxmsvwEE Xk X-Received: by 2002:a05:600c:19c7:b0:45d:dc85:c009 with SMTP id 5b1f17b1804b1-483201e160dmr47405795e9.10.1770399281553; Fri, 06 Feb 2026 09:34:41 -0800 (PST) Received: from xeon ([188.163.112.49]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-436296bd4a1sm7454523f8f.17.2026.02.06.09.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Feb 2026 09:34:41 -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 v2 4/5] ASoC: tegra: Support WM8962 by machine driver Date: Fri, 6 Feb 2026 19:34:21 +0200 Message-ID: <20260206173423.145954-5-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260206173423.145954-1-clamor95@gmail.com> References: <20260206173423.145954-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 dd58525b7079..fdc954028d62 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 && INPUT && 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