aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/samsung
diff options
context:
space:
mode:
authorMark Brown <broonie@linaro.org>2013-07-26 07:42:19 -0400
committerMark Brown <broonie@linaro.org>2013-07-29 13:34:29 -0400
commitd30c148bb1cab23d3c330e6352b8d882575a0c3a (patch)
tree4c4a965708400255f1d6c14a16d59d11adb054d1 /sound/soc/samsung
parentf6ecf50b5e33119620b446dd0bce8b0a01a39669 (diff)
ASoC: smdk_wm8994: Configure the MCLK1 rate based on the board
Make the code more generally applicable by refactoring so that the MCLK1 rate can be selected based on the compatible string provided by the device tree, allowing use on other boards which have different rates or use other information sources. Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/samsung')
-rw-r--r--sound/soc/samsung/smdk_wm8994.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/sound/soc/samsung/smdk_wm8994.c b/sound/soc/samsung/smdk_wm8994.c
index a56117536c94..5fd7a05a9b9e 100644
--- a/sound/soc/samsung/smdk_wm8994.c
+++ b/sound/soc/samsung/smdk_wm8994.c
@@ -11,6 +11,7 @@
11#include <sound/pcm_params.h> 11#include <sound/pcm_params.h>
12#include <linux/module.h> 12#include <linux/module.h>
13#include <linux/of.h> 13#include <linux/of.h>
14#include <linux/of_device.h>
14 15
15 /* 16 /*
16 * Default CFG switch settings to use this driver: 17 * Default CFG switch settings to use this driver:
@@ -37,6 +38,15 @@
37/* SMDK has a 16.934MHZ crystal attached to WM8994 */ 38/* SMDK has a 16.934MHZ crystal attached to WM8994 */
38#define SMDK_WM8994_FREQ 16934000 39#define SMDK_WM8994_FREQ 16934000
39 40
41struct smdk_wm8994_data {
42 int mclk1_rate;
43};
44
45/* Default SMDKs */
46static struct smdk_wm8994_data smdk_board_data = {
47 .mclk1_rate = SMDK_WM8994_FREQ,
48};
49
40static int smdk_hw_params(struct snd_pcm_substream *substream, 50static int smdk_hw_params(struct snd_pcm_substream *substream,
41 struct snd_pcm_hw_params *params) 51 struct snd_pcm_hw_params *params)
42{ 52{
@@ -141,15 +151,28 @@ static struct snd_soc_card smdk = {
141 .num_links = ARRAY_SIZE(smdk_dai), 151 .num_links = ARRAY_SIZE(smdk_dai),
142}; 152};
143 153
154#ifdef CONFIG_OF
155static const struct of_device_id samsung_wm8994_of_match[] = {
156 { .compatible = "samsung,smdk-wm8994", .data = &smdk_board_data },
157 {},
158};
159MODULE_DEVICE_TABLE(of, samsung_wm8994_of_match);
160#endif /* CONFIG_OF */
144 161
145static int smdk_audio_probe(struct platform_device *pdev) 162static int smdk_audio_probe(struct platform_device *pdev)
146{ 163{
147 int ret; 164 int ret;
148 struct device_node *np = pdev->dev.of_node; 165 struct device_node *np = pdev->dev.of_node;
149 struct snd_soc_card *card = &smdk; 166 struct snd_soc_card *card = &smdk;
167 struct smdk_wm8994_data *board;
168 const struct of_device_id *id;
150 169
151 card->dev = &pdev->dev; 170 card->dev = &pdev->dev;
152 171
172 board = devm_kzalloc(&pdev->dev, sizeof(*board), GFP_KERNEL);
173 if (!board)
174 return -ENOMEM;
175
153 if (np) { 176 if (np) {
154 smdk_dai[0].cpu_dai_name = NULL; 177 smdk_dai[0].cpu_dai_name = NULL;
155 smdk_dai[0].cpu_of_node = of_parse_phandle(np, 178 smdk_dai[0].cpu_of_node = of_parse_phandle(np,
@@ -164,6 +187,12 @@ static int smdk_audio_probe(struct platform_device *pdev)
164 smdk_dai[0].platform_of_node = smdk_dai[0].cpu_of_node; 187 smdk_dai[0].platform_of_node = smdk_dai[0].cpu_of_node;
165 } 188 }
166 189
190 id = of_match_device(samsung_wm8994_of_match, &pdev->dev);
191 if (id)
192 *board = *((struct smdk_wm8994_data *)id->data);
193
194 platform_set_drvdata(pdev, board);
195
167 ret = snd_soc_register_card(card); 196 ret = snd_soc_register_card(card);
168 197
169 if (ret) 198 if (ret)
@@ -181,14 +210,6 @@ static int smdk_audio_remove(struct platform_device *pdev)
181 return 0; 210 return 0;
182} 211}
183 212
184#ifdef CONFIG_OF
185static const struct of_device_id samsung_wm8994_of_match[] = {
186 { .compatible = "samsung,smdk-wm8994", },
187 {},
188};
189MODULE_DEVICE_TABLE(of, samsung_wm8994_of_match);
190#endif /* CONFIG_OF */
191
192static struct platform_driver smdk_audio_driver = { 213static struct platform_driver smdk_audio_driver = {
193 .driver = { 214 .driver = {
194 .name = "smdk-audio-wm8894", 215 .name = "smdk-audio-wm8894",