Skip to content

Commit 3b628e6

Browse files
linuswbroonie
authored andcommitted
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: Linus Walleij <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent e15cc90 commit 3b628e6

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

sound/soc/codecs/tas5086.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@
2424
#include <linux/module.h>
2525
#include <linux/slab.h>
2626
#include <linux/delay.h>
27-
#include <linux/gpio.h>
27+
#include <linux/gpio/consumer.h>
2828
#include <linux/i2c.h>
2929
#include <linux/regmap.h>
3030
#include <linux/regulator/consumer.h>
3131
#include <linux/spi/spi.h>
3232
#include <linux/of.h>
3333
#include <linux/of_device.h>
34-
#include <linux/of_gpio.h>
3534
#include <sound/pcm.h>
3635
#include <sound/pcm_params.h>
3736
#include <sound/soc.h>
@@ -246,7 +245,7 @@ struct tas5086_private {
246245
/* Current sample rate for de-emphasis control */
247246
int rate;
248247
/* GPIO driving Reset pin, if any */
249-
int gpio_nreset;
248+
struct gpio_desc *reset;
250249
struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)];
251250
};
252251

@@ -462,11 +461,11 @@ static int tas5086_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
462461

463462
static void tas5086_reset(struct tas5086_private *priv)
464463
{
465-
if (gpio_is_valid(priv->gpio_nreset)) {
464+
if (priv->reset) {
466465
/* Reset codec - minimum assertion time is 400ns */
467-
gpio_direction_output(priv->gpio_nreset, 0);
466+
gpiod_direction_output(priv->reset, 1);
468467
udelay(1);
469-
gpio_set_value(priv->gpio_nreset, 1);
468+
gpiod_set_value(priv->reset, 0);
470469

471470
/* Codec needs ~15ms to wake up */
472471
msleep(15);
@@ -867,9 +866,9 @@ static void tas5086_remove(struct snd_soc_component *component)
867866
{
868867
struct tas5086_private *priv = snd_soc_component_get_drvdata(component);
869868

870-
if (gpio_is_valid(priv->gpio_nreset))
869+
if (priv->reset)
871870
/* Set codec to the reset state */
872-
gpio_set_value(priv->gpio_nreset, 0);
871+
gpiod_set_value(priv->reset, 1);
873872

874873
regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
875874
};
@@ -914,7 +913,6 @@ static int tas5086_i2c_probe(struct i2c_client *i2c)
914913
{
915914
struct tas5086_private *priv;
916915
struct device *dev = &i2c->dev;
917-
int gpio_nreset = -EINVAL;
918916
int i, ret;
919917

920918
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -940,12 +938,11 @@ static int tas5086_i2c_probe(struct i2c_client *i2c)
940938

941939
i2c_set_clientdata(i2c, priv);
942940

943-
gpio_nreset = of_get_named_gpio(dev->of_node, "reset-gpio", 0);
944-
if (gpio_is_valid(gpio_nreset))
945-
if (devm_gpio_request(dev, gpio_nreset, "TAS5086 Reset"))
946-
gpio_nreset = -EINVAL;
947-
948-
priv->gpio_nreset = gpio_nreset;
941+
/* Request line asserted */
942+
priv->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
943+
if (IS_ERR(priv->reset))
944+
return PTR_ERR(priv->reset);
945+
gpiod_set_consumer_name(priv->reset, "TAS5086 Reset");
949946

950947
ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
951948
if (ret < 0) {

0 commit comments

Comments
 (0)