1 // SPDX-License-Identifier: GPL-2.0-only
3 * e800-wm9712.c -- SoC audio for e800
5 * Copyright 2007 (c) Ian Molton <spyro@f2s.com>
8 #include <linux/module.h>
9 #include <linux/moduleparam.h>
10 #include <linux/gpio.h>
12 #include <sound/core.h>
13 #include <sound/pcm.h>
14 #include <sound/soc.h>
16 #include <asm/mach-types.h>
17 #include <mach/audio.h>
18 #include <mach/eseries-gpio.h>
20 static int e800_spk_amp_event(struct snd_soc_dapm_widget
*w
,
21 struct snd_kcontrol
*kcontrol
, int event
)
23 if (event
& SND_SOC_DAPM_PRE_PMU
)
24 gpio_set_value(GPIO_E800_SPK_AMP_ON
, 1);
25 else if (event
& SND_SOC_DAPM_POST_PMD
)
26 gpio_set_value(GPIO_E800_SPK_AMP_ON
, 0);
31 static int e800_hp_amp_event(struct snd_soc_dapm_widget
*w
,
32 struct snd_kcontrol
*kcontrol
, int event
)
34 if (event
& SND_SOC_DAPM_PRE_PMU
)
35 gpio_set_value(GPIO_E800_HP_AMP_OFF
, 0);
36 else if (event
& SND_SOC_DAPM_POST_PMD
)
37 gpio_set_value(GPIO_E800_HP_AMP_OFF
, 1);
42 static const struct snd_soc_dapm_widget e800_dapm_widgets
[] = {
43 SND_SOC_DAPM_HP("Headphone Jack", NULL
),
44 SND_SOC_DAPM_MIC("Mic (Internal1)", NULL
),
45 SND_SOC_DAPM_MIC("Mic (Internal2)", NULL
),
46 SND_SOC_DAPM_SPK("Speaker", NULL
),
47 SND_SOC_DAPM_PGA_E("Headphone Amp", SND_SOC_NOPM
, 0, 0, NULL
, 0,
48 e800_hp_amp_event
, SND_SOC_DAPM_PRE_PMU
|
49 SND_SOC_DAPM_POST_PMD
),
50 SND_SOC_DAPM_PGA_E("Speaker Amp", SND_SOC_NOPM
, 0, 0, NULL
, 0,
51 e800_spk_amp_event
, SND_SOC_DAPM_PRE_PMU
|
52 SND_SOC_DAPM_POST_PMD
),
55 static const struct snd_soc_dapm_route audio_map
[] = {
56 {"Headphone Jack", NULL
, "HPOUTL"},
57 {"Headphone Jack", NULL
, "HPOUTR"},
58 {"Headphone Jack", NULL
, "Headphone Amp"},
60 {"Speaker Amp", NULL
, "MONOOUT"},
61 {"Speaker", NULL
, "Speaker Amp"},
63 {"MIC1", NULL
, "Mic (Internal1)"},
64 {"MIC2", NULL
, "Mic (Internal2)"},
68 SND_SOC_DAILINK_DEFS(ac97
,
69 DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97")),
70 DAILINK_COMP_ARRAY(COMP_CODEC("wm9712-codec", "wm9712-hifi")),
71 DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
73 SND_SOC_DAILINK_DEFS(ac97_aux
,
74 DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97-aux")),
75 DAILINK_COMP_ARRAY(COMP_CODEC("wm9712-codec", "wm9712-aux")),
76 DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
78 static struct snd_soc_dai_link e800_dai
[] = {
81 .stream_name
= "AC97 HiFi",
82 SND_SOC_DAILINK_REG(ac97
),
86 .stream_name
= "AC97 Aux",
87 SND_SOC_DAILINK_REG(ac97_aux
),
91 static struct snd_soc_card e800
= {
92 .name
= "Toshiba e800",
95 .num_links
= ARRAY_SIZE(e800_dai
),
97 .dapm_widgets
= e800_dapm_widgets
,
98 .num_dapm_widgets
= ARRAY_SIZE(e800_dapm_widgets
),
99 .dapm_routes
= audio_map
,
100 .num_dapm_routes
= ARRAY_SIZE(audio_map
),
103 static struct gpio e800_audio_gpios
[] = {
104 { GPIO_E800_SPK_AMP_ON
, GPIOF_OUT_INIT_HIGH
, "Headphone amp" },
105 { GPIO_E800_HP_AMP_OFF
, GPIOF_OUT_INIT_HIGH
, "Speaker amp" },
108 static int e800_probe(struct platform_device
*pdev
)
110 struct snd_soc_card
*card
= &e800
;
113 ret
= gpio_request_array(e800_audio_gpios
,
114 ARRAY_SIZE(e800_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(e800_audio_gpios
, ARRAY_SIZE(e800_audio_gpios
));
129 static int e800_remove(struct platform_device
*pdev
)
131 gpio_free_array(e800_audio_gpios
, ARRAY_SIZE(e800_audio_gpios
));
135 static struct platform_driver e800_driver
= {
137 .name
= "e800-audio",
138 .pm
= &snd_soc_pm_ops
,
141 .remove
= e800_remove
,
144 module_platform_driver(e800_driver
);
146 /* Module information */
147 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
148 MODULE_DESCRIPTION("ALSA SoC driver for e800");
149 MODULE_LICENSE("GPL v2");
150 MODULE_ALIAS("platform:e800-audio");