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 SND_SOC_DAILINK_DEFS(ac97
,
67 DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97")),
68 DAILINK_COMP_ARRAY(COMP_CODEC("wm9705-codec", "wm9705-hifi")),
69 DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
71 SND_SOC_DAILINK_DEFS(ac97_aux
,
72 DAILINK_COMP_ARRAY(COMP_CPU("pxa2xx-ac97-aux")),
73 DAILINK_COMP_ARRAY(COMP_CODEC("wm9705-codec", "wm9705-aux")),
74 DAILINK_COMP_ARRAY(COMP_PLATFORM("pxa-pcm-audio")));
76 static struct snd_soc_dai_link e750_dai
[] = {
79 .stream_name
= "AC97 HiFi",
80 SND_SOC_DAILINK_REG(ac97
),
81 /* use ops to check startup state */
85 .stream_name
= "AC97 Aux",
86 SND_SOC_DAILINK_REG(ac97_aux
),
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");