2 * Machine driver for EVAL-ADAU1701MINIZ on Analog Devices bfin
5 * Copyright 2011 Analog Devices Inc.
6 * Author: Lars-Peter Clausen <lars@metafoo.de>
8 * Licensed under the GPL-2 or later.
11 #include <linux/module.h>
12 #include <linux/device.h>
13 #include <sound/core.h>
14 #include <sound/pcm.h>
15 #include <sound/soc.h>
16 #include <sound/pcm_params.h>
18 #include "../codecs/adau1701.h"
20 static const struct snd_soc_dapm_widget bfin_eval_adau1701_dapm_widgets
[] = {
21 SND_SOC_DAPM_SPK("Speaker", NULL
),
22 SND_SOC_DAPM_LINE("Line Out", NULL
),
23 SND_SOC_DAPM_LINE("Line In", NULL
),
26 static const struct snd_soc_dapm_route bfin_eval_adau1701_dapm_routes
[] = {
27 { "Speaker", NULL
, "OUT0" },
28 { "Speaker", NULL
, "OUT1" },
29 { "Line Out", NULL
, "OUT2" },
30 { "Line Out", NULL
, "OUT3" },
32 { "IN0", NULL
, "Line In" },
33 { "IN1", NULL
, "Line In" },
36 static int bfin_eval_adau1701_hw_params(struct snd_pcm_substream
*substream
,
37 struct snd_pcm_hw_params
*params
)
39 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
40 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
41 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
44 ret
= snd_soc_dai_set_fmt(cpu_dai
, SND_SOC_DAIFMT_I2S
|
45 SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBM_CFM
);
49 ret
= snd_soc_dai_set_fmt(codec_dai
, SND_SOC_DAIFMT_I2S
|
50 SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBM_CFM
);
54 ret
= snd_soc_dai_set_sysclk(codec_dai
, ADAU1701_CLK_SRC_OSC
, 12288000,
60 static struct snd_soc_ops bfin_eval_adau1701_ops
= {
61 .hw_params
= bfin_eval_adau1701_hw_params
,
64 static struct snd_soc_dai_link bfin_eval_adau1701_dai
[] = {
67 .stream_name
= "adau1701",
68 .cpu_dai_name
= "bfin-i2s.0",
69 .codec_dai_name
= "adau1701",
70 .platform_name
= "bfin-i2s-pcm-audio",
71 .codec_name
= "adau1701.0-0034",
72 .ops
= &bfin_eval_adau1701_ops
,
76 .stream_name
= "adau1701",
77 .cpu_dai_name
= "bfin-i2s.1",
78 .codec_dai_name
= "adau1701",
79 .platform_name
= "bfin-i2s-pcm-audio",
80 .codec_name
= "adau1701.0-0034",
81 .ops
= &bfin_eval_adau1701_ops
,
85 static struct snd_soc_card bfin_eval_adau1701
= {
86 .name
= "bfin-eval-adau1701",
87 .dai_link
= &bfin_eval_adau1701_dai
[CONFIG_SND_BF5XX_SPORT_NUM
],
90 .dapm_widgets
= bfin_eval_adau1701_dapm_widgets
,
91 .num_dapm_widgets
= ARRAY_SIZE(bfin_eval_adau1701_dapm_widgets
),
92 .dapm_routes
= bfin_eval_adau1701_dapm_routes
,
93 .num_dapm_routes
= ARRAY_SIZE(bfin_eval_adau1701_dapm_routes
),
96 static int bfin_eval_adau1701_probe(struct platform_device
*pdev
)
98 struct snd_soc_card
*card
= &bfin_eval_adau1701
;
100 card
->dev
= &pdev
->dev
;
102 return snd_soc_register_card(&bfin_eval_adau1701
);
105 static int __devexit
bfin_eval_adau1701_remove(struct platform_device
*pdev
)
107 struct snd_soc_card
*card
= platform_get_drvdata(pdev
);
109 snd_soc_unregister_card(card
);
114 static struct platform_driver bfin_eval_adau1701_driver
= {
116 .name
= "bfin-eval-adau1701",
117 .owner
= THIS_MODULE
,
118 .pm
= &snd_soc_pm_ops
,
120 .probe
= bfin_eval_adau1701_probe
,
121 .remove
= __devexit_p(bfin_eval_adau1701_remove
),
124 static int __init
bfin_eval_adau1701_init(void)
126 return platform_driver_register(&bfin_eval_adau1701_driver
);
128 module_init(bfin_eval_adau1701_init
);
130 static void __exit
bfin_eval_adau1701_exit(void)
132 platform_driver_unregister(&bfin_eval_adau1701_driver
);
134 module_exit(bfin_eval_adau1701_exit
);
136 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
137 MODULE_DESCRIPTION("ALSA SoC bfin ADAU1701 driver");
138 MODULE_LICENSE("GPL");
139 MODULE_ALIAS("platform:bfin-eval-adau1701");