2 * Machine driver for EVAL-ADAV801 and EVAL-ADAV803 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/init.h>
12 #include <linux/platform_device.h>
13 #include <linux/module.h>
14 #include <sound/core.h>
15 #include <sound/pcm.h>
16 #include <sound/soc.h>
18 #include "../codecs/adav80x.h"
20 static const struct snd_soc_dapm_widget bfin_eval_adav80x_dapm_widgets
[] = {
21 SND_SOC_DAPM_LINE("Line Out", NULL
),
22 SND_SOC_DAPM_LINE("Line In", NULL
),
25 static const struct snd_soc_dapm_route bfin_eval_adav80x_dapm_routes
[] = {
26 { "Line Out", NULL
, "VOUTL" },
27 { "Line Out", NULL
, "VOUTR" },
29 { "VINL", NULL
, "Line In" },
30 { "VINR", NULL
, "Line In" },
33 static int bfin_eval_adav80x_hw_params(struct snd_pcm_substream
*substream
,
34 struct snd_pcm_hw_params
*params
)
36 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
37 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
38 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
41 ret
= snd_soc_dai_set_fmt(cpu_dai
, SND_SOC_DAIFMT_I2S
|
42 SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBM_CFM
);
46 ret
= snd_soc_dai_set_fmt(codec_dai
, SND_SOC_DAIFMT_I2S
|
47 SND_SOC_DAIFMT_NB_NF
| SND_SOC_DAIFMT_CBM_CFM
);
51 ret
= snd_soc_dai_set_pll(codec_dai
, ADAV80X_PLL1
, ADAV80X_PLL_SRC_XTAL
,
52 27000000, params_rate(params
) * 256);
56 ret
= snd_soc_dai_set_sysclk(codec_dai
, ADAV80X_CLK_PLL1
,
57 params_rate(params
) * 256, SND_SOC_CLOCK_IN
);
62 static int bfin_eval_adav80x_codec_init(struct snd_soc_pcm_runtime
*rtd
)
64 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
66 snd_soc_dai_set_sysclk(codec_dai
, ADAV80X_CLK_SYSCLK1
, 0,
68 snd_soc_dai_set_sysclk(codec_dai
, ADAV80X_CLK_SYSCLK2
, 0,
70 snd_soc_dai_set_sysclk(codec_dai
, ADAV80X_CLK_SYSCLK3
, 0,
73 snd_soc_dai_set_sysclk(codec_dai
, ADAV80X_CLK_XTAL
, 2700000, 0);
78 static struct snd_soc_ops bfin_eval_adav80x_ops
= {
79 .hw_params
= bfin_eval_adav80x_hw_params
,
82 static struct snd_soc_dai_link bfin_eval_adav80x_dais
[] = {
85 .stream_name
= "ADAV80x HiFi",
86 .cpu_dai_name
= "bfin-i2s.0",
87 .codec_dai_name
= "adav80x-hifi",
88 .platform_name
= "bfin-i2s-pcm-audio",
89 .init
= bfin_eval_adav80x_codec_init
,
90 .ops
= &bfin_eval_adav80x_ops
,
94 static struct snd_soc_card bfin_eval_adav80x
= {
95 .name
= "bfin-eval-adav80x",
97 .dai_link
= bfin_eval_adav80x_dais
,
98 .num_links
= ARRAY_SIZE(bfin_eval_adav80x_dais
),
100 .dapm_widgets
= bfin_eval_adav80x_dapm_widgets
,
101 .num_dapm_widgets
= ARRAY_SIZE(bfin_eval_adav80x_dapm_widgets
),
102 .dapm_routes
= bfin_eval_adav80x_dapm_routes
,
103 .num_dapm_routes
= ARRAY_SIZE(bfin_eval_adav80x_dapm_routes
),
106 enum bfin_eval_adav80x_type
{
111 static int bfin_eval_adav80x_probe(struct platform_device
*pdev
)
113 struct snd_soc_card
*card
= &bfin_eval_adav80x
;
114 const char *codec_name
;
116 switch (platform_get_device_id(pdev
)->driver_data
) {
117 case BFIN_EVAL_ADAV801
:
118 codec_name
= "spi0.1";
120 case BFIN_EVAL_ADAV803
:
121 codec_name
= "adav803.0-0034";
127 bfin_eval_adav80x_dais
[0].codec_name
= codec_name
;
129 card
->dev
= &pdev
->dev
;
131 return snd_soc_register_card(&bfin_eval_adav80x
);
134 static int __devexit
bfin_eval_adav80x_remove(struct platform_device
*pdev
)
136 struct snd_soc_card
*card
= platform_get_drvdata(pdev
);
138 snd_soc_unregister_card(card
);
143 static const struct platform_device_id bfin_eval_adav80x_ids
[] = {
144 { "bfin-eval-adav801", BFIN_EVAL_ADAV801
},
145 { "bfin-eval-adav803", BFIN_EVAL_ADAV803
},
148 MODULE_DEVICE_TABLE(platform
, bfin_eval_adav80x_ids
);
150 static struct platform_driver bfin_eval_adav80x_driver
= {
152 .name
= "bfin-eval-adav80x",
153 .owner
= THIS_MODULE
,
154 .pm
= &snd_soc_pm_ops
,
156 .probe
= bfin_eval_adav80x_probe
,
157 .remove
= __devexit_p(bfin_eval_adav80x_remove
),
158 .id_table
= bfin_eval_adav80x_ids
,
161 module_platform_driver(bfin_eval_adav80x_driver
);
163 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
164 MODULE_DESCRIPTION("ALSA SoC bfin adav80x driver");
165 MODULE_LICENSE("GPL");