diff options
author | Lee Jones <lee.jones@linaro.org> | 2012-07-26 11:48:34 -0400 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2012-09-20 03:10:56 -0400 |
commit | 0af541ce47ee4e80393dda12109a1efaf757fdcd (patch) | |
tree | 9e6a8d3df92b3bbd5d8d035f52a5ede33adf724c | |
parent | 5ca032ee21cdabd08fb368ce3f02fa8906b0ef5f (diff) |
ASoC: Ux500: Enable MOP500 driver for Device Tree
Here we ensure that the MOP500 audio driver will be probed during a
Device Tree boot. We also parse the sound node to link together the
codec, dma and the CPU-side Digital Audio Interface.
Acked-by: Ola Lilja <ola.o.lilja@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r-- | sound/soc/ux500/mop500.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sound/soc/ux500/mop500.c b/sound/soc/ux500/mop500.c index 31c4d26d0359..6840df79d798 100644 --- a/sound/soc/ux500/mop500.c +++ b/sound/soc/ux500/mop500.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/io.h> | 17 | #include <linux/io.h> |
18 | #include <linux/spi/spi.h> | 18 | #include <linux/spi/spi.h> |
19 | #include <linux/of.h> | ||
19 | 20 | ||
20 | #include <sound/soc.h> | 21 | #include <sound/soc.h> |
21 | #include <sound/initval.h> | 22 | #include <sound/initval.h> |
@@ -56,8 +57,35 @@ static struct snd_soc_card mop500_card = { | |||
56 | .num_links = ARRAY_SIZE(mop500_dai_links), | 57 | .num_links = ARRAY_SIZE(mop500_dai_links), |
57 | }; | 58 | }; |
58 | 59 | ||
60 | static int __devinit mop500_of_probe(struct platform_device *pdev, | ||
61 | struct device_node *np) | ||
62 | { | ||
63 | struct device_node *codec_np, *msp_np[2]; | ||
64 | int i; | ||
65 | |||
66 | msp_np[0] = of_parse_phandle(np, "stericsson,cpu-dai", 0); | ||
67 | msp_np[1] = of_parse_phandle(np, "stericsson,cpu-dai", 1); | ||
68 | codec_np = of_parse_phandle(np, "stericsson,audio-codec", 0); | ||
69 | |||
70 | if (!(msp_np[0] && msp_np[1] && codec_np)) { | ||
71 | dev_err(&pdev->dev, "Phandle missing or invalid\n"); | ||
72 | return -EINVAL; | ||
73 | } | ||
74 | |||
75 | for (i = 0; i < 2; i++) { | ||
76 | mop500_dai_links[i].cpu_of_node = msp_np[i]; | ||
77 | mop500_dai_links[i].cpu_dai_name = NULL; | ||
78 | mop500_dai_links[i].codec_of_node = codec_np; | ||
79 | mop500_dai_links[i].codec_name = NULL; | ||
80 | } | ||
81 | |||
82 | snd_soc_of_parse_card_name(&mop500_card, "stericsson,card-name"); | ||
83 | |||
84 | return 0; | ||
85 | } | ||
59 | static int __devinit mop500_probe(struct platform_device *pdev) | 86 | static int __devinit mop500_probe(struct platform_device *pdev) |
60 | { | 87 | { |
88 | struct device_node *np = pdev->dev.of_node; | ||
61 | int ret; | 89 | int ret; |
62 | 90 | ||
63 | pr_debug("%s: Enter.\n", __func__); | 91 | pr_debug("%s: Enter.\n", __func__); |
@@ -66,6 +94,12 @@ static int __devinit mop500_probe(struct platform_device *pdev) | |||
66 | 94 | ||
67 | mop500_card.dev = &pdev->dev; | 95 | mop500_card.dev = &pdev->dev; |
68 | 96 | ||
97 | if (np) { | ||
98 | ret = mop500_of_probe(pdev, np); | ||
99 | if (ret) | ||
100 | return ret; | ||
101 | } | ||
102 | |||
69 | dev_dbg(&pdev->dev, "%s: Card %s: Set platform drvdata.\n", | 103 | dev_dbg(&pdev->dev, "%s: Card %s: Set platform drvdata.\n", |
70 | __func__, mop500_card.name); | 104 | __func__, mop500_card.name); |
71 | platform_set_drvdata(pdev, &mop500_card); | 105 | platform_set_drvdata(pdev, &mop500_card); |
@@ -101,10 +135,16 @@ static int __devexit mop500_remove(struct platform_device *pdev) | |||
101 | return 0; | 135 | return 0; |
102 | } | 136 | } |
103 | 137 | ||
138 | static const struct of_device_id snd_soc_mop500_match[] = { | ||
139 | { .compatible = "stericsson,snd-soc-mop500", }, | ||
140 | {}, | ||
141 | }; | ||
142 | |||
104 | static struct platform_driver snd_soc_mop500_driver = { | 143 | static struct platform_driver snd_soc_mop500_driver = { |
105 | .driver = { | 144 | .driver = { |
106 | .owner = THIS_MODULE, | 145 | .owner = THIS_MODULE, |
107 | .name = "snd-soc-mop500", | 146 | .name = "snd-soc-mop500", |
147 | .of_match_table = snd_soc_mop500_match, | ||
108 | }, | 148 | }, |
109 | .probe = mop500_probe, | 149 | .probe = mop500_probe, |
110 | .remove = __devexit_p(mop500_remove), | 150 | .remove = __devexit_p(mop500_remove), |