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 ;
0 commit comments