diff options
author | Ian Molton <ian@mnementh.co.uk> | 2009-01-08 16:03:55 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-01-16 11:40:26 -0500 |
commit | a7e2e735dcf98717150d3c8eaa731de8038af05a (patch) | |
tree | 575640b85bdfaa0f40866a9d15a4d2fe51390259 /sound/soc/pxa | |
parent | 2aceefefc891e85d336c1d95d9d89fd785f5d44c (diff) |
ASoC: machine driver for Toshiba e750
This patch adds support for the wm9705 ac97 codec as used in the Toshiba e750
PDA. It includes support for powering up / down the external headphone and
speaker amplifiers on this machine.
Signed-off-by: Ian Molton <ian@mnementh.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/pxa')
-rw-r--r-- | sound/soc/pxa/Kconfig | 9 | ||||
-rw-r--r-- | sound/soc/pxa/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/pxa/e750_wm9705.c | 189 |
3 files changed, 200 insertions, 0 deletions
diff --git a/sound/soc/pxa/Kconfig b/sound/soc/pxa/Kconfig index f82e10699471..b9b1a3f5d673 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 | ||
64 | config SND_PXA2XX_SOC_E750 | ||
65 | tristate "SoC AC97 Audio support for e750" | ||
66 | depends on SND_PXA2XX_SOC && MACH_E750 | ||
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 e750 PDA | ||
72 | |||
64 | config SND_PXA2XX_SOC_E800 | 73 | config SND_PXA2XX_SOC_E800 |
65 | tristate "SoC AC97 Audio support for e800" | 74 | tristate "SoC AC97 Audio support for e800" |
66 | depends on SND_PXA2XX_SOC && MACH_E800 | 75 | depends on SND_PXA2XX_SOC && MACH_E800 |
diff --git a/sound/soc/pxa/Makefile b/sound/soc/pxa/Makefile index 08a9f2797729..c7d4cceeed92 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 | |||
13 | snd-soc-corgi-objs := corgi.o | 13 | snd-soc-corgi-objs := corgi.o |
14 | snd-soc-poodle-objs := poodle.o | 14 | snd-soc-poodle-objs := poodle.o |
15 | snd-soc-tosa-objs := tosa.o | 15 | snd-soc-tosa-objs := tosa.o |
16 | snd-soc-e750-objs := e750_wm9705.o | ||
16 | snd-soc-e800-objs := e800_wm9712.o | 17 | snd-soc-e800-objs := e800_wm9712.o |
17 | snd-soc-spitz-objs := spitz.o | 18 | snd-soc-spitz-objs := spitz.o |
18 | snd-soc-em-x270-objs := em-x270.o | 19 | snd-soc-em-x270-objs := em-x270.o |
@@ -22,6 +23,7 @@ snd-soc-zylonite-objs := zylonite.o | |||
22 | obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o | 23 | obj-$(CONFIG_SND_PXA2XX_SOC_CORGI) += snd-soc-corgi.o |
23 | obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o | 24 | obj-$(CONFIG_SND_PXA2XX_SOC_POODLE) += snd-soc-poodle.o |
24 | obj-$(CONFIG_SND_PXA2XX_SOC_TOSA) += snd-soc-tosa.o | 25 | obj-$(CONFIG_SND_PXA2XX_SOC_TOSA) += snd-soc-tosa.o |
26 | obj-$(CONFIG_SND_PXA2XX_SOC_E750) += snd-soc-e750.o | ||
25 | obj-$(CONFIG_SND_PXA2XX_SOC_E800) += snd-soc-e800.o | 27 | obj-$(CONFIG_SND_PXA2XX_SOC_E800) += snd-soc-e800.o |
26 | obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o | 28 | obj-$(CONFIG_SND_PXA2XX_SOC_SPITZ) += snd-soc-spitz.o |
27 | obj-$(CONFIG_SND_PXA2XX_SOC_EM_X270) += snd-soc-em-x270.o | 29 | obj-$(CONFIG_SND_PXA2XX_SOC_EM_X270) += snd-soc-em-x270.o |
diff --git a/sound/soc/pxa/e750_wm9705.c b/sound/soc/pxa/e750_wm9705.c new file mode 100644 index 000000000000..20fbdcfa9f78 --- /dev/null +++ b/sound/soc/pxa/e750_wm9705.c | |||
@@ -0,0 +1,189 @@ | |||
1 | /* | ||
2 | * e750-wm9705.c -- SoC audio for e750 | ||
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 | static int e750_spk_amp_event(struct snd_soc_dapm_widget *w, | ||
33 | struct snd_kcontrol *kcontrol, int event) | ||
34 | { | ||
35 | if (event & SND_SOC_DAPM_PRE_PMU) | ||
36 | gpio_set_value(GPIO_E750_SPK_AMP_OFF, 0); | ||
37 | else if (event & SND_SOC_DAPM_POST_PMD) | ||
38 | gpio_set_value(GPIO_E750_SPK_AMP_OFF, 1); | ||
39 | |||
40 | return 0; | ||
41 | } | ||
42 | |||
43 | static int e750_hp_amp_event(struct snd_soc_dapm_widget *w, | ||
44 | struct snd_kcontrol *kcontrol, int event) | ||
45 | { | ||
46 | if (event & SND_SOC_DAPM_PRE_PMU) | ||
47 | gpio_set_value(GPIO_E750_HP_AMP_OFF, 0); | ||
48 | else if (event & SND_SOC_DAPM_POST_PMD) | ||
49 | gpio_set_value(GPIO_E750_HP_AMP_OFF, 1); | ||
50 | |||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | static const struct snd_soc_dapm_widget e750_dapm_widgets[] = { | ||
55 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | ||
56 | SND_SOC_DAPM_SPK("Speaker", NULL), | ||
57 | SND_SOC_DAPM_MIC("Mic (Internal)", NULL), | ||
58 | SND_SOC_DAPM_PGA_E("Headphone Amp", SND_SOC_NOPM, 0, 0, NULL, 0, | ||
59 | e750_hp_amp_event, SND_SOC_DAPM_PRE_PMU | | ||
60 | SND_SOC_DAPM_POST_PMD), | ||
61 | SND_SOC_DAPM_PGA_E("Speaker Amp", SND_SOC_NOPM, 0, 0, NULL, 0, | ||
62 | e750_spk_amp_event, SND_SOC_DAPM_PRE_PMU | | ||
63 | SND_SOC_DAPM_POST_PMD), | ||
64 | }; | ||
65 | |||
66 | static const struct snd_soc_dapm_route audio_map[] = { | ||
67 | {"Headphone Amp", NULL, "HPOUTL"}, | ||
68 | {"Headphone Amp", NULL, "HPOUTR"}, | ||
69 | {"Headphone Jack", NULL, "Headphone Amp"}, | ||
70 | |||
71 | {"Speaker Amp", NULL, "MONOOUT"}, | ||
72 | {"Speaker", NULL, "Speaker Amp"}, | ||
73 | |||
74 | {"MIC1", NULL, "Mic (Internal)"}, | ||
75 | }; | ||
76 | |||
77 | static int e750_ac97_init(struct snd_soc_codec *codec) | ||
78 | { | ||
79 | snd_soc_dapm_nc_pin(codec, "LOUT"); | ||
80 | snd_soc_dapm_nc_pin(codec, "ROUT"); | ||
81 | snd_soc_dapm_nc_pin(codec, "PHONE"); | ||
82 | snd_soc_dapm_nc_pin(codec, "LINEINL"); | ||
83 | snd_soc_dapm_nc_pin(codec, "LINEINR"); | ||
84 | snd_soc_dapm_nc_pin(codec, "CDINL"); | ||
85 | snd_soc_dapm_nc_pin(codec, "CDINR"); | ||
86 | snd_soc_dapm_nc_pin(codec, "PCBEEP"); | ||
87 | snd_soc_dapm_nc_pin(codec, "MIC2"); | ||
88 | |||
89 | snd_soc_dapm_new_controls(codec, e750_dapm_widgets, | ||
90 | ARRAY_SIZE(e750_dapm_widgets)); | ||
91 | |||
92 | snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map)); | ||
93 | |||
94 | snd_soc_dapm_sync(codec); | ||
95 | |||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | static struct snd_soc_dai_link e750_dai[] = { | ||
100 | { | ||
101 | .name = "AC97", | ||
102 | .stream_name = "AC97 HiFi", | ||
103 | .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_HIFI], | ||
104 | .codec_dai = &wm9705_dai[WM9705_DAI_AC97_HIFI], | ||
105 | .init = e750_ac97_init, | ||
106 | /* use ops to check startup state */ | ||
107 | }, | ||
108 | { | ||
109 | .name = "AC97 Aux", | ||
110 | .stream_name = "AC97 Aux", | ||
111 | .cpu_dai = &pxa_ac97_dai[PXA2XX_DAI_AC97_AUX], | ||
112 | .codec_dai = &wm9705_dai[WM9705_DAI_AC97_AUX], | ||
113 | }, | ||
114 | }; | ||
115 | |||
116 | static struct snd_soc_card e750 = { | ||
117 | .name = "Toshiba e750", | ||
118 | .platform = &pxa2xx_soc_platform, | ||
119 | .dai_link = e750_dai, | ||
120 | .num_links = ARRAY_SIZE(e750_dai), | ||
121 | }; | ||
122 | |||
123 | static struct snd_soc_device e750_snd_devdata = { | ||
124 | .card = &e750, | ||
125 | .codec_dev = &soc_codec_dev_wm9705, | ||
126 | }; | ||
127 | |||
128 | static struct platform_device *e750_snd_device; | ||
129 | |||
130 | static int __init e750_init(void) | ||
131 | { | ||
132 | int ret; | ||
133 | |||
134 | if (!machine_is_e750()) | ||
135 | return -ENODEV; | ||
136 | |||
137 | ret = gpio_request(GPIO_E750_HP_AMP_OFF, "Headphone amp"); | ||
138 | if (ret) | ||
139 | return ret; | ||
140 | |||
141 | ret = gpio_request(GPIO_E750_SPK_AMP_OFF, "Speaker amp"); | ||
142 | if (ret) | ||
143 | goto free_hp_amp_gpio; | ||
144 | |||
145 | ret = gpio_direction_output(GPIO_E750_HP_AMP_OFF, 1); | ||
146 | if (ret) | ||
147 | goto free_spk_amp_gpio; | ||
148 | |||
149 | ret = gpio_direction_output(GPIO_E750_SPK_AMP_OFF, 1); | ||
150 | if (ret) | ||
151 | goto free_spk_amp_gpio; | ||
152 | |||
153 | e750_snd_device = platform_device_alloc("soc-audio", -1); | ||
154 | if (!e750_snd_device) { | ||
155 | ret = -ENOMEM; | ||
156 | goto free_spk_amp_gpio; | ||
157 | } | ||
158 | |||
159 | platform_set_drvdata(e750_snd_device, &e750_snd_devdata); | ||
160 | e750_snd_devdata.dev = &e750_snd_device->dev; | ||
161 | ret = platform_device_add(e750_snd_device); | ||
162 | |||
163 | if (!ret) | ||
164 | return 0; | ||
165 | |||
166 | /* Fail gracefully */ | ||
167 | platform_device_put(e750_snd_device); | ||
168 | free_spk_amp_gpio: | ||
169 | gpio_free(GPIO_E750_SPK_AMP_OFF); | ||
170 | free_hp_amp_gpio: | ||
171 | gpio_free(GPIO_E750_HP_AMP_OFF); | ||
172 | |||
173 | return ret; | ||
174 | } | ||
175 | |||
176 | static void __exit e750_exit(void) | ||
177 | { | ||
178 | platform_device_unregister(e750_snd_device); | ||
179 | gpio_free(GPIO_E750_SPK_AMP_OFF); | ||
180 | gpio_free(GPIO_E750_HP_AMP_OFF); | ||
181 | } | ||
182 | |||
183 | module_init(e750_init); | ||
184 | module_exit(e750_exit); | ||
185 | |||
186 | /* Module information */ | ||
187 | MODULE_AUTHOR("Ian Molton <spyro@f2s.com>"); | ||
188 | MODULE_DESCRIPTION("ALSA SoC driver for e750"); | ||
189 | MODULE_LICENSE("GPL v2"); | ||