2 * am3517evm.c -- ALSA SoC support for OMAP3517 / AM3517 EVM
4 * Author: Anuj Aggarwal <anuj.aggarwal@ti.com>
6 * Based on sound/soc/omap/beagle.c by Steve Sakoman
8 * Copyright (C) 2009 Texas Instruments Incorporated
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation version 2.
14 * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
15 * whether express or implied; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
20 #include <linux/clk.h>
21 #include <linux/platform_device.h>
22 #include <sound/core.h>
23 #include <sound/pcm.h>
24 #include <sound/soc.h>
25 #include <sound/soc-dapm.h>
27 #include <asm/mach-types.h>
28 #include <mach/hardware.h>
29 #include <mach/gpio.h>
30 #include <plat/mcbsp.h>
32 #include "omap-mcbsp.h"
35 #include "../codecs/tlv320aic23.h"
37 #define CODEC_CLOCK 12000000
39 static int am3517evm_hw_params(struct snd_pcm_substream
*substream
,
40 struct snd_pcm_hw_params
*params
)
42 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
43 struct snd_soc_dai
*codec_dai
= rtd
->codec_dai
;
44 struct snd_soc_dai
*cpu_dai
= rtd
->cpu_dai
;
47 /* Set codec DAI configuration */
48 ret
= snd_soc_dai_set_fmt(codec_dai
,
49 SND_SOC_DAIFMT_DSP_B
|
50 SND_SOC_DAIFMT_NB_NF
|
51 SND_SOC_DAIFMT_CBM_CFM
);
53 printk(KERN_ERR
"can't set codec DAI configuration\n");
57 /* Set cpu DAI configuration */
58 ret
= snd_soc_dai_set_fmt(cpu_dai
,
59 SND_SOC_DAIFMT_DSP_B
|
60 SND_SOC_DAIFMT_NB_NF
|
61 SND_SOC_DAIFMT_CBM_CFM
);
63 printk(KERN_ERR
"can't set cpu DAI configuration\n");
67 /* Set the codec system clock for DAC and ADC */
68 ret
= snd_soc_dai_set_sysclk(codec_dai
, 0,
69 CODEC_CLOCK
, SND_SOC_CLOCK_IN
);
71 printk(KERN_ERR
"can't set codec system clock\n");
75 ret
= snd_soc_dai_set_sysclk(cpu_dai
, OMAP_MCBSP_CLKR_SRC_CLKX
, 0,
78 printk(KERN_ERR
"can't set CPU system clock OMAP_MCBSP_CLKR_SRC_CLKX\n");
82 snd_soc_dai_set_sysclk(cpu_dai
, OMAP_MCBSP_FSR_SRC_FSX
, 0,
85 printk(KERN_ERR
"can't set CPU system clock OMAP_MCBSP_FSR_SRC_FSX\n");
92 static struct snd_soc_ops am3517evm_ops
= {
93 .hw_params
= am3517evm_hw_params
,
96 /* am3517evm machine dapm widgets */
97 static const struct snd_soc_dapm_widget tlv320aic23_dapm_widgets
[] = {
98 SND_SOC_DAPM_HP("Line Out", NULL
),
99 SND_SOC_DAPM_LINE("Line In", NULL
),
100 SND_SOC_DAPM_MIC("Mic In", NULL
),
103 static const struct snd_soc_dapm_route audio_map
[] = {
104 /* Line Out connected to LLOUT, RLOUT */
105 {"Line Out", NULL
, "LOUT"},
106 {"Line Out", NULL
, "ROUT"},
108 {"LLINEIN", NULL
, "Line In"},
109 {"RLINEIN", NULL
, "Line In"},
111 {"MICIN", NULL
, "Mic In"},
114 static int am3517evm_aic23_init(struct snd_soc_pcm_runtime
*rtd
)
116 struct snd_soc_codec
*codec
= rtd
->codec
;
117 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
119 /* Add am3517-evm specific widgets */
120 snd_soc_dapm_new_controls(dapm
, tlv320aic23_dapm_widgets
,
121 ARRAY_SIZE(tlv320aic23_dapm_widgets
));
123 /* Set up davinci-evm specific audio path audio_map */
124 snd_soc_dapm_add_routes(dapm
, audio_map
, ARRAY_SIZE(audio_map
));
126 /* always connected */
127 snd_soc_dapm_enable_pin(dapm
, "Line Out");
128 snd_soc_dapm_enable_pin(dapm
, "Line In");
129 snd_soc_dapm_enable_pin(dapm
, "Mic In");
131 snd_soc_dapm_sync(dapm
);
136 /* Digital audio interface glue - connects codec <--> CPU */
137 static struct snd_soc_dai_link am3517evm_dai
= {
138 .name
= "TLV320AIC23",
139 .stream_name
= "AIC23",
140 .cpu_dai_name
="omap-mcbsp-dai.0",
141 .codec_dai_name
= "tlv320aic23-hifi",
142 .platform_name
= "omap-pcm-audio",
143 .codec_name
= "tlv320aic23-codec",
144 .init
= am3517evm_aic23_init
,
145 .ops
= &am3517evm_ops
,
148 /* Audio machine driver */
149 static struct snd_soc_card snd_soc_am3517evm
= {
151 .dai_link
= &am3517evm_dai
,
155 static struct platform_device
*am3517evm_snd_device
;
157 static int __init
am3517evm_soc_init(void)
161 if (!machine_is_omap3517evm())
163 pr_info("OMAP3517 / AM3517 EVM SoC init\n");
165 am3517evm_snd_device
= platform_device_alloc("soc-audio", -1);
166 if (!am3517evm_snd_device
) {
167 printk(KERN_ERR
"Platform device allocation failed\n");
171 platform_set_drvdata(am3517evm_snd_device
, &snd_soc_am3517evm
);
173 ret
= platform_device_add(am3517evm_snd_device
);
180 printk(KERN_ERR
"Unable to add platform device\n");
181 platform_device_put(am3517evm_snd_device
);
186 static void __exit
am3517evm_soc_exit(void)
188 platform_device_unregister(am3517evm_snd_device
);
191 module_init(am3517evm_soc_init
);
192 module_exit(am3517evm_soc_exit
);
194 MODULE_AUTHOR("Anuj Aggarwal <anuj.aggarwal@ti.com>");
195 MODULE_DESCRIPTION("ALSA SoC OMAP3517 / AM3517 EVM");
196 MODULE_LICENSE("GPL v2");