2 * omap3evm.c -- ALSA SoC support for OMAP3 EVM
4 * Author: Anuj Aggarwal <anuj.aggarwal@ti.com>
6 * Based on sound/soc/omap/beagle.c by Steve Sakoman
8 * Copyright (C) 2008 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 <mach/mcbsp.h>
32 #include "omap-mcbsp.h"
34 #include "../codecs/twl4030.h"
36 static int omap3evm_hw_params(struct snd_pcm_substream
*substream
,
37 struct snd_pcm_hw_params
*params
)
39 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
40 struct snd_soc_dai
*codec_dai
= rtd
->dai
->codec_dai
;
41 struct snd_soc_dai
*cpu_dai
= rtd
->dai
->cpu_dai
;
44 /* Set codec DAI configuration */
45 ret
= snd_soc_dai_set_fmt(codec_dai
,
47 SND_SOC_DAIFMT_NB_NF
|
48 SND_SOC_DAIFMT_CBM_CFM
);
50 printk(KERN_ERR
"Can't set codec DAI configuration\n");
54 /* Set cpu DAI configuration */
55 ret
= snd_soc_dai_set_fmt(cpu_dai
,
57 SND_SOC_DAIFMT_NB_NF
|
58 SND_SOC_DAIFMT_CBM_CFM
);
60 printk(KERN_ERR
"Can't set cpu DAI configuration\n");
64 /* Set the codec system clock for DAC and ADC */
65 ret
= snd_soc_dai_set_sysclk(codec_dai
, 0, 26000000,
68 printk(KERN_ERR
"Can't set codec system clock\n");
75 static struct snd_soc_ops omap3evm_ops
= {
76 .hw_params
= omap3evm_hw_params
,
79 /* Digital audio interface glue - connects codec <--> CPU */
80 static struct snd_soc_dai_link omap3evm_dai
= {
82 .stream_name
= "TWL4030",
83 .cpu_dai
= &omap_mcbsp_dai
[0],
84 .codec_dai
= &twl4030_dai
[TWL4030_DAI_HIFI
],
88 /* Audio machine driver */
89 static struct snd_soc_card snd_soc_omap3evm
= {
91 .platform
= &omap_soc_platform
,
92 .dai_link
= &omap3evm_dai
,
97 static struct snd_soc_device omap3evm_snd_devdata
= {
98 .card
= &snd_soc_omap3evm
,
99 .codec_dev
= &soc_codec_dev_twl4030
,
102 static struct platform_device
*omap3evm_snd_device
;
104 static int __init
omap3evm_soc_init(void)
108 if (!machine_is_omap3evm()) {
109 pr_err("Not OMAP3 EVM!\n");
112 pr_info("OMAP3 EVM SoC init\n");
114 omap3evm_snd_device
= platform_device_alloc("soc-audio", -1);
115 if (!omap3evm_snd_device
) {
116 printk(KERN_ERR
"Platform device allocation failed\n");
120 platform_set_drvdata(omap3evm_snd_device
, &omap3evm_snd_devdata
);
121 omap3evm_snd_devdata
.dev
= &omap3evm_snd_device
->dev
;
122 *(unsigned int *)omap3evm_dai
.cpu_dai
->private_data
= 1;
124 ret
= platform_device_add(omap3evm_snd_device
);
131 printk(KERN_ERR
"Unable to add platform device\n");
132 platform_device_put(omap3evm_snd_device
);
137 static void __exit
omap3evm_soc_exit(void)
139 platform_device_unregister(omap3evm_snd_device
);
142 module_init(omap3evm_soc_init
);
143 module_exit(omap3evm_soc_exit
);
145 MODULE_AUTHOR("Anuj Aggarwal <anuj.aggarwal@ti.com>");
146 MODULE_DESCRIPTION("ALSA SoC OMAP3 EVM");
147 MODULE_LICENSE("GPLv2");