2 * Machine driver for EVAL-ADAU1x61MINIZ 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_adau1x61_dapm_widgets
[] = {
22 SND_SOC_DAPM_LINE("In 1", NULL
),
23 SND_SOC_DAPM_LINE("In 2", NULL
),
24 SND_SOC_DAPM_LINE("In 3-4", NULL
),
26 SND_SOC_DAPM_LINE("Diff Out L", NULL
),
27 SND_SOC_DAPM_LINE("Diff Out R", NULL
),
28 SND_SOC_DAPM_LINE("Stereo Out", NULL
),
29 SND_SOC_DAPM_HP("Capless HP Out", NULL
),
32 static const struct snd_soc_dapm_route bfin_eval_adau1x61_dapm_routes
[] = {
33 { "LAUX", NULL
, "In 3-4" },
34 { "RAUX", NULL
, "In 3-4" },
35 { "LINP", NULL
, "In 1" },
36 { "LINN", NULL
, "In 1"},
37 { "RINP", NULL
, "In 2" },
38 { "RINN", NULL
, "In 2" },
40 { "In 1", NULL
, "MICBIAS" },
41 { "In 2", NULL
, "MICBIAS" },
43 { "Capless HP Out", NULL
, "LHP" },
44 { "Capless HP Out", NULL
, "RHP" },
45 { "Diff Out L", NULL
, "LOUT" },
46 { "Diff Out R", NULL
, "ROUT" },
47 { "Stereo Out", NULL
, "LOUT" },
48 { "Stereo Out", NULL
, "ROUT" },
51 static int bfin_eval_adau1x61_hw_params(struct snd_pcm_substream
*substream
,
52 struct snd_pcm_hw_params
*params
)
54 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
55 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
59 switch (params_rate(params
)) {
67 pll_rate
= 48000 * 1024;
76 pll_rate
= 44100 * 1024;
82 ret
= snd_soc_dai_set_pll(codec_dai
, ADAU17X1_PLL
,
83 ADAU17X1_PLL_SRC_MCLK
, 12288000, pll_rate
);
87 ret
= snd_soc_dai_set_sysclk(codec_dai
, ADAU17X1_CLK_SRC_PLL
, pll_rate
,
93 static const struct snd_soc_ops bfin_eval_adau1x61_ops
= {
94 .hw_params
= bfin_eval_adau1x61_hw_params
,
97 static struct snd_soc_dai_link bfin_eval_adau1x61_dai
= {
99 .stream_name
= "adau1x61",
100 .cpu_dai_name
= "bfin-i2s.0",
101 .codec_dai_name
= "adau-hifi",
102 .platform_name
= "bfin-i2s-pcm-audio",
103 .codec_name
= "adau1761.0-0038",
104 .ops
= &bfin_eval_adau1x61_ops
,
105 .dai_fmt
= SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
|
106 SND_SOC_DAIFMT_CBM_CFM
,
109 static struct snd_soc_card bfin_eval_adau1x61
= {
110 .name
= "bfin-eval-adau1x61",
111 .driver_name
= "eval-adau1x61",
112 .dai_link
= &bfin_eval_adau1x61_dai
,
115 .dapm_widgets
= bfin_eval_adau1x61_dapm_widgets
,
116 .num_dapm_widgets
= ARRAY_SIZE(bfin_eval_adau1x61_dapm_widgets
),
117 .dapm_routes
= bfin_eval_adau1x61_dapm_routes
,
118 .num_dapm_routes
= ARRAY_SIZE(bfin_eval_adau1x61_dapm_routes
),
119 .fully_routed
= true,
122 static int bfin_eval_adau1x61_probe(struct platform_device
*pdev
)
124 bfin_eval_adau1x61
.dev
= &pdev
->dev
;
126 return devm_snd_soc_register_card(&pdev
->dev
, &bfin_eval_adau1x61
);
129 static struct platform_driver bfin_eval_adau1x61_driver
= {
131 .name
= "bfin-eval-adau1x61",
132 .pm
= &snd_soc_pm_ops
,
134 .probe
= bfin_eval_adau1x61_probe
,
136 module_platform_driver(bfin_eval_adau1x61_driver
);
138 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
139 MODULE_DESCRIPTION("ALSA SoC bfin adau1x61 driver");
140 MODULE_LICENSE("GPL");
141 MODULE_ALIAS("platform:bfin-eval-adau1x61");