2 * e750-wm9705.c -- SoC audio for e750
4 * Copyright 2007 (c) Ian Molton <spyro@f2s.com>
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.
12 #include <linux/module.h>
13 #include <linux/moduleparam.h>
14 #include <linux/gpio.h>
16 #include <sound/core.h>
17 #include <sound/pcm.h>
18 #include <sound/soc.h>
20 #include <mach/audio.h>
21 #include <mach/eseries-gpio.h>
23 #include <asm/mach-types.h>
25 static int e750_spk_amp_event(struct snd_soc_dapm_widget
*w
,
26 struct snd_kcontrol
*kcontrol
, int event
)
28 if (event
& SND_SOC_DAPM_PRE_PMU
)
29 gpio_set_value(GPIO_E750_SPK_AMP_OFF
, 0);
30 else if (event
& SND_SOC_DAPM_POST_PMD
)
31 gpio_set_value(GPIO_E750_SPK_AMP_OFF
, 1);
36 static int e750_hp_amp_event(struct snd_soc_dapm_widget
*w
,
37 struct snd_kcontrol
*kcontrol
, int event
)
39 if (event
& SND_SOC_DAPM_PRE_PMU
)
40 gpio_set_value(GPIO_E750_HP_AMP_OFF
, 0);
41 else if (event
& SND_SOC_DAPM_POST_PMD
)
42 gpio_set_value(GPIO_E750_HP_AMP_OFF
, 1);
47 static const struct snd_soc_dapm_widget e750_dapm_widgets
[] = {
48 SND_SOC_DAPM_HP("Headphone Jack", NULL
),
49 SND_SOC_DAPM_SPK("Speaker", NULL
),
50 SND_SOC_DAPM_MIC("Mic (Internal)", NULL
),
51 SND_SOC_DAPM_PGA_E("Headphone Amp", SND_SOC_NOPM
, 0, 0, NULL
, 0,
52 e750_hp_amp_event
, SND_SOC_DAPM_PRE_PMU
|
53 SND_SOC_DAPM_POST_PMD
),
54 SND_SOC_DAPM_PGA_E("Speaker Amp", SND_SOC_NOPM
, 0, 0, NULL
, 0,
55 e750_spk_amp_event
, SND_SOC_DAPM_PRE_PMU
|
56 SND_SOC_DAPM_POST_PMD
),
59 static const struct snd_soc_dapm_route audio_map
[] = {
60 {"Headphone Amp", NULL
, "HPOUTL"},
61 {"Headphone Amp", NULL
, "HPOUTR"},
62 {"Headphone Jack", NULL
, "Headphone Amp"},
64 {"Speaker Amp", NULL
, "MONOOUT"},
65 {"Speaker", NULL
, "Speaker Amp"},
67 {"MIC1", NULL
, "Mic (Internal)"},
70 static struct snd_soc_dai_link e750_dai
[] = {
73 .stream_name
= "AC97 HiFi",
74 .cpu_dai_name
= "pxa2xx-ac97",
75 .codec_dai_name
= "wm9705-hifi",
76 .platform_name
= "pxa-pcm-audio",
77 .codec_name
= "wm9705-codec",
78 /* use ops to check startup state */
82 .stream_name
= "AC97 Aux",
83 .cpu_dai_name
= "pxa2xx-ac97-aux",
84 .codec_dai_name
= "wm9705-aux",
85 .platform_name
= "pxa-pcm-audio",
86 .codec_name
= "wm9705-codec",
90 static struct snd_soc_card e750
= {
91 .name
= "Toshiba e750",
94 .num_links
= ARRAY_SIZE(e750_dai
),
96 .dapm_widgets
= e750_dapm_widgets
,
97 .num_dapm_widgets
= ARRAY_SIZE(e750_dapm_widgets
),
98 .dapm_routes
= audio_map
,
99 .num_dapm_routes
= ARRAY_SIZE(audio_map
),
100 .fully_routed
= true,
103 static struct gpio e750_audio_gpios
[] = {
104 { GPIO_E750_HP_AMP_OFF
, GPIOF_OUT_INIT_HIGH
, "Headphone amp" },
105 { GPIO_E750_SPK_AMP_OFF
, GPIOF_OUT_INIT_HIGH
, "Speaker amp" },
108 static int e750_probe(struct platform_device
*pdev
)
110 struct snd_soc_card
*card
= &e750
;
113 ret
= gpio_request_array(e750_audio_gpios
,
114 ARRAY_SIZE(e750_audio_gpios
));
118 card
->dev
= &pdev
->dev
;
120 ret
= devm_snd_soc_register_card(&pdev
->dev
, card
);
122 dev_err(&pdev
->dev
, "snd_soc_register_card() failed: %d\n",
124 gpio_free_array(e750_audio_gpios
, ARRAY_SIZE(e750_audio_gpios
));
129 static int e750_remove(struct platform_device
*pdev
)
131 gpio_free_array(e750_audio_gpios
, ARRAY_SIZE(e750_audio_gpios
));
135 static struct platform_driver e750_driver
= {
137 .name
= "e750-audio",
138 .pm
= &snd_soc_pm_ops
,
141 .remove
= e750_remove
,
144 module_platform_driver(e750_driver
);
146 /* Module information */
147 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
148 MODULE_DESCRIPTION("ALSA SoC driver for e750");
149 MODULE_LICENSE("GPL v2");
150 MODULE_ALIAS("platform:e750-audio");