From f43aed8dfecb10e95b8235d002990739ebe72c5e Mon Sep 17 00:00:00 2001 From: Yauhen Kharuzhy Date: Wed, 11 Feb 2026 02:18:33 +0200 Subject: [PATCH 1/7] ASoC: rt5677: Add 10EC5677 ACPI ID as supported Add 10EC5677 ACPI ID to the match table. It is used in the Lenovo Yoga Book YB1-X91 tablet at least. Signed-off-by: Yauhen Kharuzhy Link: https://patch.msgid.link/20260211002255.4090440-2-jekhor@gmail.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index d46385249867..ccbd32cf8298 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -5204,6 +5204,7 @@ MODULE_DEVICE_TABLE(of, rt5677_of_match); static const struct acpi_device_id rt5677_acpi_match[] = { { "10EC5677", RT5677 }, { "RT5677CE", RT5677 }, + { "10EC5677", RT5677 }, { } }; MODULE_DEVICE_TABLE(acpi, rt5677_acpi_match); From 9f56f0bd2e49876ceeaf9036887fe9b50dfa6b6b Mon Sep 17 00:00:00 2001 From: Yauhen Kharuzhy Date: Wed, 11 Feb 2026 02:18:34 +0200 Subject: [PATCH 2/7] ASoC: rt5677: Allow it to be defined as an I2C board Some devices (e.g., Lenovo Yoga Book YB1-X90) define the codec as i2c_board, so add an I2C ID table to support this. Signed-off-by: Yauhen Kharuzhy Link: https://patch.msgid.link/20260211002255.4090440-3-jekhor@gmail.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index ccbd32cf8298..6628c7ca5a8a 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -5209,6 +5209,12 @@ static const struct acpi_device_id rt5677_acpi_match[] = { }; MODULE_DEVICE_TABLE(acpi, rt5677_acpi_match); +static const struct i2c_device_id rt5677_i2c_id[] = { + { "rt5677", RT5677 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id); + static void rt5677_read_device_properties(struct rt5677_priv *rt5677, struct device *dev) { @@ -5532,7 +5538,6 @@ static int rt5677_init_irq(struct i2c_client *i2c) static int rt5677_i2c_probe(struct i2c_client *i2c) { - struct device *dev = &i2c->dev; struct rt5677_priv *rt5677; int ret; unsigned int val; @@ -5547,7 +5552,7 @@ static int rt5677_i2c_probe(struct i2c_client *i2c) INIT_DELAYED_WORK(&rt5677->dsp_work, rt5677_dsp_work); i2c_set_clientdata(i2c, rt5677); - rt5677->type = (enum rt5677_type)(uintptr_t)device_get_match_data(dev); + rt5677->type = (enum rt5677_type)(uintptr_t)i2c_get_match_data(i2c); if (rt5677->type == 0) return -EINVAL; @@ -5666,6 +5671,7 @@ static struct i2c_driver rt5677_i2c_driver = { .of_match_table = rt5677_of_match, .acpi_match_table = rt5677_acpi_match, }, + .id_table = rt5677_i2c_id, .probe = rt5677_i2c_probe, .remove = rt5677_i2c_remove, }; From 687f2679e8bf65bca247ca7f4013130d609e1e56 Mon Sep 17 00:00:00 2001 From: Yauhen Kharuzhy Date: Wed, 11 Feb 2026 02:18:35 +0200 Subject: [PATCH 3/7] ASoC: rt5677: Fix typo in the header file Fix a typo in the DAC1 Digital Volume register description comment (it was mistakenly named as DAC3). Signed-off-by: Yauhen Kharuzhy Link: https://patch.msgid.link/20260211002255.4090440-4-jekhor@gmail.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h index d67ebae067d9..876f7674015c 100644 --- a/sound/soc/codecs/rt5677.h +++ b/sound/soc/codecs/rt5677.h @@ -421,7 +421,7 @@ #define RT5677_DAC3_R_VOL_MASK (0xff) #define RT5677_DAC3_R_VOL_SFT 0 -/* DAC3 Digital Volume (0x19) */ +/* DAC1 Digital Volume (0x19) */ #define RT5677_DAC1_L_VOL_MASK (0xff << 8) #define RT5677_DAC1_L_VOL_SFT 8 #define RT5677_DAC1_R_VOL_MASK (0xff) From 14848e6a8058916e9b008734aa36da989725b6df Mon Sep 17 00:00:00 2001 From: Yauhen Kharuzhy Date: Wed, 11 Feb 2026 02:18:36 +0200 Subject: [PATCH 4/7] ASoC: rt5677: Report error if the ID register cannot be read To make error messages clearer, report if the ID register failed to be read via I2C during probing. Signed-off-by: Yauhen Kharuzhy Link: https://patch.msgid.link/20260211002255.4090440-5-jekhor@gmail.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 6628c7ca5a8a..845385c1fb88 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -5602,7 +5602,13 @@ static int rt5677_i2c_probe(struct i2c_client *i2c) return ret; } - regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val); + ret = regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val); + if (ret) { + dev_err(&i2c->dev, + "Failed to read ID register: %d\n", ret); + return -ENODEV; + } + if (val != RT5677_DEVICE_ID) { dev_err(&i2c->dev, "Device with ID register %#x is not rt5677\n", val); From 0cc00de3dd5b66c80e6ec1705ec929f4a45ffa1c Mon Sep 17 00:00:00 2001 From: Yauhen Kharuzhy Date: Wed, 11 Feb 2026 02:18:37 +0200 Subject: [PATCH 5/7] ASoC: rt5677: Set up ACPI GPIO pins mapping table 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 Link: https://patch.msgid.link/20260211002255.4090440-6-jekhor@gmail.com Signed-off-by: Mark Brown --- 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 From 904e71d42505ca2af19b0031ffffefc8c1fefb48 Mon Sep 17 00:00:00 2001 From: Yauhen Kharuzhy Date: Wed, 11 Feb 2026 02:18:38 +0200 Subject: [PATCH 6/7] ASoC: rt5677: Reset the codec during probing To ensure that the codec is in a known state, reset it during driver initialization. Signed-off-by: Yauhen Kharuzhy Link: https://patch.msgid.link/20260211002255.4090440-7-jekhor@gmail.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index f56ac267f53b..60a93c3fe2e7 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -5581,14 +5581,21 @@ static int rt5677_i2c_probe(struct i2c_client *i2c) dev_err(&i2c->dev, "Failed to request POW_LDO2: %d\n", ret); return ret; } + rt5677->reset_pin = devm_gpiod_get_optional(&i2c->dev, - "realtek,reset", GPIOD_OUT_LOW); + "realtek,reset", GPIOD_OUT_HIGH); + if (IS_ERR(rt5677->reset_pin)) { ret = PTR_ERR(rt5677->reset_pin); dev_err(&i2c->dev, "Failed to request RESET: %d\n", ret); return ret; } + if (rt5677->reset_pin) { + msleep(1); + gpiod_set_value_cansleep(rt5677->reset_pin, 0); + } + if (rt5677->pow_ldo2 || rt5677->reset_pin) { /* Wait a while until I2C bus becomes available. The datasheet * does not specify the exact we should wait but startup From bf122191473e26a8f195308b1ba924c98424c8e1 Mon Sep 17 00:00:00 2001 From: Yauhen Kharuzhy Date: Wed, 11 Feb 2026 02:18:39 +0200 Subject: [PATCH 7/7] ASoC: rt5677-spi: Add SPI device ID matching table To allow defining a device in board-specific drivers, add 'rt5677' as a supported SPI device ID. Signed-off-by: Yauhen Kharuzhy Link: https://patch.msgid.link/20260211002255.4090440-8-jekhor@gmail.com Signed-off-by: Mark Brown --- sound/soc/codecs/rt5677-spi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/codecs/rt5677-spi.c b/sound/soc/codecs/rt5677-spi.c index 885edcf0a3a5..548180ec5762 100644 --- a/sound/soc/codecs/rt5677-spi.c +++ b/sound/soc/codecs/rt5677-spi.c @@ -624,12 +624,19 @@ static const struct acpi_device_id rt5677_spi_acpi_id[] = { MODULE_DEVICE_TABLE(acpi, rt5677_spi_acpi_id); #endif +static const struct spi_device_id rt5677_spi_ids[] = { + { "rt5677", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(spi, rt5677_spi_ids); + static struct spi_driver rt5677_spi_driver = { .driver = { .name = DRV_NAME, .acpi_match_table = ACPI_PTR(rt5677_spi_acpi_id), }, .probe = rt5677_spi_probe, + .id_table = rt5677_spi_ids, }; module_spi_driver(rt5677_spi_driver);