From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Mark Brown <broonie@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>
Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org
Subject: [PATCH 03/11] ASoC: tas5086: switch to using gpiod API
Date: Tue, 15 Nov 2022 21:38:09 -0800 [thread overview]
Message-ID: <20221116053817.2929810-3-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20221116053817.2929810-1-dmitry.torokhov@gmail.com>
Switch the driver from legacy gpio API that is deprecated to the newer
gpiod API that respects line polarities described in ACPI/DT.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
sound/soc/codecs/tas5086.c | 32 ++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)
diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c
index 22143cc5afa7..66b22b800e01 100644
--- a/sound/soc/codecs/tas5086.c
+++ b/sound/soc/codecs/tas5086.c
@@ -24,14 +24,14 @@
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/err.h>
+#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/spi/spi.h>
#include <linux/of.h>
#include <linux/of_device.h>
-#include <linux/of_gpio.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
@@ -246,7 +246,7 @@ struct tas5086_private {
/* Current sample rate for de-emphasis control */
int rate;
/* GPIO driving Reset pin, if any */
- int gpio_nreset;
+ struct gpio_desc *reset_gpio;
struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)];
};
@@ -462,11 +462,11 @@ static int tas5086_mute_stream(struct snd_soc_dai *dai, int mute, int stream)
static void tas5086_reset(struct tas5086_private *priv)
{
- if (gpio_is_valid(priv->gpio_nreset)) {
+ if (priv->reset_gpio) {
/* Reset codec - minimum assertion time is 400ns */
- gpio_direction_output(priv->gpio_nreset, 0);
+ gpiod_set_value_cansleep(priv->reset_gpio, 1);
udelay(1);
- gpio_set_value(priv->gpio_nreset, 1);
+ gpiod_set_value_cansleep(priv->reset_gpio, 0);
/* Codec needs ~15ms to wake up */
msleep(15);
@@ -867,9 +867,10 @@ static void tas5086_remove(struct snd_soc_component *component)
{
struct tas5086_private *priv = snd_soc_component_get_drvdata(component);
- if (gpio_is_valid(priv->gpio_nreset))
+ if (priv->reset_gpio) {
/* Set codec to the reset state */
- gpio_set_value(priv->gpio_nreset, 0);
+ gpiod_set_value_cansleep(priv->reset_gpio, 1);
+ }
regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies);
};
@@ -914,7 +915,6 @@ static int tas5086_i2c_probe(struct i2c_client *i2c)
{
struct tas5086_private *priv;
struct device *dev = &i2c->dev;
- int gpio_nreset = -EINVAL;
int i, ret;
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -940,16 +940,12 @@ static int tas5086_i2c_probe(struct i2c_client *i2c)
i2c_set_clientdata(i2c, priv);
- if (of_match_device(of_match_ptr(tas5086_dt_ids), dev)) {
- struct device_node *of_node = dev->of_node;
- gpio_nreset = of_get_named_gpio(of_node, "reset-gpio", 0);
- }
-
- if (gpio_is_valid(gpio_nreset))
- if (devm_gpio_request(dev, gpio_nreset, "TAS5086 Reset"))
- gpio_nreset = -EINVAL;
+ priv->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
+ ret = PTR_ERR_OR_ZERO(priv->reset_gpio);
+ if (ret)
+ return ret;
- priv->gpio_nreset = gpio_nreset;
+ gpiod_set_consumer_name(priv->reset_gpio, "TAS5086 Reset");
ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies);
if (ret < 0) {
--
2.38.1.431.g37b22c650d-goog
next prev parent reply other threads:[~2022-11-16 5:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-16 5:38 [PATCH 01/11] ASoC: ak5386: " Dmitry Torokhov
2022-11-16 5:38 ` [PATCH 02/11] ASoC: max98373: " Dmitry Torokhov
2022-11-16 5:38 ` Dmitry Torokhov [this message]
2022-11-16 5:38 ` [PATCH 04/11] ASoC: tpa6130a2: remove support for platform data Dmitry Torokhov
2022-11-16 5:38 ` [PATCH 05/11] ASoC: tpa6130a2: switch to using gpiod API Dmitry Torokhov
2022-11-16 5:38 ` [PATCH 06/11] ASoC: tlv320aic32x4: remove support for platform data Dmitry Torokhov
2022-11-16 5:38 ` [PATCH 07/11] ASoC: tlv320aic32x4: switch to using gpiod API Dmitry Torokhov
2022-11-16 5:38 ` [PATCH 08/11] ASoC: dt-bindings: wcd9335: fix reset line polarity in example Dmitry Torokhov
2022-11-16 5:38 ` [PATCH 09/11] ASoC: wcd9335: switch to using gpiod API Dmitry Torokhov
2022-11-16 5:38 ` [PATCH 10/11] ASoC: dt-bindings: wcd938x: fix codec reset line polarity in example Dmitry Torokhov
2022-11-16 5:38 ` [PATCH 11/11] ASoC: wcd938x: switch to using gpiod API Dmitry Torokhov
2023-03-08 18:11 ` Krzysztof Kozlowski
2022-11-16 10:36 ` [PATCH 01/11] ASoC: ak5386: " Mark Brown
2022-11-16 19:07 ` Dmitry Torokhov
2022-11-17 11:34 ` Mark Brown
2022-11-18 6:31 ` Dmitry Torokhov
2022-11-18 13:12 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221116053817.2929810-3-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®