public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
From: Yauhen Kharuzhy <jekhor@gmail.com>
To: Oder Chiou <oder_chiou@realtek.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	Hans de Goede <hansg@kernel.org>,
	Yauhen Kharuzhy <jekhor@gmail.com>
Subject: [PATCH 5/7] ASoC: rt5677: Set up ACPI GPIO pins mapping table
Date: Wed, 11 Feb 2026 02:18:37 +0200	[thread overview]
Message-ID: <20260211002255.4090440-6-jekhor@gmail.com> (raw)
In-Reply-To: <20260211002255.4090440-1-jekhor@gmail.com>

To get GPIO configuration from ACPI, define an ACPI GPIO mapping table,
linking GPIO names with CRS entries.

The only known device that has an ACPI entry for the RT5677 codec is
the Lenovo Yoga Book YB1-X91, and it uses this entry to describe the
entire sound system configuration: codec connections and jack detection
chip connections.

This ACPI definition looks YogaBook-specific, but codec GPIOs may be
recognized as generic, so add this lookup table for all devices.

Details about the YogaBook RT5677 ACPI entry are provided below.

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

ACPI decompiled dump fragment:

    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>
---
 sound/soc/codecs/rt5677.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
index 845385c1fb88..f56ac267f53b 100644
--- a/sound/soc/codecs/rt5677.c
+++ b/sound/soc/codecs/rt5677.c
@@ -5536,6 +5536,15 @@ static int rt5677_init_irq(struct i2c_client *i2c)
 	return ret;
 }
 
+static const struct acpi_gpio_params rt5677_acpi_reset_gpios = {0, 0, true};
+static const struct acpi_gpio_params rt5677_acpi_ldo2_gpios = {1, 0, false};
+
+static const struct acpi_gpio_mapping rt5677_acpi_gpios[] = {
+	{ "realtek,reset-gpios", &rt5677_acpi_reset_gpios, 1 },
+	{ "realtek,pow-ldo2-gpios", &rt5677_acpi_ldo2_gpios, 1 },
+	{},
+};
+
 static int rt5677_i2c_probe(struct i2c_client *i2c)
 {
 	struct rt5677_priv *rt5677;
@@ -5556,6 +5565,9 @@ static int rt5677_i2c_probe(struct i2c_client *i2c)
 	if (rt5677->type == 0)
 		return -EINVAL;
 
+	if (devm_acpi_dev_add_driver_gpios(rt5677->dev, rt5677_acpi_gpios))
+		dev_warn(rt5677->dev, "Unable to add GPIO mapping table\n");
+
 	rt5677_read_device_properties(rt5677, &i2c->dev);
 
 	/* pow-ldo2 and reset are optional. The codec pins may be statically
-- 
2.51.0


  parent reply	other threads:[~2026-02-11  0:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-11  0:18 ASoC rt5677: Prepare to support Lenovo Yoga Book tablets Yauhen Kharuzhy
2026-02-11  0:18 ` [PATCH 1/7] ASoC: rt5677: Add 10EC5677 ACPI ID as supported Yauhen Kharuzhy
2026-02-25 19:06   ` Mark Brown
2026-02-11  0:18 ` [PATCH 2/7] ASoC: rt5677: Allow it to be defined as an I2C board Yauhen Kharuzhy
2026-02-11  0:18 ` [PATCH 3/7] ASoC: rt5677: Fix typo in the header file Yauhen Kharuzhy
2026-02-11  0:18 ` [PATCH 4/7] ASoC: rt5677: Report error if the ID register cannot be read Yauhen Kharuzhy
2026-02-11  0:18 ` Yauhen Kharuzhy [this message]
2026-02-11  0:18 ` [PATCH 6/7] ASoC: rt5677: Reset the codec during probing Yauhen Kharuzhy
2026-02-11  0:18 ` [PATCH 7/7] ASoC: rt5677-spi: Add SPI device ID matching table Yauhen Kharuzhy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260211002255.4090440-6-jekhor@gmail.com \
    --to=jekhor@gmail.com \
    --cc=broonie@kernel.org \
    --cc=hansg@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=oder_chiou@realtek.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox