Commit 3b628e61 authored by Linus Walleij's avatar Linus Walleij Committed by Mark Brown

ASoC: tas5086: Convert to GPIO descriptors

Switch the driver to use GPIO descriptors.

Notice that we let the gpiolib handle line inversion for the
active low reset line (nreset !reset).

There are no upstream device trees using the tas5086 compatible
string, if there were, we would need to ascertain that they all
set the GPIO_ACTIVE_LOW flag on their GPIO lines.
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://patch.msgid.link/20240701-asoc-tas-gpios-v1-1-d69ec5d79939@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e15cc906
...@@ -24,14 +24,13 @@ ...@@ -24,14 +24,13 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_gpio.h>
#include <sound/pcm.h> #include <sound/pcm.h>
#include <sound/pcm_params.h> #include <sound/pcm_params.h>
#include <sound/soc.h> #include <sound/soc.h>
...@@ -246,7 +245,7 @@ struct tas5086_private { ...@@ -246,7 +245,7 @@ struct tas5086_private {
/* Current sample rate for de-emphasis control */ /* Current sample rate for de-emphasis control */
int rate; int rate;
/* GPIO driving Reset pin, if any */ /* GPIO driving Reset pin, if any */
int gpio_nreset; struct gpio_desc *reset;
struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)];
}; };
...@@ -462,11 +461,11 @@ static int tas5086_mute_stream(struct snd_soc_dai *dai, int mute, int stream) ...@@ -462,11 +461,11 @@ static int tas5086_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
static void tas5086_reset(struct tas5086_private *priv) static void tas5086_reset(struct tas5086_private *priv)
{ {
if (gpio_is_valid(priv->gpio_nreset)) { if (priv->reset) {
/* Reset codec - minimum assertion time is 400ns */ /* Reset codec - minimum assertion time is 400ns */
gpio_direction_output(priv->gpio_nreset, 0); gpiod_direction_output(priv->reset, 1);
udelay(1); udelay(1);
gpio_set_value(priv->gpio_nreset, 1); gpiod_set_value(priv->reset, 0);
/* Codec needs ~15ms to wake up */ /* Codec needs ~15ms to wake up */
msleep(15); msleep(15);
...@@ -867,9 +866,9 @@ static void tas5086_remove(struct snd_soc_component *component) ...@@ -867,9 +866,9 @@ static void tas5086_remove(struct snd_soc_component *component)
{ {
struct tas5086_private *priv = snd_soc_component_get_drvdata(component); struct tas5086_private *priv = snd_soc_component_get_drvdata(component);
if (gpio_is_valid(priv->gpio_nreset)) if (priv->reset)
/* Set codec to the reset state */ /* Set codec to the reset state */
gpio_set_value(priv->gpio_nreset, 0); gpiod_set_value(priv->reset, 1);
regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
}; };
...@@ -914,7 +913,6 @@ static int tas5086_i2c_probe(struct i2c_client *i2c) ...@@ -914,7 +913,6 @@ static int tas5086_i2c_probe(struct i2c_client *i2c)
{ {
struct tas5086_private *priv; struct tas5086_private *priv;
struct device *dev = &i2c->dev; struct device *dev = &i2c->dev;
int gpio_nreset = -EINVAL;
int i, ret; int i, ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
...@@ -940,12 +938,11 @@ static int tas5086_i2c_probe(struct i2c_client *i2c) ...@@ -940,12 +938,11 @@ static int tas5086_i2c_probe(struct i2c_client *i2c)
i2c_set_clientdata(i2c, priv); i2c_set_clientdata(i2c, priv);
gpio_nreset = of_get_named_gpio(dev->of_node, "reset-gpio", 0); /* Request line asserted */
if (gpio_is_valid(gpio_nreset)) priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
if (devm_gpio_request(dev, gpio_nreset, "TAS5086 Reset")) if (IS_ERR(priv->reset))
gpio_nreset = -EINVAL; return PTR_ERR(priv->reset);
gpiod_set_consumer_name(priv->reset, "TAS5086 Reset");
priv->gpio_nreset = gpio_nreset;
ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
if (ret < 0) { if (ret < 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment