blob: 653dc7592e8160ba6d6f4d40666cc3f0ccf422ec [file] [log] [blame]
Ben Dooks14412ac2009-08-20 22:50:40 +01001/* sound/soc/s3c24xx/s3c24xx_simtec_tlv320aic23.c
2 *
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>
17#include <sound/soc-dapm.h>
18
19#include <plat/audio-simtec.h>
20
Jassi Brard3ff5a32009-11-17 16:53:31 +090021#include "s3c-dma.h"
Ben Dooks14412ac2009-08-20 22:50:40 +010022#include "s3c24xx-i2s.h"
23#include "s3c24xx_simtec.h"
24
25#include "../codecs/tlv320aic23.h"
26
27/* supported machines:
28 *
29 * Machine Connections AMP
30 * ------- ----------- ---
31 * BAST MIC, HPOUT, LOUT, LIN TPA2001D1 (HPOUTL,R) (gain hardwired)
32 * VR1000 HPOUT, LIN None
33 * VR2000 LIN, LOUT, MIC, HP LM4871 (HPOUTL,R)
34 * DePicture LIN, LOUT, MIC, HP LM4871 (HPOUTL,R)
35 * Anubis LIN, LOUT, MIC, HP TPA2001D1 (HPOUTL,R)
36 */
37
38static const struct snd_soc_dapm_widget dapm_widgets[] = {
39 SND_SOC_DAPM_HP("Headphone Jack", NULL),
40 SND_SOC_DAPM_LINE("Line In", NULL),
41 SND_SOC_DAPM_LINE("Line Out", NULL),
42 SND_SOC_DAPM_MIC("Mic Jack", NULL),
43};
44
45static const struct snd_soc_dapm_route base_map[] = {
46 { "Headphone Jack", NULL, "LHPOUT"},
47 { "Headphone Jack", NULL, "RHPOUT"},
48
49 { "Line Out", NULL, "LOUT" },
50 { "Line Out", NULL, "ROUT" },
51
52 { "LLINEIN", NULL, "Line In"},
53 { "RLINEIN", NULL, "Line In"},
54
55 { "MICIN", NULL, "Mic Jack"},
56};
57
58/**
59 * simtec_tlv320aic23_init - initialise and add controls
60 * @codec; The codec instance to attach to.
61 *
62 * Attach our controls and configure the necessary codec
63 * mappings for our sound card instance.
64*/
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000065static int simtec_tlv320aic23_init(struct snd_soc_pcm_runtime *rtd)
Ben Dooks14412ac2009-08-20 22:50:40 +010066{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000067 struct snd_soc_codec *codec = rtd->codec;
Liam Girdwoodce6120c2010-11-05 15:53:46 +020068 struct snd_soc_dapm_context *dapm = &codec->dapm;
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000069
Liam Girdwoodce6120c2010-11-05 15:53:46 +020070 snd_soc_dapm_new_controls(dapm, dapm_widgets,
Ben Dooks14412ac2009-08-20 22:50:40 +010071 ARRAY_SIZE(dapm_widgets));
72
Liam Girdwoodce6120c2010-11-05 15:53:46 +020073 snd_soc_dapm_add_routes(dapm, base_map, ARRAY_SIZE(base_map));
Ben Dooks14412ac2009-08-20 22:50:40 +010074
Liam Girdwoodce6120c2010-11-05 15:53:46 +020075 snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
76 snd_soc_dapm_enable_pin(dapm, "Line In");
77 snd_soc_dapm_enable_pin(dapm, "Line Out");
78 snd_soc_dapm_enable_pin(dapm, "Mic Jack");
Ben Dooks14412ac2009-08-20 22:50:40 +010079
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000080 simtec_audio_init(rtd);
Liam Girdwoodce6120c2010-11-05 15:53:46 +020081 snd_soc_dapm_sync(dapm);
Ben Dooks14412ac2009-08-20 22:50:40 +010082
83 return 0;
84}
85
86static struct snd_soc_dai_link simtec_dai_aic23 = {
87 .name = "tlv320aic23",
88 .stream_name = "TLV320AIC23",
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +000089 .codec_name = "tlv320aic3x-codec.0-0x1a",
90 .cpu_dai_name = "s3c24xx-i2s",
91 .codec_dai_name = "tlv320aic3x-hifi",
92 .platform_name = "s3c24xx-pcm-audio",
Ben Dooks14412ac2009-08-20 22:50:40 +010093 .init = simtec_tlv320aic23_init,
94};
95
96/* simtec audio machine driver */
97static struct snd_soc_card snd_soc_machine_simtec_aic23 = {
98 .name = "Simtec",
Ben Dooks14412ac2009-08-20 22:50:40 +010099 .dai_link = &simtec_dai_aic23,
100 .num_links = 1,
101};
102
Ben Dooks14412ac2009-08-20 22:50:40 +0100103static int __devinit simtec_audio_tlv320aic23_probe(struct platform_device *pd)
104{
Liam Girdwoodf0fba2a2010-03-17 20:15:21 +0000105 return simtec_audio_core_probe(pd, &snd_soc_machine_simtec_aic23);
Ben Dooks14412ac2009-08-20 22:50:40 +0100106}
107
108static struct platform_driver simtec_audio_tlv320aic23_platdrv = {
109 .driver = {
110 .owner = THIS_MODULE,
111 .name = "s3c24xx-simtec-tlv320aic23",
112 .pm = simtec_audio_pm,
113 },
114 .probe = simtec_audio_tlv320aic23_probe,
115 .remove = __devexit_p(simtec_audio_remove),
116};
117
118MODULE_ALIAS("platform:s3c24xx-simtec-tlv320aic23");
119
120static int __init simtec_tlv320aic23_modinit(void)
121{
122 return platform_driver_register(&simtec_audio_tlv320aic23_platdrv);
123}
124
125static void __exit simtec_tlv320aic23_modexit(void)
126{
127 platform_driver_unregister(&simtec_audio_tlv320aic23_platdrv);
128}
129
130module_init(simtec_tlv320aic23_modinit);
131module_exit(simtec_tlv320aic23_modexit);
132
133MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
134MODULE_DESCRIPTION("ALSA SoC Simtec Audio support");
135MODULE_LICENSE("GPL");