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
*codec_dai
= rtd
->codec_dai
;
40 ret
= snd_soc_dai_set_pll(codec_dai
, ADAV80X_PLL1
, ADAV80X_PLL_SRC_XTAL
,
41 27000000, params_rate(params
) * 256);
45 ret
= snd_soc_dai_set_sysclk(codec_dai
, ADAV80X_CLK_PLL1
,
46 params_rate(params
) * 256, SND_SOC_CLOCK_IN
);
51 static int bfin_eval_adav80x_codec_init(struct snd_soc_pcm_runtime
*rtd
)
53 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
55 snd_soc_dai_set_sysclk(codec_dai
, ADAV80X_CLK_SYSCLK1
, 0,
57 snd_soc_dai_set_sysclk(codec_dai
, ADAV80X_CLK_SYSCLK2
, 0,
59 snd_soc_dai_set_sysclk(codec_dai
, ADAV80X_CLK_SYSCLK3
, 0,
62 snd_soc_dai_set_sysclk(codec_dai
, ADAV80X_CLK_XTAL
, 2700000, 0);
67 static const struct snd_soc_ops bfin_eval_adav80x_ops
= {
68 .hw_params
= bfin_eval_adav80x_hw_params
,
71 static struct snd_soc_dai_link bfin_eval_adav80x_dais
[] = {
74 .stream_name
= "ADAV80x HiFi",
75 .cpu_dai_name
= "bfin-i2s.0",
76 .codec_dai_name
= "adav80x-hifi",
77 .platform_name
= "bfin-i2s-pcm-audio",
78 .init
= bfin_eval_adav80x_codec_init
,
79 .ops
= &bfin_eval_adav80x_ops
,
80 .dai_fmt
= SND_SOC_DAIFMT_I2S
| SND_SOC_DAIFMT_NB_NF
|
81 SND_SOC_DAIFMT_CBM_CFM
,
85 static struct snd_soc_card bfin_eval_adav80x
= {
86 .name
= "bfin-eval-adav80x",
88 .dai_link
= bfin_eval_adav80x_dais
,
89 .num_links
= ARRAY_SIZE(bfin_eval_adav80x_dais
),
91 .dapm_widgets
= bfin_eval_adav80x_dapm_widgets
,
92 .num_dapm_widgets
= ARRAY_SIZE(bfin_eval_adav80x_dapm_widgets
),
93 .dapm_routes
= bfin_eval_adav80x_dapm_routes
,
94 .num_dapm_routes
= ARRAY_SIZE(bfin_eval_adav80x_dapm_routes
),
97 enum bfin_eval_adav80x_type
{
102 static int bfin_eval_adav80x_probe(struct platform_device
*pdev
)
104 struct snd_soc_card
*card
= &bfin_eval_adav80x
;
105 const char *codec_name
;
107 switch (platform_get_device_id(pdev
)->driver_data
) {
108 case BFIN_EVAL_ADAV801
:
109 codec_name
= "spi0.1";
111 case BFIN_EVAL_ADAV803
:
112 codec_name
= "adav803.0-0034";
118 bfin_eval_adav80x_dais
[0].codec_name
= codec_name
;
120 card
->dev
= &pdev
->dev
;
122 return devm_snd_soc_register_card(&pdev
->dev
, &bfin_eval_adav80x
);
125 static const struct platform_device_id bfin_eval_adav80x_ids
[] = {
126 { "bfin-eval-adav801", BFIN_EVAL_ADAV801
},
127 { "bfin-eval-adav803", BFIN_EVAL_ADAV803
},
130 MODULE_DEVICE_TABLE(platform
, bfin_eval_adav80x_ids
);
132 static struct platform_driver bfin_eval_adav80x_driver
= {
134 .name
= "bfin-eval-adav80x",
135 .pm
= &snd_soc_pm_ops
,
137 .probe
= bfin_eval_adav80x_probe
,
138 .id_table
= bfin_eval_adav80x_ids
,
141 module_platform_driver(bfin_eval_adav80x_driver
);
143 MODULE_AUTHOR("Lars-Peter Clausen <lars@metafoo.de>");
144 MODULE_DESCRIPTION("ALSA SoC bfin adav80x driver");
145 MODULE_LICENSE("GPL");