From nobody Mon Apr 6 10:43:37 2026 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 C89283451B5 for ; Mon, 23 Feb 2026 06:51:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771829468; cv=none; b=C76Op2IO4zBwYgwJk+RaSC1F+QG8o1aC5HxiM7beV0WX7Ty90xNXOlQ8DL36qB+IeR2s6dbf3WJwJZ2WzVNmZ0KYY5cA2xG+XC1KoveO8YIBS9RaeiVUbJKtaqKawgiEMBF/smzciteIkY4deNhKyfAY8gY4nMu957n1wNpuvRE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771829468; 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=rQTPIIvo0UlFM+U0aMNpSwhnnaz6KhTicKIf7iq00mXPA7kLmkWlmeVuca2HI2viVCwnfzM14T+K7BzoNc7/taACsuCRtUoasr8UhGmHjhqI4+fn867a2ouAcXboqXpQTClb0W6IFZyZOQmpdsXs9p8/kF796T4hWC8qVQ57OLg= 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=I4NLqrtP; arc=none smtp.client-ip=209.85.167.53 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="I4NLqrtP" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-59e57973dbfso3921742e87.1 for ; Sun, 22 Feb 2026 22:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771829465; x=1772434265; 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=I4NLqrtPHh+gW6u5qIrPsHNzjyQWwfyP16vOKgmm01EACoIygnFeinBzIQcvahnX/s zuy+6G/C6T/ELNl5jnZoU+RqPXcd0qymeB6GhUDdgLh6TmlwdeVFmtJ2Pz+UblRAq9r4 ZTB3HbaCAIu8ycEnneljBBFVCmmeY+kqlcpj6lamNBcTE8aSYgyjgwpNuoGuYQWjFWs7 yPz3IT9AJprs5GiHAOkm8/oxZfo9kCVURt4ZlQZlpowBbvllgFUsZwixH3W2ACOpBWDx H741DrlmP1m6/HCCK5SSj9LGU+6US0RYf4WS/hNsziiEeZ0vxvZ9BwnzQT8e2moaFAMX YtWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771829465; x=1772434265; 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=MWb5HCwc0PbMgj3ol5I+JT3DN5wmGYqpXLc7E7VOgZhBLj4Yo3XpuS+s/kZ8Thzx5j eR3Ku1sw1Yn+xfVcCpJlhwA6Pu9VS7/RYfe8HCxtpa8DSRroecWoVGUsWcHDnqTKFyxV Mw737Wj8wIei0F/dE6Y+Wrwt7NFCBA5OxJTIeFks2KjLMPt3Fze1X86rgHd4LcF8NAD2 eAj0PAPi96hlFK+8AdDYPdsajqn4VM+/Mrcr4w0+Bb4BmDTzBT8mAVK8NOH6Aqb38uyh BbPr7oFdDy9S+EDzMhoyihhs9c6FJGJ+j7lvG0ROy0n7ISdZIXPeQqdqZ8nT3aovCQ1o 7wpA== X-Forwarded-Encrypted: i=1; AJvYcCUyI+eVB8/ymCjnu0OSQmXpaMOR0ZOFwKz9qMYfa4JOWT0n0e/ZEN3cyInhv88fyBYmb0cMn0tMZTBKC+k=@vger.kernel.org X-Gm-Message-State: AOJu0Yw31TKdzuuFdOZkGVXmgKGMzQXB2F3si9vus/WtIHipoYUF85iQ FV6Z/mtWRxm9zvu2dbebE2/7mf2k1gRq0X7upr0K8BgLyURLkHdhyTdc X-Gm-Gg: AZuq6aJxoWcyQn6cwdv65oxJlJtYYAJ3oHzF+aDKof6RWYzMqPrV3U9MVcv3fjSyAtI Nm7mErVFJIFyPl7qJyAVzsbAKLdQg/5F7OlnKjgL6ZdmSPpGua3AWV8LWA5p+qF/zjW0sM+Nr8v j8wkV0Kx/ffxc+OD0Q4TSAaBvAFhUlWp3E8orbG+VZggvqZ4o4ixMKsRiM6VjJ0yXVOLfulm1xS eSyVDEHBs/ZB2VzfgoZkZqoJQN4KF3i2Iy+D3mc2e+PmsC62ktJHQfFer7g0GjmgCNjJC+qLvdT UvpM0IeLDNYmtIMSO4mRRHRH0cR3tFAKSPvtt8rXo1ae23s/e8hRXp2jUGW5fmC/XInsoCu+alb cMLPrYf1GBS7HV775wGNyQVRr8/H46EIuI2i2pUkXN04IlOBF6FBEbyCPa8uua9BcmC+zcEIPrW /N01VT7/l4ef8l X-Received: by 2002:a05:6512:ac5:b0:59e:5589:26c6 with SMTP id 2adb3069b0e04-59f8abe6f22mr4724303e87.9.1771829464668; Sun, 22 Feb 2026 22:51:04 -0800 (PST) Received: from xeon ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-389a78b4a45sm13916521fa.13.2026.02.22.22.51.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Feb 2026 22:51:04 -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 v3 4/5] ASoC: tegra: Support WM8962 by machine driver Date: Mon, 23 Feb 2026 08:50:50 +0200 Message-ID: <20260223065051.13070-5-clamor95@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260223065051.13070-1-clamor95@gmail.com> References: <20260223065051.13070-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