Convert Rockchip ASoC drivers to GPIO descriptors

Merge series from Linus Walleij <linus.walleij@linaro.org>:

The Rockchip drivers are pretty straight-forward to convert
over to using GPIO descriptors.
This commit is contained in:
Mark Brown 2023-10-09 18:40:19 +01:00
commit fee44f43b2
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
4 changed files with 14 additions and 38 deletions

View File

@ -12,8 +12,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/of_gpio.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/jack.h> #include <sound/jack.h>
#include <sound/pcm.h> #include <sound/pcm.h>
@ -26,8 +25,7 @@
#define DRV_NAME "rk3288-snd-hdmi-analog" #define DRV_NAME "rk3288-snd-hdmi-analog"
struct rk_drvdata { struct rk_drvdata {
int gpio_hp_en; struct gpio_desc *gpio_hp_en;
int gpio_hp_det;
}; };
static int rk_hp_power(struct snd_soc_dapm_widget *w, 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); struct rk_drvdata *machine = snd_soc_card_get_drvdata(w->dapm->card);
if (!gpio_is_valid(machine->gpio_hp_en)) gpiod_set_value_cansleep(machine->gpio_hp_en,
return 0; SND_SOC_DAPM_EVENT_ON(event));
gpio_set_value_cansleep(machine->gpio_hp_en,
SND_SOC_DAPM_EVENT_ON(event));
return 0; 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 = { static struct snd_soc_jack_gpio rk_hp_jack_gpio = {
.name = "Headphone detection", .name = "rockchip,hp-det",
.report = SND_JACK_HEADPHONE, .report = SND_JACK_HEADPHONE,
.debounce_time = 150 .debounce_time = 150
}; };
static int rk_init(struct snd_soc_pcm_runtime *runtime) 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 */ /* Enable optional Headset Jack detection */
if (gpio_is_valid(machine->gpio_hp_det)) { 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_soc_card_jack_new_pins(runtime->card, "Headphone Jack",
SND_JACK_HEADPHONE, &headphone_jack, SND_JACK_HEADPHONE, &headphone_jack,
headphone_jack_pins, headphone_jack_pins,
ARRAY_SIZE(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); 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; card->dev = &pdev->dev;
machine->gpio_hp_det = of_get_named_gpio(np, machine->gpio_hp_en = devm_gpiod_get_optional(&pdev->dev, "rockchip,hp-en", GPIOD_OUT_LOW);
"rockchip,hp-det-gpios", 0); if (IS_ERR(machine->gpio_hp_en))
if (!gpio_is_valid(machine->gpio_hp_det) && machine->gpio_hp_det != -ENODEV) return PTR_ERR(machine->gpio_hp_en);
return machine->gpio_hp_det; gpiod_set_consumer_name(machine->gpio_hp_en, "hp_en");
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;
}
}
ret = snd_soc_of_parse_card_name(card, "rockchip,model"); ret = snd_soc_of_parse_card_name(card, "rockchip,model");
if (ret) { if (ret) {

View File

@ -8,8 +8,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/i2c.h> #include <linux/i2c.h>

View File

@ -9,8 +9,6 @@
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/jack.h> #include <sound/jack.h>
#include <sound/pcm.h> #include <sound/pcm.h>

View File

@ -8,8 +8,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <sound/core.h> #include <sound/core.h>
#include <sound/jack.h> #include <sound/jack.h>