Commit 26e91f61 authored by Linus Walleij's avatar Linus Walleij Committed by Mark Brown

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: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://msgid.link/r/20231214-gpio-descriptors-sound-misc-v1-4-e3004176bd8b@linaro.orgSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4504f633
...@@ -446,7 +446,7 @@ lvp0 { ...@@ -446,7 +446,7 @@ lvp0 {
tegra_ac97: ac97@70002000 { tegra_ac97: ac97@70002000 {
status = "okay"; status = "okay";
nvidia,codec-reset-gpio = nvidia,codec-reset-gpio =
<&gpio TEGRA_GPIO(V, 0) GPIO_ACTIVE_HIGH>; <&gpio TEGRA_GPIO(V, 0) GPIO_ACTIVE_LOW>;
nvidia,codec-sync-gpio = nvidia,codec-sync-gpio =
<&gpio TEGRA_GPIO(P, 0) GPIO_ACTIVE_HIGH>; <&gpio TEGRA_GPIO(P, 0) GPIO_ACTIVE_HIGH>;
}; };
......
...@@ -12,12 +12,11 @@ ...@@ -12,12 +12,11 @@
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/reset.h> #include <linux/reset.h>
...@@ -39,11 +38,15 @@ static void tegra20_ac97_codec_reset(struct snd_ac97 *ac97) ...@@ -39,11 +38,15 @@ static void tegra20_ac97_codec_reset(struct snd_ac97 *ac97)
u32 readback; u32 readback;
unsigned long timeout; unsigned long timeout;
/* reset line is not driven by DAC pad group, have to toggle GPIO */ /*
gpio_set_value(workdata->reset_gpio, 0); * The reset line is not driven by DAC pad group, have to toggle GPIO.
* The RESET line is active low but this is abstracted by the GPIO
* library.
*/
gpiod_set_value(workdata->reset_gpio, 1);
udelay(2); udelay(2);
gpio_set_value(workdata->reset_gpio, 1); gpiod_set_value(workdata->reset_gpio, 0);
udelay(2); udelay(2);
timeout = jiffies + msecs_to_jiffies(100); timeout = jiffies + msecs_to_jiffies(100);
...@@ -66,14 +69,10 @@ static void tegra20_ac97_codec_warm_reset(struct snd_ac97 *ac97) ...@@ -66,14 +69,10 @@ static void tegra20_ac97_codec_warm_reset(struct snd_ac97 *ac97)
* the controller cmd is not working, have to toggle sync line * the controller cmd is not working, have to toggle sync line
* manually. * manually.
*/ */
gpio_request(workdata->sync_gpio, "codec-sync"); gpiod_direction_output(workdata->sync_gpio, 1);
gpio_direction_output(workdata->sync_gpio, 1);
udelay(2); udelay(2);
gpio_set_value(workdata->sync_gpio, 0); gpiod_set_value(workdata->sync_gpio, 0);
udelay(2); udelay(2);
gpio_free(workdata->sync_gpio);
timeout = jiffies + msecs_to_jiffies(100); timeout = jiffies + msecs_to_jiffies(100);
...@@ -342,28 +341,26 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev) ...@@ -342,28 +341,26 @@ static int tegra20_ac97_platform_probe(struct platform_device *pdev)
goto err_clk_put; goto err_clk_put;
} }
ac97->reset_gpio = of_get_named_gpio(pdev->dev.of_node, /* Obtain RESET de-asserted */
"nvidia,codec-reset-gpio", 0); ac97->reset_gpio = devm_gpiod_get(&pdev->dev,
if (gpio_is_valid(ac97->reset_gpio)) { "nvidia,codec-reset",
ret = devm_gpio_request_one(&pdev->dev, ac97->reset_gpio, GPIOD_OUT_LOW);
GPIOF_OUT_INIT_HIGH, "codec-reset"); if (IS_ERR(ac97->reset_gpio)) {
if (ret) { ret = PTR_ERR(ac97->reset_gpio);
dev_err(&pdev->dev, "could not get codec-reset GPIO\n"); dev_err(&pdev->dev, "no RESET GPIO supplied: %d\n", ret);
goto err_clk_put;
}
} else {
dev_err(&pdev->dev, "no codec-reset GPIO supplied\n");
ret = -EINVAL;
goto err_clk_put; goto err_clk_put;
} }
gpiod_set_consumer_name(ac97->reset_gpio, "codec-reset");
ac97->sync_gpio = of_get_named_gpio(pdev->dev.of_node,
"nvidia,codec-sync-gpio", 0); ac97->sync_gpio = devm_gpiod_get(&pdev->dev,
if (!gpio_is_valid(ac97->sync_gpio)) { "nvidia,codec-sync",
dev_err(&pdev->dev, "no codec-sync GPIO supplied\n"); GPIOD_OUT_LOW);
ret = -EINVAL; if (IS_ERR(ac97->sync_gpio)) {
ret = PTR_ERR(ac97->sync_gpio);
dev_err(&pdev->dev, "no codec-sync GPIO supplied: %d\n", ret);
goto err_clk_put; goto err_clk_put;
} }
gpiod_set_consumer_name(ac97->sync_gpio, "codec-sync");
ac97->capture_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_RX1; ac97->capture_dma_data.addr = mem->start + TEGRA20_AC97_FIFO_RX1;
ac97->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; ac97->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
......
...@@ -80,7 +80,7 @@ struct tegra20_ac97 { ...@@ -80,7 +80,7 @@ struct tegra20_ac97 {
struct snd_dmaengine_dai_dma_data playback_dma_data; struct snd_dmaengine_dai_dma_data playback_dma_data;
struct reset_control *reset; struct reset_control *reset;
struct regmap *regmap; struct regmap *regmap;
int reset_gpio; struct gpio_desc *reset_gpio;
int sync_gpio; struct gpio_desc *sync_gpio;
}; };
#endif /* __TEGRA20_AC97_H__ */ #endif /* __TEGRA20_AC97_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment