1 // SPDX-License-Identifier: GPL-2.0-only
3 * e750-wm9705.c -- SoC audio for e750
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 <mach/audio.h>
17 #include <mach/eseries-gpio.h>
19 #include <asm/mach-types.h>
21 static int e750_spk_amp_event(struct snd_soc_dapm_widget
*w
,
22 struct snd_kcontrol
*kcontrol
, int event
)
24 if (event
& SND_SOC_DAPM_PRE_PMU
)
25 gpio_set_value(GPIO_E750_SPK_AMP_OFF
, 0);
26 else if (event
& SND_SOC_DAPM_POST_PMD
)
27 gpio_set_value(GPIO_E750_SPK_AMP_OFF
, 1);
32 static int e750_hp_amp_event(struct snd_soc_dapm_widget
*w
,
33 struct snd_kcontrol
*kcontrol
, int event
)
35 if (event
& SND_SOC_DAPM_PRE_PMU
)
36 gpio_set_value(GPIO_E750_HP_AMP_OFF
, 0);
37 else if (event
& SND_SOC_DAPM_POST_PMD
)
38 gpio_set_value(GPIO_E750_HP_AMP_OFF
, 1);
43 static const struct snd_soc_dapm_widget e750_dapm_widgets
[] = {
44 SND_SOC_DAPM_HP("Headphone Jack", NULL
),
45 SND_SOC_DAPM_SPK("Speaker", NULL
),
46 SND_SOC_DAPM_MIC("Mic (Internal)", NULL
),
47 SND_SOC_DAPM_PGA_E("Headphone Amp", SND_SOC_NOPM
, 0, 0, NULL
, 0,
48 e750_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 e750_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 Amp", NULL
, "HPOUTL"},
57 {"Headphone Amp", NULL
, "HPOUTR"},
58 {"Headphone Jack", NULL
, "Headphone Amp"},
60 {"Speaker Amp", NULL
, "MONOOUT"},
61 {"Speaker", NULL
, "Speaker Amp"},
63 {"MIC1", NULL
, "Mic (Internal)"},
66 static struct snd_soc_dai_link e750_dai
[] = {
69 .stream_name
= "AC97 HiFi",
70 .cpu_dai_name
= "pxa2xx-ac97",
71 .codec_dai_name
= "wm9705-hifi",
72 .platform_name
= "pxa-pcm-audio",
73 .codec_name
= "wm9705-codec",
74 /* use ops to check startup state */
78 .stream_name
= "AC97 Aux",
79 .cpu_dai_name
= "pxa2xx-ac97-aux",
80 .codec_dai_name
= "wm9705-aux",
81 .platform_name
= "pxa-pcm-audio",
82 .codec_name
= "wm9705-codec",
86 static struct snd_soc_card e750
= {
87 .name
= "Toshiba e750",
90 .num_links
= ARRAY_SIZE(e750_dai
),
92 .dapm_widgets
= e750_dapm_widgets
,
93 .num_dapm_widgets
= ARRAY_SIZE(e750_dapm_widgets
),
94 .dapm_routes
= audio_map
,
95 .num_dapm_routes
= ARRAY_SIZE(audio_map
),
99 static struct gpio e750_audio_gpios
[] = {
100 { GPIO_E750_HP_AMP_OFF
, GPIOF_OUT_INIT_HIGH
, "Headphone amp" },
101 { GPIO_E750_SPK_AMP_OFF
, GPIOF_OUT_INIT_HIGH
, "Speaker amp" },
104 static int e750_probe(struct platform_device
*pdev
)
106 struct snd_soc_card
*card
= &e750
;
109 ret
= gpio_request_array(e750_audio_gpios
,
110 ARRAY_SIZE(e750_audio_gpios
));
114 card
->dev
= &pdev
->dev
;
116 ret
= devm_snd_soc_register_card(&pdev
->dev
, card
);
118 dev_err(&pdev
->dev
, "snd_soc_register_card() failed: %d\n",
120 gpio_free_array(e750_audio_gpios
, ARRAY_SIZE(e750_audio_gpios
));
125 static int e750_remove(struct platform_device
*pdev
)
127 gpio_free_array(e750_audio_gpios
, ARRAY_SIZE(e750_audio_gpios
));
131 static struct platform_driver e750_driver
= {
133 .name
= "e750-audio",
134 .pm
= &snd_soc_pm_ops
,
137 .remove
= e750_remove
,
140 module_platform_driver(e750_driver
);
142 /* Module information */
143 MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
144 MODULE_DESCRIPTION("ALSA SoC driver for e750");
145 MODULE_LICENSE("GPL v2");
146 MODULE_ALIAS("platform:e750-audio");