Skip to content

Commit

Permalink
ASoC: rt5668: Convert to use GPIO descriptors
Browse files Browse the repository at this point in the history
Convert the RT5668 to use GPIO descriptors and drop the
legacy GPIO headers.

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-3-02fa2ca3e5b0@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
linusw authored and broonie committed Aug 17, 2023
1 parent 647a3c4 commit ab2a5d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
3 changes: 0 additions & 3 deletions include/sound/rt5668.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ enum rt5668_jd_src {
};

struct rt5668_platform_data {

int ldo1_en; /* GPIO for LDO1_EN */

enum rt5668_dmic1_data_pin dmic1_data_pin;
enum rt5668_dmic1_clk_pin dmic1_clk_pin;
enum rt5668_jd_src jd_src;
Expand Down
17 changes: 8 additions & 9 deletions sound/soc/codecs/rt5668.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/acpi.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/regulator/consumer.h>
#include <linux/mutex.h>
#include <sound/core.h>
Expand All @@ -43,6 +42,7 @@ static const char *rt5668_supply_names[RT5668_NUM_SUPPLIES] = {
struct rt5668_priv {
struct snd_soc_component *component;
struct rt5668_platform_data pdata;
struct gpio_desc *ldo1_en;
struct regmap *regmap;
struct snd_soc_jack *hs_jack;
struct regulator_bulk_data supplies[RT5668_NUM_SUPPLIES];
Expand Down Expand Up @@ -2393,9 +2393,6 @@ static int rt5668_parse_dt(struct rt5668_priv *rt5668, struct device *dev)
of_property_read_u32(dev->of_node, "realtek,jd-src",
&rt5668->pdata.jd_src);

rt5668->pdata.ldo1_en = of_get_named_gpio(dev->of_node,
"realtek,ldo1-en-gpios", 0);

return 0;
}

Expand Down Expand Up @@ -2497,10 +2494,12 @@ static int rt5668_i2c_probe(struct i2c_client *i2c)
return ret;
}

if (gpio_is_valid(rt5668->pdata.ldo1_en)) {
if (devm_gpio_request_one(&i2c->dev, rt5668->pdata.ldo1_en,
GPIOF_OUT_INIT_HIGH, "rt5668"))
dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n");
rt5668->ldo1_en = devm_gpiod_get_optional(&i2c->dev,
"realtek,ldo1-en",
GPIOD_OUT_HIGH);
if (IS_ERR(rt5668->ldo1_en)) {
dev_err(&i2c->dev, "Fail gpio request ldo1_en\n");
return PTR_ERR(rt5668->ldo1_en);
}

/* Sleep for 300 ms miniumum */
Expand Down

0 comments on commit ab2a5d1

Please sign in to comment.