blob: 82bcbbb1841b999a9be91129925f7f10257a1529 [file] [log] [blame]
Ian Moltona7e2e732009-01-08 21:03:55 +00001/*
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>
Ian Moltona7e2e732009-01-08 21:03:55 +000019
Ian Moltona7e2e732009-01-08 21:03:55 +000020#include <mach/audio.h>
21#include <mach/eseries-gpio.h>
22
23#include <asm/mach-types.h>
24
Ian Moltona7e2e732009-01-08 21:03:55 +000025static int e750_spk_amp_event(struct snd_soc_dapm_widget *w,
26 struct snd_kcontrol *kcontrol, int event)
27{
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);
32
33 return 0;
34}
35
36static int e750_hp_amp_event(struct snd_soc_dapm_widget *w,
37 struct snd_kcontrol *kcontrol, int event)
38{
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);
43
44 return 0;
45}
46
47static 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),
57};
58
59static const struct snd_soc_dapm_route audio_map[] = {
60 {"Headphone Amp", NULL, "HPOUTL"},
61 {"Headphone Amp", NULL, "HPOUTR"},
62 {"Headphone Jack", NULL, "Headphone Amp"},
63
64 {"Speaker Amp", NULL, "MONOOUT"},
65 {"Speaker", NULL, "Speaker Amp"},
66
67 {"MIC1", NULL, "Mic (Internal)"},
68};
69
Ian Moltona7e2e732009-01-08 21:03:55 +000070static struct snd_soc_dai_link e750_dai[] = {
71 {
72 .name = "AC97",
73 .stream_name = "AC97 HiFi",
Dmitry Eremin-Solenikov4bfc4e22011-02-23 02:29:11 +030074 .cpu_dai_name = "pxa2xx-ac97",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000075 .codec_dai_name = "wm9705-hifi",
76 .platform_name = "pxa-pcm-audio",
77 .codec_name = "wm9705-codec",
Ian Moltona7e2e732009-01-08 21:03:55 +000078 /* use ops to check startup state */
79 },
80 {
81 .name = "AC97 Aux",
82 .stream_name = "AC97 Aux",
Dmitry Eremin-Solenikov4bfc4e22011-02-23 02:29:11 +030083 .cpu_dai_name = "pxa2xx-ac97-aux",
Codrut Grosu7be5c5f2017-02-25 22:25:23 +020084 .codec_dai_name = "wm9705-aux",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000085 .platform_name = "pxa-pcm-audio",
86 .codec_name = "wm9705-codec",
Ian Moltona7e2e732009-01-08 21:03:55 +000087 },
88};
89
90static struct snd_soc_card e750 = {
91 .name = "Toshiba e750",
Axel Lin561c6a12011-12-22 09:44:43 +080092 .owner = THIS_MODULE,
Ian Moltona7e2e732009-01-08 21:03:55 +000093 .dai_link = e750_dai,
94 .num_links = ARRAY_SIZE(e750_dai),
Lars-Peter Clausen98308c82014-03-01 15:48:15 +010095
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),
Lars-Peter Clausen7523f692015-01-09 22:03:28 +0100100 .fully_routed = true,
Ian Moltona7e2e732009-01-08 21:03:55 +0000101};
102
Axel Lin5eb2c3d2011-12-15 10:53:29 +0800103static 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" },
106};
Ian Moltona7e2e732009-01-08 21:03:55 +0000107
Bill Pemberton570f6fe2012-12-07 09:26:17 -0500108static int e750_probe(struct platform_device *pdev)
Ian Moltona7e2e732009-01-08 21:03:55 +0000109{
Axel Lin5eb2c3d2011-12-15 10:53:29 +0800110 struct snd_soc_card *card = &e750;
Ian Moltona7e2e732009-01-08 21:03:55 +0000111 int ret;
112
Axel Lin5eb2c3d2011-12-15 10:53:29 +0800113 ret = gpio_request_array(e750_audio_gpios,
114 ARRAY_SIZE(e750_audio_gpios));
Ian Moltona7e2e732009-01-08 21:03:55 +0000115 if (ret)
116 return ret;
117
Axel Lin5eb2c3d2011-12-15 10:53:29 +0800118 card->dev = &pdev->dev;
Ian Moltona7e2e732009-01-08 21:03:55 +0000119
Axel Lin2fd70762015-09-01 10:32:59 +0800120 ret = devm_snd_soc_register_card(&pdev->dev, card);
Axel Lin5eb2c3d2011-12-15 10:53:29 +0800121 if (ret) {
122 dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n",
123 ret);
124 gpio_free_array(e750_audio_gpios, ARRAY_SIZE(e750_audio_gpios));
Ian Moltona7e2e732009-01-08 21:03:55 +0000125 }
Ian Moltona7e2e732009-01-08 21:03:55 +0000126 return ret;
127}
128
Bill Pemberton570f6fe2012-12-07 09:26:17 -0500129static int e750_remove(struct platform_device *pdev)
Ian Moltona7e2e732009-01-08 21:03:55 +0000130{
Axel Lin5eb2c3d2011-12-15 10:53:29 +0800131 gpio_free_array(e750_audio_gpios, ARRAY_SIZE(e750_audio_gpios));
Axel Lin5eb2c3d2011-12-15 10:53:29 +0800132 return 0;
Ian Moltona7e2e732009-01-08 21:03:55 +0000133}
134
Axel Lin5eb2c3d2011-12-15 10:53:29 +0800135static struct platform_driver e750_driver = {
136 .driver = {
137 .name = "e750-audio",
Dmitry Eremin-Solenikov7db16982013-10-17 14:01:37 +0400138 .pm = &snd_soc_pm_ops,
Axel Lin5eb2c3d2011-12-15 10:53:29 +0800139 },
140 .probe = e750_probe,
Bill Pemberton570f6fe2012-12-07 09:26:17 -0500141 .remove = e750_remove,
Axel Lin5eb2c3d2011-12-15 10:53:29 +0800142};
143
144module_platform_driver(e750_driver);
Ian Moltona7e2e732009-01-08 21:03:55 +0000145
146/* Module information */
147MODULE_AUTHOR("Ian Molton <spyro@f2s.com>");
148MODULE_DESCRIPTION("ALSA SoC driver for e750");
149MODULE_LICENSE("GPL v2");
Axel Lin5eb2c3d2011-12-15 10:53:29 +0800150MODULE_ALIAS("platform:e750-audio");