diff options
author | Zhangfei Gao <zhangfei.gao@marvell.com> | 2012-06-11 06:04:40 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-13 08:16:13 -0400 |
commit | 5ebf20ae286a7d2b02551757166247a901d705e5 (patch) | |
tree | 91bd6076fa069d2a122162083fa2b86fe5fe542d /sound/soc/pxa | |
parent | fa375d42f0e531b7ca4316ea9fd5444e01d585e8 (diff) |
ASoC: add mmp brownstone support
Adds Alsa audio platform driver for mmp brownstone machine
Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
Signed-off-by: Leo Yan <leoy@marvell.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/pxa')
-rw-r--r-- | sound/soc/pxa/Kconfig | 10 | ||||
-rw-r--r-- | sound/soc/pxa/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/pxa/brownstone.c | 174 |
3 files changed, 186 insertions, 0 deletions
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig index 6c3d00b8ea0b..d389fd574efe 100644 --- a/sound/soc/pxa/Kconfig +++ b/sound/soc/pxa/Kconfig | |||
@@ -206,3 +206,13 @@ config SND_PXA2XX_SOC_IMOTE2 | |||
206 | help | 206 | help |
207 | Say Y if you want to add support for SoC audio on the | 207 | Say Y if you want to add support for SoC audio on the |
208 | IMote 2. | 208 | IMote 2. |
209 | |||
210 | config SND_MMP_SOC_BROWNSTONE | ||
211 | tristate "SoC Audio support for Marvell Brownstone" | ||
212 | depends on SND_MMP_SOC && MACH_BROWNSTONE | ||
213 | select SND_MMP_SOC_SSPA | ||
214 | select MFD_WM8994 | ||
215 | select SND_SOC_WM8994 | ||
216 | help | ||
217 | Say Y if you want to add support for SoC audio on the | ||
218 | Marvell Brownstone reference platform. | ||
diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile index 07b841746fc3..c12aa2a9bf74 100644 --- a/sound/soc/pxa/Makefile +++ b/sound/soc/pxa/Makefile | |||
@@ -32,6 +32,7 @@ snd-soc-mioa701-objs := mioa701_wm9713.o | |||
32 | snd-soc-z2-objs := z2.o | 32 | snd-soc-z2-objs := z2.o |
33 | snd-soc-imote2-objs := imote2.o | 33 | snd-soc-imote2-objs := imote2.o |
34 | snd-soc-raumfeld-objs := raumfeld.o | 34 | snd-soc-raumfeld-objs := raumfeld.o |
35 | snd-soc-brownstone-objs := brownstone.o | ||
35 | 36 | ||
36 | obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o | 37 | obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o |
37 | obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o | 38 | obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o |
@@ -51,3 +52,4 @@ obj-$(CONFIG_SND_SOC_TAVOREVB3) += snd-soc-tavorevb3.o | |||
51 | obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o | 52 | obj-$(CONFIG_SND_SOC_ZYLONITE) += snd-soc-zylonite.o |
52 | obj-$(CONFIG_SND_PXA2XX_SOC_IMOTE2) += snd-soc-imote2.o | 53 | obj-$(CONFIG_SND_PXA2XX_SOC_IMOTE2) += snd-soc-imote2.o |
53 | obj-$(CONFIG_SND_SOC_RAUMFELD) += snd-soc-raumfeld.o | 54 | obj-$(CONFIG_SND_SOC_RAUMFELD) += snd-soc-raumfeld.o |
55 | obj-$(CONFIG_SND_MMP_SOC_BROWNSTONE) += snd-soc-brownstone.o | ||
diff --git a/sound/soc/pxa/brownstone.c b/sound/soc/pxa/brownstone.c new file mode 100644 index 000000000000..5e666e03d333 --- /dev/null +++ b/sound/soc/pxa/brownstone.c | |||
@@ -0,0 +1,174 @@ | |||
1 | /* | ||
2 | * linux/sound/soc/pxa/brownstone.c | ||
3 | * | ||
4 | * Copyright (C) 2011 Marvell International Ltd. | ||
5 | * | ||
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. | ||
10 | * | ||
11 | */ | ||
12 | |||
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> | ||
18 | |||
19 | #include "../codecs/wm8994.h" | ||
20 | #include "mmp-sspa.h" | ||
21 | |||
22 | static const struct snd_kcontrol_new brownstone_dapm_control[] = { | ||
23 | SOC_DAPM_PIN_SWITCH("Ext Spk"), | ||
24 | }; | ||
25 | |||
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), | ||
31 | }; | ||
32 | |||
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"}, | ||
38 | |||
39 | {"Headset Stereophone", NULL, "HPOUT1L"}, | ||
40 | {"Headset Stereophone", NULL, "HPOUT1R"}, | ||
41 | |||
42 | {"IN1RN", NULL, "Headset Mic"}, | ||
43 | |||
44 | {"DMIC1DAT", NULL, "MICBIAS1"}, | ||
45 | {"MICBIAS1", NULL, "Main Mic"}, | ||
46 | }; | ||
47 | |||
48 | static int brownstone_wm8994_init(struct snd_soc_pcm_runtime *rtd) | ||
49 | { | ||
50 | struct snd_soc_codec *codec = rtd->codec; | ||
51 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
52 | |||
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"); | ||
57 | |||
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"); | ||
72 | |||
73 | snd_soc_dapm_sync(dapm); | ||
74 | |||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | static int brownstone_wm8994_hw_params(struct snd_pcm_substream *substream, | ||
79 | struct snd_pcm_hw_params *params) | ||
80 | { | ||
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; | ||
86 | |||
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; | ||
95 | } | ||
96 | sspa_div = freq_out; | ||
97 | do_div(sspa_div, sspa_mclk); | ||
98 | |||
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); | ||
102 | |||
103 | /* set wm8994 sysclk */ | ||
104 | snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK1, sysclk, 0); | ||
105 | |||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | /* machine stream operations */ | ||
110 | static struct snd_soc_ops brownstone_ops = { | ||
111 | .hw_params = brownstone_wm8994_hw_params, | ||
112 | }; | ||
113 | |||
114 | static struct snd_soc_dai_link brownstone_wm8994_dai[] = { | ||
115 | { | ||
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, | ||
126 | }, | ||
127 | }; | ||
128 | |||
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), | ||
134 | |||
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), | ||
141 | }; | ||
142 | |||
143 | static int __devinit brownstone_probe(struct platform_device *pdev) | ||
144 | { | ||
145 | int ret; | ||
146 | |||
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; | ||
153 | } | ||
154 | |||
155 | static int __devexit brownstone_remove(struct platform_device *pdev) | ||
156 | { | ||
157 | snd_soc_unregister_card(&brownstone); | ||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | static struct platform_driver mmp_driver = { | ||
162 | .driver = { | ||
163 | .name = "brownstone-audio", | ||
164 | .owner = THIS_MODULE, | ||
165 | }, | ||
166 | .probe = brownstone_probe, | ||
167 | .remove = __devexit_p(brownstone_remove), | ||
168 | }; | ||
169 | |||
170 | module_platform_driver(mmp_driver); | ||
171 | |||
172 | MODULE_AUTHOR("Leo Yan <leoy@marvell.com>"); | ||
173 | MODULE_DESCRIPTION("ALSA SoC Brownstone"); | ||
174 | MODULE_LICENSE("GPL"); | ||