Skip to content

Commit 26e91f6

Browse files
Linus Walleijbroonie
authored andcommitted
ASoC: tegra: tegra20_ac97: Convert to use GPIO descriptors
The Tegra20 AC97 driver is using the legacy GPIO APIs in <linux/of_gpio.h> and <linux/gpio.h> to obtain GPIOs for reset and sync. Convert it over and fix the polarity error on the RESET line in the process: this reset line is clearly active low. Just fix the one in-tree device tree site using it at the same time. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://msgid.link/r/20231214-gpio-descriptors-sound-misc-v1-4-e3004176bd8b@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4504f63 commit 26e91f6

3 files changed

Lines changed: 29 additions & 32 deletions

File tree

arch/arm/boot/dts/nvidia/tegra20-colibri.dtsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@
446446
tegra_ac97: ac97@70002000 {
447447
status = "okay";
448448
nvidia,codec-reset-gpio =
449-
<&gpio TEGRA_GPIO(V, 0) GPIO_ACTIVE_HIGH>;
449+
<&gpio TEGRA_GPIO(V, 0) GPIO_ACTIVE_LOW>;
450450
nvidia,codec-sync-gpio =
451451
<&gpio TEGRA_GPIO(P, 0) GPIO_ACTIVE_HIGH>;
452452
};

sound/soc/tegra/tegra20_ac97.c

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
#include <linux/clk.h>
1313
#include <linux/delay.h>
1414
#include <linux/device.h>
15-
#include <linux/gpio.h>
15+
#include <linux/gpio/consumer.h>
1616
#include <linux/io.h>
1717
#include <linux/jiffies.h>
1818
#include <linux/module.h>
1919
#include <linux/of.h>
20-
#include <linux/of_gpio.h>
2120
#include <linux/platform_device.h>
2221
#include <linux/regmap.h>
2322
#include <linux/reset.h>
@@ -39,11 +38,15 @@ static void tegra20_ac97_codec_reset(struct snd_ac97 *ac97)
3938
u32 readback;
4039
unsigned long timeout;
4140

42-
/* reset line is not driven by DAC pad group, have to toggle GPIO */
43-
gpio_set_value(workdata->reset_gpio, 0);
41+
/*
42+
* The reset line is not driven by DAC pad group, have to toggle GPIO.
43+
* The RESET line is active low but this is abstracted by the GPIO
44+
* library.
45+
*/
46+
gpiod_set_value(workdata->reset_gpio, 1);
4447
udelay(2);
4548

46-
gpio_set_value(workdata->reset_gpio, 1);
49+
gpiod_set_value(workdata->reset_gpio, 0);
4750
udelay(2);
4851

4952
timeout = jiffies + msecs_to_jiffies(100);
@@ -66,14 +69,10 @@ static void tegra20_ac97_codec_warm_reset(struct snd_ac97 *ac97)
6669
* the controller cmd is not working, have to toggle sync line
6770
* manually.
6871
*/
69-
gpio_request(workdata->sync_gpio, "codec-sync");
70-
71-
gpio_direction_output(workdata->sync_gpio, 1);
72-
72+
gpiod_direction_output(workdata->sync_gpio, 1);
7373
udelay(2);
74-
gpio_set_value(workdata->sync_gpio, 0);
74+
gpiod_set_value(workdata->sync_gpio, 0);
7575
udelay(2);
76-
gpio_free(workdata->sync_gpio);
7776

7877
timeout = jiffies + msecs_to_jiffies(100);
7978

@@ -342,28 +341,26 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
342341
goto err_clk_put;
343342
}
344343

345-
ac97->reset_gpio = of_get_named_gpio(pdev->dev.of_node,
346-
"nvidia,codec-reset-gpio", 0);
347-
if (gpio_is_valid(ac97->reset_gpio)) {
348-
ret = devm_gpio_request_one(&pdev->dev, ac97->reset_gpio,
349-
GPIOF_OUT_INIT_HIGH, "codec-reset");
350-
if (ret) {
351-
dev_err(&pdev->dev, "could not get codec-reset GPIO\n");
352-
goto err_clk_put;
353-
}
354-
} else {
355-
dev_err(&pdev->dev, "no codec-reset GPIO supplied\n");
356-
ret = -EINVAL;
344+
/* Obtain RESET de-asserted */
345+
ac97->reset_gpio = devm_gpiod_get(&pdev->dev,
346+
"nvidia,codec-reset",
347+
GPIOD_OUT_LOW);
348+
if (IS_ERR(ac97->reset_gpio)) {
349+
ret = PTR_ERR(ac97->reset_gpio);
350+
dev_err(&pdev->dev, "no RESET GPIO supplied: %d\n", ret);
357351
goto err_clk_put;
358352
}
359-
360-
ac97->sync_gpio = of_get_named_gpio(pdev->dev.of_node,
361-
"nvidia,codec-sync-gpio", 0);
362-
if (!gpio_is_valid(ac97->sync_gpio)) {
363-
dev_err(&pdev->dev, "no codec-sync GPIO supplied\n");
364-
ret = -EINVAL;
353+
gpiod_set_consumer_name(ac97->reset_gpio, "codec-reset");
354+
355+
ac97->sync_gpio = devm_gpiod_get(&pdev->dev,
356+
"nvidia,codec-sync",
357+
GPIOD_OUT_LOW);
358+
if (IS_ERR(ac97->sync_gpio)) {
359+
ret = PTR_ERR(ac97->sync_gpio);
360+
dev_err(&pdev->dev, "no codec-sync GPIO supplied: %d\n", ret);
365361
goto err_clk_put;
366362
}
363+
gpiod_set_consumer_name(ac97->sync_gpio, "codec-sync");
367364

368365
ac97->capture_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_RX1;
369366
ac97->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;

sound/soc/tegra/tegra20_ac97.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct tegra20_ac97 {
8080
struct snd_dmaengine_dai_dma_data playback_dma_data;
8181
struct reset_control *reset;
8282
struct regmap *regmap;
83-
int reset_gpio;
84-
int sync_gpio;
83+
struct gpio_desc *reset_gpio;
84+
struct gpio_desc *sync_gpio;
8585
};
8686
#endif /* __TEGRA20_AC97_H__ */

0 commit comments

Comments
 (0)