diff options
author | Alexander Stein <alexanders83@web.de> | 2014-12-29 07:08:39 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-01-07 01:56:19 -0500 |
commit | b2d8957f288e2e51085e7c468a05d5d98f0a785f (patch) | |
tree | 6e801ca7d486eb61dde95055680703c68df098d2 /sound/atmel | |
parent | ff6defa6a8fae12205d64f55db395b1fcf35af8e (diff) |
ALSA: sound/atmel/ac97c.c: Add device tree support
This adds device tree support for the AC97 controller. It uses the
soc-ac97link bindings, but actually only ac97-reset is used.
Signed-off-by: Alexander Stein <alexanders83@web.de>
Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/atmel')
-rw-r--r-- | sound/atmel/ac97c.c | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/sound/atmel/ac97c.c b/sound/atmel/ac97c.c index 5e6a1db70948..cf4cedf2b420 100644 --- a/sound/atmel/ac97c.c +++ b/sound/atmel/ac97c.c | |||
@@ -22,6 +22,9 @@ | |||
22 | #include <linux/gpio.h> | 22 | #include <linux/gpio.h> |
23 | #include <linux/types.h> | 23 | #include <linux/types.h> |
24 | #include <linux/io.h> | 24 | #include <linux/io.h> |
25 | #include <linux/of.h> | ||
26 | #include <linux/of_gpio.h> | ||
27 | #include <linux/of_device.h> | ||
25 | 28 | ||
26 | #include <sound/core.h> | 29 | #include <sound/core.h> |
27 | #include <sound/initval.h> | 30 | #include <sound/initval.h> |
@@ -902,6 +905,40 @@ static void atmel_ac97c_reset(struct atmel_ac97c *chip) | |||
902 | } | 905 | } |
903 | } | 906 | } |
904 | 907 | ||
908 | #ifdef CONFIG_OF | ||
909 | static const struct of_device_id atmel_ac97c_dt_ids[] = { | ||
910 | { .compatible = "atmel,at91sam9263-ac97c", }, | ||
911 | { } | ||
912 | }; | ||
913 | MODULE_DEVICE_TABLE(of, atmel_ac97c_dt_ids); | ||
914 | |||
915 | static struct ac97c_platform_data *atmel_ac97c_probe_dt(struct device *dev) | ||
916 | { | ||
917 | struct ac97c_platform_data *pdata; | ||
918 | struct device_node *node = dev->of_node; | ||
919 | const struct of_device_id *match; | ||
920 | |||
921 | if (!node) { | ||
922 | dev_err(dev, "Device does not have associated DT data\n"); | ||
923 | return ERR_PTR(-EINVAL); | ||
924 | } | ||
925 | |||
926 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | ||
927 | if (!pdata) | ||
928 | return ERR_PTR(-ENOMEM); | ||
929 | |||
930 | pdata->reset_pin = of_get_named_gpio(dev->of_node, "ac97-gpios", 2); | ||
931 | |||
932 | return pdata; | ||
933 | } | ||
934 | #else | ||
935 | static struct ac97c_platform_data *atmel_ac97c_probe_dt(struct device *dev) | ||
936 | { | ||
937 | dev_err(dev, "no platform data defined\n"); | ||
938 | return ERR_PTR(-ENXIO); | ||
939 | } | ||
940 | #endif | ||
941 | |||
905 | static int atmel_ac97c_probe(struct platform_device *pdev) | 942 | static int atmel_ac97c_probe(struct platform_device *pdev) |
906 | { | 943 | { |
907 | struct snd_card *card; | 944 | struct snd_card *card; |
@@ -922,10 +959,11 @@ static int atmel_ac97c_probe(struct platform_device *pdev) | |||
922 | return -ENXIO; | 959 | return -ENXIO; |
923 | } | 960 | } |
924 | 961 | ||
925 | pdata = pdev->dev.platform_data; | 962 | pdata = dev_get_platdata(&pdev->dev); |
926 | if (!pdata) { | 963 | if (!pdata) { |
927 | dev_dbg(&pdev->dev, "no platform data\n"); | 964 | pdata = atmel_ac97c_probe_dt(&pdev->dev); |
928 | return -ENXIO; | 965 | if (IS_ERR(pdata)) |
966 | return PTR_ERR(pdata); | ||
929 | } | 967 | } |
930 | 968 | ||
931 | irq = platform_get_irq(pdev, 0); | 969 | irq = platform_get_irq(pdev, 0); |
@@ -1204,6 +1242,7 @@ static struct platform_driver atmel_ac97c_driver = { | |||
1204 | .driver = { | 1242 | .driver = { |
1205 | .name = "atmel_ac97c", | 1243 | .name = "atmel_ac97c", |
1206 | .pm = ATMEL_AC97C_PM_OPS, | 1244 | .pm = ATMEL_AC97C_PM_OPS, |
1245 | .of_match_table = of_match_ptr(atmel_ac97c_dt_ids), | ||
1207 | }, | 1246 | }, |
1208 | }; | 1247 | }; |
1209 | module_platform_driver(atmel_ac97c_driver); | 1248 | module_platform_driver(atmel_ac97c_driver); |