14
14
#include <linux/ctype.h>
15
15
#include <linux/delay.h>
16
16
#include <linux/export.h>
17
- #include <linux/gpio.h>
17
+ #include <linux/gpio/consumer .h>
18
18
#include <linux/gpio/driver.h>
19
19
#include <linux/init.h>
20
- #include <linux/of_gpio.h>
21
20
#include <linux/of.h>
22
21
#include <linux/pinctrl/consumer.h>
23
22
#include <linux/slab.h>
@@ -29,9 +28,9 @@ struct snd_ac97_reset_cfg {
29
28
struct pinctrl_state * pstate_reset ;
30
29
struct pinctrl_state * pstate_warm_reset ;
31
30
struct pinctrl_state * pstate_run ;
32
- int gpio_sdata ;
33
- int gpio_sync ;
34
- int gpio_reset ;
31
+ struct gpio_desc * reset_gpio ;
32
+ struct gpio_desc * sdata_gpio ;
33
+ struct gpio_desc * sync_gpio ;
35
34
};
36
35
37
36
static struct snd_ac97_bus soc_ac97_bus = {
@@ -268,11 +267,11 @@ static void snd_soc_ac97_warm_reset(struct snd_ac97 *ac97)
268
267
269
268
pinctrl_select_state (pctl , snd_ac97_rst_cfg .pstate_warm_reset );
270
269
271
- gpio_direction_output (snd_ac97_rst_cfg .gpio_sync , 1 );
270
+ gpiod_direction_output_raw (snd_ac97_rst_cfg .sync_gpio , 1 );
272
271
273
272
udelay (10 );
274
273
275
- gpio_direction_output (snd_ac97_rst_cfg .gpio_sync , 0 );
274
+ gpiod_direction_output_raw (snd_ac97_rst_cfg .sync_gpio , 0 );
276
275
277
276
pinctrl_select_state (pctl , snd_ac97_rst_cfg .pstate_run );
278
277
msleep (2 );
@@ -284,13 +283,13 @@ static void snd_soc_ac97_reset(struct snd_ac97 *ac97)
284
283
285
284
pinctrl_select_state (pctl , snd_ac97_rst_cfg .pstate_reset );
286
285
287
- gpio_direction_output (snd_ac97_rst_cfg .gpio_sync , 0 );
288
- gpio_direction_output (snd_ac97_rst_cfg .gpio_sdata , 0 );
289
- gpio_direction_output (snd_ac97_rst_cfg .gpio_reset , 0 );
286
+ gpiod_direction_output_raw (snd_ac97_rst_cfg .sync_gpio , 0 );
287
+ gpiod_direction_output_raw (snd_ac97_rst_cfg .sdata_gpio , 0 );
288
+ gpiod_direction_output_raw (snd_ac97_rst_cfg .reset_gpio , 0 );
290
289
291
290
udelay (10 );
292
291
293
- gpio_direction_output (snd_ac97_rst_cfg .gpio_reset , 1 );
292
+ gpiod_direction_output_raw (snd_ac97_rst_cfg .reset_gpio , 1 );
294
293
295
294
pinctrl_select_state (pctl , snd_ac97_rst_cfg .pstate_run );
296
295
msleep (2 );
@@ -301,8 +300,6 @@ static int snd_soc_ac97_parse_pinctl(struct device *dev,
301
300
{
302
301
struct pinctrl * p ;
303
302
struct pinctrl_state * state ;
304
- int gpio ;
305
- int ret ;
306
303
307
304
p = devm_pinctrl_get (dev );
308
305
if (IS_ERR (p )) {
@@ -332,41 +329,20 @@ static int snd_soc_ac97_parse_pinctl(struct device *dev,
332
329
}
333
330
cfg -> pstate_run = state ;
334
331
335
- gpio = of_get_named_gpio (dev -> of_node , "ac97-gpios" , 0 );
336
- if (gpio < 0 ) {
337
- dev_err (dev , "Can't find ac97-sync gpio\n" );
338
- return gpio ;
339
- }
340
- ret = devm_gpio_request (dev , gpio , "AC97 link sync" );
341
- if (ret ) {
342
- dev_err (dev , "Failed requesting ac97-sync gpio\n" );
343
- return ret ;
344
- }
345
- cfg -> gpio_sync = gpio ;
332
+ cfg -> sync_gpio = devm_gpiod_get_index (dev , "ac97" , 0 , GPIOD_ASIS );
333
+ if (IS_ERR (cfg -> sync_gpio ))
334
+ return dev_err_probe (dev , PTR_ERR (cfg -> sync_gpio ), "Can't find ac97-sync gpio\n" );
335
+ gpiod_set_consumer_name (cfg -> sync_gpio , "AC97 link sync" );
346
336
347
- gpio = of_get_named_gpio (dev -> of_node , "ac97-gpios" , 1 );
348
- if (gpio < 0 ) {
349
- dev_err (dev , "Can't find ac97-sdata gpio %d\n" , gpio );
350
- return gpio ;
351
- }
352
- ret = devm_gpio_request (dev , gpio , "AC97 link sdata" );
353
- if (ret ) {
354
- dev_err (dev , "Failed requesting ac97-sdata gpio\n" );
355
- return ret ;
356
- }
357
- cfg -> gpio_sdata = gpio ;
337
+ cfg -> sdata_gpio = devm_gpiod_get_index (dev , "ac97" , 1 , GPIOD_ASIS );
338
+ if (IS_ERR (cfg -> sdata_gpio ))
339
+ return dev_err_probe (dev , PTR_ERR (cfg -> sync_gpio ), "Can't find ac97-sdata gpio\n" );
340
+ gpiod_set_consumer_name (cfg -> sdata_gpio , "AC97 link sdata" );
358
341
359
- gpio = of_get_named_gpio (dev -> of_node , "ac97-gpios" , 2 );
360
- if (gpio < 0 ) {
361
- dev_err (dev , "Can't find ac97-reset gpio\n" );
362
- return gpio ;
363
- }
364
- ret = devm_gpio_request (dev , gpio , "AC97 link reset" );
365
- if (ret ) {
366
- dev_err (dev , "Failed requesting ac97-reset gpio\n" );
367
- return ret ;
368
- }
369
- cfg -> gpio_reset = gpio ;
342
+ cfg -> reset_gpio = devm_gpiod_get_index (dev , "ac97" , 2 , GPIOD_ASIS );
343
+ if (IS_ERR (cfg -> reset_gpio ))
344
+ return dev_err_probe (dev , PTR_ERR (cfg -> sync_gpio ), "Can't find ac97-reset gpio\n" );
345
+ gpiod_set_consumer_name (cfg -> reset_gpio , "AC97 link reset" );
370
346
371
347
return 0 ;
372
348
}
0 commit comments