diff options
Diffstat (limited to 'sound/soc/mxs/mxs-sgtl5000.c')
-rw-r--r-- | sound/soc/mxs/mxs-sgtl5000.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/sound/soc/mxs/mxs-sgtl5000.c b/sound/soc/mxs/mxs-sgtl5000.c index 60f052b7cf22..3e6e8764b2e6 100644 --- a/sound/soc/mxs/mxs-sgtl5000.c +++ b/sound/soc/mxs/mxs-sgtl5000.c | |||
@@ -18,6 +18,8 @@ | |||
18 | 18 | ||
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
21 | #include <linux/of.h> | ||
22 | #include <linux/of_device.h> | ||
21 | #include <sound/core.h> | 23 | #include <sound/core.h> |
22 | #include <sound/pcm.h> | 24 | #include <sound/pcm.h> |
23 | #include <sound/soc.h> | 25 | #include <sound/soc.h> |
@@ -90,7 +92,7 @@ static struct snd_soc_dai_link mxs_sgtl5000_dai[] = { | |||
90 | .codec_dai_name = "sgtl5000", | 92 | .codec_dai_name = "sgtl5000", |
91 | .codec_name = "sgtl5000.0-000a", | 93 | .codec_name = "sgtl5000.0-000a", |
92 | .cpu_dai_name = "mxs-saif.0", | 94 | .cpu_dai_name = "mxs-saif.0", |
93 | .platform_name = "mxs-pcm-audio.0", | 95 | .platform_name = "mxs-saif.0", |
94 | .ops = &mxs_sgtl5000_hifi_ops, | 96 | .ops = &mxs_sgtl5000_hifi_ops, |
95 | }, { | 97 | }, { |
96 | .name = "HiFi Rx", | 98 | .name = "HiFi Rx", |
@@ -98,7 +100,7 @@ static struct snd_soc_dai_link mxs_sgtl5000_dai[] = { | |||
98 | .codec_dai_name = "sgtl5000", | 100 | .codec_dai_name = "sgtl5000", |
99 | .codec_name = "sgtl5000.0-000a", | 101 | .codec_name = "sgtl5000.0-000a", |
100 | .cpu_dai_name = "mxs-saif.1", | 102 | .cpu_dai_name = "mxs-saif.1", |
101 | .platform_name = "mxs-pcm-audio.1", | 103 | .platform_name = "mxs-saif.1", |
102 | .ops = &mxs_sgtl5000_hifi_ops, | 104 | .ops = &mxs_sgtl5000_hifi_ops, |
103 | }, | 105 | }, |
104 | }; | 106 | }; |
@@ -110,11 +112,48 @@ static struct snd_soc_card mxs_sgtl5000 = { | |||
110 | .num_links = ARRAY_SIZE(mxs_sgtl5000_dai), | 112 | .num_links = ARRAY_SIZE(mxs_sgtl5000_dai), |
111 | }; | 113 | }; |
112 | 114 | ||
115 | static int __devinit mxs_sgtl5000_probe_dt(struct platform_device *pdev) | ||
116 | { | ||
117 | struct device_node *np = pdev->dev.of_node; | ||
118 | struct device_node *saif_np[2], *codec_np; | ||
119 | int i, ret = 0; | ||
120 | |||
121 | if (!np) | ||
122 | return 1; /* no device tree */ | ||
123 | |||
124 | saif_np[0] = of_parse_phandle(np, "saif-controllers", 0); | ||
125 | saif_np[1] = of_parse_phandle(np, "saif-controllers", 1); | ||
126 | codec_np = of_parse_phandle(np, "audio-codec", 0); | ||
127 | if (!saif_np[0] || !saif_np[1] || !codec_np) { | ||
128 | dev_err(&pdev->dev, "phandle missing or invalid\n"); | ||
129 | return -EINVAL; | ||
130 | } | ||
131 | |||
132 | for (i = 0; i < 2; i++) { | ||
133 | mxs_sgtl5000_dai[i].codec_name = NULL; | ||
134 | mxs_sgtl5000_dai[i].codec_of_node = codec_np; | ||
135 | mxs_sgtl5000_dai[i].cpu_dai_name = NULL; | ||
136 | mxs_sgtl5000_dai[i].cpu_dai_of_node = saif_np[i]; | ||
137 | mxs_sgtl5000_dai[i].platform_name = NULL; | ||
138 | mxs_sgtl5000_dai[i].platform_of_node = saif_np[i]; | ||
139 | } | ||
140 | |||
141 | of_node_put(codec_np); | ||
142 | of_node_put(saif_np[0]); | ||
143 | of_node_put(saif_np[1]); | ||
144 | |||
145 | return ret; | ||
146 | } | ||
147 | |||
113 | static int __devinit mxs_sgtl5000_probe(struct platform_device *pdev) | 148 | static int __devinit mxs_sgtl5000_probe(struct platform_device *pdev) |
114 | { | 149 | { |
115 | struct snd_soc_card *card = &mxs_sgtl5000; | 150 | struct snd_soc_card *card = &mxs_sgtl5000; |
116 | int ret; | 151 | int ret; |
117 | 152 | ||
153 | ret = mxs_sgtl5000_probe_dt(pdev); | ||
154 | if (ret < 0) | ||
155 | return ret; | ||
156 | |||
118 | /* | 157 | /* |
119 | * Set an init clock(11.28Mhz) for sgtl5000 initialization(i2c r/w). | 158 | * Set an init clock(11.28Mhz) for sgtl5000 initialization(i2c r/w). |
120 | * The Sgtl5000 sysclk is derived from saif0 mclk and it's range | 159 | * The Sgtl5000 sysclk is derived from saif0 mclk and it's range |
@@ -148,10 +187,17 @@ static int __devexit mxs_sgtl5000_remove(struct platform_device *pdev) | |||
148 | return 0; | 187 | return 0; |
149 | } | 188 | } |
150 | 189 | ||
190 | static const struct of_device_id mxs_sgtl5000_dt_ids[] = { | ||
191 | { .compatible = "fsl,mxs-audio-sgtl5000", }, | ||
192 | { /* sentinel */ } | ||
193 | }; | ||
194 | MODULE_DEVICE_TABLE(of, mxs_sgtl5000_dt_ids); | ||
195 | |||
151 | static struct platform_driver mxs_sgtl5000_audio_driver = { | 196 | static struct platform_driver mxs_sgtl5000_audio_driver = { |
152 | .driver = { | 197 | .driver = { |
153 | .name = "mxs-sgtl5000", | 198 | .name = "mxs-sgtl5000", |
154 | .owner = THIS_MODULE, | 199 | .owner = THIS_MODULE, |
200 | .of_match_table = mxs_sgtl5000_dt_ids, | ||
155 | }, | 201 | }, |
156 | .probe = mxs_sgtl5000_probe, | 202 | .probe = mxs_sgtl5000_probe, |
157 | .remove = __devexit_p(mxs_sgtl5000_remove), | 203 | .remove = __devexit_p(mxs_sgtl5000_remove), |