Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC rt5677: Prepare to support Lenovo Yoga Book tablets

Merge series from Yauhen Kharuzhy <jekhor@gmail.com>:

There are two Intel Cherry Trail-based devices using the RT5677 as a sound
codec: Lenovo Yoga Book YB1-X90 (Android tablet) and YB1-X91 (Windows
tablet).

They both have the same hardware configuration, but the X90 doesn't have
correct ACPI table definitions for many peripherals, whereas the X91 does.

Devices missing in the ACPI are defined in the board-specific driver
platform/x86/x86-android-tablets. In the X91 tablet, an ACPI _CRS method
for the RT5677 contains GPIO configuration entries which were not
supported by the codec driver before.

To support such device definitions, some modifications are added to the
RT5677 code: ACPI, SPI, and I2C matching ids have been introduced,
as well as some GPIO-related magic.

+44 -5
+7
sound/soc/codecs/rt5677-spi.c
··· 624 624 MODULE_DEVICE_TABLE(acpi, rt5677_spi_acpi_id); 625 625 #endif 626 626 627 + static const struct spi_device_id rt5677_spi_ids[] = { 628 + { "rt5677", 0 }, 629 + { }, 630 + }; 631 + MODULE_DEVICE_TABLE(spi, rt5677_spi_ids); 632 + 627 633 static struct spi_driver rt5677_spi_driver = { 628 634 .driver = { 629 635 .name = DRV_NAME, 630 636 .acpi_match_table = ACPI_PTR(rt5677_spi_acpi_id), 631 637 }, 632 638 .probe = rt5677_spi_probe, 639 + .id_table = rt5677_spi_ids, 633 640 }; 634 641 module_spi_driver(rt5677_spi_driver); 635 642
+36 -4
sound/soc/codecs/rt5677.c
··· 5204 5204 static const struct acpi_device_id rt5677_acpi_match[] = { 5205 5205 { "10EC5677", RT5677 }, 5206 5206 { "RT5677CE", RT5677 }, 5207 + { "10EC5677", RT5677 }, 5207 5208 { } 5208 5209 }; 5209 5210 MODULE_DEVICE_TABLE(acpi, rt5677_acpi_match); 5211 + 5212 + static const struct i2c_device_id rt5677_i2c_id[] = { 5213 + { "rt5677", RT5677 }, 5214 + { } 5215 + }; 5216 + MODULE_DEVICE_TABLE(i2c, rt5677_i2c_id); 5210 5217 5211 5218 static void rt5677_read_device_properties(struct rt5677_priv *rt5677, 5212 5219 struct device *dev) ··· 5536 5529 return ret; 5537 5530 } 5538 5531 5532 + static const struct acpi_gpio_params rt5677_acpi_reset_gpios = {0, 0, true}; 5533 + static const struct acpi_gpio_params rt5677_acpi_ldo2_gpios = {1, 0, false}; 5534 + 5535 + static const struct acpi_gpio_mapping rt5677_acpi_gpios[] = { 5536 + { "realtek,reset-gpios", &rt5677_acpi_reset_gpios, 1 }, 5537 + { "realtek,pow-ldo2-gpios", &rt5677_acpi_ldo2_gpios, 1 }, 5538 + {}, 5539 + }; 5540 + 5539 5541 static int rt5677_i2c_probe(struct i2c_client *i2c) 5540 5542 { 5541 - struct device *dev = &i2c->dev; 5542 5543 struct rt5677_priv *rt5677; 5543 5544 int ret; 5544 5545 unsigned int val; ··· 5561 5546 INIT_DELAYED_WORK(&rt5677->dsp_work, rt5677_dsp_work); 5562 5547 i2c_set_clientdata(i2c, rt5677); 5563 5548 5564 - rt5677->type = (enum rt5677_type)(uintptr_t)device_get_match_data(dev); 5549 + rt5677->type = (enum rt5677_type)(uintptr_t)i2c_get_match_data(i2c); 5565 5550 if (rt5677->type == 0) 5566 5551 return -EINVAL; 5552 + 5553 + if (devm_acpi_dev_add_driver_gpios(rt5677->dev, rt5677_acpi_gpios)) 5554 + dev_warn(rt5677->dev, "Unable to add GPIO mapping table\n"); 5567 5555 5568 5556 rt5677_read_device_properties(rt5677, &i2c->dev); 5569 5557 ··· 5581 5563 dev_err(&i2c->dev, "Failed to request POW_LDO2: %d\n", ret); 5582 5564 return ret; 5583 5565 } 5566 + 5584 5567 rt5677->reset_pin = devm_gpiod_get_optional(&i2c->dev, 5585 - "realtek,reset", GPIOD_OUT_LOW); 5568 + "realtek,reset", GPIOD_OUT_HIGH); 5569 + 5586 5570 if (IS_ERR(rt5677->reset_pin)) { 5587 5571 ret = PTR_ERR(rt5677->reset_pin); 5588 5572 dev_err(&i2c->dev, "Failed to request RESET: %d\n", ret); 5589 5573 return ret; 5574 + } 5575 + 5576 + if (rt5677->reset_pin) { 5577 + msleep(1); 5578 + gpiod_set_value_cansleep(rt5677->reset_pin, 0); 5590 5579 } 5591 5580 5592 5581 if (rt5677->pow_ldo2 || rt5677->reset_pin) { ··· 5621 5596 return ret; 5622 5597 } 5623 5598 5624 - regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val); 5599 + ret = regmap_read(rt5677->regmap, RT5677_VENDOR_ID2, &val); 5600 + if (ret) { 5601 + dev_err(&i2c->dev, 5602 + "Failed to read ID register: %d\n", ret); 5603 + return -ENODEV; 5604 + } 5605 + 5625 5606 if (val != RT5677_DEVICE_ID) { 5626 5607 dev_err(&i2c->dev, 5627 5608 "Device with ID register %#x is not rt5677\n", val); ··· 5696 5665 .of_match_table = rt5677_of_match, 5697 5666 .acpi_match_table = rt5677_acpi_match, 5698 5667 }, 5668 + .id_table = rt5677_i2c_id, 5699 5669 .probe = rt5677_i2c_probe, 5700 5670 .remove = rt5677_i2c_remove, 5701 5671 };
+1 -1
sound/soc/codecs/rt5677.h
··· 421 421 #define RT5677_DAC3_R_VOL_MASK (0xff) 422 422 #define RT5677_DAC3_R_VOL_SFT 0 423 423 424 - /* DAC3 Digital Volume (0x19) */ 424 + /* DAC1 Digital Volume (0x19) */ 425 425 #define RT5677_DAC1_L_VOL_MASK (0xff << 8) 426 426 #define RT5677_DAC1_L_VOL_SFT 8 427 427 #define RT5677_DAC1_R_VOL_MASK (0xff)