From 15b26d8165b39a07f038fb4d2b67a04c50463eb9 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 29 Sep 2023 00:12:54 +0200 Subject: [PATCH 1/4] ASoC: rockchip: Convert RK3288 HDMI to GPIO descriptors This converts the Rockchip RK3288 HDMI driver to use GPIO descriptors: - Look up the HP EN GPIO as an optional descriptor and handle it directly, the gpiod API is NULL-tolerant so no special guards are needed. - Let the Jack detection core obtain and handle the HP detection GPIO, just pass the right name and gpiod_dev and it will do the job. Make sure to check that the GPIO property is there first, so it becomes optional. Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20230929-descriptors-asoc-rockchip-v2-1-2d2c0e043aab@linaro.org Signed-off-by: Mark Brown --- sound/soc/rockchip/rk3288_hdmi_analog.c | 46 ++++++++----------------- 1 file changed, 14 insertions(+), 32 deletions(-) diff --git a/sound/soc/rockchip/rk3288_hdmi_analog.c b/sound/soc/rockchip/rk3288_hdmi_analog.c index 5ff499c81d3f..a65d923d94dc 100644 --- a/sound/soc/rockchip/rk3288_hdmi_analog.c +++ b/sound/soc/rockchip/rk3288_hdmi_analog.c @@ -12,8 +12,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -26,8 +25,7 @@ #define DRV_NAME "rk3288-snd-hdmi-analog" struct rk_drvdata { - int gpio_hp_en; - int gpio_hp_det; + struct gpio_desc *gpio_hp_en; }; static int rk_hp_power(struct snd_soc_dapm_widget *w, @@ -35,11 +33,8 @@ static int rk_hp_power(struct snd_soc_dapm_widget *w, { struct rk_drvdata *machine = snd_soc_card_get_drvdata(w->dapm->card); - if (!gpio_is_valid(machine->gpio_hp_en)) - return 0; - - gpio_set_value_cansleep(machine->gpio_hp_en, - SND_SOC_DAPM_EVENT_ON(event)); + gpiod_set_value_cansleep(machine->gpio_hp_en, + SND_SOC_DAPM_EVENT_ON(event)); return 0; } @@ -113,22 +108,23 @@ static int rk_hw_params(struct snd_pcm_substream *substream, } static struct snd_soc_jack_gpio rk_hp_jack_gpio = { - .name = "Headphone detection", + .name = "rockchip,hp-det", .report = SND_JACK_HEADPHONE, .debounce_time = 150 }; static int rk_init(struct snd_soc_pcm_runtime *runtime) { - struct rk_drvdata *machine = snd_soc_card_get_drvdata(runtime->card); + struct snd_soc_card *card = runtime->card; + struct device *dev = card->dev; - /* Enable Headset Jack detection */ - if (gpio_is_valid(machine->gpio_hp_det)) { + /* Enable optional Headset Jack detection */ + if (of_property_present(dev->of_node, "rockchip,hp-det-gpios")) { + rk_hp_jack_gpio.gpiod_dev = dev; snd_soc_card_jack_new_pins(runtime->card, "Headphone Jack", SND_JACK_HEADPHONE, &headphone_jack, headphone_jack_pins, ARRAY_SIZE(headphone_jack_pins)); - rk_hp_jack_gpio.gpio = machine->gpio_hp_det; snd_soc_jack_add_gpios(&headphone_jack, 1, &rk_hp_jack_gpio); } @@ -182,24 +178,10 @@ static int snd_rk_mc_probe(struct platform_device *pdev) card->dev = &pdev->dev; - machine->gpio_hp_det = of_get_named_gpio(np, - "rockchip,hp-det-gpios", 0); - if (!gpio_is_valid(machine->gpio_hp_det) && machine->gpio_hp_det != -ENODEV) - return machine->gpio_hp_det; - - machine->gpio_hp_en = of_get_named_gpio(np, - "rockchip,hp-en-gpios", 0); - if (!gpio_is_valid(machine->gpio_hp_en) && machine->gpio_hp_en != -ENODEV) - return machine->gpio_hp_en; - - if (gpio_is_valid(machine->gpio_hp_en)) { - ret = devm_gpio_request_one(&pdev->dev, machine->gpio_hp_en, - GPIOF_OUT_INIT_LOW, "hp_en"); - if (ret) { - dev_err(card->dev, "cannot get hp_en gpio\n"); - return ret; - } - } + machine->gpio_hp_en = devm_gpiod_get_optional(&pdev->dev, "rockchip,hp-en", GPIOD_OUT_LOW); + if (IS_ERR(machine->gpio_hp_en)) + return PTR_ERR(machine->gpio_hp_en); + gpiod_set_consumer_name(machine->gpio_hp_en, "hp_en"); ret = snd_soc_of_parse_card_name(card, "rockchip,model"); if (ret) { From 3116dc2e16542d56bd173e90ce1893bed697a830 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 29 Sep 2023 00:12:55 +0200 Subject: [PATCH 2/4] ASoC: rockchip: Drop includes from RK3399 The RK3399 ASoC driver includes two legacy GPIO headers but doesn't use symbols from any of them. Delete the includes. Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20230929-descriptors-asoc-rockchip-v2-2-2d2c0e043aab@linaro.org Signed-off-by: Mark Brown --- sound/soc/rockchip/rk3399_gru_sound.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index 4c3b8b363530..1a504ebd3a0e 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -8,8 +8,6 @@ #include #include #include -#include -#include #include #include #include From 7214141067922836b48157e8266335096a0ea4ea Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 29 Sep 2023 00:12:56 +0200 Subject: [PATCH 3/4] ASoC: rockchip: Drop includes from Rockchip MAX98090 The Rockchip MAX98090 ASoC driver includes two legacy GPIO headers but doesn't use symbols from any of them. Delete the includes. Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20230929-descriptors-asoc-rockchip-v2-3-2d2c0e043aab@linaro.org Signed-off-by: Mark Brown --- sound/soc/rockchip/rockchip_max98090.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/rockchip/rockchip_max98090.c b/sound/soc/rockchip/rockchip_max98090.c index 17087b504a37..e3d603dbc151 100644 --- a/sound/soc/rockchip/rockchip_max98090.c +++ b/sound/soc/rockchip/rockchip_max98090.c @@ -9,8 +9,6 @@ #include #include #include -#include -#include #include #include #include From 329b017ccdf80cdcc3550f6caecbf2bc80a67432 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Fri, 29 Sep 2023 00:12:57 +0200 Subject: [PATCH 4/4] ASoC: rockchip: Drop includes from Rockchip RT5645 The Rockchip RT5645 ASoC driver includes two legacy GPIO headers but doesn't use symbols from any of them. Delete the includes. Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20230929-descriptors-asoc-rockchip-v2-4-2d2c0e043aab@linaro.org Signed-off-by: Mark Brown --- sound/soc/rockchip/rockchip_rt5645.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/rockchip/rockchip_rt5645.c b/sound/soc/rockchip/rockchip_rt5645.c index d5cfef9be1af..449f62820045 100644 --- a/sound/soc/rockchip/rockchip_rt5645.c +++ b/sound/soc/rockchip/rockchip_rt5645.c @@ -8,8 +8,6 @@ #include #include #include -#include -#include #include #include #include