Revert "microblaze_mmu_v2: Update signal returning address"
[linux/fpc-iii.git] / sound / soc / pxa / brownstone.c
blob5e666e03d3331d39921a95bee2b5dc5e13c55230
1 /*
2 * linux/sound/soc/pxa/brownstone.c
4 * Copyright (C) 2011 Marvell International Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
13 #include <linux/module.h>
14 #include <sound/core.h>
15 #include <sound/pcm.h>
16 #include <sound/soc.h>
17 #include <sound/jack.h>
19 #include "../codecs/wm8994.h"
20 #include "mmp-sspa.h"
22 static const struct snd_kcontrol_new brownstone_dapm_control[] = {
23 SOC_DAPM_PIN_SWITCH("Ext Spk"),
26 static const struct snd_soc_dapm_widget brownstone_dapm_widgets[] = {
27 SND_SOC_DAPM_SPK("Ext Spk", NULL),
28 SND_SOC_DAPM_HP("Headset Stereophone", NULL),
29 SND_SOC_DAPM_MIC("Headset Mic", NULL),
30 SND_SOC_DAPM_MIC("Main Mic", NULL),
33 static const struct snd_soc_dapm_route brownstone_audio_map[] = {
34 {"Ext Spk", NULL, "SPKOUTLP"},
35 {"Ext Spk", NULL, "SPKOUTLN"},
36 {"Ext Spk", NULL, "SPKOUTRP"},
37 {"Ext Spk", NULL, "SPKOUTRN"},
39 {"Headset Stereophone", NULL, "HPOUT1L"},
40 {"Headset Stereophone", NULL, "HPOUT1R"},
42 {"IN1RN", NULL, "Headset Mic"},
44 {"DMIC1DAT", NULL, "MICBIAS1"},
45 {"MICBIAS1", NULL, "Main Mic"},
48 static int brownstone_wm8994_init(struct snd_soc_pcm_runtime *rtd)
50 struct snd_soc_codec *codec = rtd->codec;
51 struct snd_soc_dapm_context *dapm = &codec->dapm;
53 snd_soc_dapm_enable_pin(dapm, "Ext Spk");
54 snd_soc_dapm_enable_pin(dapm, "Headset Stereophone");
55 snd_soc_dapm_enable_pin(dapm, "Headset Mic");
56 snd_soc_dapm_enable_pin(dapm, "Main Mic");
58 /* set endpoints to not connected */
59 snd_soc_dapm_nc_pin(dapm, "HPOUT2P");
60 snd_soc_dapm_nc_pin(dapm, "HPOUT2N");
61 snd_soc_dapm_nc_pin(dapm, "LINEOUT1N");
62 snd_soc_dapm_nc_pin(dapm, "LINEOUT1P");
63 snd_soc_dapm_nc_pin(dapm, "LINEOUT2N");
64 snd_soc_dapm_nc_pin(dapm, "LINEOUT2P");
65 snd_soc_dapm_nc_pin(dapm, "IN1LN");
66 snd_soc_dapm_nc_pin(dapm, "IN1LP");
67 snd_soc_dapm_nc_pin(dapm, "IN1RP");
68 snd_soc_dapm_nc_pin(dapm, "IN2LP:VXRN");
69 snd_soc_dapm_nc_pin(dapm, "IN2RN");
70 snd_soc_dapm_nc_pin(dapm, "IN2RP:VXRP");
71 snd_soc_dapm_nc_pin(dapm, "IN2LN");
73 snd_soc_dapm_sync(dapm);
75 return 0;
78 static int brownstone_wm8994_hw_params(struct snd_pcm_substream *substream,
79 struct snd_pcm_hw_params *params)
81 struct snd_soc_pcm_runtime *rtd = substream->private_data;
82 struct snd_soc_dai *codec_dai = rtd->codec_dai;
83 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
84 int freq_out, sspa_mclk, sysclk;
85 int sspa_div;
87 if (params_rate(params) > 11025) {
88 freq_out = params_rate(params) * 512;
89 sysclk = params_rate(params) * 256;
90 sspa_mclk = params_rate(params) * 64;
91 } else {
92 freq_out = params_rate(params) * 1024;
93 sysclk = params_rate(params) * 512;
94 sspa_mclk = params_rate(params) * 64;
96 sspa_div = freq_out;
97 do_div(sspa_div, sspa_mclk);
99 snd_soc_dai_set_sysclk(cpu_dai, MMP_SSPA_CLK_AUDIO, freq_out, 0);
100 snd_soc_dai_set_pll(cpu_dai, MMP_SYSCLK, 0, freq_out, sysclk);
101 snd_soc_dai_set_pll(cpu_dai, MMP_SSPA_CLK, 0, freq_out, sspa_mclk);
103 /* set wm8994 sysclk */
104 snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1, sysclk, 0);
106 return 0;
109 /* machine stream operations */
110 static struct snd_soc_ops brownstone_ops = {
111 .hw_params = brownstone_wm8994_hw_params,
114 static struct snd_soc_dai_link brownstone_wm8994_dai[] = {
116 .name = "WM8994",
117 .stream_name = "WM8994 HiFi",
118 .cpu_dai_name = "mmp-sspa-dai.0",
119 .codec_dai_name = "wm8994-aif1",
120 .platform_name = "mmp-pcm-audio",
121 .codec_name = "wm8994-codec",
122 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
123 SND_SOC_DAIFMT_CBS_CFS,
124 .ops = &brownstone_ops,
125 .init = brownstone_wm8994_init,
129 /* audio machine driver */
130 static struct snd_soc_card brownstone = {
131 .name = "brownstone",
132 .dai_link = brownstone_wm8994_dai,
133 .num_links = ARRAY_SIZE(brownstone_wm8994_dai),
135 .controls = brownstone_dapm_control,
136 .num_controls = ARRAY_SIZE(brownstone_dapm_control),
137 .dapm_widgets = brownstone_dapm_widgets,
138 .num_dapm_widgets = ARRAY_SIZE(brownstone_dapm_widgets),
139 .dapm_routes = brownstone_audio_map,
140 .num_dapm_routes = ARRAY_SIZE(brownstone_audio_map),
143 static int __devinit brownstone_probe(struct platform_device *pdev)
145 int ret;
147 brownstone.dev = &pdev->dev;
148 ret = snd_soc_register_card(&brownstone);
149 if (ret)
150 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
151 ret);
152 return ret;
155 static int __devexit brownstone_remove(struct platform_device *pdev)
157 snd_soc_unregister_card(&brownstone);
158 return 0;
161 static struct platform_driver mmp_driver = {
162 .driver = {
163 .name = "brownstone-audio",
164 .owner = THIS_MODULE,
166 .probe = brownstone_probe,
167 .remove = __devexit_p(brownstone_remove),
170 module_platform_driver(mmp_driver);
172 MODULE_AUTHOR("Leo Yan <leoy@marvell.com>");
173 MODULE_DESCRIPTION("ALSA SoC Brownstone");
174 MODULE_LICENSE("GPL");