blob: 08fcaaa66907b3c04cfde7a43327a37c5fca139e [file] [log] [blame]
Jassi Brar5033f432010-11-22 15:37:25 +09001/* sound/soc/samsung/s3c24xx_simtec_hermes.c
Ben Dooksb2ec22e2009-08-20 22:50:43 +01002 *
3 * Copyright 2009 Simtec Electronics
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8*/
9
10#include <linux/module.h>
11#include <linux/clk.h>
12#include <linux/platform_device.h>
13
14#include <sound/core.h>
15#include <sound/pcm.h>
16#include <sound/soc.h>
Ben Dooksb2ec22e2009-08-20 22:50:43 +010017
18#include <plat/audio-simtec.h>
19
Jassi Brar4b640cf2010-11-22 15:35:57 +090020#include "dma.h"
Ben Dooksb2ec22e2009-08-20 22:50:43 +010021#include "s3c24xx-i2s.h"
22#include "s3c24xx_simtec.h"
23
Ben Dooksb2ec22e2009-08-20 22:50:43 +010024static const struct snd_soc_dapm_widget dapm_widgets[] = {
25 SND_SOC_DAPM_LINE("GSM Out", NULL),
26 SND_SOC_DAPM_LINE("GSM In", NULL),
27 SND_SOC_DAPM_LINE("Line In", NULL),
28 SND_SOC_DAPM_LINE("Line Out", NULL),
29 SND_SOC_DAPM_LINE("ZV", NULL),
30 SND_SOC_DAPM_MIC("Mic Jack", NULL),
31 SND_SOC_DAPM_HP("Headphone Jack", NULL),
32};
33
34static const struct snd_soc_dapm_route base_map[] = {
35 /* Headphone connected to HP{L,R}OUT and HP{L,R}COM */
36
37 { "Headphone Jack", NULL, "HPLOUT" },
38 { "Headphone Jack", NULL, "HPLCOM" },
39 { "Headphone Jack", NULL, "HPROUT" },
40 { "Headphone Jack", NULL, "HPRCOM" },
41
42 /* ZV connected to Line1 */
43
44 { "LINE1L", NULL, "ZV" },
45 { "LINE1R", NULL, "ZV" },
46
47 /* Line In connected to Line2 */
48
49 { "LINE2L", NULL, "Line In" },
50 { "LINE2R", NULL, "Line In" },
51
52 /* Microphone connected to MIC3R and MIC_BIAS */
53
54 { "MIC3L", NULL, "Mic Jack" },
55
56 /* GSM connected to MONO_LOUT and MIC3L (in) */
57
58 { "GSM Out", NULL, "MONO_LOUT" },
59 { "MIC3L", NULL, "GSM In" },
60
61 /* Speaker is connected to LINEOUT{LN,LP,RN,RP}, however we are
62 * not using the DAPM to power it up and down as there it makes
63 * a click when powering up. */
64};
65
66/**
67 * simtec_hermes_init - initialise and add controls
68 * @codec; The codec instance to attach to.
69 *
70 * Attach our controls and configure the necessary codec
71 * mappings for our sound card instance.
72*/
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000073static int simtec_hermes_init(struct snd_soc_pcm_runtime *rtd)
Ben Dooksb2ec22e2009-08-20 22:50:43 +010074{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000075 struct snd_soc_codec *codec = rtd->codec;
Liam Girdwoodce6120c2010-11-05 15:53:46 +020076 struct snd_soc_dapm_context *dapm = &codec->dapm;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000077
Liam Girdwoodce6120c2010-11-05 15:53:46 +020078 snd_soc_dapm_new_controls(dapm, dapm_widgets,
Ben Dooksb2ec22e2009-08-20 22:50:43 +010079 ARRAY_SIZE(dapm_widgets));
80
Liam Girdwoodce6120c2010-11-05 15:53:46 +020081 snd_soc_dapm_add_routes(dapm, base_map, ARRAY_SIZE(base_map));
Ben Dooksb2ec22e2009-08-20 22:50:43 +010082
Liam Girdwoodce6120c2010-11-05 15:53:46 +020083 snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
84 snd_soc_dapm_enable_pin(dapm, "Line In");
85 snd_soc_dapm_enable_pin(dapm, "Line Out");
86 snd_soc_dapm_enable_pin(dapm, "Mic Jack");
Ben Dooksb2ec22e2009-08-20 22:50:43 +010087
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000088 simtec_audio_init(rtd);
Liam Girdwoodce6120c2010-11-05 15:53:46 +020089 snd_soc_dapm_sync(dapm);
Ben Dooksb2ec22e2009-08-20 22:50:43 +010090
91 return 0;
92}
93
Ben Dooksb2ec22e2009-08-20 22:50:43 +010094static struct snd_soc_dai_link simtec_dai_aic33 = {
95 .name = "tlv320aic33",
96 .stream_name = "TLV320AIC33",
Lars-Peter Clausen81d7da52011-01-24 22:09:22 +010097 .codec_name = "tlv320aic3x-codec.0-001a",
Lars-Peter Clausen518aa592011-01-24 22:12:42 +010098 .cpu_dai_name = "s3c24xx-iis",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000099 .codec_dai_name = "tlv320aic3x-hifi",
Jassi Brar58bb4072010-11-22 15:35:50 +0900100 .platform_name = "samsung-audio",
Ben Dooksb2ec22e2009-08-20 22:50:43 +0100101 .init = simtec_hermes_init,
102};
103
104/* simtec audio machine driver */
105static struct snd_soc_card snd_soc_machine_simtec_aic33 = {
106 .name = "Simtec-Hermes",
Ben Dooksb2ec22e2009-08-20 22:50:43 +0100107 .dai_link = &simtec_dai_aic33,
108 .num_links = 1,
109};
110
Ben Dooksb2ec22e2009-08-20 22:50:43 +0100111static int __devinit simtec_audio_hermes_probe(struct platform_device *pd)
112{
113 dev_info(&pd->dev, "probing....\n");
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000114 return simtec_audio_core_probe(pd, &snd_soc_machine_simtec_aic33);
Ben Dooksb2ec22e2009-08-20 22:50:43 +0100115}
116
117static struct platform_driver simtec_audio_hermes_platdrv = {
118 .driver = {
119 .owner = THIS_MODULE,
120 .name = "s3c24xx-simtec-hermes-snd",
121 .pm = simtec_audio_pm,
122 },
123 .probe = simtec_audio_hermes_probe,
124 .remove = __devexit_p(simtec_audio_remove),
125};
126
127MODULE_ALIAS("platform:s3c24xx-simtec-hermes-snd");
128
129static int __init simtec_hermes_modinit(void)
130{
131 return platform_driver_register(&simtec_audio_hermes_platdrv);
132}
133
134static void __exit simtec_hermes_modexit(void)
135{
136 platform_driver_unregister(&simtec_audio_hermes_platdrv);
137}
138
139module_init(simtec_hermes_modinit);
140module_exit(simtec_hermes_modexit);
141
142MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
143MODULE_DESCRIPTION("ALSA SoC Simtec Audio support");
144MODULE_LICENSE("GPL");