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

ASoC: rt5665: Convert to use GPIO descriptors

The RT5665 driver has some stub support for GPIO descriptors
going back to the initial driver commit, where there are
two GPIO descriptors for the LDO and headphone detection
defined in the device state. Well, let's make use of the
descriptor properly.

We remove the global GPIO number from the platform data,
but it is still possible to create board files using GPIO
descriptor tables, if desired.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230817-descriptors-asoc-rt-v2-2-02fa2ca3e5b0@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Linus Walleij and committed by
Mark Brown
647a3c4c a9b5f210

+8 -11
-2
include/sound/rt5665.h
··· 31 31 bool in3_diff; 32 32 bool in4_diff; 33 33 34 - int ldo1_en; /* GPIO for LDO1_EN */ 35 - 36 34 enum rt5665_dmic1_data_pin dmic1_data_pin; 37 35 enum rt5665_dmic2_data_pin dmic2_data_pin; 38 36 enum rt5665_jd_src jd_src;
+8 -9
sound/soc/codecs/rt5665.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/spi/spi.h> 17 17 #include <linux/acpi.h> 18 - #include <linux/gpio.h> 19 - #include <linux/of_gpio.h> 18 + #include <linux/gpio/consumer.h> 20 19 #include <linux/regulator/consumer.h> 21 20 #include <linux/mutex.h> 22 21 #include <sound/core.h> ··· 4658 4659 of_property_read_u32(dev->of_node, "realtek,jd-src", 4659 4660 &rt5665->pdata.jd_src); 4660 4661 4661 - rt5665->pdata.ldo1_en = of_get_named_gpio(dev->of_node, 4662 - "realtek,ldo1-en-gpios", 0); 4663 - 4664 4662 return 0; 4665 4663 } 4666 4664 ··· 4791 4795 return ret; 4792 4796 } 4793 4797 4794 - if (gpio_is_valid(rt5665->pdata.ldo1_en)) { 4795 - if (devm_gpio_request_one(&i2c->dev, rt5665->pdata.ldo1_en, 4796 - GPIOF_OUT_INIT_HIGH, "rt5665")) 4797 - dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n"); 4798 + 4799 + rt5665->gpiod_ldo1_en = devm_gpiod_get_optional(&i2c->dev, 4800 + "realtek,ldo1-en", 4801 + GPIOD_OUT_HIGH); 4802 + if (IS_ERR(rt5665->gpiod_ldo1_en)) { 4803 + dev_err(&i2c->dev, "Failed gpio request ldo1_en\n"); 4804 + return PTR_ERR(rt5665->gpiod_ldo1_en); 4798 4805 } 4799 4806 4800 4807 /* Sleep for 300 ms miniumum */