mirror of
https://github.com/torvalds/linux.git
synced 2024-11-21 19:46:16 +00:00
ASoC: rt5682: Convert to use GPIO descriptors
Convert the RT5682 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. Make sure to make sure SDW devices can associate with an LDO1 EN descriptor too, if they so desire by putting the lookup into the common code. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20230817-descriptors-asoc-rt-v2-4-02fa2ca3e5b0@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
ab2a5d1706
commit
ed11701751
@ -31,9 +31,6 @@ enum rt5682_dai_clks {
|
||||
};
|
||||
|
||||
struct rt5682_platform_data {
|
||||
|
||||
int ldo1_en; /* GPIO for LDO1_EN */
|
||||
|
||||
enum rt5682_dmic1_data_pin dmic1_data_pin;
|
||||
enum rt5682_dmic1_clk_pin dmic1_clk_pin;
|
||||
enum rt5682_jd_src jd_src;
|
||||
|
@ -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/mutex.h>
|
||||
#include <sound/core.h>
|
||||
#include <sound/pcm.h>
|
||||
@ -170,11 +169,9 @@ static int rt5682_i2c_probe(struct i2c_client *i2c)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (gpio_is_valid(rt5682->pdata.ldo1_en)) {
|
||||
if (devm_gpio_request_one(&i2c->dev, rt5682->pdata.ldo1_en,
|
||||
GPIOF_OUT_INIT_HIGH, "rt5682"))
|
||||
dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n");
|
||||
}
|
||||
ret = rt5682_get_ldo1(rt5682, &i2c->dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
/* Sleep for 300 ms miniumum */
|
||||
usleep_range(300000, 350000);
|
||||
|
@ -320,6 +320,11 @@ static int rt5682_sdw_init(struct device *dev, struct regmap *regmap,
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
ret = rt5682_get_ldo1(rt5682, dev);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
regcache_cache_only(rt5682->sdw_regmap, true);
|
||||
regcache_cache_only(rt5682->regmap, true);
|
||||
|
||||
|
@ -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/mutex.h>
|
||||
#include <sound/core.h>
|
||||
#include <sound/pcm.h>
|
||||
@ -3094,9 +3093,6 @@ int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev)
|
||||
device_property_read_u32(dev, "realtek,dmic-delay-ms",
|
||||
&rt5682->pdata.dmic_delay);
|
||||
|
||||
rt5682->pdata.ldo1_en = of_get_named_gpio(dev->of_node,
|
||||
"realtek,ldo1-en-gpios", 0);
|
||||
|
||||
if (device_property_read_string_array(dev, "clock-output-names",
|
||||
rt5682->pdata.dai_clk_names,
|
||||
RT5682_DAI_NUM_CLKS) < 0)
|
||||
@ -3111,6 +3107,20 @@ int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rt5682_parse_dt);
|
||||
|
||||
int rt5682_get_ldo1(struct rt5682_priv *rt5682, struct device *dev)
|
||||
{
|
||||
rt5682->ldo1_en = devm_gpiod_get_optional(dev,
|
||||
"realtek,ldo1-en",
|
||||
GPIOD_OUT_HIGH);
|
||||
if (IS_ERR(rt5682->ldo1_en)) {
|
||||
dev_err(dev, "Fail gpio request ldo1_en\n");
|
||||
return PTR_ERR(rt5682->ldo1_en);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rt5682_get_ldo1);
|
||||
|
||||
void rt5682_calibrate(struct rt5682_priv *rt5682)
|
||||
{
|
||||
int value, count;
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include <sound/rt5682.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/clkdev.h>
|
||||
#include <linux/clk-provider.h>
|
||||
@ -1430,6 +1431,7 @@ struct rt5682_priv {
|
||||
struct snd_soc_component *component;
|
||||
struct device *i2c_dev;
|
||||
struct rt5682_platform_data pdata;
|
||||
struct gpio_desc *ldo1_en;
|
||||
struct regmap *regmap;
|
||||
struct regmap *sdw_regmap;
|
||||
struct snd_soc_jack *hs_jack;
|
||||
@ -1481,6 +1483,7 @@ int rt5682_register_component(struct device *dev);
|
||||
void rt5682_calibrate(struct rt5682_priv *rt5682);
|
||||
void rt5682_reset(struct rt5682_priv *rt5682);
|
||||
int rt5682_parse_dt(struct rt5682_priv *rt5682, struct device *dev);
|
||||
int rt5682_get_ldo1(struct rt5682_priv *rt5682, struct device *dev);
|
||||
|
||||
int rt5682_register_dai_clks(struct rt5682_priv *rt5682);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user