|
|
Log in / Subscribe / Register

Add ASoC machine driver for Cherryview tablets with RT5677

From:  Yauhen Kharuzhy <jekhor-AT-gmail.com>
To:  Cezary Rojewski <cezary.rojewski-AT-intel.com>, Liam Girdwood <liam.r.girdwood-AT-linux.intel.com>, Peter Ujfalusi <peter.ujfalusi-AT-linux.intel.com>, Bard Liao <yung-chuan.liao-AT-linux.intel.com>, Ranjani Sridharan <ranjani.sridharan-AT-linux.intel.com>, Kai Vehmanen <kai.vehmanen-AT-linux.intel.com>, Pierre-Louis Bossart <pierre-louis.bossart-AT-linux.dev>, Mark Brown <broonie-AT-kernel.org>, Jaroslav Kysela <perex-AT-perex.cz>, Takashi Iwai <tiwai-AT-suse.com>
Subject:  [PATCH v3 0/3] Add ASoC machine driver for Cherryview tablets with RT5677
Date:  Thu, 11 Jun 2026 02:51:54 +0300
Message-ID:  <20260611-asoc-yogabook-v2-v3-0-3128447b67b6@gmail.com>
Cc:  linux-sound-AT-vger.kernel.org, linux-kernel-AT-vger.kernel.org, Hans de Goede <hansg-AT-kernel.org>, Yauhen Kharuzhy <jekhor-AT-gmail.com>
Archive-link:  Article

This is the third iteration of my submission for sound support for Lenovo
    Yoga Book YB1-X90/X91 tablets.

    These are Cherry Trail-based platforms that use the RT5677 codec and
    TS3A227E jack detection IC.

    The YB1-X90 is an Android-designated device and has incorrect ACPI entries
    for many onboard peripherals, including sound devices. The YB1-X91 has a
    DSDT node for the codec, and the same node is shared with the TS3A227E
    jack detection IC (see below).

    Matching with ACPI entries is somewhat tricky; see the corresponding
    commit. Jack detection IC info is defined in the x86-android-tablets driver
    for both platforms to simplify the code.

    The ASoC machine driver is called 'cht_rt5677' but has some
    device-specific things hardcoded because no other known
    Cherry Trail-based platforms use an RT5677 codec.

v3:
- Rename cht_yogabook driver to cht_rt5677;
- Allocate snd_soc_card structure dynamically;
- Reset the codec name in the global dailink array back to the default
  at driver remove() method to prevent use-after-free error;
- Apply small fixes like removing code duplication and renaming variables in
  the probe method;
- Remove support for SOF;
- Skip checking if ctx->mclk is valid since probe() will fail if not;
- Ensure error codes are included in error messages during initialization;
- Eliminate debug messages;
- Split cht_rt5677_platform_clock_control() function into enable/disable
  subroutines;
- Move GPIOs initialization from codec init to probe and use gpiod_*
  functions instead of devm_gpiod_* versions because GPIOs are linked to
  another device;
- Rename variable 'k' to 'kctl' for struct snd_kcontrol arguments;
- Remove ambiguous copyright statements;
- Switch from using *-objs to *-y in the Makefile;
- Correct alignment warnings reported by checkpatch;
- Update ACPI matching code: rename cht_quirk_nocodec() to cht_quirk_strict(),
  and use a default entry for the YB1-X91 tablet.
- Link to v2: https://lore.kernel.org/r/20260301-asoc-yogabook-v2-v2-0-...

v2:
 cht_yogabook driver:
 - Remove likely obsolete code from the driver: GPIO magic manipulations
   when enabling the speaker amplifier and msleep() calls when turning
   the speaker/headphones on and off.
 - Remove MICBIAS1 manipulation on headphone jack insertion (click
   prevention): the TS3A227E should handle it by itself.
 - Rename struct cht_mc_private to cht_yb_private.

 ACPI matching code:
 - Split the changes into two commits: reworking existing entries and adding
   new ones.
 - Use dmi_system_id.driver_data to specify matched machine data instead
   of callbacks.

For reference, there is an ACPI node for sound configuration from YB1-X91
DSDT below:

HID: 10EC5677
_CRS resources:

  I2C devices:
  0: rt5677 codec
  1: ts3a227e jack detection IC

  GPIOs:
  0: rt5677 codec reset
  1: rt5677 codec pow-ldo2
  2: speaker enable

  INTs:
  0: rt5677 codec
  1: ts3a227e jack detection IC

  SPI device:
  0: rt5677 codec SPI connection

Decompiled fragment of ACPI dump:

    Device (RTEK)
    {
        Name (_ADR, Zero)  // _ADR: Address
        Name (_HID, "10EC5677")  // _HID: Hardware ID
        Name (_CID, "10EC5677")  // _CID: Compatible ID
        Name (_DDN, "Realtek IIS Audio Codec")  // _DDN: DOS Device Name
        Name (_SUB, "17AA7005")  // _SUB: Subsystem ID
        Name (_UID, One)  // _UID: Unique ID
        Name (_PR0, Package (0x01)  // _PR0: Power Resources for D0
        {
            CLK3
        })
        Name (CHAN, Package (0x02)
        {
            One,
            0x0124F800
        })
        Method (_CRS, 0, NotSerialized)  // _CRS: Current Resource Settings
        {
            Name (SBUF, ResourceTemplate ()
            {
                I2cSerialBusV2 (0x002C, ControllerInitiated, 0x000186A0,
                    AddressingMode7Bit, "\\_SB.PCI0.I2C1",
                    0x00, ResourceConsumer, , Exclusive,
                    )
                I2cSerialBusV2 (0x003B, ControllerInitiated, 0x000186A0,
                    AddressingMode7Bit, "\\_SB.PCI0.I2C1",
                    0x00, ResourceConsumer, , Exclusive,
                    )
                GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
                    "\\_SB.GPO3", 0x00, ResourceConsumer, ,
                    )
                    {   // Pin list
                        0x0019
                    }
                GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
                    "\\_SB.GPO3", 0x00, ResourceConsumer, ,
                    )
                    {   // Pin list
                        0x0012
                    }
                GpioIo (Exclusive, PullDefault, 0x0000, 0x0000, IoRestrictionOutputOnly,
                    "\\_SB.GPO3", 0x00, ResourceConsumer, ,
                    )
                    {   // Pin list
                        0x0030
                    }
                GpioInt (Edge, ActiveLow, Exclusive, PullNone, 0x0000,
                    "\\_SB.GPO0", 0x00, ResourceConsumer, ,
                    )
                    {   // Pin list
                        0x005B
                    }
                GpioInt (Edge, ActiveLow, Exclusive, PullNone, 0x0000,
                    "\\_SB.GPO0", 0x00, ResourceConsumer, ,
                    )
                    {   // Pin list
                        0x004D
                    }
                SpiSerialBusV2 (0x0001, PolarityLow, FourWireMode, 0x08,
                    ControllerInitiated, 0x003D0900, ClockPolarityHigh,
                    ClockPhaseSecond, "\\_SB.PCI0.SPI1",
                    0x00, ResourceConsumer, , Exclusive,
                    )
            })
            Return (SBUF) /* \_SB_.PCI0.I2C1.RTEK._CRS.SBUF */
        }
    }

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
---
Yauhen Kharuzhy (3):
      ASoC: Intel: soc-acpi-cht: Unify device quirks
      ASoC: Intel: soc-acpi-cht: Add Lenovo Yoga Book entries
      ASoC: Intel: Add cht_rt5677 driver

 sound/soc/intel/boards/Kconfig                    |  18 +
 sound/soc/intel/boards/Makefile                   |   2 +
 sound/soc/intel/boards/cht_rt5677.c               | 564 ++++++++++++++++++++++
 sound/soc/intel/common/soc-acpi-intel-cht-match.c | 121 ++---
 4 files changed, 648 insertions(+), 57 deletions(-)
---
base-commit: 94a662ada263eb2238b85e1eb4b21fd03b9b5fa2
change-id: 20260219-asoc-yogabook-v2-70c146371d20

Best regards,
-- 
Yauhen Kharuzhy




Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds