12
12
#include <linux/bitmap.h>
13
13
#include <linux/device.h>
14
14
#include <linux/atmel_pdc.h>
15
+ #include <linux/gpio/consumer.h>
15
16
#include <linux/init.h>
16
17
#include <linux/interrupt.h>
17
18
#include <linux/module.h>
18
19
#include <linux/platform_device.h>
19
20
#include <linux/mutex.h>
20
- #include <linux/gpio.h>
21
21
#include <linux/types.h>
22
22
#include <linux/io.h>
23
23
#include <linux/of.h>
24
- #include <linux/of_gpio.h>
25
24
#include <linux/of_device.h>
26
25
27
26
#include <sound/core.h>
28
27
#include <sound/initval.h>
29
28
#include <sound/pcm.h>
30
29
#include <sound/pcm_params.h>
31
30
#include <sound/ac97_codec.h>
32
- #include <sound/atmel-ac97c.h>
33
31
#include <sound/memalloc.h>
34
32
35
33
#include "ac97c.h"
@@ -56,7 +54,7 @@ struct atmel_ac97c {
56
54
void __iomem * regs ;
57
55
int irq ;
58
56
int opened ;
59
- int reset_pin ;
57
+ struct gpio_desc * reset_pin ;
60
58
};
61
59
62
60
#define get_chip (card ) ((struct atmel_ac97c *)(card)->private_data)
@@ -700,57 +698,30 @@ static void atmel_ac97c_reset(struct atmel_ac97c *chip)
700
698
ac97c_writel (chip , CAMR , 0 );
701
699
ac97c_writel (chip , COMR , 0 );
702
700
703
- if (gpio_is_valid (chip -> reset_pin )) {
704
- gpio_set_value (chip -> reset_pin , 0 );
701
+ if (! IS_ERR (chip -> reset_pin )) {
702
+ gpiod_set_value (chip -> reset_pin , 0 );
705
703
/* AC97 v2.2 specifications says minimum 1 us. */
706
704
udelay (2 );
707
- gpio_set_value (chip -> reset_pin , 1 );
705
+ gpiod_set_value (chip -> reset_pin , 1 );
708
706
} else {
709
707
ac97c_writel (chip , MR , AC97C_MR_WRST | AC97C_MR_ENA );
710
708
udelay (2 );
711
709
ac97c_writel (chip , MR , AC97C_MR_ENA );
712
710
}
713
711
}
714
712
715
- #ifdef CONFIG_OF
716
713
static const struct of_device_id atmel_ac97c_dt_ids [] = {
717
714
{ .compatible = "atmel,at91sam9263-ac97c" , },
718
715
{ }
719
716
};
720
717
MODULE_DEVICE_TABLE (of , atmel_ac97c_dt_ids );
721
718
722
- static struct ac97c_platform_data * atmel_ac97c_probe_dt (struct device * dev )
723
- {
724
- struct ac97c_platform_data * pdata ;
725
- struct device_node * node = dev -> of_node ;
726
-
727
- if (!node ) {
728
- dev_err (dev , "Device does not have associated DT data\n" );
729
- return ERR_PTR (- EINVAL );
730
- }
731
-
732
- pdata = devm_kzalloc (dev , sizeof (* pdata ), GFP_KERNEL );
733
- if (!pdata )
734
- return ERR_PTR (- ENOMEM );
735
-
736
- pdata -> reset_pin = of_get_named_gpio (dev -> of_node , "ac97-gpios" , 2 );
737
-
738
- return pdata ;
739
- }
740
- #else
741
- static struct ac97c_platform_data * atmel_ac97c_probe_dt (struct device * dev )
742
- {
743
- dev_err (dev , "no platform data defined\n" );
744
- return ERR_PTR (- ENXIO );
745
- }
746
- #endif
747
-
748
719
static int atmel_ac97c_probe (struct platform_device * pdev )
749
720
{
721
+ struct device * dev = & pdev -> dev ;
750
722
struct snd_card * card ;
751
723
struct atmel_ac97c * chip ;
752
724
struct resource * regs ;
753
- struct ac97c_platform_data * pdata ;
754
725
struct clk * pclk ;
755
726
static struct snd_ac97_bus_ops ops = {
756
727
.write = atmel_ac97c_write ,
@@ -765,13 +736,6 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
765
736
return - ENXIO ;
766
737
}
767
738
768
- pdata = dev_get_platdata (& pdev -> dev );
769
- if (!pdata ) {
770
- pdata = atmel_ac97c_probe_dt (& pdev -> dev );
771
- if (IS_ERR (pdata ))
772
- return PTR_ERR (pdata );
773
- }
774
-
775
739
irq = platform_get_irq (pdev , 0 );
776
740
if (irq < 0 ) {
777
741
dev_dbg (& pdev -> dev , "could not get irq: %d\n" , irq );
@@ -819,17 +783,9 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
819
783
goto err_ioremap ;
820
784
}
821
785
822
- if (gpio_is_valid (pdata -> reset_pin )) {
823
- if (gpio_request (pdata -> reset_pin , "reset_pin" )) {
824
- dev_dbg (& pdev -> dev , "reset pin not available\n" );
825
- chip -> reset_pin = - ENODEV ;
826
- } else {
827
- gpio_direction_output (pdata -> reset_pin , 1 );
828
- chip -> reset_pin = pdata -> reset_pin ;
829
- }
830
- } else {
831
- chip -> reset_pin = - EINVAL ;
832
- }
786
+ chip -> reset_pin = devm_gpiod_get_index (dev , "ac97" , 2 , GPIOD_OUT_HIGH );
787
+ if (IS_ERR (chip -> reset_pin ))
788
+ dev_dbg (dev , "reset pin not available\n" );
833
789
834
790
atmel_ac97c_reset (chip );
835
791
@@ -869,9 +825,6 @@ static int atmel_ac97c_probe(struct platform_device *pdev)
869
825
return 0 ;
870
826
871
827
err_ac97_bus :
872
- if (gpio_is_valid (chip -> reset_pin ))
873
- gpio_free (chip -> reset_pin );
874
-
875
828
iounmap (chip -> regs );
876
829
err_ioremap :
877
830
free_irq (irq , chip );
@@ -913,9 +866,6 @@ static int atmel_ac97c_remove(struct platform_device *pdev)
913
866
struct snd_card * card = platform_get_drvdata (pdev );
914
867
struct atmel_ac97c * chip = get_chip (card );
915
868
916
- if (gpio_is_valid (chip -> reset_pin ))
917
- gpio_free (chip -> reset_pin );
918
-
919
869
ac97c_writel (chip , CAMR , 0 );
920
870
ac97c_writel (chip , COMR , 0 );
921
871
ac97c_writel (chip , MR , 0 );
@@ -936,7 +886,7 @@ static struct platform_driver atmel_ac97c_driver = {
936
886
.driver = {
937
887
.name = "atmel_ac97c" ,
938
888
.pm = ATMEL_AC97C_PM_OPS ,
939
- .of_match_table = of_match_ptr ( atmel_ac97c_dt_ids ) ,
889
+ .of_match_table = atmel_ac97c_dt_ids ,
940
890
},
941
891
};
942
892
module_platform_driver (atmel_ac97c_driver );
0 commit comments