aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/davinci/davinci-evm.c
diff options
context:
space:
mode:
authorJyri Sarha <jsarha@ti.com>2013-09-17 05:26:00 -0400
committerMark Brown <broonie@linaro.org>2013-09-18 05:53:24 -0400
commitbcf25567ecec6cb0a8078cbf68969baed047fdf4 (patch)
treea46fed1a5bb480ea00a3a46c7d87345e12efefd0 /sound/soc/davinci/davinci-evm.c
parent272b98c6455f00884f0350f775c5342358ebb73f (diff)
ASoC: davinci-evm: Move sysclk logic away from evm_hw_params
The sysclk rate does not change runtime so it should be initialized at init time. Signed-off-by: Jyri Sarha <jsarha@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/davinci/davinci-evm.c')
-rw-r--r--sound/soc/davinci/davinci-evm.c64
1 files changed, 44 insertions, 20 deletions
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index fd7c45b9ed5a..2f8161c1d5f0 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -27,6 +27,10 @@
27#include "davinci-i2s.h" 27#include "davinci-i2s.h"
28#include "davinci-mcasp.h" 28#include "davinci-mcasp.h"
29 29
30struct snd_soc_card_drvdata_davinci {
31 unsigned sysclk;
32};
33
30#define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \ 34#define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \
31 SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF) 35 SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF)
32static int evm_hw_params(struct snd_pcm_substream *substream, 36static int evm_hw_params(struct snd_pcm_substream *substream,
@@ -35,27 +39,11 @@ static int evm_hw_params(struct snd_pcm_substream *substream,
35 struct snd_soc_pcm_runtime *rtd = substream->private_data; 39 struct snd_soc_pcm_runtime *rtd = substream->private_data;
36 struct snd_soc_dai *codec_dai = rtd->codec_dai; 40 struct snd_soc_dai *codec_dai = rtd->codec_dai;
37 struct snd_soc_dai *cpu_dai = rtd->cpu_dai; 41 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
42 struct snd_soc_codec *codec = rtd->codec;
43 struct snd_soc_card *soc_card = codec->card;
38 int ret = 0; 44 int ret = 0;
39 unsigned sysclk; 45 unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *)
40 46 snd_soc_card_get_drvdata(soc_card))->sysclk;
41 /* ASP1 on DM355 EVM is clocked by an external oscillator */
42 if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm() ||
43 machine_is_davinci_dm365_evm())
44 sysclk = 27000000;
45
46 /* ASP0 in DM6446 EVM is clocked by U55, as configured by
47 * board-dm644x-evm.c using GPIOs from U18. There are six
48 * options; here we "know" we use a 48 KHz sample rate.
49 */
50 else if (machine_is_davinci_evm())
51 sysclk = 12288000;
52
53 else if (machine_is_davinci_da830_evm() ||
54 machine_is_davinci_da850_evm())
55 sysclk = 24576000;
56
57 else
58 return -EINVAL;
59 47
60 /* set codec DAI configuration */ 48 /* set codec DAI configuration */
61 ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT); 49 ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT);
@@ -243,35 +231,65 @@ static struct snd_soc_dai_link da850_evm_dai = {
243}; 231};
244 232
245/* davinci dm6446 evm audio machine driver */ 233/* davinci dm6446 evm audio machine driver */
234/*
235 * ASP0 in DM6446 EVM is clocked by U55, as configured by
236 * board-dm644x-evm.c using GPIOs from U18. There are six
237 * options; here we "know" we use a 48 KHz sample rate.
238 */
239static struct snd_soc_card_drvdata_davinci dm6446_snd_soc_card_drvdata = {
240 .sysclk = 12288000,
241};
242
246static struct snd_soc_card dm6446_snd_soc_card_evm = { 243static struct snd_soc_card dm6446_snd_soc_card_evm = {
247 .name = "DaVinci DM6446 EVM", 244 .name = "DaVinci DM6446 EVM",
248 .owner = THIS_MODULE, 245 .owner = THIS_MODULE,
249 .dai_link = &dm6446_evm_dai, 246 .dai_link = &dm6446_evm_dai,
250 .num_links = 1, 247 .num_links = 1,
248 .drvdata = &dm6446_snd_soc_card_drvdata,
251}; 249};
252 250
253/* davinci dm355 evm audio machine driver */ 251/* davinci dm355 evm audio machine driver */
252/* ASP1 on DM355 EVM is clocked by an external oscillator */
253static struct snd_soc_card_drvdata_davinci dm355_snd_soc_card_drvdata = {
254 .sysclk = 27000000,
255};
256
254static struct snd_soc_card dm355_snd_soc_card_evm = { 257static struct snd_soc_card dm355_snd_soc_card_evm = {
255 .name = "DaVinci DM355 EVM", 258 .name = "DaVinci DM355 EVM",
256 .owner = THIS_MODULE, 259 .owner = THIS_MODULE,
257 .dai_link = &dm355_evm_dai, 260 .dai_link = &dm355_evm_dai,
258 .num_links = 1, 261 .num_links = 1,
262 .drvdata = &dm355_snd_soc_card_drvdata,
259}; 263};
260 264
261/* davinci dm365 evm audio machine driver */ 265/* davinci dm365 evm audio machine driver */
266static struct snd_soc_card_drvdata_davinci dm365_snd_soc_card_drvdata = {
267 .sysclk = 27000000,
268};
269
262static struct snd_soc_card dm365_snd_soc_card_evm = { 270static struct snd_soc_card dm365_snd_soc_card_evm = {
263 .name = "DaVinci DM365 EVM", 271 .name = "DaVinci DM365 EVM",
264 .owner = THIS_MODULE, 272 .owner = THIS_MODULE,
265 .dai_link = &dm365_evm_dai, 273 .dai_link = &dm365_evm_dai,
266 .num_links = 1, 274 .num_links = 1,
275 .drvdata = &dm365_snd_soc_card_drvdata,
267}; 276};
268 277
269/* davinci dm6467 evm audio machine driver */ 278/* davinci dm6467 evm audio machine driver */
279static struct snd_soc_card_drvdata_davinci dm6467_snd_soc_card_drvdata = {
280 .sysclk = 27000000,
281};
282
270static struct snd_soc_card dm6467_snd_soc_card_evm = { 283static struct snd_soc_card dm6467_snd_soc_card_evm = {
271 .name = "DaVinci DM6467 EVM", 284 .name = "DaVinci DM6467 EVM",
272 .owner = THIS_MODULE, 285 .owner = THIS_MODULE,
273 .dai_link = dm6467_evm_dai, 286 .dai_link = dm6467_evm_dai,
274 .num_links = ARRAY_SIZE(dm6467_evm_dai), 287 .num_links = ARRAY_SIZE(dm6467_evm_dai),
288 .drvdata = &dm6467_snd_soc_card_drvdata,
289};
290
291static struct snd_soc_card_drvdata_davinci da830_snd_soc_card_drvdata = {
292 .sysclk = 24576000,
275}; 293};
276 294
277static struct snd_soc_card da830_snd_soc_card = { 295static struct snd_soc_card da830_snd_soc_card = {
@@ -279,6 +297,11 @@ static struct snd_soc_card da830_snd_soc_card = {
279 .owner = THIS_MODULE, 297 .owner = THIS_MODULE,
280 .dai_link = &da830_evm_dai, 298 .dai_link = &da830_evm_dai,
281 .num_links = 1, 299 .num_links = 1,
300 .drvdata = &da830_snd_soc_card_drvdata,
301};
302
303static struct snd_soc_card_drvdata_davinci da850_snd_soc_card_drvdata = {
304 .sysclk = 24576000,
282}; 305};
283 306
284static struct snd_soc_card da850_snd_soc_card = { 307static struct snd_soc_card da850_snd_soc_card = {
@@ -286,6 +309,7 @@ static struct snd_soc_card da850_snd_soc_card = {
286 .owner = THIS_MODULE, 309 .owner = THIS_MODULE,
287 .dai_link = &da850_evm_dai, 310 .dai_link = &da850_evm_dai,
288 .num_links = 1, 311 .num_links = 1,
312 .drvdata = &da850_snd_soc_card_drvdata,
289}; 313};
290 314
291static struct platform_device *evm_snd_device; 315static struct platform_device *evm_snd_device;