2 * Machine driver for EVAL-ADAU1x81 on Analog Devices bfin
5 * Copyright 2011-2014 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 <linux/slab.h>
14 #include <sound/core.h>
15 #include <sound/pcm.h>
16 #include <sound/soc.h>
17 #include <sound/pcm_params.h>
19 #include "../codecs/adau17x1.h"
21 static const struct snd_soc_dapm_widget bfin_eval_adau1x81_dapm_widgets
[] = {
22 SND_SOC_DAPM_LINE("Stereo In", NULL
),
23 SND_SOC_DAPM_LINE("Beep", NULL
),
25 SND_SOC_DAPM_SPK("Speaker", NULL
),
26 SND_SOC_DAPM_HP("Headphone", NULL
),
29 static const struct snd_soc_dapm_route bfin_eval_adau1x81_dapm_routes
[] = {
30 { "BEEP", NULL
, "Beep" },
31 { "LMIC", NULL
, "Stereo In" },
32 { "LMIC", NULL
, "Stereo In" },
34 { "Headphone", NULL
, "AOUTL" },
35 { "Headphone", NULL
, "AOUTR" },
36 { "Speaker", NULL
, "SP" },
39 static int bfin_eval_adau1x81_hw_params(struct snd_pcm_substream
*substream
,
40 struct snd_pcm_hw_params
*params
)
42 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
43 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
47 switch (params_rate(params
)) {
55 pll_rate
= 48000 * 1024;
64 pll_rate
= 44100 * 1024;
70 ret
= snd_soc_dai_set_pll(codec_dai
, ADAU17X1_PLL
,
71 ADAU17X1_PLL_SRC_MCLK
, 12288000, pll_rate
);
75 ret
= snd_soc_dai_set_sysclk(codec_dai
, ADAU17X1_CLK_SRC_PLL
, pll_rate
,
81 static const struct snd_soc_ops bfin_eval_adau1x81_ops
= {
82 .hw_params
= bfin_eval_adau1x81_hw_params
,
85 static struct snd_soc_dai_link bfin_eval_adau1x81_dai
= {
87 .stream_name
= "adau1x81",
88 .cpu_dai_name
= "bfin-i2s.0",
89 .codec_dai_name
= "adau-hifi",
90 .platform_name
= "bfin-i2s-pcm-audio",
91 .codec_name
= "adau1781.0-0038",
92 .ops
= &bfin_eval_adau1x81_ops
,
93 .dai_fmt
= SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
|
94 SND_SOC_DAIFMT_CBM_CFM
,
97 static struct snd_soc_card bfin_eval_adau1x81
= {
98 .name
= "bfin-eval-adau1x81",
99 .driver_name
= "eval-adau1x81",
100 .dai_link
= &bfin_eval_adau1x81_dai
,
103 .dapm_widgets
= bfin_eval_adau1x81_dapm_widgets
,
104 .num_dapm_widgets
= ARRAY_SIZE(bfin_eval_adau1x81_dapm_widgets
),
105 .dapm_routes
= bfin_eval_adau1x81_dapm_routes
,
106 .num_dapm_routes
= ARRAY_SIZE(bfin_eval_adau1x81_dapm_routes
),
107 .fully_routed
= true,
110 static int bfin_eval_adau1x81_probe(struct platform_device
*pdev
)
112 bfin_eval_adau1x81
.dev
= &pdev
->dev
;
114 return devm_snd_soc_register_card(&pdev
->dev
, &bfin_eval_adau1x81
);
117 static struct platform_driver bfin_eval_adau1x81_driver
= {
119 .name
= "bfin-eval-adau1x81",
120 .pm
= &snd_soc_pm_ops
,
122 .probe
= bfin_eval_adau1x81_probe
,
124 module_platform_driver(bfin_eval_adau1x81_driver
);
126 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
127 MODULE_DESCRIPTION("ALSA SoC bfin adau1x81 driver");
128 MODULE_LICENSE("GPL");
129 MODULE_ALIAS("platform:bfin-eval-adau1x81");