4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
10 #include "../codecs/wm8994.h"
11 #include <sound/pcm_params.h>
12 #include <linux/module.h>
16 * Default CFG switch settings to use this driver:
17 * SMDKV310: CFG5-1000, CFG7-111111
21 * Configure audio route as :-
22 * $ amixer sset 'DAC1' on,on
23 * $ amixer sset 'Right Headphone Mux' 'DAC'
24 * $ amixer sset 'Left Headphone Mux' 'DAC'
25 * $ amixer sset 'DAC1R Mixer AIF1.1' on
26 * $ amixer sset 'DAC1L Mixer AIF1.1' on
27 * $ amixer sset 'IN2L' on
28 * $ amixer sset 'IN2L PGA IN2LN' on
29 * $ amixer sset 'MIXINL IN2L' on
30 * $ amixer sset 'AIF1ADC1L Mixer ADC/DMIC' on
31 * $ amixer sset 'IN2R' on
32 * $ amixer sset 'IN2R PGA IN2RN' on
33 * $ amixer sset 'MIXINR IN2R' on
34 * $ amixer sset 'AIF1ADC1R Mixer ADC/DMIC' on
37 /* SMDK has a 16.934MHZ crystal attached to WM8994 */
38 #define SMDK_WM8994_FREQ 16934000
40 static int smdk_hw_params(struct snd_pcm_substream
*substream
,
41 struct snd_pcm_hw_params
*params
)
43 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
44 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
45 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
49 /* AIF1CLK should be >=3MHz for optimal performance */
50 if (params_format(params
) == SNDRV_PCM_FORMAT_S24_LE
)
51 pll_out
= params_rate(params
) * 384;
52 else if (params_rate(params
) == 8000 || params_rate(params
) == 11025)
53 pll_out
= params_rate(params
) * 512;
55 pll_out
= params_rate(params
) * 256;
57 ret
= snd_soc_dai_set_fmt(codec_dai
, SND_SOC_DAIFMT_I2S
58 | SND_SOC_DAIFMT_NB_NF
59 | SND_SOC_DAIFMT_CBM_CFM
);
63 ret
= snd_soc_dai_set_fmt(cpu_dai
, SND_SOC_DAIFMT_I2S
64 | SND_SOC_DAIFMT_NB_NF
65 | SND_SOC_DAIFMT_CBM_CFM
);
69 ret
= snd_soc_dai_set_pll(codec_dai
, WM8994_FLL1
, WM8994_FLL_SRC_MCLK1
,
70 SMDK_WM8994_FREQ
, pll_out
);
74 ret
= snd_soc_dai_set_sysclk(codec_dai
, WM8994_SYSCLK_FLL1
,
75 pll_out
, SND_SOC_CLOCK_IN
);
83 * SMDK WM8994 DAI operations.
85 static struct snd_soc_ops smdk_ops
= {
86 .hw_params
= smdk_hw_params
,
89 static int smdk_wm8994_init_paiftx(struct snd_soc_pcm_runtime
*rtd
)
91 struct snd_soc_codec
*codec
= rtd
->codec
;
92 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
95 snd_soc_dapm_enable_pin(dapm
, "HPOUT1R");
96 snd_soc_dapm_enable_pin(dapm
, "HPOUT1L");
99 snd_soc_dapm_enable_pin(dapm
, "IN1LN");
100 snd_soc_dapm_enable_pin(dapm
, "IN1RN");
103 snd_soc_dapm_enable_pin(dapm
, "IN2LN");
104 snd_soc_dapm_enable_pin(dapm
, "IN2RN");
107 snd_soc_dapm_nc_pin(dapm
, "HPOUT2P");
108 snd_soc_dapm_nc_pin(dapm
, "HPOUT2N");
109 snd_soc_dapm_nc_pin(dapm
, "SPKOUTLN");
110 snd_soc_dapm_nc_pin(dapm
, "SPKOUTLP");
111 snd_soc_dapm_nc_pin(dapm
, "SPKOUTRP");
112 snd_soc_dapm_nc_pin(dapm
, "SPKOUTRN");
113 snd_soc_dapm_nc_pin(dapm
, "LINEOUT1N");
114 snd_soc_dapm_nc_pin(dapm
, "LINEOUT1P");
115 snd_soc_dapm_nc_pin(dapm
, "LINEOUT2N");
116 snd_soc_dapm_nc_pin(dapm
, "LINEOUT2P");
117 snd_soc_dapm_nc_pin(dapm
, "IN1LP");
118 snd_soc_dapm_nc_pin(dapm
, "IN2LP:VXRN");
119 snd_soc_dapm_nc_pin(dapm
, "IN1RP");
120 snd_soc_dapm_nc_pin(dapm
, "IN2RP:VXRP");
125 static struct snd_soc_dai_link smdk_dai
[] = {
126 { /* Primary DAI i/f */
127 .name
= "WM8994 AIF1",
128 .stream_name
= "Pri_Dai",
129 .cpu_dai_name
= "samsung-i2s.0",
130 .codec_dai_name
= "wm8994-aif1",
131 .platform_name
= "samsung-i2s.0",
132 .codec_name
= "wm8994-codec",
133 .init
= smdk_wm8994_init_paiftx
,
135 }, { /* Sec_Fifo Playback i/f */
136 .name
= "Sec_FIFO TX",
137 .stream_name
= "Sec_Dai",
138 .cpu_dai_name
= "samsung-i2s-sec",
139 .codec_dai_name
= "wm8994-aif1",
140 .platform_name
= "samsung-i2s-sec",
141 .codec_name
= "wm8994-codec",
146 static struct snd_soc_card smdk
= {
148 .owner
= THIS_MODULE
,
149 .dai_link
= smdk_dai
,
150 .num_links
= ARRAY_SIZE(smdk_dai
),
154 static int smdk_audio_probe(struct platform_device
*pdev
)
157 struct device_node
*np
= pdev
->dev
.of_node
;
158 struct snd_soc_card
*card
= &smdk
;
160 card
->dev
= &pdev
->dev
;
163 smdk_dai
[0].cpu_dai_name
= NULL
;
164 smdk_dai
[0].cpu_of_node
= of_parse_phandle(np
,
165 "samsung,i2s-controller", 0);
166 if (!smdk_dai
[0].cpu_of_node
) {
168 "Property 'samsung,i2s-controller' missing or invalid\n");
172 smdk_dai
[0].platform_name
= NULL
;
173 smdk_dai
[0].platform_of_node
= smdk_dai
[0].cpu_of_node
;
176 ret
= snd_soc_register_card(card
);
179 dev_err(&pdev
->dev
, "snd_soc_register_card() failed:%d\n", ret
);
184 static int smdk_audio_remove(struct platform_device
*pdev
)
186 struct snd_soc_card
*card
= platform_get_drvdata(pdev
);
188 snd_soc_unregister_card(card
);
194 static const struct of_device_id samsung_wm8994_of_match
[] = {
195 { .compatible
= "samsung,smdk-wm8994", },
198 MODULE_DEVICE_TABLE(of
, samsung_wm8994_of_match
);
199 #endif /* CONFIG_OF */
201 static struct platform_driver smdk_audio_driver
= {
203 .name
= "smdk-audio",
204 .owner
= THIS_MODULE
,
205 .of_match_table
= of_match_ptr(samsung_wm8994_of_match
),
207 .probe
= smdk_audio_probe
,
208 .remove
= smdk_audio_remove
,
211 module_platform_driver(smdk_audio_driver
);
213 MODULE_DESCRIPTION("ALSA SoC SMDK WM8994");
214 MODULE_LICENSE("GPL");
215 MODULE_ALIAS("platform:smdk-audio");