[PATCH 0/8] Convert Mediatek ASoC codecs to use GPIO descriptors
Convert over the Mediatek codecs to use GPIO descriptors.
One few-liner affects gpiolib-of.h, I don't think there will be conflicts so I suggest that all of this can be merged through ASoC after review.
Signed-off-by: Linus Walleij linus.walleij@linaro.org --- Linus Walleij (8): gpiolib: of: Add quirk for mt2701-cs42448 ASoC sound ASoC: mediatek: mt2701-cs42448: Convert to GPIO descriptors ASoC: mt8173-max98090: Drop unused include ASoC: mt8173-rt5650-rt5514: Drop unused includes ASoC: mt8173-rt5650-rt5676: Drop unused includes ASoC: mt8173-rt5650: Drop unused includes ASoC: mt8186-mt6366-rt1019-rt5682s: Drop unused include ASoC: mt8192-afe-gpio: Drop unused include
drivers/gpio/gpiolib-of.c | 4 ++ sound/soc/mediatek/mt2701/mt2701-cs42448.c | 54 +++++++++------------- sound/soc/mediatek/mt8173/mt8173-max98090.c | 1 - sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c | 2 - sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c | 2 - sound/soc/mediatek/mt8173/mt8173-rt5650.c | 2 - sound/soc/mediatek/mt8186/mt8186-afe-gpio.c | 1 - .../mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c | 1 - sound/soc/mediatek/mt8192/mt8192-afe-gpio.c | 1 - 9 files changed, 26 insertions(+), 42 deletions(-) --- base-commit: 0bb80ecc33a8fb5a682236443c1e740d5c917d1d change-id: 20231006-descriptors-asoc-mediatek-01c3ff4005db
Best regards,
These gpio names are due to old DT bindings not following the "-gpio"/"-gpios" conventions. Handle it using a quirk so the driver can just look up the GPIOs.
Signed-off-by: Linus Walleij linus.walleij@linaro.org --- drivers/gpio/gpiolib-of.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 531faabead0f..d9525d95e818 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -512,6 +512,10 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, #if IS_ENABLED(CONFIG_SND_SOC_CS42L56) { "reset", "cirrus,gpio-nreset", "cirrus,cs42l56" }, #endif +#if IS_ENABLED(CONFIG_SND_SOC_MT2701_CS42448) + { "i2s1-in-sel-gpio1", NULL, "mediatek,mt2701-cs42448-machine" }, + { "i2s1-in-sel-gpio2", NULL, "mediatek,mt2701-cs42448-machine" }, +#endif #if IS_ENABLED(CONFIG_SND_SOC_TLV320AIC3X) { "reset", "gpio-reset", "ti,tlv320aic3x" }, { "reset", "gpio-reset", "ti,tlv320aic33" },
On Fri, Oct 6, 2023 at 3:46 PM Linus Walleij linus.walleij@linaro.org wrote:
These gpio names are due to old DT bindings not following the "-gpio"/"-gpios" conventions. Handle it using a quirk so the driver can just look up the GPIOs.
Signed-off-by: Linus Walleij linus.walleij@linaro.org
drivers/gpio/gpiolib-of.c | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 531faabead0f..d9525d95e818 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -512,6 +512,10 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np, #if IS_ENABLED(CONFIG_SND_SOC_CS42L56) { "reset", "cirrus,gpio-nreset", "cirrus,cs42l56" }, #endif +#if IS_ENABLED(CONFIG_SND_SOC_MT2701_CS42448)
{ "i2s1-in-sel-gpio1", NULL, "mediatek,mt2701-cs42448-machine" },
{ "i2s1-in-sel-gpio2", NULL, "mediatek,mt2701-cs42448-machine" },
+#endif #if IS_ENABLED(CONFIG_SND_SOC_TLV320AIC3X) { "reset", "gpio-reset", "ti,tlv320aic3x" }, { "reset", "gpio-reset", "ti,tlv320aic33" },
-- 2.34.1
I suppose this is a run-time dependency only for the other patches? Can I just pick it up into my tree?
Bart
On Mon, Oct 9, 2023 at 9:09 AM Bartosz Golaszewski brgl@bgdev.pl wrote:
+#if IS_ENABLED(CONFIG_SND_SOC_MT2701_CS42448)
{ "i2s1-in-sel-gpio1", NULL, "mediatek,mt2701-cs42448-machine" },
{ "i2s1-in-sel-gpio2", NULL, "mediatek,mt2701-cs42448-machine" },
+#endif
I suppose this is a run-time dependency only for the other patches? Can I just pick it up into my tree?
You can, I was just thinking about bisectability and the low risk of collisions with other patches. (Actually no-one gets hurt if it's applied to both trees either, which IMO is perfectly fine in cases like this.)
Yours, Linus Walleij
On Mon, Oct 9, 2023 at 9:33 AM Linus Walleij linus.walleij@linaro.org wrote:
On Mon, Oct 9, 2023 at 9:09 AM Bartosz Golaszewski brgl@bgdev.pl wrote:
+#if IS_ENABLED(CONFIG_SND_SOC_MT2701_CS42448)
{ "i2s1-in-sel-gpio1", NULL, "mediatek,mt2701-cs42448-machine" },
{ "i2s1-in-sel-gpio2", NULL, "mediatek,mt2701-cs42448-machine" },
+#endif
I suppose this is a run-time dependency only for the other patches? Can I just pick it up into my tree?
You can, I was just thinking about bisectability and the low risk of collisions with other patches. (Actually no-one gets hurt if it's applied to both trees either, which IMO is perfectly fine in cases like this.)
Nah, Stephen Rothwell will auto-yell at you for that. I'm fine either way.
Acked-by: Bartosz Golaszewski bartosz.golaszewski@linaro.org
If we get any conflicts in next, then we'll deal with it with immutable tags.
Bart
Il 06/10/23 15:46, Linus Walleij ha scritto:
These gpio names are due to old DT bindings not following the "-gpio"/"-gpios" conventions. Handle it using a quirk so the driver can just look up the GPIOs.
Signed-off-by: Linus Walleij linus.walleij@linaro.org
Reviewed-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com
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);
On Fri, Oct 6, 2023 at 3:46 PM Linus Walleij linus.walleij@linaro.org wrote:
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
Reviewed-by: Bartosz Golaszewski bartosz.golaszewski@linaro.org
Il 06/10/23 15:46, Linus Walleij ha scritto:
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
Reviewed-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com
This driver includes the legacy GPIO header <linux/gpio.h> but is not using any symbols from it. Drop the include.
Signed-off-by: Linus Walleij linus.walleij@linaro.org --- sound/soc/mediatek/mt8173/mt8173-max98090.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/sound/soc/mediatek/mt8173/mt8173-max98090.c b/sound/soc/mediatek/mt8173/mt8173-max98090.c index bfb2094758ff..0200da192116 100644 --- a/sound/soc/mediatek/mt8173/mt8173-max98090.c +++ b/sound/soc/mediatek/mt8173/mt8173-max98090.c @@ -9,7 +9,6 @@ #include <linux/module.h> #include <sound/soc.h> #include <sound/jack.h> -#include <linux/gpio.h> #include "../../codecs/max98090.h"
static struct snd_soc_jack mt8173_max98090_jack;
Il 06/10/23 15:46, Linus Walleij ha scritto:
This driver includes the legacy GPIO header <linux/gpio.h> but is not using any symbols from it. Drop the include.
Signed-off-by: Linus Walleij linus.walleij@linaro.org
Reviewed-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com Tested-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com
This driver includes the legacy GPIO header <linux/gpio.h> and <linux/of_gpio.h> but does not use any symbols from either of them so drop the includes.
Signed-off-by: Linus Walleij linus.walleij@linaro.org --- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c index e502cd1670ba..0204b461e291 100644 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c @@ -7,8 +7,6 @@ */
#include <linux/module.h> -#include <linux/gpio.h> -#include <linux/of_gpio.h> #include <sound/soc.h> #include <sound/jack.h> #include "../../codecs/rt5645.h"
Il 06/10/23 15:46, Linus Walleij ha scritto:
This driver includes the legacy GPIO header <linux/gpio.h> and <linux/of_gpio.h> but does not use any symbols from either of them so drop the includes.
Signed-off-by: Linus Walleij linus.walleij@linaro.org
Reviewed-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com
This driver includes the legacy GPIO header <linux/gpio.h> and <linux/of_gpio.h> but does not use any symbols from either of them so drop the includes.
Signed-off-by: Linus Walleij linus.walleij@linaro.org --- sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c index ffb094284bfb..351b586e01b0 100644 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c @@ -7,8 +7,6 @@ */
#include <linux/module.h> -#include <linux/gpio.h> -#include <linux/of_gpio.h> #include <sound/soc.h> #include <sound/jack.h> #include "../../codecs/rt5645.h"
Il 06/10/23 15:46, Linus Walleij ha scritto:
This driver includes the legacy GPIO header <linux/gpio.h> and <linux/of_gpio.h> but does not use any symbols from either of them so drop the includes.
Signed-off-by: Linus Walleij linus.walleij@linaro.org
Reviewed-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com
This driver includes the legacy GPIO header <linux/gpio.h> and <linux/of_gpio.h> but does not use any symbols from either of them so drop the includes.
Signed-off-by: Linus Walleij linus.walleij@linaro.org --- sound/soc/mediatek/mt8173/mt8173-rt5650.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650.c b/sound/soc/mediatek/mt8173/mt8173-rt5650.c index 18cf84bb25c7..bcec1d9d790b 100644 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650.c +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650.c @@ -7,8 +7,6 @@ */
#include <linux/module.h> -#include <linux/gpio.h> -#include <linux/of_gpio.h> #include <sound/soc.h> #include <sound/jack.h> #include "../../codecs/rt5645.h"
Il 06/10/23 15:46, Linus Walleij ha scritto:
This driver includes the legacy GPIO header <linux/gpio.h> and <linux/of_gpio.h> but does not use any symbols from either of them so drop the includes.
Signed-off-by: Linus Walleij linus.walleij@linaro.org
Reviewed-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com Tested-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com
This driver includes the legacy GPIO header <linux/gpio.h> but is not using any symbols from it. AFE has a custom GPIO implementation that is not using the kernel GPIO framework, so it need not include it either.
Signed-off-by: Linus Walleij linus.walleij@linaro.org --- sound/soc/mediatek/mt8186/mt8186-afe-gpio.c | 1 - sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c | 1 - 2 files changed, 2 deletions(-)
diff --git a/sound/soc/mediatek/mt8186/mt8186-afe-gpio.c b/sound/soc/mediatek/mt8186/mt8186-afe-gpio.c index f12e91cc4fcf..9e86e7079718 100644 --- a/sound/soc/mediatek/mt8186/mt8186-afe-gpio.c +++ b/sound/soc/mediatek/mt8186/mt8186-afe-gpio.c @@ -5,7 +5,6 @@ // Copyright (c) 2022 MediaTek Inc. // Author: Jiaxin Yu jiaxin.yu@mediatek.com
-#include <linux/gpio.h> #include <linux/pinctrl/consumer.h>
#include "mt8186-afe-common.h" diff --git a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c index 9c11016f032c..87ec39a5e1f4 100644 --- a/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c +++ b/sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c @@ -7,7 +7,6 @@ // Author: Jiaxin Yu jiaxin.yu@mediatek.com //
-#include <linux/gpio.h> #include <linux/gpio/consumer.h> #include <linux/input.h> #include <linux/module.h>
Il 06/10/23 15:46, Linus Walleij ha scritto:
This driver includes the legacy GPIO header <linux/gpio.h> but is not using any symbols from it. AFE has a custom GPIO implementation that is not using the kernel GPIO framework, so it need not include it either.
Signed-off-by: Linus Walleij linus.walleij@linaro.org
Reviewed-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com Tested-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com
This driver includes the legacy GPIO header <linux/gpio.h> but is not using any symbols from it. AFE has a custom GPIO implementation that is not using the kernel GPIO framework.
Signed-off-by: Linus Walleij linus.walleij@linaro.org --- sound/soc/mediatek/mt8192/mt8192-afe-gpio.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/sound/soc/mediatek/mt8192/mt8192-afe-gpio.c b/sound/soc/mediatek/mt8192/mt8192-afe-gpio.c index 165663a78e36..de5e1deaa167 100644 --- a/sound/soc/mediatek/mt8192/mt8192-afe-gpio.c +++ b/sound/soc/mediatek/mt8192/mt8192-afe-gpio.c @@ -6,7 +6,6 @@ // Author: Shane Chien shane.chien@mediatek.com //
-#include <linux/gpio.h> #include <linux/pinctrl/consumer.h>
#include "mt8192-afe-common.h"
Il 06/10/23 15:46, Linus Walleij ha scritto:
This driver includes the legacy GPIO header <linux/gpio.h> but is not using any symbols from it. AFE has a custom GPIO implementation that is not using the kernel GPIO framework.
Signed-off-by: Linus Walleij linus.walleij@linaro.org
Reviewed-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com Tested-by: AngeloGioacchino Del Regno angelogioacchino.delregno@collabora.com
On Fri, 06 Oct 2023 15:46:23 +0200, Linus Walleij wrote:
Convert over the Mediatek codecs to use GPIO descriptors.
One few-liner affects gpiolib-of.h, I don't think there will be conflicts so I suggest that all of this can be merged through ASoC after review.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/8] gpiolib: of: Add quirk for mt2701-cs42448 ASoC sound commit: 9e189e80dcb68528dea9e061d9704993f98cb84f [2/8] ASoC: mediatek: mt2701-cs42448: Convert to GPIO descriptors commit: 654a23724072f37c0d07b31395e1d9f45f5563ab [3/8] ASoC: mt8173-max98090: Drop unused include commit: b1306c3b6140f0c299f727edc9bb90ec79700614 [4/8] ASoC: mt8173-rt5650-rt5514: Drop unused includes commit: 94a7f618211652235f3e4b88aca477391078dba6 [5/8] ASoC: mt8173-rt5650-rt5676: Drop unused includes commit: cb1c18e8a7337c7f3ee461b613a52a45c3f723d5 [6/8] ASoC: mt8173-rt5650: Drop unused includes commit: 6dffd1f38ad76660e7fff8e269889284e892603d [7/8] ASoC: mt8186-mt6366-rt1019-rt5682s: Drop unused include commit: 73e1f8a05bd8289ab5154c703a0592729267e979 [8/8] ASoC: mt8192-afe-gpio: Drop unused include commit: 3b5d22bdf33c4e44016fdcfc8904a0b0bf218e75
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
participants (4)
-
AngeloGioacchino Del Regno
-
Bartosz Golaszewski
-
Linus Walleij
-
Mark Brown