From: Linus Walleij <linus.walleij@linaro.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>,
Andy Shevchenko <andy@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
Takashi Iwai <tiwai@suse.com>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, alsa-devel@alsa-project.org,
Linus Walleij <linus.walleij@linaro.org>
Subject: [PATCH 2/8] ASoC: mediatek: mt2701-cs42448: Convert to GPIO descriptors
Date: Fri, 06 Oct 2023 15:46:25 +0200 [thread overview]
Message-ID: <20231006-descriptors-asoc-mediatek-v1-2-07fe79f337f5@linaro.org> (raw)
In-Reply-To: <20231006-descriptors-asoc-mediatek-v1-0-07fe79f337f5@linaro.org>
The driver is pretty straight-forward to convert to use GPIO
descriptors, however a separate patch is needed to accept
the DT GPIO resources ending with "-gpio1" and "-gpio2"
instead of the standard "-gpio" or "-gpios" name convention.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
sound/soc/mediatek/mt2701/mt2701-cs42448.c | 54 ++++++++++++------------------
1 file changed, 22 insertions(+), 32 deletions(-)
diff --git a/sound/soc/mediatek/mt2701/mt2701-cs42448.c b/sound/soc/mediatek/mt2701/mt2701-cs42448.c
index 08ef109744c7..81b695a19dc7 100644
--- a/sound/soc/mediatek/mt2701/mt2701-cs42448.c
+++ b/sound/soc/mediatek/mt2701/mt2701-cs42448.c
@@ -10,16 +10,15 @@
#include <linux/module.h>
#include <sound/soc.h>
#include <linux/delay.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/pinctrl/consumer.h>
-#include <linux/of_gpio.h>
#include "mt2701-afe-common.h"
struct mt2701_cs42448_private {
int i2s1_in_mux;
- int i2s1_in_mux_gpio_sel_1;
- int i2s1_in_mux_gpio_sel_2;
+ struct gpio_desc *i2s1_in_mux_sel_1;
+ struct gpio_desc *i2s1_in_mux_sel_2;
};
static const char * const i2sin_mux_switch_text[] = {
@@ -53,20 +52,20 @@ static int mt2701_cs42448_i2sin1_mux_set(struct snd_kcontrol *kcontrol,
switch (ucontrol->value.integer.value[0]) {
case 0:
- gpio_set_value(priv->i2s1_in_mux_gpio_sel_1, 0);
- gpio_set_value(priv->i2s1_in_mux_gpio_sel_2, 0);
+ gpiod_set_value(priv->i2s1_in_mux_sel_1, 0);
+ gpiod_set_value(priv->i2s1_in_mux_sel_2, 0);
break;
case 1:
- gpio_set_value(priv->i2s1_in_mux_gpio_sel_1, 1);
- gpio_set_value(priv->i2s1_in_mux_gpio_sel_2, 0);
+ gpiod_set_value(priv->i2s1_in_mux_sel_1, 1);
+ gpiod_set_value(priv->i2s1_in_mux_sel_2, 0);
break;
case 2:
- gpio_set_value(priv->i2s1_in_mux_gpio_sel_1, 0);
- gpio_set_value(priv->i2s1_in_mux_gpio_sel_2, 1);
+ gpiod_set_value(priv->i2s1_in_mux_sel_1, 0);
+ gpiod_set_value(priv->i2s1_in_mux_sel_2, 1);
break;
case 3:
- gpio_set_value(priv->i2s1_in_mux_gpio_sel_1, 1);
- gpio_set_value(priv->i2s1_in_mux_gpio_sel_2, 1);
+ gpiod_set_value(priv->i2s1_in_mux_sel_1, 1);
+ gpiod_set_value(priv->i2s1_in_mux_sel_2, 1);
break;
default:
dev_warn(card->dev, "%s invalid setting\n", __func__);
@@ -382,27 +381,18 @@ static int mt2701_cs42448_machine_probe(struct platform_device *pdev)
return ret;
}
- priv->i2s1_in_mux_gpio_sel_1 =
- of_get_named_gpio(dev->of_node, "i2s1-in-sel-gpio1", 0);
- if (gpio_is_valid(priv->i2s1_in_mux_gpio_sel_1)) {
- ret = devm_gpio_request(dev, priv->i2s1_in_mux_gpio_sel_1,
- "i2s1_in_mux_gpio_sel_1");
- if (ret)
- dev_warn(&pdev->dev, "%s devm_gpio_request fail %d\n",
- __func__, ret);
- gpio_direction_output(priv->i2s1_in_mux_gpio_sel_1, 0);
- }
+ priv->i2s1_in_mux_sel_1 = devm_gpiod_get_optional(dev, "i2s1-in-sel-gpio1",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(priv->i2s1_in_mux_sel_1))
+ return dev_err_probe(dev, PTR_ERR(priv->i2s1_in_mux_sel_1),
+ "error getting mux 1 selector\n");
+
+ priv->i2s1_in_mux_sel_2 = devm_gpiod_get_optional(dev, "i2s1-in-sel-gpio2",
+ GPIOD_OUT_LOW);
+ if (IS_ERR(priv->i2s1_in_mux_sel_2))
+ return dev_err_probe(dev, PTR_ERR(priv->i2s1_in_mux_sel_2),
+ "error getting mux 2 selector\n");
- priv->i2s1_in_mux_gpio_sel_2 =
- of_get_named_gpio(dev->of_node, "i2s1-in-sel-gpio2", 0);
- if (gpio_is_valid(priv->i2s1_in_mux_gpio_sel_2)) {
- ret = devm_gpio_request(dev, priv->i2s1_in_mux_gpio_sel_2,
- "i2s1_in_mux_gpio_sel_2");
- if (ret)
- dev_warn(&pdev->dev, "%s devm_gpio_request fail2 %d\n",
- __func__, ret);
- gpio_direction_output(priv->i2s1_in_mux_gpio_sel_2, 0);
- }
snd_soc_card_set_drvdata(card, priv);
ret = devm_snd_soc_register_card(&pdev->dev, card);
--
2.34.1
next prev parent reply other threads:[~2023-10-06 13:47 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-06 13:46 [PATCH 0/8] Convert Mediatek ASoC codecs to use GPIO descriptors Linus Walleij
2023-10-06 13:46 ` [PATCH 1/8] gpiolib: of: Add quirk for mt2701-cs42448 ASoC sound Linus Walleij
2023-10-09 7:09 ` Bartosz Golaszewski
2023-10-09 7:33 ` Linus Walleij
2023-10-09 12:57 ` Bartosz Golaszewski
2023-10-09 8:51 ` AngeloGioacchino Del Regno
2023-10-06 13:46 ` Linus Walleij [this message]
2023-10-09 7:12 ` [PATCH 2/8] ASoC: mediatek: mt2701-cs42448: Convert to GPIO descriptors Bartosz Golaszewski
2023-10-09 8:51 ` AngeloGioacchino Del Regno
2023-10-06 13:46 ` [PATCH 3/8] ASoC: mt8173-max98090: Drop unused include Linus Walleij
2023-10-09 8:51 ` AngeloGioacchino Del Regno
2023-10-06 13:46 ` [PATCH 4/8] ASoC: mt8173-rt5650-rt5514: Drop unused includes Linus Walleij
2023-10-09 8:51 ` AngeloGioacchino Del Regno
2023-10-06 13:46 ` [PATCH 5/8] ASoC: mt8173-rt5650-rt5676: " Linus Walleij
2023-10-09 8:51 ` AngeloGioacchino Del Regno
2023-10-06 13:46 ` [PATCH 6/8] ASoC: mt8173-rt5650: " Linus Walleij
2023-10-09 8:51 ` AngeloGioacchino Del Regno
2023-10-06 13:46 ` [PATCH 7/8] ASoC: mt8186-mt6366-rt1019-rt5682s: Drop unused include Linus Walleij
2023-10-09 8:51 ` AngeloGioacchino Del Regno
2023-10-06 13:46 ` [PATCH 8/8] ASoC: mt8192-afe-gpio: " Linus Walleij
2023-10-09 8:51 ` AngeloGioacchino Del Regno
2023-10-09 19:33 ` [PATCH 0/8] Convert Mediatek ASoC codecs to use GPIO descriptors 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=20231006-descriptors-asoc-mediatek-v1-2-07fe79f337f5@linaro.org \
--to=linus.walleij@linaro.org \
--cc=alsa-devel@alsa-project.org \
--cc=andy@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=brgl@bgdev.pl \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/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;
as well as URLs for NNTP newsgroup(s).