Skip to content

Commit 647a3c4

Browse files
Linus Walleijbroonie
authored andcommitted
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>
1 parent a9b5f21 commit 647a3c4

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

include/sound/rt5665.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ struct rt5665_platform_data {
3131
bool in3_diff;
3232
bool in4_diff;
3333

34-
int ldo1_en; /* GPIO for LDO1_EN */
35-
3634
enum rt5665_dmic1_data_pin dmic1_data_pin;
3735
enum rt5665_dmic2_data_pin dmic2_data_pin;
3836
enum rt5665_jd_src jd_src;

sound/soc/codecs/rt5665.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
#include <linux/platform_device.h>
1616
#include <linux/spi/spi.h>
1717
#include <linux/acpi.h>
18-
#include <linux/gpio.h>
19-
#include <linux/of_gpio.h>
18+
#include <linux/gpio/consumer.h>
2019
#include <linux/regulator/consumer.h>
2120
#include <linux/mutex.h>
2221
#include <sound/core.h>
@@ -4659,9 +4658,6 @@ static int rt5665_parse_dt(struct rt5665_priv *rt5665, struct device *dev)
46594658
of_property_read_u32(dev->of_node, "realtek,jd-src",
46604659
&rt5665->pdata.jd_src);
46614660

4662-
rt5665->pdata.ldo1_en = of_get_named_gpio(dev->of_node,
4663-
"realtek,ldo1-en-gpios", 0);
4664-
46654661
return 0;
46664662
}
46674663

@@ -4795,10 +4791,13 @@ static int rt5665_i2c_probe(struct i2c_client *i2c)
47954791
return ret;
47964792
}
47974793

4798-
if (gpio_is_valid(rt5665->pdata.ldo1_en)) {
4799-
if (devm_gpio_request_one(&i2c->dev, rt5665->pdata.ldo1_en,
4800-
GPIOF_OUT_INIT_HIGH, "rt5665"))
4801-
dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n");
4794+
4795+
rt5665->gpiod_ldo1_en = devm_gpiod_get_optional(&i2c->dev,
4796+
"realtek,ldo1-en",
4797+
GPIOD_OUT_HIGH);
4798+
if (IS_ERR(rt5665->gpiod_ldo1_en)) {
4799+
dev_err(&i2c->dev, "Failed gpio request ldo1_en\n");
4800+
return PTR_ERR(rt5665->gpiod_ldo1_en);
48024801
}
48034802

48044803
/* Sleep for 300 ms miniumum */

0 commit comments

Comments
 (0)