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-audio",
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.4",
139 .codec_dai_name = "wm8994-aif1",
140 .platform_name = "samsung-audio",
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),
153 static struct platform_device *smdk_snd_device;
155 static int __init smdk_audio_init(void)
159 if (!of_machine_is_compatible("samsung,smdk5250"))
162 smdk_snd_device = platform_device_alloc("soc-audio", -1);
163 if (!smdk_snd_device)
166 platform_set_drvdata(smdk_snd_device, &smdk);
168 ret = platform_device_add(smdk_snd_device);
170 platform_device_put(smdk_snd_device);
174 module_init(smdk_audio_init);
176 static void __exit smdk_audio_exit(void)
178 platform_device_unregister(smdk_snd_device);
180 module_exit(smdk_audio_exit);
182 MODULE_DESCRIPTION("ALSA SoC SMDK WM8994");
183 MODULE_LICENSE("GPL");