aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorIan Molton <ian@mnementh.co.uk>2009-01-17 10:11:06 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-01-19 11:15:41 -0500
commit28796eaf806502b9bd86cbacf8edbc14c80c14b0 (patch)
tree2b398373c2fe7b7b67b32f8868f83fabf3261dc9 /sound
parent2c782f5981a022f7a238d550af5daa75c8acf382 (diff)
ASoC: machine support for Toshiba e740 PDA
This patch provides suupport for the wm9705 AC97 codec on the Toshiba e740. Note: The e740 has a hard headphone switch that turns the speaker off and is not software detectable or controlable. Also both headphone and speaker amps share a common output enable. Signed-off-by: Ian Molton <ian@mnementh.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/pxa/Kconfig9
-rw-r--r--sound/soc/pxa/Makefile2
-rw-r--r--sound/soc/pxa/e740_wm9705.c213
3 files changed, 224 insertions, 0 deletions
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig
index b9b1a3f5d673..958ac3fe15d1 100644
--- a/sound/soc/pxa/Kconfig
+++ b/sound/soc/pxa/Kconfig
@@ -61,6 +61,15 @@ config SND_PXA2XX_SOC_TOSA
61 Say Y if you want to add support for SoC audio on Sharp 61 Say Y if you want to add support for SoC audio on Sharp
62 Zaurus SL-C6000x models (Tosa). 62 Zaurus SL-C6000x models (Tosa).
63 63
64config SND_PXA2XX_SOC_E740
65 tristate "SoC AC97 Audio support for e740"
66 depends on SND_PXA2XX_SOC && MACH_E740
67 select SND_SOC_WM9705
68 select SND_PXA2XX_SOC_AC97
69 help
70 Say Y if you want to add support for SoC audio on the
71 toshiba e740 PDA
72
64config SND_PXA2XX_SOC_E750 73config SND_PXA2XX_SOC_E750
65 tristate "SoC AC97 Audio support for e750" 74 tristate "SoC AC97 Audio support for e750"
66 depends on SND_PXA2XX_SOC && MACH_E750 75 depends on SND_PXA2XX_SOC && MACH_E750
diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile
index c7d4cceeed92..97a51a8c936c 100644
--- a/sound/soc/pxa/Makefile
+++ b/sound/soc/pxa/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_SND_PXA_SOC_SSP) += snd-soc-pxa-ssp.o
13snd-soc-corgi-objs := corgi.o 13snd-soc-corgi-objs := corgi.o
14snd-soc-poodle-objs := poodle.o 14snd-soc-poodle-objs := poodle.o
15snd-soc-tosa-objs := tosa.o 15snd-soc-tosa-objs := tosa.o
16snd-soc-e740-objs := e740_wm9705.o
16snd-soc-e750-objs := e750_wm9705.o 17snd-soc-e750-objs := e750_wm9705.o
17snd-soc-e800-objs := e800_wm9712.o 18snd-soc-e800-objs := e800_wm9712.o
18snd-soc-spitz-objs := spitz.o 19snd-soc-spitz-objs := spitz.o
@@ -23,6 +24,7 @@ snd-soc-zylonite-objs := zylonite.o
23obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o 24obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o
24obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o 25obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o
25obj-$(CONFIG_SND_PXA2XX_SOC_TOSA) += snd-soc-tosa.o 26obj-$(CONFIG_SND_PXA2XX_SOC_TOSA) += snd-soc-tosa.o
27obj-$(CONFIG_SND_PXA2XX_SOC_E740) += snd-soc-e740.o
26obj-$(CONFIG_SND_PXA2XX_SOC_E750) += snd-soc-e750.o 28obj-$(CONFIG_SND_PXA2XX_SOC_E750) += snd-soc-e750.o
27obj-$(CONFIG_SND_PXA2XX_SOC_E800) += snd-soc-e800.o 29obj-$(CONFIG_SND_PXA2XX_SOC_E800) += snd-soc-e800.o
28obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o 30obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o
diff --git a/sound/soc/pxa/e740_wm9705.c b/sound/soc/pxa/e740_wm9705.c
new file mode 100644
index 000000000000..ac3617651734
--- /dev/null
+++ b/sound/soc/pxa/e740_wm9705.c
@@ -0,0 +1,213 @@
1/*
2 * e740-wm9705.c -- SoC audio for e740
3 *
4 * Copyright 2007 (c) Ian Molton <spyro@f2s.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; version 2 ONLY.
9 *
10 */
11
12#include <linux/module.h>
13#include <linux/moduleparam.h>
14#include <linux/gpio.h>
15
16#include <sound/core.h>
17#include <sound/pcm.h>
18#include <sound/soc.h>
19#include <sound/soc-dapm.h>
20
21#include <mach/pxa-regs.h>
22#include <mach/hardware.h>
23#include <mach/audio.h>
24#include <mach/eseries-gpio.h>
25
26#include <asm/mach-types.h>
27
28#include "../codecs/wm9705.h"
29#include "pxa2xx-pcm.h"
30#include "pxa2xx-ac97.h"
31
32
33#define E740_AUDIO_OUT 1
34#define E740_AUDIO_IN 2
35
36static int e740_audio_power;
37
38static void e740_sync_audio_power(int status)
39{
40 gpio_set_value(GPIO_E740_WM9705_nAVDD2, !status);
41 gpio_set_value(GPIO_E740_AMP_ON, (status & E740_AUDIO_OUT) ? 1 : 0);
42 gpio_set_value(GPIO_E740_MIC_ON, (status & E740_AUDIO_IN) ? 1 : 0);
43}
44
45static int e740_mic_amp_event(struct snd_soc_dapm_widget *w,
46 struct snd_kcontrol *kcontrol, int event)
47{
48 if (event & SND_SOC_DAPM_PRE_PMU)
49 e740_audio_power |= E740_AUDIO_IN;
50 else if (event & SND_SOC_DAPM_POST_PMD)
51 e740_audio_power &= ~E740_AUDIO_IN;
52
53 e740_sync_audio_power(e740_audio_power);
54
55 return 0;
56}
57
58static int e740_output_amp_event(struct snd_soc_dapm_widget *w,
59 struct snd_kcontrol *kcontrol, int event)
60{
61 if (event & SND_SOC_DAPM_PRE_PMU)
62 e740_audio_power |= E740_AUDIO_OUT;
63 else if (event & SND_SOC_DAPM_POST_PMD)
64 e740_audio_power &= ~E740_AUDIO_OUT;
65
66 e740_sync_audio_power(e740_audio_power);
67
68 return 0;
69}
70
71static const struct snd_soc_dapm_widget e740_dapm_widgets[] = {
72 SND_SOC_DAPM_HP("Headphone Jack", NULL),
73 SND_SOC_DAPM_SPK("Speaker", NULL),
74 SND_SOC_DAPM_MIC("Mic (Internal)", NULL),
75 SND_SOC_DAPM_PGA_E("Output Amp", SND_SOC_NOPM, 0, 0, NULL, 0,
76 e740_output_amp_event, SND_SOC_DAPM_PRE_PMU |
77 SND_SOC_DAPM_POST_PMD),
78 SND_SOC_DAPM_PGA_E("Mic Amp", SND_SOC_NOPM, 0, 0, NULL, 0,
79 e740_mic_amp_event, SND_SOC_DAPM_PRE_PMU |
80 SND_SOC_DAPM_POST_PMD),
81};
82
83static const struct snd_soc_dapm_route audio_map[] = {
84 {"Output Amp", NULL, "LOUT"},
85 {"Output Amp", NULL, "ROUT"},
86 {"Output Amp", NULL, "MONOOUT"},
87
88 {"Speaker", NULL, "Output Amp"},
89 {"Headphone Jack", NULL, "Output Amp"},
90
91 {"MIC1", NULL, "Mic Amp"},
92 {"Mic Amp", NULL, "Mic (Internal)"},
93};
94
95static int e740_ac97_init(struct snd_soc_codec *codec)
96{
97 snd_soc_dapm_nc_pin(codec, "HPOUTL");
98 snd_soc_dapm_nc_pin(codec, "HPOUTR");
99 snd_soc_dapm_nc_pin(codec, "PHONE");
100 snd_soc_dapm_nc_pin(codec, "LINEINL");
101 snd_soc_dapm_nc_pin(codec, "LINEINR");
102 snd_soc_dapm_nc_pin(codec, "CDINL");
103 snd_soc_dapm_nc_pin(codec, "CDINR");
104 snd_soc_dapm_nc_pin(codec, "PCBEEP");
105 snd_soc_dapm_nc_pin(codec, "MIC2");
106
107 snd_soc_dapm_new_controls(codec, e740_dapm_widgets,
108 ARRAY_SIZE(e740_dapm_widgets));
109
110 snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
111
112 snd_soc_dapm_sync(codec);
113
114 return 0;
115}
116
117static struct snd_soc_dai_link e740_dai[] = {
118 {
119 .name = "AC97",
120 .stream_name = "AC97 HiFi",
121 .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI],
122 .codec_dai = &wm9705_dai[WM9705_DAI_AC97_HIFI],
123 .init = e740_ac97_init,
124 },
125 {
126 .name = "AC97 Aux",
127 .stream_name = "AC97 Aux",
128 .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX],
129 .codec_dai = &wm9705_dai[WM9705_DAI_AC97_AUX],
130 },
131};
132
133static struct snd_soc_card e740 = {
134 .name = "Toshiba e740",
135 .platform = &pxa2xx_soc_platform,
136 .dai_link = e740_dai,
137 .num_links = ARRAY_SIZE(e740_dai),
138};
139
140static struct snd_soc_device e740_snd_devdata = {
141 .card = &e740,
142 .codec_dev = &soc_codec_dev_wm9705,
143};
144
145static struct platform_device *e740_snd_device;
146
147static int __init e740_init(void)
148{
149 int ret;
150
151 if (!machine_is_e740())
152 return -ENODEV;
153
154 ret = gpio_request(GPIO_E740_MIC_ON, "Mic amp");
155 if (ret)
156 return ret;
157
158 ret = gpio_request(GPIO_E740_AMP_ON, "Output amp");
159 if (ret)
160 goto free_mic_amp_gpio;
161
162 ret = gpio_request(GPIO_E740_WM9705_nAVDD2, "Audio power");
163 if (ret)
164 goto free_op_amp_gpio;
165
166 /* Disable audio */
167 ret = gpio_direction_output(GPIO_E740_MIC_ON, 0);
168 if (ret)
169 goto free_apwr_gpio;
170 ret = gpio_direction_output(GPIO_E740_AMP_ON, 0);
171 if (ret)
172 goto free_apwr_gpio;
173 ret = gpio_direction_output(GPIO_E740_WM9705_nAVDD2, 1);
174 if (ret)
175 goto free_apwr_gpio;
176
177 e740_snd_device = platform_device_alloc("soc-audio", -1);
178 if (!e740_snd_device) {
179 ret = -ENOMEM;
180 goto free_apwr_gpio;
181 }
182
183 platform_set_drvdata(e740_snd_device, &e740_snd_devdata);
184 e740_snd_devdata.dev = &e740_snd_device->dev;
185 ret = platform_device_add(e740_snd_device);
186
187 if (!ret)
188 return 0;
189
190/* Fail gracefully */
191 platform_device_put(e740_snd_device);
192free_apwr_gpio:
193 gpio_free(GPIO_E740_WM9705_nAVDD2);
194free_op_amp_gpio:
195 gpio_free(GPIO_E740_AMP_ON);
196free_mic_amp_gpio:
197 gpio_free(GPIO_E740_MIC_ON);
198
199 return ret;
200}
201
202static void __exit e740_exit(void)
203{
204 platform_device_unregister(e740_snd_device);
205}
206
207module_init(e740_init);
208module_exit(e740_exit);
209
210/* Module information */
211MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
212MODULE_DESCRIPTION("ALSA SoC driver for e740");
213MODULE_LICENSE("GPL v2");