From nobody Fri Apr 3 04:39:51 2026 Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 A5D4A30AD1A for ; Tue, 17 Feb 2026 23:13:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771370015; cv=none; b=TXaP+Uj9vOA55I+rLyFFMlx4FhotTNQzrZyKS5A1C+YxzTMydUeFWrpT8uyXyI8wSaZ9fY0vYig5+B/91LLC2W0JL//c69RIOGfTCguicSzlrGcIOn9hHRSYJUB0+DAtJJ0RLaQdgnuMpEPQerQ62Xnh4oTMZfPzHuhB2NWb4OY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771370015; c=relaxed/simple; bh=gC0e01eJBPun914gwlEhfyHeJO2JZFG21Vn6CMakvBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dNwzvHuOVJnQ8Z6CX9utzIeUFEjlZYY2zZo8B0sgGuckzRO8oKbmIJWZtN2AQBSWuNUbsBwo0vI/bMRGOzNkestbFQn5G2ysosec7a2qOQVN9M4fdGG7e7wANi0jUHLoaO7n8/1IyVieE3Qv/vxjzb0bv5MqSApGpC/RxcRMzJM= 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=lrtmGzFB; arc=none smtp.client-ip=209.85.208.42 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="lrtmGzFB" Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-65b9608a9adso8155469a12.3 for ; Tue, 17 Feb 2026 15:13:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771370012; x=1771974812; 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=I4clpRw+MW0lpDpQZNraBpNnI6WWTp28IpMKJeRXQP8=; b=lrtmGzFByecvHkfuaJAFiniqlmw2FhtkL0uFhXN296fIwgeyFjyd9yOewEbLS9UVw7 tO6g8BqPN6skyH+byBR5sfoKk+hDOR8hZfj5JgM11sNrCUrfxmIvRfRk/TRrd9mPrznl NKnqZv16ZylfxyaERmfYVeqUjL8J/9y/RmnxC9l7cGa5DAtq2JVovZbD2JUO6o9YAEU/ Y99XVsunu0s+d20YPUtM2ereyxBPLdXKDLqmeI2HC/bRfupvSKvSsxRnyGF57NHrY5xu nZ8Byj90CglosIk1s+gXieFWrir2rcWXfEymVQY8kXxhm8sjYcqmelMxe2L92glylHVr vSag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771370012; x=1771974812; 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=I4clpRw+MW0lpDpQZNraBpNnI6WWTp28IpMKJeRXQP8=; b=oTWqfZE9vCOqh20sqcimy0Wql1CZnTkYSo0XXx7jTnzdSnij+blm6weNKVDyffFYpQ 8dMD2q1t7uhiVYF0vdwFkiynabSqG4+lhb+rCx7XSiB5DSXG6bzx9xyn+x3Q8TiOe5fE m7udt4S1lrrOT7iw9Z7/2KUDexnTk+UyQLwZlATV/l9CQ9PSueKMIPgUGE4GLzYzwg4k p0bSWSOCSgveaZSW/IBvByhObkK6DX2LZ/BSndah2ytbn2k2yD+PYoub8BUtHL4NoaxR vfSuBByRGmvjAzku75j7xsituTX64AfcB+qeC+gXqmZAVOm6l8e08QKPI28+wpZtEjQO D04A== X-Gm-Message-State: AOJu0Yx1Wyhdhf6j/xFaVQqGB1IB0pXolK7Vb0+UZIf6EdAsnAQDwgG0 okOg6YoWi1HyhOY3Q1v9LxGg2Q0UzmktCawJVD/8OsB0QKXQBvBIUYiH X-Gm-Gg: AZuq6aK2+tUul2U8w7YVDSISHYo43y/k6i2T0wGJt2mxlYFSEzvKe34zlTZOTlKoVTJ MRBVT2ArcmyXJNfano0L+HYNQrm8C7uQHdUp+8DkI5Yd5OaEcGKnvm5nPer8Jpe5tvDIMVVW311 VIaUb5C5qEJ5kHCXPAbWy0NNWGtIF9f06YqXxxx062dXCixRs7fo/y4h8v69uZXJThxc+5po75a XVdicuVTyvQ2BQyaV8PVsWuqT1l0ym9GrKDbYI2P6SZtWVbvO2xrHr/rh7kknp+D9Uip1G9l2n1 QrbZcMWHVMVhOhuExhl5DiKRbrPNnnfaiRYKA0efoWWfKp6LEzW+vrnBrcdpYw3l2m+ny9Em8gH 84/TCM4TNU6eLq4dgBHBDWKNZA0C6JSKou1aOjTKQCt46seIZsXfxBtR8gopQfx8mHzVxcVfrKm xpyLnGuTYs3YzA+Q== X-Received: by 2002:a17:907:3e14:b0:b8f:99c2:1a99 with SMTP id a640c23a62f3a-b8fc38f1e4dmr642097566b.9.1771370011630; Tue, 17 Feb 2026 15:13:31 -0800 (PST) Received: from jekhomev ([46.251.53.180]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-65bad3f137dsm2661375a12.27.2026.02.17.15.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Feb 2026 15:13:31 -0800 (PST) From: Yauhen Kharuzhy To: linux-sound@vger.kernel.org, Cezary Rojewski , Liam Girdwood , Pierre-Louis Bossart , Mark Brown Cc: linux-kernel@vger.kernel.org, Hans de Goede , Yauhen Kharuzhy Subject: [PATCH v1 1/2] ASoC: Intel: cht_yogabook: Add driver for Lenovo Yoga Book tablets Date: Wed, 18 Feb 2026 01:13:23 +0200 Message-ID: <20260217231324.1319392-2-jekhor@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260217231324.1319392-1-jekhor@gmail.com> References: <20260217231324.1319392-1-jekhor@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a new ASoC machine driver for Lenovo Yoga Book Intel Cherry Trail-based tablets (YB1-X90F/L, YB1-X91F/L models). This platform uses a Realtek ALC5677 codec accompanied by a TS3A227E jack configuration detection IC. The driver is based on the cht_bsw_rt5672.c mainline driver and the driver from the vendor's Android kernel [1]. There are no other known Cherry Trail platforms using an RT5677 codec, so the driver is named 'cht_yogabook', and some device-specific tricks are hardcoded, such as jack events and additional GPIOs controlling the speaker amplifier. [1] https://github.com/deadman96385/android_kernel_lenovo_yeti/blob/master/= sound/soc/intel/board/cht_bl_dpcm_rt5677.c Signed-off-by: Yauhen Kharuzhy --- sound/soc/intel/boards/Kconfig | 15 + sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/cht_yogabook.c | 602 ++++++++++++++++++++++++++ 3 files changed, 619 insertions(+) create mode 100644 sound/soc/intel/boards/cht_yogabook.c diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index c5942b5655d3..f7346ee085e7 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -237,6 +237,21 @@ config SND_SOC_INTEL_BYT_CHT_ES8316_MACH Say Y or m if you have such a device. This is a recommended option. If unsure select "N". =20 +config SND_SOC_INTEL_CHT_YOGABOOK_MACH + tristate "Cherrytrail-based Lenovo Yoga Book tablet" + depends on I2C && ACPI + depends on X86_INTEL_LPSS || COMPILE_TEST + depends on GPIOLIB || COMPILE_TEST + select SND_SOC_ACPI + select SND_SOC_RT5677 + select SND_SOC_TS3A227E + help + This adds support for ASoC machine driver for the Lenovo Yoga Book + tablets based on CherryTrail platform with RT5677 audio codec, models + YB1-X90F, YB1-X90L, YB1-X91F, YB1-X91L. + Say Y or m if you have such a device. This is a recommended opti= on. + If unsure select "N". + endif ## SND_SST_ATOM_HIFI2_PLATFORM || SND_SOC_SOF_BAYTRAIL =20 if SND_SST_ATOM_HIFI2_PLATFORM diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makef= ile index 25a1a9066cbf..58bd6029545b 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -15,6 +15,7 @@ snd-soc-sst-cht-bsw-nau8824-y :=3D cht_bsw_nau8824.o snd-soc-sst-byt-cht-cx2072x-y :=3D bytcht_cx2072x.o snd-soc-sst-byt-cht-da7213-y :=3D bytcht_da7213.o snd-soc-sst-byt-cht-es8316-y :=3D bytcht_es8316.o +snd-soc-sst-cht-yogabook-objs :=3D cht_yogabook.o snd-soc-sst-byt-cht-nocodec-y :=3D bytcht_nocodec.o snd-soc-sof_rt5682-y :=3D sof_rt5682.o snd-soc-sof_cs42l42-y :=3D sof_cs42l42.o @@ -47,6 +48,7 @@ obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_NAU8824_MACH) +=3D snd= -soc-sst-cht-bsw-nau8824. obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_CX2072X_MACH) +=3D snd-soc-sst-byt-cht-= cx2072x.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH) +=3D snd-soc-sst-byt-cht-d= a7213.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH) +=3D snd-soc-sst-byt-cht-e= s8316.o +obj-$(CONFIG_SND_SOC_INTEL_CHT_YOGABOOK_MACH) +=3D snd-soc-sst-cht-yogaboo= k.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH) +=3D snd-soc-sst-byt-cht-= nocodec.o obj-$(CONFIG_SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH) +=3D snd-soc-skl_hda_= dsp.o obj-$(CONFIG_SND_SOC_INTEL_EHL_RT5660_MACH) +=3D snd-soc-ehl-rt5660.o diff --git a/sound/soc/intel/boards/cht_yogabook.c b/sound/soc/intel/boards= /cht_yogabook.c new file mode 100644 index 000000000000..2ce8233a1630 --- /dev/null +++ b/sound/soc/intel/boards/cht_yogabook.c @@ -0,0 +1,602 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * cht_yogabook.c - ASoc Machine driver for Lenovo Yoga Book YB1-X90/X91 + * tablets, based on Intel Cherrytrail platform with RT5677 codec. + * + * Copyright (C) 2026 Yauhen Kharuzhy + * + * Based on cht_bsw_rt5672.c: + * Copyright (C) 2014 Intel Corp + * Author: Subhransu S. Prusty + * Mengdong Lin + * + * And based on the cht_bl_dpcm_rt5677.c from the Lenovo's Android kernel: + * Copyright (C) 2014 Intel Corp + * Author: Mythri P K + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../codecs/rt5677.h" +#include "../../codecs/ts3a227e.h" +#include "../atom/sst-atom-controls.h" + +#define RT5677_I2C_DEFAULT "i2c-rt5677" + +/* The platform clock #3 outputs 19.2Mhz clock to codec as I2S MCLK */ +#define CHT_PLAT_CLK_3_HZ 19200000 +#define CHT_CODEC_DAI "rt5677-aif1" + +struct cht_mc_private { + char codec_name[SND_ACPI_I2C_ID_LEN]; + struct snd_soc_jack jack; + struct clk *mclk; + struct gpio_desc *gpio_spk_en1; + struct gpio_desc *gpio_spk_en2; + struct gpio_desc *gpio_hp_en; +}; + +static int cht_yb_platform_clock_control(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + struct snd_soc_card *card =3D snd_soc_dapm_to_card(w->dapm); + struct snd_soc_dai *codec_dai; + struct cht_mc_private *ctx =3D snd_soc_card_get_drvdata(card); + int ret; + + codec_dai =3D snd_soc_card_get_codec_dai(card, CHT_CODEC_DAI); + if (!codec_dai) { + dev_err(card->dev, + "Codec dai not found; Unable to set platform clock\n"); + return -EIO; + } + + if (SND_SOC_DAPM_EVENT_ON(event)) { + if (ctx->mclk) { + ret =3D clk_prepare_enable(ctx->mclk); + if (ret < 0) { + dev_err(card->dev, + "could not configure MCLK state"); + return ret; + } + } + + /* set codec PLL source to the 19.2MHz platform clock (MCLK) */ + ret =3D snd_soc_dai_set_pll(codec_dai, 0, RT5677_PLL1_S_MCLK, + CHT_PLAT_CLK_3_HZ, 48000 * 512); + if (ret < 0) { + dev_err(card->dev, "can't set codec pll: %d\n", ret); + return ret; + } + + /* set codec sysclk source to PLL */ + ret =3D snd_soc_dai_set_sysclk(codec_dai, RT5677_SCLK_S_PLL1, + 48000 * 512, SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(card->dev, "can't set codec sysclk: %d\n", ret); + return ret; + } + } else { + /* Set codec sysclk source to its internal clock because codec + * PLL will be off when idle and MCLK will also be off by ACPI + * when codec is runtime suspended. Codec needs clock for jack + * detection and button press. + */ + snd_soc_dai_set_sysclk(codec_dai, RT5677_SCLK_S_RCCLK, + 48000 * 512, SND_SOC_CLOCK_IN); + + if (ctx->mclk) + clk_disable_unprepare(ctx->mclk); + } + return 0; +} + +static int cht_yb_hp_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + struct snd_soc_card *card =3D snd_soc_dapm_to_card(w->dapm); + struct cht_mc_private *ctx =3D snd_soc_card_get_drvdata(card); + + dev_dbg(card->dev, "HP event: %s\n", + SND_SOC_DAPM_EVENT_ON(event) ? "ON" : "OFF"); + + if (SND_SOC_DAPM_EVENT_ON(event)) { + msleep(20); + gpiod_set_value_cansleep(ctx->gpio_hp_en, 1); + msleep(50); + } else { + gpiod_set_value_cansleep(ctx->gpio_hp_en, 0); + } + + return 0; +} + +static int cht_yb_spk_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + struct snd_soc_card *card =3D snd_soc_dapm_to_card(w->dapm); + struct cht_mc_private *ctx =3D snd_soc_card_get_drvdata(card); + + dev_dbg(card->dev, "SPK event: %s\n", + SND_SOC_DAPM_EVENT_ON(event) ? "ON" : "OFF"); + + /* Black magic from the Lenovo's Android kernel + * FIXME: Check if it is needed, an original comment: + * "use gpio GPIO_SPK_EN to enable/disable ext boost pa + * use mode 3" + */ + if (SND_SOC_DAPM_EVENT_ON(event)) { + gpiod_set_value_cansleep(ctx->gpio_spk_en1, 1); + udelay(2); + gpiod_set_value_cansleep(ctx->gpio_spk_en1, 0); + udelay(2); + gpiod_set_value_cansleep(ctx->gpio_spk_en1, 1); + udelay(2); + gpiod_set_value_cansleep(ctx->gpio_spk_en1, 0); + udelay(2); + } + + gpiod_set_value_cansleep(ctx->gpio_spk_en1, + SND_SOC_DAPM_EVENT_ON(event)); + gpiod_set_value_cansleep(ctx->gpio_spk_en2, + SND_SOC_DAPM_EVENT_ON(event)); + msleep(50); + + return 0; +} + +static const struct snd_soc_dapm_widget cht_yb_dapm_widgets[] =3D { + SND_SOC_DAPM_HP("Headphone", cht_yb_hp_event), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Int Mic", NULL), + SND_SOC_DAPM_SPK("Speaker", cht_yb_spk_event), + SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, + cht_yb_platform_clock_control, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), +}; + +static const struct snd_soc_dapm_route cht_yb_audio_map[] =3D { + {"IN1P", NULL, "Headset Mic"}, + {"IN1N", NULL, "Headset Mic"}, + {"DMIC L1", NULL, "Int Mic"}, + {"DMIC R1", NULL, "Int Mic"}, + {"Headphone", NULL, "LOUT1"}, + {"Headphone", NULL, "LOUT2"}, + {"Speaker", NULL, "LOUT1"}, + {"Speaker", NULL, "LOUT2"}, + + {"AIF1 Playback", NULL, "ssp2 Tx"}, + {"ssp2 Tx", NULL, "codec_out0"}, + {"ssp2 Tx", NULL, "codec_out1"}, + {"codec_in0", NULL, "ssp2 Rx"}, + {"codec_in1", NULL, "ssp2 Rx"}, + {"ssp2 Rx", NULL, "AIF1 Capture"}, + {"Headphone", NULL, "Platform Clock"}, + {"Speaker", NULL, "Platform Clock"}, + {"Headset Mic", NULL, "Platform Clock"}, + {"Int Mic", NULL, "Platform Clock"}, +}; + +static const struct snd_kcontrol_new cht_mc_controls[] =3D { + SOC_DAPM_PIN_SWITCH("Headphone"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Int Mic"), + SOC_DAPM_PIN_SWITCH("Speaker"), +}; + +static int cht_yb_aif1_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd =3D substream->private_data; + struct snd_soc_dai *codec_dai =3D snd_soc_rtd_to_codec(rtd, 0); + int ret; + + /* set codec PLL source to the 19.2MHz platform clock (MCLK) */ + ret =3D snd_soc_dai_set_pll(codec_dai, 0, RT5677_PLL1_S_MCLK, + CHT_PLAT_CLK_3_HZ, params_rate(params) * 512); + if (ret < 0) { + dev_err(rtd->dev, "can't set codec pll: %d\n", ret); + return ret; + } + + /* set codec sysclk source to PLL */ + ret =3D snd_soc_dai_set_sysclk(codec_dai, RT5677_SCLK_S_PLL1, + params_rate(params) * 512, + SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret); + return ret; + } + /* + * Default mode for SSP configuration is TDM 4 slot + */ + ret =3D snd_soc_dai_set_fmt(codec_dai, + SND_SOC_DAIFMT_DSP_B | + SND_SOC_DAIFMT_IB_NF | + SND_SOC_DAIFMT_CBC_CFC); + if (ret < 0) { + dev_err(codec_dai->dev, "can't set format to TDM %d\n", ret); + return ret; + } + + /* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */ + ret =3D snd_soc_dai_set_tdm_slot(codec_dai, 0xF, 0xF, 4, 25); + if (ret < 0) { + dev_err(rtd->dev, "can't set codec TDM slot %d\n", ret); + return ret; + } + + return 0; +} + +static int cht_yb_jack_event(struct notifier_block *nb, + unsigned long event, void *data) +{ + struct snd_soc_jack *jack =3D (struct snd_soc_jack *)data; + struct snd_soc_dapm_context *dapm =3D jack->card->dapm; + + if (event & SND_JACK_MICROPHONE) { + snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); + snd_soc_dapm_sync(dapm); + } else { + snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); + snd_soc_dapm_sync(dapm); + } + + return 0; +} + +static struct notifier_block cht_yb_jack_nb =3D { + .notifier_call =3D cht_yb_jack_event, +}; + +static int cht_yb_codec_init(struct snd_soc_pcm_runtime *runtime) +{ + int ret =3D 0; + struct snd_soc_dai *codec_dai =3D snd_soc_rtd_to_codec(runtime, 0); + struct snd_soc_component *component =3D codec_dai->component; + struct cht_mc_private *ctx =3D snd_soc_card_get_drvdata(runtime->card); + struct snd_soc_jack *jack =3D &ctx->jack; + + /* Enable codec ASRC function for Stereo DAC/Stereo1 ADC/DMIC/I2S1. + * The ASRC clock source is clk_i2s1_asrc. + */ + rt5677_sel_asrc_clk_src(component, RT5677_DA_STEREO_FILTER | + RT5677_AD_STEREO1_FILTER | RT5677_I2S1_SOURCE, + RT5677_CLK_SEL_I2S1_ASRC); + /* Enable codec ASRC function for Mono ADC L. + * The ASRC clock source is clk_sys2_asrc. + */ + rt5677_sel_asrc_clk_src(component, RT5677_AD_MONO_L_FILTER, + RT5677_CLK_SEL_SYS2); + + ctx->gpio_spk_en1 =3D devm_gpiod_get(component->dev, "speaker-enable", + GPIOD_OUT_LOW); + if (IS_ERR(ctx->gpio_spk_en1)) { + dev_err(component->dev, "Can't find speaker enable GPIO\n"); + return PTR_ERR(ctx->gpio_spk_en1); + } + + ctx->gpio_spk_en2 =3D devm_gpiod_get(component->dev, "speaker-enable2", + GPIOD_OUT_LOW); + if (IS_ERR(ctx->gpio_spk_en2)) { + dev_err(component->dev, "Can't find speaker enable 2 GPIO\n"); + return PTR_ERR(ctx->gpio_spk_en2); + } + + ctx->gpio_hp_en =3D devm_gpiod_get(component->dev, "headphone-enable", + GPIOD_OUT_LOW); + if (IS_ERR(ctx->gpio_hp_en)) { + dev_err(component->dev, "Can't find headphone enable GPIO\n"); + return PTR_ERR(ctx->gpio_hp_en); + } + + snd_soc_jack_notifier_register(jack, &cht_yb_jack_nb); + + if (ctx->mclk) { + /* + * The firmware might enable the clock at + * boot (this information may or may not + * be reflected in the enable clock register). + * To change the rate we must disable the clock + * first to cover these cases. Due to common + * clock framework restrictions that do not allow + * to disable a clock that has not been enabled, + * we need to enable the clock first. + */ + ret =3D clk_prepare_enable(ctx->mclk); + if (!ret) + clk_disable_unprepare(ctx->mclk); + + ret =3D clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ); + + if (ret) { + dev_err(runtime->dev, "unable to set MCLK rate\n"); + return ret; + } + } + + return 0; +} + +static int cht_yb_codec_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate =3D hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels =3D hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + + /* The DSP will convert the FE rate to 48k, stereo, 24bits */ + rate->min =3D rate->max =3D 48000; + channels->min =3D channels->max =3D 2; + + /* + * set SSP2 to 24-bit + * Looks like strange black magic because ssp2-port supports S16LE + * format only, taken from Intel's code + */ + params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); + + return 0; +} + +static struct snd_soc_jack_pin cht_yb_jack_pins[] =3D { + { + .pin =3D "Headphone", + .mask =3D SND_JACK_HEADPHONE, + }, + { + .pin =3D "Headset Mic", + .mask =3D SND_JACK_MICROPHONE, + }, +}; + +static int cht_yb_headset_init(struct snd_soc_component *component) +{ + struct snd_soc_card *card =3D component->card; + struct cht_mc_private *ctx =3D snd_soc_card_get_drvdata(card); + struct snd_soc_jack *jack =3D &ctx->jack; + int jack_type; + int ret; + + /* + * TS3A227E supports 4 butons headset detection + * KEY_MEDIA + * KEY_VOICECOMMAND + * KEY_VOLUMEUP + * KEY_VOLUMEDOWN + */ + jack_type =3D SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3; + + ret =3D snd_soc_card_jack_new_pins(card, "Headset Jack", + jack_type, jack, + cht_yb_jack_pins, + ARRAY_SIZE(cht_yb_jack_pins)); + if (ret) { + dev_err(card->dev, "Headset Jack creation failed %d\n", ret); + return ret; + } + + return ts3a227e_enable_jack_detect(component, jack); +} + +static int cht_yb_aif1_startup(struct snd_pcm_substream *substream) +{ + return snd_pcm_hw_constraint_single(substream->runtime, + SNDRV_PCM_HW_PARAM_RATE, 48000); +} + +static const struct snd_soc_ops cht_yb_aif1_ops =3D { + .startup =3D cht_yb_aif1_startup, +}; + +static const struct snd_soc_ops cht_yb_be_ssp2_ops =3D { + .hw_params =3D cht_yb_aif1_hw_params, +}; + +static struct snd_soc_aux_dev cht_yb_headset_dev =3D { + .dlc =3D COMP_AUX("i2c-ts3a227e"), + .init =3D cht_yb_headset_init, +}; + +SND_SOC_DAILINK_DEF(dummy, + DAILINK_COMP_ARRAY(COMP_DUMMY())); + +SND_SOC_DAILINK_DEF(media, + DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai"))); + +SND_SOC_DAILINK_DEF(deepbuffer, + DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai"))); + +SND_SOC_DAILINK_DEF(ssp2_port, + DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port"))); +SND_SOC_DAILINK_DEF(ssp2_codec, + DAILINK_COMP_ARRAY(COMP_CODEC(RT5677_I2C_DEFAULT, "rt5677-aif1"))); + +SND_SOC_DAILINK_DEF(platform, + DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform"))); + +static struct snd_soc_dai_link cht_yb_dailink[] =3D { + /* Front End DAI links */ + [MERR_DPCM_AUDIO] =3D { + .name =3D "Audio Port", + .stream_name =3D "Audio", + .nonatomic =3D true, + .dynamic =3D 1, + .ops =3D &cht_yb_aif1_ops, + SND_SOC_DAILINK_REG(media, dummy, platform), + }, + [MERR_DPCM_DEEP_BUFFER] =3D { + .name =3D "Deep-Buffer Audio Port", + .stream_name =3D "Deep-Buffer Audio", + .nonatomic =3D true, + .dynamic =3D 1, + .playback_only =3D 1, + .ops =3D &cht_yb_aif1_ops, + SND_SOC_DAILINK_REG(deepbuffer, dummy, platform), + }, + + /* Back End DAI links */ + { + /* SSP2 - Codec */ + .name =3D "SSP2-Codec", + .id =3D 0, + .no_pcm =3D 1, + .nonatomic =3D true, + .init =3D cht_yb_codec_init, + .be_hw_params_fixup =3D cht_yb_codec_fixup, + .ops =3D &cht_yb_be_ssp2_ops, + SND_SOC_DAILINK_REG(ssp2_port, ssp2_codec, platform), + }, +}; + +/* SoC card */ +static struct snd_soc_card snd_soc_card_cht_yb =3D { + .owner =3D THIS_MODULE, + .dai_link =3D cht_yb_dailink, + .num_links =3D ARRAY_SIZE(cht_yb_dailink), + .aux_dev =3D &cht_yb_headset_dev, + .num_aux_devs =3D 1, + .dapm_widgets =3D cht_yb_dapm_widgets, + .num_dapm_widgets =3D ARRAY_SIZE(cht_yb_dapm_widgets), + .dapm_routes =3D cht_yb_audio_map, + .num_dapm_routes =3D ARRAY_SIZE(cht_yb_audio_map), + .controls =3D cht_mc_controls, + .num_controls =3D ARRAY_SIZE(cht_mc_controls), +}; + +static const struct acpi_gpio_params speaker_enable_gpio =3D { 2, 0, false= }; +static const struct acpi_gpio_mapping cht_yb_gpios[] =3D { + { "speaker-enable-gpios", &speaker_enable_gpio, 1 }, + { NULL } +}; + +#define SOF_CARD_NAME "cht yogabook" +#define SOF_DRIVER_NAME "SOF" + +#define CARD_NAME "cht-yogabook" +#define DRIVER_NAME NULL + +static int snd_cht_yb_mc_probe(struct platform_device *pdev) +{ + int ret_val =3D 0; + struct cht_mc_private *drv; + struct snd_soc_acpi_mach *mach =3D pdev->dev.platform_data; + const char *platform_name; + struct acpi_device *adev; + struct device *codec_dev; + bool sof_parent; + int i; + + drv =3D devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); + if (!drv) + return -ENOMEM; + + strscpy(drv->codec_name, RT5677_I2C_DEFAULT); + + /* fixup codec name based on HID if ACPI node is present */ + adev =3D acpi_dev_get_first_match_dev(mach->id, NULL, -1); + if (adev) { + snprintf(drv->codec_name, sizeof(drv->codec_name), + "i2c-%s", acpi_dev_name(adev)); + dev_info(&pdev->dev, "real codec name: %s\n", drv->codec_name); + + put_device(&adev->dev); + for (i =3D 0; i < ARRAY_SIZE(cht_yb_dailink); i++) { + if (cht_yb_dailink[i].codecs->name && + !strcmp(cht_yb_dailink[i].codecs->name, + RT5677_I2C_DEFAULT)) { + cht_yb_dailink[i].codecs->name =3D drv->codec_name; + break; + } + } + } + + codec_dev =3D bus_find_device_by_name(&i2c_bus_type, NULL, + drv->codec_name); + if (!codec_dev) + return -EPROBE_DEFER; + + if (adev) { + ret_val =3D devm_acpi_dev_add_driver_gpios(codec_dev, + cht_yb_gpios); + if (ret_val) + dev_warn(&pdev->dev, + "Unable to add GPIO mapping table: %d\n", + ret_val); + } + + /* override platform name, if required */ + snd_soc_card_cht_yb.dev =3D &pdev->dev; + platform_name =3D mach->mach_params.platform; + + ret_val =3D snd_soc_fixup_dai_links_platform_name(&snd_soc_card_cht_yb, + platform_name); + if (ret_val) { + dev_err(&pdev->dev, + "snd_soc_fixup_dai_links_platform_name failed: %d\n", + ret_val); + return ret_val; + } + + drv->mclk =3D devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); + if (IS_ERR(drv->mclk)) { + dev_err(&pdev->dev, + "Failed to get MCLK from pmc_plt_clk_3: %ld\n", + PTR_ERR(drv->mclk)); + return PTR_ERR(drv->mclk); + } + snd_soc_card_set_drvdata(&snd_soc_card_cht_yb, drv); + + sof_parent =3D snd_soc_acpi_sof_parent(&pdev->dev); + + /* set the card and driver name */ + if (sof_parent) { + snd_soc_card_cht_yb.name =3D SOF_CARD_NAME; + snd_soc_card_cht_yb.driver_name =3D SOF_DRIVER_NAME; + } else { + snd_soc_card_cht_yb.name =3D CARD_NAME; + snd_soc_card_cht_yb.driver_name =3D DRIVER_NAME; + } + + /* register the soc card */ + snd_soc_card_cht_yb.dev =3D &pdev->dev; + ret_val =3D devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht_yb); + if (ret_val) { + dev_err(&pdev->dev, + "snd_soc_register_card failed %d\n", ret_val); + return ret_val; + } + platform_set_drvdata(pdev, &snd_soc_card_cht_yb); + + return ret_val; +} + +static struct platform_driver snd_cht_yb_mc_driver =3D { + .driver =3D { + .name =3D "cht-yogabook", + }, + .probe =3D snd_cht_yb_mc_probe, +}; + +module_platform_driver(snd_cht_yb_mc_driver); + +MODULE_DESCRIPTION("Lenovo Yoga Book YB1-X9x machine driver"); +MODULE_AUTHOR("Yauhen Kharuzhy"); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:cht-yogabook"); --=20 2.51.0 From nobody Fri Apr 3 04:39:51 2026 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (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 0D32528D8D1 for ; Tue, 17 Feb 2026 23:13:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771370015; cv=none; b=NhOs4/XuYuO10DYyxGUqGBeb/at+Q1SiwPxtJJvZ1vhQrqlKxHx9LMENdsfj+EuKRMkgno8jWVKb8xt3nKjUYaYKyDiXM+PkwKuKHbX0ChCq/QWN6JLI369drEHKVuMkcw+xkLps39KcAYslMCnWHfQ01FdxtVlh9u6CmMYKc/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771370015; c=relaxed/simple; bh=aEdMirBVX3PPQ1QFkY6pFwuZYxuJIL/jbDi5a1WULFI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ddLVFh83WUbqqtB1iHpgn+qCiEjVUe6PyGX5mMNnVPsvwY1ccVhQCKkEQf1iE4sw3YgIWcbZcH+2Z8l0xHnAWANjKODZLu++pKaNsafpqVeVZh8WT6XzGI3eW6TsiTGn+X73Hn4HgjN5WPyVWpy+rLrxrCwU8XZF8PuYwTW8jy4= 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=IpIfbGL5; arc=none smtp.client-ip=209.85.208.49 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="IpIfbGL5" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-65a2fea1a1eso514177a12.0 for ; Tue, 17 Feb 2026 15:13:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771370012; x=1771974812; 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=ChNMzOH279vklBP3A89PcATTRSKJjuOlqr/8qHAiJfo=; b=IpIfbGL52kPzS4cQZ1amP7z+sW7sXRhCWyLgOAKufPB5ZfqmULH208cCf+IsaCOdCR tmLhiG3W76F3b5SWtOIJFBV88hRW1S3KSDAMq5d5VSY6IjK45ANZj3uiUOlG5Af8PVVD nv+C/OWFGV/bscjSl2tOdAMUSd1NMTv3Jn98B0U4ECW2l2T3Exjnx9f2hh2fREh9oCa3 0y5s7ZYsDY132y8sFjhdCdC+udeRhT+sLZXMO29chi2jTyOdDtO06+VEN0eOHYycNej3 sJKzHDj3S5UX7okaQuop5uh4DX/32TWmJRzYWdcJJOD0ko07p8UEcLsaKON5w8/N1JkZ 6pCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771370012; x=1771974812; 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=ChNMzOH279vklBP3A89PcATTRSKJjuOlqr/8qHAiJfo=; b=CmlCHDZzz7Hjj1+8rPamDFqHGXx404LpjQpLBsJPk1NehqDPGYR2pSes4wsNe+mJeX T+9zYygwka8KnO0XzWjBykWghmA6l9LAn3IJoUzsiCiGIjEGetsia7+xsUm+31tIQiK/ +GaAMyEFEUDzgZjpuXvQvso8hUk00UnF+cKOx0klGvDwe914x3wAatSsZtfFnH30RO9q aFYDPHUPwF2UOrNHbzdAvwARTPgxd3nHjclB06O5cKuij1K3166WZKlTvTyj4LKvl4v2 Yv5QZ4k69SaUiSFkoc+uaeUU1AjqvOctZCb1asp/Rkv+C9nN7+weRwI+4GPXDt+KIXqM jJAQ== X-Gm-Message-State: AOJu0YzjvfGk8+ZjYsEsoIHZqO/HcFG9V/MrATJM2qqOUZqW1aG6mjXa apPx7QUzmc5gJu9Y4gAodfnrwIoEZUWhVcwCPq3ZKFll/6JBSQg1YKQ4 X-Gm-Gg: AZuq6aK1LxrisOBauZELhfLE8r23g+N4UNmc0V3FOop+ptOXoiYuRB46KbAYyOmORfz eh33bsbRqZdYXScnOHWy3/eIFUDrMvFeEkCmahDvFk/x9fEQE2eRWwQ3xQbp1n7tJAEaRuZe+Mw BN6Q+05nZ8c6mvnXG7uMjZFOZ6fFLvxYLTkF27OVKtg/qs09Q5cwG1gggNZ4bP/CC6qe9z58nT0 XI6qAblYiVnljeFAgRP+qFbpLTlAr8y8jwjWzIdkUMdM3poNxj7I7nGTJBH/A0sI7koy8V5eWgy KGcrnzS7Suu2aRCAfrnii6wFN6kT+TIIdC/zokFlOyFAG659vRbxGLk7AohuIagwhxzAJJ9LlW7 534BH27nBHxVvaUMJnh1aTdS6YzRccYNAKtoCAjYccX+QzaRGBt5+q/K6lVUD7zrdj/9PngRtDD CAkcrLU4UhxJnHtw== X-Received: by 2002:a17:907:9341:b0:b72:5629:1789 with SMTP id a640c23a62f3a-b903ce43635mr3012566b.13.1771370012393; Tue, 17 Feb 2026 15:13:32 -0800 (PST) Received: from jekhomev ([46.251.53.180]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-65bad3f137dsm2661375a12.27.2026.02.17.15.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Feb 2026 15:13:32 -0800 (PST) From: Yauhen Kharuzhy To: linux-sound@vger.kernel.org, Cezary Rojewski , Liam Girdwood , Pierre-Louis Bossart , Mark Brown Cc: linux-kernel@vger.kernel.org, Hans de Goede , Yauhen Kharuzhy Subject: [PATCH v1 2/2] ASoC: Intel: soc-acpi-cht: Add Lenovo Yoga Book entries Date: Wed, 18 Feb 2026 01:13:24 +0200 Message-ID: <20260217231324.1319392-3-jekhor@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260217231324.1319392-1-jekhor@gmail.com> References: <20260217231324.1319392-1-jekhor@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Lenovo Yoga Book YB1-X91 device uses a Cherry Trail SoC and has a valid ACPI DSDT entry for the RT5677 codec. This entry has some non-standard resource definitions, such as jack detection chip information, and hardware has some additional GPIO controls so use 'cht-yogabook' for the driver name instead of some default (like 'cht-bsw-rt5677'). Lenovo Yoga Book YB1-X90 device (Android version of the tablet) has the same hardware configuration but lacks a valid ACPI DSDT entry for the codec. To match this device, extend the existing quirk designated for the Lenovo Yoga Tab 3 Pro YT3-X90 and make it more generic: select a matched machine using the dmi_check_system() quirk mechanism. Signed-off-by: Yauhen Kharuzhy --- .../intel/common/soc-acpi-intel-cht-match.c | 144 ++++++++++++------ 1 file changed, 94 insertions(+), 50 deletions(-) diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/= intel/common/soc-acpi-intel-cht-match.c index e4c3492a0c28..cadb7790d86a 100644 --- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c @@ -9,13 +9,47 @@ #include #include =20 -static unsigned long cht_machine_id; +static struct snd_soc_acpi_mach *cht_quirk_mach; =20 -#define CHT_SURFACE_MACH 1 +static struct snd_soc_acpi_mach cht_surface_mach =3D { + .id =3D "10EC5640", + .drv_name =3D "cht-bsw-rt5645", + .fw_filename =3D "intel/fw_sst_22a8.bin", + .board =3D "cht-bsw", + .sof_tplg_filename =3D "sof-cht-rt5645.tplg", +}; + +static struct snd_soc_acpi_mach cht_yogabook_mach =3D { + .id =3D "10EC5677", + .drv_name =3D "cht-yogabook", + .fw_filename =3D "intel/fw_sst_22a8.bin", + .board =3D "cht-yogabook", + .sof_tplg_filename =3D "sof-cht-rt5677.tplg", +}; + +static struct snd_soc_acpi_mach cht_lenovo_yoga_tab3_x90_mach =3D { + .id =3D "10WM5102", + .drv_name =3D "bytcr_wm5102", + .fw_filename =3D "intel/fw_sst_22a8.bin", + .board =3D "bytcr_wm5102", + .sof_tplg_filename =3D "sof-cht-wm5102.tplg", +}; =20 static int cht_surface_quirk_cb(const struct dmi_system_id *id) { - cht_machine_id =3D CHT_SURFACE_MACH; + cht_quirk_mach =3D &cht_surface_mach; + return 1; +} + +static int cht_yogabook_quirk_cb(const struct dmi_system_id *id) +{ + cht_quirk_mach =3D &cht_yogabook_mach; + return 1; +} + +static int cht_yt3_quirk_cb(const struct dmi_system_id *id) +{ + cht_quirk_mach =3D &cht_lenovo_yoga_tab3_x90_mach; return 1; } =20 @@ -27,29 +61,57 @@ static const struct dmi_system_id cht_table[] =3D { DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"), }, }, + { + .callback =3D cht_yogabook_quirk_cb, + .ident =3D "Lenovo Yoga Book YB1-X91", + /* YB1-X91L/F */ + .matches =3D { + DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X91"), + } + }, + { + .callback =3D cht_yogabook_quirk_cb, + .ident =3D "Lenovo Yoga Book YB1-X90", + /* YB1-X90L/F, codec is not listed in DSDT */ + .matches =3D { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"), + DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "YETI-11"), + } + }, + { + /* + * The Lenovo Yoga Tab 3 Pro YT3-X90, with Android factory OS + * has a buggy DSDT with the codec not being listed at all. + */ + .callback =3D cht_yt3_quirk_cb, + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), + DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"), + }, + }, { } }; =20 -static struct snd_soc_acpi_mach cht_surface_mach =3D { - .id =3D "10EC5640", - .drv_name =3D "cht-bsw-rt5645", - .fw_filename =3D "intel/fw_sst_22a8.bin", - .board =3D "cht-bsw", - .sof_tplg_filename =3D "sof-cht-rt5645.tplg", -}; - static struct snd_soc_acpi_mach *cht_quirk(void *arg) { struct snd_soc_acpi_mach *mach =3D arg; =20 dmi_check_system(cht_table); =20 - if (cht_machine_id =3D=3D CHT_SURFACE_MACH) - return &cht_surface_mach; + if (cht_quirk_mach) + return cht_quirk_mach; else return mach; } =20 +static struct snd_soc_acpi_mach *cht_quirk_nocodec(void *arg) +{ + struct snd_soc_acpi_mach *mach =3D cht_quirk(arg); + + return mach =3D=3D arg ? NULL : mach; +} + /* * Some tablets with Android factory OS have buggy DSDTs with an ESSX8316 = device * in the ACPI tables. While they are not using an ESS8316 codec. These DS= DTs @@ -75,38 +137,6 @@ static struct snd_soc_acpi_mach *cht_ess8316_quirk(void= *arg) return arg; } =20 -/* - * The Lenovo Yoga Tab 3 Pro YT3-X90, with Android factory OS has a buggy = DSDT - * with the coded not being listed at all. - */ -static const struct dmi_system_id lenovo_yoga_tab3_x90[] =3D { - { - /* Lenovo Yoga Tab 3 Pro YT3-X90, codec missing from DSDT */ - .matches =3D { - DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"), - DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"), - }, - }, - { } -}; - -static struct snd_soc_acpi_mach cht_lenovo_yoga_tab3_x90_mach =3D { - .id =3D "10WM5102", - .drv_name =3D "bytcr_wm5102", - .fw_filename =3D "intel/fw_sst_22a8.bin", - .board =3D "bytcr_wm5102", - .sof_tplg_filename =3D "sof-cht-wm5102.tplg", -}; - -static struct snd_soc_acpi_mach *lenovo_yt3_x90_quirk(void *arg) -{ - if (dmi_check_system(lenovo_yoga_tab3_x90)) - return &cht_lenovo_yoga_tab3_x90_mach; - - /* Skip wildcard match snd_soc_acpi_intel_cherrytrail_machines[] entry */ - return NULL; -} - static const struct snd_soc_acpi_codecs rt5640_comp_ids =3D { .num_codecs =3D 2, .codecs =3D { "10EC5640", "10EC3276" }, @@ -137,6 +167,20 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytra= il_machines[] =3D { .board =3D "cht-bsw", .sof_tplg_filename =3D "sof-cht-rt5670.tplg", }, + /* + * The only known Cherry Trail device with RT5677 codec and 10EC677 + * DSTD entry is the Lenovo Yoga Book YB1-X91. It has a device-specific + * driver, so check DMI and use a machine quirk to override the default + * (non-existent) machine driver. + */ + { + .id =3D "10EC5677", + .drv_name =3D "cht-bsw-rt5677", + .fw_filename =3D "intel/fw_sst_22a8.bin", + .board =3D "cht-bsw", + .machine_quirk =3D cht_quirk, + .sof_tplg_filename =3D "sof-cht-rt5677.tplg", + }, { .comp_ids =3D &rt5645_comp_ids, .drv_name =3D "cht-bsw-rt5645", @@ -208,14 +252,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytr= ail_machines[] =3D { .sof_tplg_filename =3D "sof-cht-src-50khz-pcm512x.tplg", }, /* - * Special case for the Lenovo Yoga Tab 3 Pro YT3-X90 where the DSDT - * misses the codec. Match on the SST id instead, lenovo_yt3_x90_quirk() - * will return a YT3 specific mach or NULL when called on other hw, - * skipping this entry. + * Special case for the Lenovo Yoga Tab 3 Pro YT3-X90 and Lenovo + * Yoga Book YB1-X90 where the DSDT misses the codec. Match on the + * SST id instead, cht_quirk_nocodec() will return a machine-specific + * mach or NULL when called on other hw, skipping this entry. */ { .id =3D "808622A8", - .machine_quirk =3D lenovo_yt3_x90_quirk, + .machine_quirk =3D cht_quirk_nocodec, }, =20 #if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH) --=20 2.51.0